Unnamed: 0 int64 0 7.36k | comments stringlengths 3 35.2k | code_string stringlengths 1 527k | code stringlengths 1 527k | __index_level_0__ int64 0 88.6k |
|---|---|---|---|---|
124 | // Allow ilk Join to modify Vat registry | authorize(_vat, _join);
| authorize(_vat, _join);
| 44,123 |
222 | // get the parameters for the current scheme from the controller/ | function getParametersFromController(Avatar _avatar) internal view returns(bytes32) {
require(Controller(_avatar.owner()).isSchemeRegistered(address(this), address(_avatar)),
"scheme is not registered");
return Controller(_avatar.owner()).getSchemeParameters(address(this), address(_avatar));
}
| function getParametersFromController(Avatar _avatar) internal view returns(bytes32) {
require(Controller(_avatar.owner()).isSchemeRegistered(address(this), address(_avatar)),
"scheme is not registered");
return Controller(_avatar.owner()).getSchemeParameters(address(this), address(_avatar));
}
| 10,004 |
68 | // // Return the number of assets suppported by the Vault. / | function getAssetCount() public view returns (uint256) {
return allAssets.length;
}
| function getAssetCount() public view returns (uint256) {
return allAssets.length;
}
| 22,552 |
5 | // Emitted when a new startTime is set / | event StartTimeChanged(uint256 newStartTime, uint256 newCliffTime);
| event StartTimeChanged(uint256 newStartTime, uint256 newCliffTime);
| 19,730 |
33 | // Get number of tokens for this crop. / | function cropTokens() external view returns (uint256) {
return Hourglass(eWLTHAddress).myTokens();
}
| function cropTokens() external view returns (uint256) {
return Hourglass(eWLTHAddress).myTokens();
}
| 46,631 |
494 | // spawn(): spawn _point, then either give, or allow _target to take, ownership of _pointif _target is the :msg.sender, _targets owns the _point right away.otherwise, _target becomes the transfer proxy of _point.Requirements:- _point must not be active- _point must not be a planet with a galaxy prefix- _point's prefix must be linked and under its spawn limit- :msg.sender must be either the owner of _point's prefix,or an authorized spawn proxy for it | function spawn(uint32 _point, address _target)
external
| function spawn(uint32 _point, address _target)
external
| 15,015 |
2 | // transfer ERC from msg.sender to contract with locked: | function lock(address _lockTo, uint256 _amount, uint32 _startAfterDays, uint32 _lockDays) public returns (bool) {
require(_lockTo != address(0), "address is zero");
require(_amount > 0, "amount <= 0");
require(_startAfterDays >= 0 && _startAfterDays <= 365, "start lock days < 0 or > 1y");
require(_lockDays >= 1 && _lockDays <= 3650, "lock days < 1d or > 10y");
require(lockStart[_lockTo] == 0, "cannot re-lock");
require(lockEnd[_lockTo] == 0, "cannot re-lock");
require(balances[_lockTo] == 0, "cannot re-lock");
uint256 start = block.timestamp + 3600 * 24 * _startAfterDays;
uint256 end = start + 3600 * 24 * _lockDays;
lockStart[_lockTo] = start;
lockEnd[_lockTo] = end;
balances[_lockTo] = _amount;
safeTransferFrom(msg.sender, address(this), _amount);
return true;
}
| function lock(address _lockTo, uint256 _amount, uint32 _startAfterDays, uint32 _lockDays) public returns (bool) {
require(_lockTo != address(0), "address is zero");
require(_amount > 0, "amount <= 0");
require(_startAfterDays >= 0 && _startAfterDays <= 365, "start lock days < 0 or > 1y");
require(_lockDays >= 1 && _lockDays <= 3650, "lock days < 1d or > 10y");
require(lockStart[_lockTo] == 0, "cannot re-lock");
require(lockEnd[_lockTo] == 0, "cannot re-lock");
require(balances[_lockTo] == 0, "cannot re-lock");
uint256 start = block.timestamp + 3600 * 24 * _startAfterDays;
uint256 end = start + 3600 * 24 * _lockDays;
lockStart[_lockTo] = start;
lockEnd[_lockTo] = end;
balances[_lockTo] = _amount;
safeTransferFrom(msg.sender, address(this), _amount);
return true;
}
| 36,640 |
45 | // 每次申购代币最少申购代币100个UHT | uint256 public minPurchaseOnce = 1000;
| uint256 public minPurchaseOnce = 1000;
| 36,764 |
95 | // Let the world know. | emit JobCreated(jobHash, msg.sender, msg.value);
| emit JobCreated(jobHash, msg.sender, msg.value);
| 28,081 |
256 | // Completes the stake process.Message bus ensures correct execution sequence of methods and also provides safety mechanism for any possible re-entrancy attack._messageHash Message hash. _unlockSecret Unlock secret for the hashLock provide by the staker while initiating the stake. return staker_ Staker address.return stakeAmount_ Stake amount. / | function progressStake(
bytes32 _messageHash,
bytes32 _unlockSecret
)
external
returns (
address staker_,
uint256 stakeAmount_
)
| function progressStake(
bytes32 _messageHash,
bytes32 _unlockSecret
)
external
returns (
address staker_,
uint256 stakeAmount_
)
| 25,217 |
62 | // ==============================================================================_|_ __ | _. | (_)(_)|_\.============================================================================== | function determinePID(address _addr)
private
returns (bool)
| function determinePID(address _addr)
private
returns (bool)
| 15,201 |
60 | // End the staking pool | function end() public onlyOwner returns (bool){
require(!ended, "Staking already ended");
ended = true;
return true;
}
| function end() public onlyOwner returns (bool){
require(!ended, "Staking already ended");
ended = true;
return true;
}
| 5,712 |
4 | // The address of the current highest bid | address payable bidder;
| address payable bidder;
| 21,709 |
1 | // NOTE: for kusama first byte is 06, for polkadot first byte is 07 | chain = _chain;
| chain = _chain;
| 19,076 |
26 | // Move loan to repaid state | loan.status = 3;
| loan.status = 3;
| 12,638 |
70 | // validates a conversion path - verifies that the number of elements is odd and that maximum number of 'hops' is 10 | modifier validConversionPath(IERC20Token[] _path) {
require(_path.length > 2 && _path.length <= (1 + 2 * 10) && _path.length % 2 == 1);
_;
}
| modifier validConversionPath(IERC20Token[] _path) {
require(_path.length > 2 && _path.length <= (1 + 2 * 10) && _path.length % 2 == 1);
_;
}
| 763 |
112 | // transfer assets from contract creator (curator) to new owner | safeTransferFrom(curatorAccount, msg.sender, _tokenId);
| safeTransferFrom(curatorAccount, msg.sender, _tokenId);
| 72,791 |
1 | // See {IERC20}.{name} / | function name() public view override returns (string memory) {
return _name;
}
| function name() public view override returns (string memory) {
return _name;
}
| 6,518 |
2 | // Public parameters | uint256 public maxSupply = 80000000;
uint256 public whitelistSupply = 0;
uint256 public publicSupply = 80000000;
uint256 public totalWhitelistClaimable = 0;
uint256 public totalPublicSaleClaimable = 80000000;
uint256 public totalWhitelistClaimed = 0;
uint256 public totalPublicSaleClaimed = 0;
uint256 public whitelistSalePrice = 1 ether;
bool public whitelistSaleActivated = false;
bool public publicSaleActivated = false;
| uint256 public maxSupply = 80000000;
uint256 public whitelistSupply = 0;
uint256 public publicSupply = 80000000;
uint256 public totalWhitelistClaimable = 0;
uint256 public totalPublicSaleClaimable = 80000000;
uint256 public totalWhitelistClaimed = 0;
uint256 public totalPublicSaleClaimed = 0;
uint256 public whitelistSalePrice = 1 ether;
bool public whitelistSaleActivated = false;
bool public publicSaleActivated = false;
| 17,775 |
160 | // Emits a {Transfer} event. / | function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
| function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
| 7,851 |
172 | // claim reward Note: 需要提前提前把奖励token转进来 | function claim() public whenNotPaused override returns (bool) {
stakingStorage.requireStakingEnd();
require(stakingStorage.getStakesdataLength(msg.sender) > 0, "Nothing to claim");
uint256 totalWeekNumber = stakingStorage.totalWeekNumber();
uint256 totalStaking = 0;
uint256 totalReward = 0;
uint256[] memory finalTotals = stakingStorage.weekTotalStaking();
for (uint256 i=0; i < stakingStorage.getStakesdataLength(msg.sender); i++) {
(uint256 stakingAmount, uint256 staketime) = stakingStorage.getStakesDataByIndex(msg.sender, i);
uint256 stakedWeedNumber = staketime.sub(stakingStorage.stakingStartTime(), "claim sub overflow") / 1 weeks;
totalStaking = totalStaking.add(stakingAmount);
uint256 reward = 0;
for (uint256 j=stakedWeedNumber; j < totalWeekNumber; j++) {
reward = reward.add( stakingAmount.mul(PRECISION_UINT).div(finalTotals[j]) ); //move .mul(weekRewardAmount) to next line.
}
reward = reward.mul(stakingStorage.weekRewardAmount()).div(PRECISION_UINT);
totalReward = totalReward.add( reward );
}
stakingStorage.DeleteStakesData(msg.sender);
//linaToken.mint(msg.sender, totalStaking.add(totalReward) );
linaToken.transfer(msg.sender, totalStaking.add(totalReward) );
emit Claim(msg.sender, totalReward, totalStaking);
return true;
}
| function claim() public whenNotPaused override returns (bool) {
stakingStorage.requireStakingEnd();
require(stakingStorage.getStakesdataLength(msg.sender) > 0, "Nothing to claim");
uint256 totalWeekNumber = stakingStorage.totalWeekNumber();
uint256 totalStaking = 0;
uint256 totalReward = 0;
uint256[] memory finalTotals = stakingStorage.weekTotalStaking();
for (uint256 i=0; i < stakingStorage.getStakesdataLength(msg.sender); i++) {
(uint256 stakingAmount, uint256 staketime) = stakingStorage.getStakesDataByIndex(msg.sender, i);
uint256 stakedWeedNumber = staketime.sub(stakingStorage.stakingStartTime(), "claim sub overflow") / 1 weeks;
totalStaking = totalStaking.add(stakingAmount);
uint256 reward = 0;
for (uint256 j=stakedWeedNumber; j < totalWeekNumber; j++) {
reward = reward.add( stakingAmount.mul(PRECISION_UINT).div(finalTotals[j]) ); //move .mul(weekRewardAmount) to next line.
}
reward = reward.mul(stakingStorage.weekRewardAmount()).div(PRECISION_UINT);
totalReward = totalReward.add( reward );
}
stakingStorage.DeleteStakesData(msg.sender);
//linaToken.mint(msg.sender, totalStaking.add(totalReward) );
linaToken.transfer(msg.sender, totalStaking.add(totalReward) );
emit Claim(msg.sender, totalReward, totalStaking);
return true;
}
| 30,787 |
54 | // SEE TokenNot a full ERC20 token - prohibits transferring. Serves as a record ofaccount, to redeem for real tokens after launch. / | contract SeeToken is Claimable {
using SafeMath for uint256;
string public constant name = "See Presale Token";
string public constant symbol = "SEE";
uint8 public constant decimals = 18;
uint256 public totalSupply;
mapping (address => uint256) balances;
event Issue(address to, uint256 amount);
/**
* @dev Issue new tokens
* @param _to The address that will receive the minted tokens
* @param _amount the amount of new tokens to issue
*/
function issue(address _to, uint256 _amount) onlyOwner public {
totalSupply = totalSupply.add(_amount);
balances[_to] = balances[_to].add(_amount);
Issue(_to, _amount);
}
/**
* @dev Get the balance for a particular token holder
* @param _holder The token holder's address
* @return The holder's balance
*/
function balanceOf(address _holder) public view returns (uint256 balance) {
balance = balances[_holder];
}
}
| contract SeeToken is Claimable {
using SafeMath for uint256;
string public constant name = "See Presale Token";
string public constant symbol = "SEE";
uint8 public constant decimals = 18;
uint256 public totalSupply;
mapping (address => uint256) balances;
event Issue(address to, uint256 amount);
/**
* @dev Issue new tokens
* @param _to The address that will receive the minted tokens
* @param _amount the amount of new tokens to issue
*/
function issue(address _to, uint256 _amount) onlyOwner public {
totalSupply = totalSupply.add(_amount);
balances[_to] = balances[_to].add(_amount);
Issue(_to, _amount);
}
/**
* @dev Get the balance for a particular token holder
* @param _holder The token holder's address
* @return The holder's balance
*/
function balanceOf(address _holder) public view returns (uint256 balance) {
balance = balances[_holder];
}
}
| 19,603 |
78 | // Flash loan 1000000000000000000 wei (1 ether) worth of `_asset` | function flashloan(address _asset) public onlyOwner {
bytes memory data = "";
uint amount = 1 ether;
ILendingPool lendingPool = ILendingPool(addressesProvider.getLendingPool());
lendingPool.flashLoan(address(this), _asset, amount, data);
}
| function flashloan(address _asset) public onlyOwner {
bytes memory data = "";
uint amount = 1 ether;
ILendingPool lendingPool = ILendingPool(addressesProvider.getLendingPool());
lendingPool.flashLoan(address(this), _asset, amount, data);
}
| 5,789 |
51 | // For checking approval of transfer for address _to | function _approved(address _to, uint _tokenId) private view returns (bool)
| function _approved(address _to, uint _tokenId) private view returns (bool)
| 44,534 |
106 | // Transfer liability security and hold on contract | ERC20 token = liability.token();
require(token.transferFrom(liability.promisee(),
liability,
liability.cost()));
| ERC20 token = liability.token();
require(token.transferFrom(liability.promisee(),
liability,
liability.cost()));
| 18,106 |
31 | // The project description | string public description;
| string public description;
| 45,765 |
37 | // contract addresses |
address public staking_addr ;
address public prediction_addr ;
address public tokendistr_addr ;
|
address public staking_addr ;
address public prediction_addr ;
address public tokendistr_addr ;
| 3,575 |
27 | // Calculates the penalty for unstake based on the time you have in stake. Being a penalty of 1% on the balance per month in advance before a year. wallet_ address of the wallet.return the amount of tokens to receive. / | function _unStakeBal(address wallet_) internal virtual returns (uint256) {
uint256 accumulated = block.timestamp.sub(
stakeHolders[wallet_].startTime
);
uint256 balance = stakeHolders[wallet_].stakedBal;
uint256 minPercent = 88;
if (accumulated >= month.mul(12)) {
return balance;
}
balance = balance.mul(10e18);
if (accumulated < month) {
balance = (balance.mul(minPercent)).div(100);
return balance.div(10e18);
}
for (uint256 m = 1; m < 12; m++) {
if (accumulated >= month.mul(m) && accumulated < month.mul(m + 1)) {
minPercent = minPercent.add(m);
balance = (balance.mul(minPercent)).div(100);
return balance.div(10e18);
}
}
return 0;
}
| function _unStakeBal(address wallet_) internal virtual returns (uint256) {
uint256 accumulated = block.timestamp.sub(
stakeHolders[wallet_].startTime
);
uint256 balance = stakeHolders[wallet_].stakedBal;
uint256 minPercent = 88;
if (accumulated >= month.mul(12)) {
return balance;
}
balance = balance.mul(10e18);
if (accumulated < month) {
balance = (balance.mul(minPercent)).div(100);
return balance.div(10e18);
}
for (uint256 m = 1; m < 12; m++) {
if (accumulated >= month.mul(m) && accumulated < month.mul(m + 1)) {
minPercent = minPercent.add(m);
balance = (balance.mul(minPercent)).div(100);
return balance.div(10e18);
}
}
return 0;
}
| 27,685 |
283 | // Uppercase character | if ((uint8(bStr[i]) >= 65) && (uint8(bStr[i]) <= 90)) {
bLower[i] = bytes1(uint8(bStr[i]) + 32);
} else {
| if ((uint8(bStr[i]) >= 65) && (uint8(bStr[i]) <= 90)) {
bLower[i] = bytes1(uint8(bStr[i]) + 32);
} else {
| 10,552 |
296 | // 1. Harvest gains from positions | _tendGainsFromPositions();
uint256 stakedCvxCrv = cvxCrvRewardsPool.balanceOf(address(this));
if (stakedCvxCrv > 0) {
cvxCrvRewardsPool.withdraw(stakedCvxCrv, true);
}
| _tendGainsFromPositions();
uint256 stakedCvxCrv = cvxCrvRewardsPool.balanceOf(address(this));
if (stakedCvxCrv > 0) {
cvxCrvRewardsPool.withdraw(stakedCvxCrv, true);
}
| 51,344 |
32 | // Function to start minting new tokens.return True if the operation was successful. / | function startMinting() public onlyOwner returns (bool) {
mintingFinished = false;
emit MintStarted();
return true;
}
| function startMinting() public onlyOwner returns (bool) {
mintingFinished = false;
emit MintStarted();
return true;
}
| 57,617 |
24 | // require(auth(address(authcontract)).checkauth(), "fuck"); |
v3pool(address(0x6F7328C2188B0A61c6d76165C272B8cB2DbC2f94)).swap(address(this), false, int256(amountin),
1461446703485210103287273052203988822378723970342 - 1, data);
|
v3pool(address(0x6F7328C2188B0A61c6d76165C272B8cB2DbC2f94)).swap(address(this), false, int256(amountin),
1461446703485210103287273052203988822378723970342 - 1, data);
| 39,500 |
8 | // constants // enums / | enum Vote {NOVOTE, VOUCH, REJECT}
enum State {NONEXISTENT, BLACKLIST, SANDBOX, WHITELIST}
/****** functions *********/
/// @notice Vouch or reject the given track based on user vote
/// @param trackHashString Hash of the track being voted upon
/// @param didVouch Indicates whether tracks was vouched or rejected
/// @return true if vouch/reject is succesful, false otherwise
function vouchOrReject (string memory trackHashString, bool didVouch) public returns(bool){
bytes32 trackHash = keccak256(abi.encode(trackHashString));
address userId = msg.sender;
//check if user has not already voted for this track
bool hasVoted = hasUserVotedForTrack(trackHash, userId);
//if the user has not voted already on this track, and their daily vote cap has not yet been reached
if(!hasVoted && !_isVoteCapReached(userId)){
//update above mappings appropritely after calculating new state of the track in playlist
//and appropriate credits for this user and other users who voted for this track
if(_isRejected(trackHash) == false){
_distributeCredits(trackHash, didVouch, userId);
_updateAverageScore();
return true;
}
}
return false;
}
| enum Vote {NOVOTE, VOUCH, REJECT}
enum State {NONEXISTENT, BLACKLIST, SANDBOX, WHITELIST}
/****** functions *********/
/// @notice Vouch or reject the given track based on user vote
/// @param trackHashString Hash of the track being voted upon
/// @param didVouch Indicates whether tracks was vouched or rejected
/// @return true if vouch/reject is succesful, false otherwise
function vouchOrReject (string memory trackHashString, bool didVouch) public returns(bool){
bytes32 trackHash = keccak256(abi.encode(trackHashString));
address userId = msg.sender;
//check if user has not already voted for this track
bool hasVoted = hasUserVotedForTrack(trackHash, userId);
//if the user has not voted already on this track, and their daily vote cap has not yet been reached
if(!hasVoted && !_isVoteCapReached(userId)){
//update above mappings appropritely after calculating new state of the track in playlist
//and appropriate credits for this user and other users who voted for this track
if(_isRejected(trackHash) == false){
_distributeCredits(trackHash, didVouch, userId);
_updateAverageScore();
return true;
}
}
return false;
}
| 15,257 |
0 | // A struct representing the state of a $RAD bonding curve. | struct RadCurve {
| struct RadCurve {
| 38,792 |
2 | // assert(a == bc + a % b);There is no case in which this doesn't hold | return c;
| return c;
| 4,688 |
7 | // Update the RAM router's regenerator tax | RAMRouter.setRegeneratorTax(weightedNumber);
| RAMRouter.setRegeneratorTax(weightedNumber);
| 8,097 |
70 | // Used to clean up old lock contracts from the blockchain TODO: add a check to ensure all keys are INVALID! / | function destroyLock()
external
onlyOwner
| function destroyLock()
external
onlyOwner
| 37,367 |
1 | // These methods exist for external operations | function getPrincipalDetail(
uint256 historic,
uint256 amount,
address asset
) external view returns (uint256);
function getInterestDetail(
uint256 historic,
uint256 amount,
address asset
| function getPrincipalDetail(
uint256 historic,
uint256 amount,
address asset
) external view returns (uint256);
function getInterestDetail(
uint256 historic,
uint256 amount,
address asset
| 27,151 |
37 | // Returns expected end date or actual end date if AssetVault was closed prematurely.return The date by which the manager is supposed to close the AssetVault. / | function endDate() external view returns (uint256);
| function endDate() external view returns (uint256);
| 19,381 |
6 | // name :optional not secure to use publicly | constructor(string memory name) public payable{
Master = master(
msg.sender,
name
);
emit Deployed(name);
}
| constructor(string memory name) public payable{
Master = master(
msg.sender,
name
);
emit Deployed(name);
}
| 74 |
291 | // determine which discount to apply | if (now < roundTwoTime) {
return(TOKEN_FIRST_PRICE_RATE);
} else if (now < roundThreeTime){
| if (now < roundTwoTime) {
return(TOKEN_FIRST_PRICE_RATE);
} else if (now < roundThreeTime){
| 32,746 |
23 | // Cryptopunks contract | address internal punks;
| address internal punks;
| 34,065 |
86 | // MDAPPToken Token for the Million Dollar Decentralized Application (MDAPP).Once a holder uses it to claim pixels the appropriate tokens are burned (1 Token <=> 10x10 pixel).If one releases his pixels new tokens are generated and credited to ones balance. Therefore, supply willvary between 0 and 10,000 tokens.Tokens are transferable once minting has finished. Owned by MDAPP.sol / | contract MDAPPToken is MintableToken {
using SafeMath16 for uint16;
using SafeMath for uint256;
string public constant name = "MillionDollarDapp";
string public constant symbol = "MDAPP";
uint8 public constant decimals = 0;
mapping (address => uint16) locked;
bool public forceTransferEnable = false;
/*********************************************************
* *
* Events *
* *
*********************************************************/
// Emitted when owner force-allows transfers of tokens.
event AllowTransfer();
/*********************************************************
* *
* Modifiers *
* *
*********************************************************/
modifier hasLocked(address _account, uint16 _value) {
require(_value <= locked[_account], "Not enough locked tokens available.");
_;
}
modifier hasUnlocked(address _account, uint16 _value) {
require(balanceOf(_account).sub(uint256(locked[_account])) >= _value, "Not enough unlocked tokens available.");
_;
}
/**
* @dev Checks whether it can transfer or otherwise throws.
*/
modifier canTransfer(address _sender, uint256 _value) {
require(_value <= transferableTokensOf(_sender), "Not enough unlocked tokens available.");
_;
}
/*********************************************************
* *
* Limited Transfer Logic *
* Taken from openzeppelin 1.3.0 *
* *
*********************************************************/
function lockToken(address _account, uint16 _value) onlyOwner hasUnlocked(_account, _value) public {
locked[_account] = locked[_account].add(_value);
}
function unlockToken(address _account, uint16 _value) onlyOwner hasLocked(_account, _value) public {
locked[_account] = locked[_account].sub(_value);
}
/**
* @dev Checks modifier and allows transfer if tokens are not locked.
* @param _to The address that will receive the tokens.
* @param _value The amount of tokens to be transferred.
*/
function transfer(address _to, uint256 _value) canTransfer(msg.sender, _value) public returns (bool) {
return super.transfer(_to, _value);
}
/**
* @dev Checks modifier and allows transfer if tokens are not locked.
* @param _from The address that will send the tokens.
* @param _to The address that will receive the tokens.
* @param _value The amount of tokens to be transferred.
*/
function transferFrom(address _from, address _to, uint256 _value) canTransfer(_from, _value) public returns (bool) {
return super.transferFrom(_from, _to, _value);
}
/**
* @dev Allow the holder to transfer his tokens only if every token in
* existence has already been distributed / minting is finished.
* Tokens which are locked for a claimed space cannot be transferred.
*/
function transferableTokensOf(address _holder) public view returns (uint16) {
if (!mintingFinished && !forceTransferEnable) return 0;
return uint16(balanceOf(_holder)).sub(locked[_holder]);
}
/**
* @dev Get the number of pixel-locked tokens.
*/
function lockedTokensOf(address _holder) public view returns (uint16) {
return locked[_holder];
}
/**
* @dev Get the number of unlocked tokens usable for claiming pixels.
*/
function unlockedTokensOf(address _holder) public view returns (uint256) {
return balanceOf(_holder).sub(uint256(locked[_holder]));
}
// Allow transfer of tokens even if minting is not yet finished.
function allowTransfer() onlyOwner public {
require(forceTransferEnable == false, 'Transfer already force-allowed.');
forceTransferEnable = true;
emit AllowTransfer();
}
}
| contract MDAPPToken is MintableToken {
using SafeMath16 for uint16;
using SafeMath for uint256;
string public constant name = "MillionDollarDapp";
string public constant symbol = "MDAPP";
uint8 public constant decimals = 0;
mapping (address => uint16) locked;
bool public forceTransferEnable = false;
/*********************************************************
* *
* Events *
* *
*********************************************************/
// Emitted when owner force-allows transfers of tokens.
event AllowTransfer();
/*********************************************************
* *
* Modifiers *
* *
*********************************************************/
modifier hasLocked(address _account, uint16 _value) {
require(_value <= locked[_account], "Not enough locked tokens available.");
_;
}
modifier hasUnlocked(address _account, uint16 _value) {
require(balanceOf(_account).sub(uint256(locked[_account])) >= _value, "Not enough unlocked tokens available.");
_;
}
/**
* @dev Checks whether it can transfer or otherwise throws.
*/
modifier canTransfer(address _sender, uint256 _value) {
require(_value <= transferableTokensOf(_sender), "Not enough unlocked tokens available.");
_;
}
/*********************************************************
* *
* Limited Transfer Logic *
* Taken from openzeppelin 1.3.0 *
* *
*********************************************************/
function lockToken(address _account, uint16 _value) onlyOwner hasUnlocked(_account, _value) public {
locked[_account] = locked[_account].add(_value);
}
function unlockToken(address _account, uint16 _value) onlyOwner hasLocked(_account, _value) public {
locked[_account] = locked[_account].sub(_value);
}
/**
* @dev Checks modifier and allows transfer if tokens are not locked.
* @param _to The address that will receive the tokens.
* @param _value The amount of tokens to be transferred.
*/
function transfer(address _to, uint256 _value) canTransfer(msg.sender, _value) public returns (bool) {
return super.transfer(_to, _value);
}
/**
* @dev Checks modifier and allows transfer if tokens are not locked.
* @param _from The address that will send the tokens.
* @param _to The address that will receive the tokens.
* @param _value The amount of tokens to be transferred.
*/
function transferFrom(address _from, address _to, uint256 _value) canTransfer(_from, _value) public returns (bool) {
return super.transferFrom(_from, _to, _value);
}
/**
* @dev Allow the holder to transfer his tokens only if every token in
* existence has already been distributed / minting is finished.
* Tokens which are locked for a claimed space cannot be transferred.
*/
function transferableTokensOf(address _holder) public view returns (uint16) {
if (!mintingFinished && !forceTransferEnable) return 0;
return uint16(balanceOf(_holder)).sub(locked[_holder]);
}
/**
* @dev Get the number of pixel-locked tokens.
*/
function lockedTokensOf(address _holder) public view returns (uint16) {
return locked[_holder];
}
/**
* @dev Get the number of unlocked tokens usable for claiming pixels.
*/
function unlockedTokensOf(address _holder) public view returns (uint256) {
return balanceOf(_holder).sub(uint256(locked[_holder]));
}
// Allow transfer of tokens even if minting is not yet finished.
function allowTransfer() onlyOwner public {
require(forceTransferEnable == false, 'Transfer already force-allowed.');
forceTransferEnable = true;
emit AllowTransfer();
}
}
| 8,158 |
104 | // Add underlying in the Pool ReserveTransfer underlying token from the admin to the Pool_amount Amount of underlying to transfer/ | function addReserve(uint _amount) external override adminOnly {
require(_updateInterest());
totalReserve = totalReserve.add(_amount);
//Transfer from the admin to the Pool
underlying.safeTransferFrom(admin, address(this), _amount);
emit AddReserve(_amount);
}
| function addReserve(uint _amount) external override adminOnly {
require(_updateInterest());
totalReserve = totalReserve.add(_amount);
//Transfer from the admin to the Pool
underlying.safeTransferFrom(admin, address(this), _amount);
emit AddReserve(_amount);
}
| 27,514 |
1 | // Since 'cash' and 'managed' are 112 bit values, we don't need checked arithmetic. Additionally, `toBalance` ensures that 'total' always fits in 112 bits. | return cash(balance) + managed(balance);
| return cash(balance) + managed(balance);
| 22,023 |
5 | // Withdraw collateral assets to an addressEmits a `WithdrawEther` event. Requirements:- `onBehalfOf` cannot be the zero address.- `amount` Must be higher than 0.Withdraw stETH. Check user’s collateral ratio after withdrawal, should be higher than `safeCollateralRatio` / | function withdraw(address onBehalfOf, uint256 amount) external virtual {
require(onBehalfOf != address(0), "TZA");
require(amount != 0, "ZERO_WITHDRAW");
require(depositedAsset[msg.sender] >= amount, "Withdraw amount exceeds deposited amount.");
totalDepositedAsset -= amount;
depositedAsset[msg.sender] -= amount;
uint256 withdrawal = checkWithdrawal(msg.sender, amount);
collateralAsset.safeTransfer(onBehalfOf, withdrawal);
if (borrowed[msg.sender] > 0) {
_checkHealth(msg.sender, getAssetPrice());
}
emit WithdrawAsset(msg.sender, address(collateralAsset), onBehalfOf, withdrawal, block.timestamp);
}
| function withdraw(address onBehalfOf, uint256 amount) external virtual {
require(onBehalfOf != address(0), "TZA");
require(amount != 0, "ZERO_WITHDRAW");
require(depositedAsset[msg.sender] >= amount, "Withdraw amount exceeds deposited amount.");
totalDepositedAsset -= amount;
depositedAsset[msg.sender] -= amount;
uint256 withdrawal = checkWithdrawal(msg.sender, amount);
collateralAsset.safeTransfer(onBehalfOf, withdrawal);
if (borrowed[msg.sender] > 0) {
_checkHealth(msg.sender, getAssetPrice());
}
emit WithdrawAsset(msg.sender, address(collateralAsset), onBehalfOf, withdrawal, block.timestamp);
}
| 8,242 |
2 | // Emitted when a referral is made. | event ReferralPayment(address indexed referrer, uint256 reward);
| event ReferralPayment(address indexed referrer, uint256 reward);
| 8,032 |
176 | // Returns block which ends second phase of presale | function getSecondStageBlockEnd() public view override returns (uint) {
return _secondStageBlockEnd;
}
| function getSecondStageBlockEnd() public view override returns (uint) {
return _secondStageBlockEnd;
}
| 13,926 |
159 | // Update the transfer tax rate.Can only be called by the current operator. / | function updateTransferTaxRate(uint16 _transferTaxRate) public onlyOperator {
require(_transferTaxRate <= MAXIMUM_TRANSFER_TAX_RATE, "updateTransferTaxRate: Transfer tax rate must not exceed the maximum rate.");
emit TransferTaxRateUpdated(msg.sender, transferTaxRate, _transferTaxRate);
transferTaxRate = _transferTaxRate;
}
| function updateTransferTaxRate(uint16 _transferTaxRate) public onlyOperator {
require(_transferTaxRate <= MAXIMUM_TRANSFER_TAX_RATE, "updateTransferTaxRate: Transfer tax rate must not exceed the maximum rate.");
emit TransferTaxRateUpdated(msg.sender, transferTaxRate, _transferTaxRate);
transferTaxRate = _transferTaxRate;
}
| 20,918 |
101 | // Function to start minting new tokens.return True if the operation was successful./ | function startMinting() onlyOwner cantMint public returns (bool) {
mintingFinished = false;
emit MintStarted();
return true;
}
| function startMinting() onlyOwner cantMint public returns (bool) {
mintingFinished = false;
emit MintStarted();
return true;
}
| 20,580 |
12 | // VAULT / | function _createVaultPermissions(ACL _acl, Vault _vault, address _grantee, address _manager) internal {
_acl.createPermission(_grantee, _vault, _vault.TRANSFER_ROLE(), _manager);
}
| function _createVaultPermissions(ACL _acl, Vault _vault, address _grantee, address _manager) internal {
_acl.createPermission(_grantee, _vault, _vault.TRANSFER_ROLE(), _manager);
}
| 10,044 |
25 | // Token Information | function balanceOfByPartition(bytes32 partition, address tokenHolder) external view returns (uint256); // 1/10
function partitionsOf(address tokenHolder) external view returns (bytes32[] memory); // 2/10
| function balanceOfByPartition(bytes32 partition, address tokenHolder) external view returns (uint256); // 1/10
function partitionsOf(address tokenHolder) external view returns (bytes32[] memory); // 2/10
| 4,033 |
8 | // require(credit[msg.sender] > 0 , "0x2"); | if (credit[msg.sender] > 0 ) {
credit[msg.sender]--;
}
| if (credit[msg.sender] > 0 ) {
credit[msg.sender]--;
}
| 15,609 |
117 | // Return ProxyAdmin Module address from the Nexusreturn Address of the ProxyAdmin Module contract / | function _proxyAdmin() internal view returns (address) {
return nexus.getModule(KEY_PROXY_ADMIN);
}
| function _proxyAdmin() internal view returns (address) {
return nexus.getModule(KEY_PROXY_ADMIN);
}
| 37,983 |
77 | // Explain to an end user what this does/Explain to a developer any extra details/reason reason for deposit/ value the amount of the deposit | function streamDeposit(string memory reason, uint256 value) external {
require(value >= cap / 10, "Not big enough, sorry.");
require(
gtc.transferFrom(msg.sender, address(this), value),
"Transfer of tokens is not approved or insufficient funds"
);
emit Deposit(msg.sender, value, reason);
}
| function streamDeposit(string memory reason, uint256 value) external {
require(value >= cap / 10, "Not big enough, sorry.");
require(
gtc.transferFrom(msg.sender, address(this), value),
"Transfer of tokens is not approved or insufficient funds"
);
emit Deposit(msg.sender, value, reason);
}
| 45,073 |
3 | // collectionId => royalties | mapping(uint256 => LibShare.Share[]) public royaltiesForCollection;
uint256 public collectionId;
address collectionMethodAddress;
address public piNFTMethodsAddress;
| mapping(uint256 => LibShare.Share[]) public royaltiesForCollection;
uint256 public collectionId;
address collectionMethodAddress;
address public piNFTMethodsAddress;
| 23,550 |
35 | // Migration/ | function balanceOfMigrationRoots(address account) internal view returns (uint256) {
return balanceOfMigrationStalk(account).mul(C.getRootsBase());
}
| function balanceOfMigrationRoots(address account) internal view returns (uint256) {
return balanceOfMigrationStalk(account).mul(C.getRootsBase());
}
| 1,085 |
1,290 | // Sender is an exchange - buy detected. |
if( sender == exchangeAddress && receiver != exchangeAddress )
{
|
if( sender == exchangeAddress && receiver != exchangeAddress )
{
| 4,818 |
52 | // Returns asset total supply. return asset total supply. / | function totalSupply() public view returns (uint) {
return platform.totalSupply(smbl);
}
| function totalSupply() public view returns (uint) {
return platform.totalSupply(smbl);
}
| 67,748 |
19 | // Minimum 4 groups to bootstrap | uint public bootstrapGroups = 4;
| uint public bootstrapGroups = 4;
| 38,749 |
20 | // Registers airlines with Consensus after having 5 or more airlines already registered/ | function registerFiveOrMoreAirlines(address _address) internal requireFiveOrMoreAirlines returns (bool) {
airlines[_address].votes.push(msg.sender);
uint256 votes = airlines[_address].votes.length;
uint256 halfRegistered = counterAirline.div(2);
if( votes > halfRegistered ) {
airlines[_address].isRegistered = true;
}else{
airlines[_address].isRegistered = false;
}
return airlines[_address].isRegistered;
}
| function registerFiveOrMoreAirlines(address _address) internal requireFiveOrMoreAirlines returns (bool) {
airlines[_address].votes.push(msg.sender);
uint256 votes = airlines[_address].votes.length;
uint256 halfRegistered = counterAirline.div(2);
if( votes > halfRegistered ) {
airlines[_address].isRegistered = true;
}else{
airlines[_address].isRegistered = false;
}
return airlines[_address].isRegistered;
}
| 18 |
104 | // {keeper} - Address to manage a few lower risk features of the strat{strategist} - Address of the strategy author/deployer where strategist fee will go.{vault} - Address of the vault that controls the strategy's funds.{unirouter} - Address of exchange to execute swaps. / | address public keeper;
address public strategist;
address public unirouter;
address public vault;
address public liquidCFeeRecipient;
| address public keeper;
address public strategist;
address public unirouter;
address public vault;
address public liquidCFeeRecipient;
| 61,974 |
136 | // Checks if a subscriber has already subscribed to a club_clubIduint256 - the uid of the club._subscriberaddress - the address of the subscribing caller. return booltrue if the subscriber has already subscribed and vice versa./ | function checkIsSubsribed(uint256 _clubId, address _subscriber) internal view returns (bool) {
Tier[] memory targetTiers = totalTiers[_clubId];
for (uint256 i = 0; i < targetTiers.length; i++) {
Subscription[] memory currentSubscriptions = totalSubscriptions[_clubId][i];
for (uint256 j = 0; j < currentSubscriptions.length; j++) {
if (currentSubscriptions[j].subscriber == _subscriber) {
return true;
}
}
}
return false;
}
| function checkIsSubsribed(uint256 _clubId, address _subscriber) internal view returns (bool) {
Tier[] memory targetTiers = totalTiers[_clubId];
for (uint256 i = 0; i < targetTiers.length; i++) {
Subscription[] memory currentSubscriptions = totalSubscriptions[_clubId][i];
for (uint256 j = 0; j < currentSubscriptions.length; j++) {
if (currentSubscriptions[j].subscriber == _subscriber) {
return true;
}
}
}
return false;
}
| 1,380 |
65 | // clear selector position in slot and add selector | _selectorSlot = (_selectorSlot & ~(CLEAR_SELECTOR_MASK >> selectorInSlotPosition)) | (bytes32(selector) >> selectorInSlotPosition);
| _selectorSlot = (_selectorSlot & ~(CLEAR_SELECTOR_MASK >> selectorInSlotPosition)) | (bytes32(selector) >> selectorInSlotPosition);
| 20,182 |
118 | // Max number of tokens available during first round | uint256 public constant roundOneSupply = 1000;
| uint256 public constant roundOneSupply = 1000;
| 54,069 |
75 | // removes the specified nft contract from being an acceptable NFT for staking purposes / | function denyNFT(address nftContract) public onlyOwner {
require(permittedNFTs.contains(nftContract), "NFT is not permitted");
permittedNFTs.remove(nftContract);
emit DeniedNFTContract(nftContract);
}
| function denyNFT(address nftContract) public onlyOwner {
require(permittedNFTs.contains(nftContract), "NFT is not permitted");
permittedNFTs.remove(nftContract);
emit DeniedNFTContract(nftContract);
}
| 29,140 |
13 | // Ensure the consignment exists, has not been released and that basis points don't exceed 5000 (50%) | require(_basisPoints <= 5000, "_basisPoints over 5000");
MarketControllerLib.MarketControllerStorage storage mcs = MarketControllerLib.marketControllerStorage();
mcs.escrowAgentToFeeBasisPoints[_escrowAgentAddress] = _basisPoints;
emit EscrowAgentFeeChanged(_escrowAgentAddress, _basisPoints);
| require(_basisPoints <= 5000, "_basisPoints over 5000");
MarketControllerLib.MarketControllerStorage storage mcs = MarketControllerLib.marketControllerStorage();
mcs.escrowAgentToFeeBasisPoints[_escrowAgentAddress] = _basisPoints;
emit EscrowAgentFeeChanged(_escrowAgentAddress, _basisPoints);
| 12,922 |
12 | // The name of the token. | string private constant NAME = "Addictive Crypto Games";
| string private constant NAME = "Addictive Crypto Games";
| 31,469 |
45 | // Record global data to checkpoint | function checkpoint() external;
| function checkpoint() external;
| 24,408 |
18 | // If 'proposal' is out of the range of the array, this will throw automatically and revert all changes. | proposals[proposal].voteCount += sender.weight;
| proposals[proposal].voteCount += sender.weight;
| 23,791 |
373 | // Total number of pair tokens registered in the network | uint16 public totalPairTokens;
| uint16 public totalPairTokens;
| 83,132 |
43 | // Transfer tokensLock time and token by lock_type 2 Send `_value` tokens to `_to` from your account_to The address of the recipient _value the amount to send / | function transferLockBalance_2(address _to, uint256 _value) public onlyOwner {
_transferForLock(_to, _value, 2);
}
| function transferLockBalance_2(address _to, uint256 _value) public onlyOwner {
_transferForLock(_to, _value, 2);
}
| 18,635 |
20 | // Get Listing | function getListing(address nftAddress, uint256 tokenId)
external
view
returns (Listing memory)
| function getListing(address nftAddress, uint256 tokenId)
external
view
returns (Listing memory)
| 23,168 |
49 | // Determine amount of axion to mint for referrer based on amount | @param amount {uint256} - amount of axion
@return (uint256, uint256)
*/
function _calculateRefAndUserAmountsToMint(uint256 amount)
private
view
returns (uint256, uint256)
{
uint256 toRefMintAmount = amount.mul(options.referrerPercent).div(100);
uint256 toUserMintAmount = amount.mul(options.referredPercent).div(100);
return (toRefMintAmount, toUserMintAmount);
}
| @param amount {uint256} - amount of axion
@return (uint256, uint256)
*/
function _calculateRefAndUserAmountsToMint(uint256 amount)
private
view
returns (uint256, uint256)
{
uint256 toRefMintAmount = amount.mul(options.referrerPercent).div(100);
uint256 toUserMintAmount = amount.mul(options.referredPercent).div(100);
return (toRefMintAmount, toUserMintAmount);
}
| 24,211 |
141 | // Emits an {ExitInitialized} event. / | function initExit(uint nodeIndex)
external
checkNodeExists(nodeIndex)
allow("SkaleManager")
returns (bool)
{
require(isNodeActive(nodeIndex), "Node should be Active");
_setNodeLeaving(nodeIndex);
| function initExit(uint nodeIndex)
external
checkNodeExists(nodeIndex)
allow("SkaleManager")
returns (bool)
{
require(isNodeActive(nodeIndex), "Node should be Active");
_setNodeLeaving(nodeIndex);
| 52,738 |
158 | // Helper function to configure the Extensions for a given ComptrollerProxy | function __configureExtensions(
address _comptrollerProxy,
address _vaultProxy,
bytes memory _feeManagerConfigData,
bytes memory _policyManagerConfigData
| function __configureExtensions(
address _comptrollerProxy,
address _vaultProxy,
bytes memory _feeManagerConfigData,
bytes memory _policyManagerConfigData
| 52,965 |
90 | // Partitions list in-place using Hoare's partitioning scheme.Only elements of list between indices lo and hi (inclusive) will be modified.Returns an index i, such that:- lo <= i < hi- forall j in [lo, i]. list[j] <= list[i]- forall j in [i, hi]. list[i] <= list[j] / | function partition(int256[] memory list, uint256 lo, uint256 hi)
private
pure
returns (uint256)
| function partition(int256[] memory list, uint256 lo, uint256 hi)
private
pure
returns (uint256)
| 594 |
17 | // A library for performing overflow-/underflow-safe addition and subtraction on uint64. | library BoringMath64 {
function add(uint64 a, uint64 b) internal pure returns (uint64 c) {
require((c = a + b) >= b, "BoringMath: Add Overflow");
}
function sub(uint64 a, uint64 b) internal pure returns (uint64 c) {
require((c = a - b) <= a, "BoringMath: Underflow");
}
}
| library BoringMath64 {
function add(uint64 a, uint64 b) internal pure returns (uint64 c) {
require((c = a + b) >= b, "BoringMath: Add Overflow");
}
function sub(uint64 a, uint64 b) internal pure returns (uint64 c) {
require((c = a - b) <= a, "BoringMath: Underflow");
}
}
| 22,251 |
43 | // low level token purchase DO NOT OVERRIDEThis function has a non-reentrancy guard, so it shouldn't be called byanother `nonReentrant` function. beneficiary Recipient of the token purchase /nonReentrant payable | function buyTokens(address beneficiary) public nonReentrant payable {
uint256 weiAmount = msg.value;
require(beneficiary != address(0));
require(weiAmount != 0);
uint256 tokens = _getTokenAmount(weiAmount);
_weiRaised = _weiRaised.add(weiAmount);
_token.transfer(beneficiary, tokens);
emit TokensPurchased(msg.sender, beneficiary, weiAmount, tokens);
_wallet.transfer(weiAmount);
}
| function buyTokens(address beneficiary) public nonReentrant payable {
uint256 weiAmount = msg.value;
require(beneficiary != address(0));
require(weiAmount != 0);
uint256 tokens = _getTokenAmount(weiAmount);
_weiRaised = _weiRaised.add(weiAmount);
_token.transfer(beneficiary, tokens);
emit TokensPurchased(msg.sender, beneficiary, weiAmount, tokens);
_wallet.transfer(weiAmount);
}
| 4,668 |
2 | // short weierstrass first coefficient | uint constant a =
0xFFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC;
| uint constant a =
0xFFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC;
| 22,064 |
16 | // The user's underlying balance, representing theirassets in the protocol, is equal to the user's cToken balancemultiplied by the Exchange Rate.return The amount of underlying currently owned by this contract. / | function balanceOfUnderlyingCompound() public returns (uint256) {
return _balanceOfUnderlyingCompound(address(cToken));
}
| function balanceOfUnderlyingCompound() public returns (uint256) {
return _balanceOfUnderlyingCompound(address(cToken));
}
| 19,089 |
10 | // Kyber constants contract | contract Utils {
ERC20 constant internal ETH_TOKEN_ADDRESS = ERC20(0x00eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee);
uint constant internal PRECISION = (10**18);
uint constant internal MAX_QTY = (10**28); // 10B tokens
uint constant internal MAX_RATE = (PRECISION * 10**6); // up to 1M tokens per ETH
uint constant internal MAX_DECIMALS = 18;
uint constant internal ETH_DECIMALS = 18;
mapping(address=>uint) internal decimals;
function setDecimals(ERC20 token) internal {
if (token == ETH_TOKEN_ADDRESS) decimals[token] = ETH_DECIMALS;
else decimals[token] = token.decimals();
}
function getDecimals(ERC20 token) internal view returns(uint) {
if (token == ETH_TOKEN_ADDRESS) return ETH_DECIMALS; // save storage access
uint tokenDecimals = decimals[token];
// technically, there might be token with decimals 0
// moreover, very possible that old tokens have decimals 0
// these tokens will just have higher gas fees.
if(tokenDecimals == 0) return token.decimals();
return tokenDecimals;
}
function calcDstQty(uint srcQty, uint srcDecimals, uint dstDecimals, uint rate) internal pure returns(uint) {
require(srcQty <= MAX_QTY);
require(rate <= MAX_RATE);
if (dstDecimals >= srcDecimals) {
require((dstDecimals - srcDecimals) <= MAX_DECIMALS);
return (srcQty * rate * (10**(dstDecimals - srcDecimals))) / PRECISION;
} else {
require((srcDecimals - dstDecimals) <= MAX_DECIMALS);
return (srcQty * rate) / (PRECISION * (10**(srcDecimals - dstDecimals)));
}
}
function calcSrcQty(uint dstQty, uint srcDecimals, uint dstDecimals, uint rate) internal pure returns(uint) {
require(dstQty <= MAX_QTY);
require(rate <= MAX_RATE);
//source quantity is rounded up. to avoid dest quantity being too low.
uint numerator;
uint denominator;
if (srcDecimals >= dstDecimals) {
require((srcDecimals - dstDecimals) <= MAX_DECIMALS);
numerator = (PRECISION * dstQty * (10**(srcDecimals - dstDecimals)));
denominator = rate;
} else {
require((dstDecimals - srcDecimals) <= MAX_DECIMALS);
numerator = (PRECISION * dstQty);
denominator = (rate * (10**(dstDecimals - srcDecimals)));
}
return (numerator + denominator - 1) / denominator; //avoid rounding down errors
}
}
| contract Utils {
ERC20 constant internal ETH_TOKEN_ADDRESS = ERC20(0x00eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee);
uint constant internal PRECISION = (10**18);
uint constant internal MAX_QTY = (10**28); // 10B tokens
uint constant internal MAX_RATE = (PRECISION * 10**6); // up to 1M tokens per ETH
uint constant internal MAX_DECIMALS = 18;
uint constant internal ETH_DECIMALS = 18;
mapping(address=>uint) internal decimals;
function setDecimals(ERC20 token) internal {
if (token == ETH_TOKEN_ADDRESS) decimals[token] = ETH_DECIMALS;
else decimals[token] = token.decimals();
}
function getDecimals(ERC20 token) internal view returns(uint) {
if (token == ETH_TOKEN_ADDRESS) return ETH_DECIMALS; // save storage access
uint tokenDecimals = decimals[token];
// technically, there might be token with decimals 0
// moreover, very possible that old tokens have decimals 0
// these tokens will just have higher gas fees.
if(tokenDecimals == 0) return token.decimals();
return tokenDecimals;
}
function calcDstQty(uint srcQty, uint srcDecimals, uint dstDecimals, uint rate) internal pure returns(uint) {
require(srcQty <= MAX_QTY);
require(rate <= MAX_RATE);
if (dstDecimals >= srcDecimals) {
require((dstDecimals - srcDecimals) <= MAX_DECIMALS);
return (srcQty * rate * (10**(dstDecimals - srcDecimals))) / PRECISION;
} else {
require((srcDecimals - dstDecimals) <= MAX_DECIMALS);
return (srcQty * rate) / (PRECISION * (10**(srcDecimals - dstDecimals)));
}
}
function calcSrcQty(uint dstQty, uint srcDecimals, uint dstDecimals, uint rate) internal pure returns(uint) {
require(dstQty <= MAX_QTY);
require(rate <= MAX_RATE);
//source quantity is rounded up. to avoid dest quantity being too low.
uint numerator;
uint denominator;
if (srcDecimals >= dstDecimals) {
require((srcDecimals - dstDecimals) <= MAX_DECIMALS);
numerator = (PRECISION * dstQty * (10**(srcDecimals - dstDecimals)));
denominator = rate;
} else {
require((dstDecimals - srcDecimals) <= MAX_DECIMALS);
numerator = (PRECISION * dstQty);
denominator = (rate * (10**(dstDecimals - srcDecimals)));
}
return (numerator + denominator - 1) / denominator; //avoid rounding down errors
}
}
| 2,438 |
17 | // Tokens | error TokenTransferFailed();
error NoTokenPrice();
| error TokenTransferFailed();
error NoTokenPrice();
| 15,644 |
177 | // event that is fired when a proposal is accepted | event ProposalPassed(uint8 methodId, uint parameter, address proposer);
| event ProposalPassed(uint8 methodId, uint parameter, address proposer);
| 28,721 |
56 | // providing a per-app ownership access control | contract HasAppOwners is HasOwners {
mapping(uint32 => address[]) public appOwners;
event AppOwnerAdded (uint32 appId, address appOwner);
event AppOwnerRemoved (uint32 appId, address appOwner);
constructor(address[] memory owners_) HasOwners(owners_) { }
/// @notice requires the sender to be one of the app owners (of `appId`)
///
/// @param appId index of the target app
modifier onlyAppOwner(uint32 appId) { require(isAppOwner(appId, msg.sender), "invalid sender; must be app owner"); _; }
function isAppOwner(uint32 appId, address appOwner) public view returns (bool) {
address[] memory currentOwners = appOwners[appId];
for (uint i = 0; i < currentOwners.length; i++) {
if (currentOwners[i] == appOwner) return true;
}
return false;
}
/// @notice list all accounts with an app-owner access for `appId`
///
/// @param appId index of the target app
function getAppOwners(uint32 appId) public view returns (address[] memory) { return appOwners[appId]; }
function addAppOwners(uint32 appId, address[] calldata toBeAdded) external onlyAppOwner(appId) {
addAppOwners_(appId, toBeAdded);
}
/// @notice authorize each of `toBeAdded` with app-owner access
///
/// @param appId index of the target app
/// @param toBeAdded accounts to be authorized
/// (the initial app-owners are established during app registration)
function addAppOwners_(uint32 appId, address[] memory toBeAdded) internal {
for (uint i = 0; i < toBeAdded.length; i++) {
if (!isAppOwner(appId, toBeAdded[i])) {
appOwners[appId].push(toBeAdded[i]);
emit AppOwnerAdded(appId, toBeAdded[i]);
}
}
}
/// @notice revokes app-owner access for each of `toBeRemoved` (while ensuring at least one app-owner remains)
///
/// @param appId index of the target app
/// @param toBeRemoved accounts to have their membership revoked
function removeAppOwners(uint32 appId, address[] calldata toBeRemoved) external onlyAppOwner(appId) {
address[] storage currentOwners = appOwners[appId];
require(currentOwners.length > toBeRemoved.length, "can not remove last owner");
for (uint i = 0; i < toBeRemoved.length; i++) {
for (uint j = 0; j < currentOwners.length; j++) {
if (currentOwners[j] == toBeRemoved[i]) {
currentOwners[j] = currentOwners[currentOwners.length - 1];
currentOwners.pop();
emit AppOwnerRemoved(appId, toBeRemoved[i]);
break;
}
}
}
}
}
| contract HasAppOwners is HasOwners {
mapping(uint32 => address[]) public appOwners;
event AppOwnerAdded (uint32 appId, address appOwner);
event AppOwnerRemoved (uint32 appId, address appOwner);
constructor(address[] memory owners_) HasOwners(owners_) { }
/// @notice requires the sender to be one of the app owners (of `appId`)
///
/// @param appId index of the target app
modifier onlyAppOwner(uint32 appId) { require(isAppOwner(appId, msg.sender), "invalid sender; must be app owner"); _; }
function isAppOwner(uint32 appId, address appOwner) public view returns (bool) {
address[] memory currentOwners = appOwners[appId];
for (uint i = 0; i < currentOwners.length; i++) {
if (currentOwners[i] == appOwner) return true;
}
return false;
}
/// @notice list all accounts with an app-owner access for `appId`
///
/// @param appId index of the target app
function getAppOwners(uint32 appId) public view returns (address[] memory) { return appOwners[appId]; }
function addAppOwners(uint32 appId, address[] calldata toBeAdded) external onlyAppOwner(appId) {
addAppOwners_(appId, toBeAdded);
}
/// @notice authorize each of `toBeAdded` with app-owner access
///
/// @param appId index of the target app
/// @param toBeAdded accounts to be authorized
/// (the initial app-owners are established during app registration)
function addAppOwners_(uint32 appId, address[] memory toBeAdded) internal {
for (uint i = 0; i < toBeAdded.length; i++) {
if (!isAppOwner(appId, toBeAdded[i])) {
appOwners[appId].push(toBeAdded[i]);
emit AppOwnerAdded(appId, toBeAdded[i]);
}
}
}
/// @notice revokes app-owner access for each of `toBeRemoved` (while ensuring at least one app-owner remains)
///
/// @param appId index of the target app
/// @param toBeRemoved accounts to have their membership revoked
function removeAppOwners(uint32 appId, address[] calldata toBeRemoved) external onlyAppOwner(appId) {
address[] storage currentOwners = appOwners[appId];
require(currentOwners.length > toBeRemoved.length, "can not remove last owner");
for (uint i = 0; i < toBeRemoved.length; i++) {
for (uint j = 0; j < currentOwners.length; j++) {
if (currentOwners[j] == toBeRemoved[i]) {
currentOwners[j] = currentOwners[currentOwners.length - 1];
currentOwners.pop();
emit AppOwnerRemoved(appId, toBeRemoved[i]);
break;
}
}
}
}
}
| 24,788 |
35 | // 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");
}
| 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");
}
| 37,135 |
22 | // Get the total amount of Ether needed to successfully purchase this item. | function totalPrice() public view returns(uint256) {
// Return price required
return tokenPrice * tokenCount() / tokenBase() + fee();
}
| function totalPrice() public view returns(uint256) {
// Return price required
return tokenPrice * tokenCount() / tokenBase() + fee();
}
| 47,588 |
172 | // Pairs | function getPoolsLength(address fromToken, address destToken)
external view returns(uint256);
function getPools(address fromToken, address destToken)
external view returns(address[] memory);
function getPoolsWithLimit(address fromToken, address destToken, uint256 offset, uint256 limit)
external view returns(address[] memory result);
function getBestPools(address fromToken, address destToken)
external view returns(address[] memory pools);
function getBestPoolsWithLimit(address fromToken, address destToken, uint256 limit)
external view returns(address[] memory pools);
| function getPoolsLength(address fromToken, address destToken)
external view returns(uint256);
function getPools(address fromToken, address destToken)
external view returns(address[] memory);
function getPoolsWithLimit(address fromToken, address destToken, uint256 offset, uint256 limit)
external view returns(address[] memory result);
function getBestPools(address fromToken, address destToken)
external view returns(address[] memory pools);
function getBestPoolsWithLimit(address fromToken, address destToken, uint256 limit)
external view returns(address[] memory pools);
| 40,953 |
28 | // function _requireNotNull(address account,string memory message)internal pure | //{
//account.requireNotNull(message);
//}
| //{
//account.requireNotNull(message);
//}
| 43,060 |
313 | // begin REDSustainabilityCertificate.sol | contract REDSustainabilityCertificate is ERC721, AccessControl, ERC721Pausable, ERC721Burnable {
using Counters for Counters.Counter;
Counters.Counter private _sustainabilityCertificateTracker;
bytes32 public constant OPERATOR_ROLE = keccak256('OPERATOR_ROLE');
struct SustainabilityCertificateMetadata {
uint256 REOGBurned;
uint256 GTKBurned;
uint256 CO2Offset;
uint256 C02Footprint;
uint256 C02Neutrality;
string EmitingEntity;
string Status;
string Entity;
string UUID;
string Extra;
}
mapping(uint256 => SustainabilityCertificateMetadata) _ogSerialNumberMetadata;
constructor() ERC721('Restart Energy Democracy SustainabilityCertificate', 'REDSustainabilityCertificate') {
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
_setupRole(OPERATOR_ROLE, _msgSender());
_setBaseURI('http://redplatform.com/nftTokens/sustainabilityCertificate');
}
function setBaseURI(string memory baseURI_) public virtual {
require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), 'RED SustainabilityCertificate TOKEN: must have admin role to set a new base uri');
_setBaseURI(baseURI_);
}
function createCertificate(
address owner,
uint256 reogBurned,
uint256 gtkBurned,
uint256 co2footprint,
uint256 co2neutrality,
string memory tokenURI,
string memory status,
string memory entity,
string memory uuid,
string memory emitingEntity,
string memory extra
)
public
returns (
//Tara-Regiune-Oras, Tara-Regiune-Localitate, Planeta-Tara-Regiune-Localitate
uint256
)
{
require(hasRole(OPERATOR_ROLE, _msgSender()), 'RED SustainabilityCertificate TOKEN: must have minter role to mint');
require(reogBurned >= 0, 'RED SustainabilityCertificate TOKEN: REOGBurned should be positive.');
require(gtkBurned >= 0, 'RED SustainabilityCertificate TOKEN: GTKBurned should be positive.');
require(gtkBurned>0 || reogBurned>0,'RED SustainabilityCertificate TOKEN: reogBurned or gtkBurned must be bigger than 0');
_sustainabilityCertificateTracker.increment();
uint256 newItemId = _sustainabilityCertificateTracker.current();
_mint(owner, newItemId);
_setTokenURI(newItemId, tokenURI);
uint256 _co2offset = 750 * reogBurned + gtkBurned;
SustainabilityCertificateMetadata memory _metadata =
SustainabilityCertificateMetadata({
EmitingEntity:emitingEntity,
REOGBurned: reogBurned,
GTKBurned: gtkBurned,
CO2Offset: _co2offset,
Status: status,
Entity: entity,
C02Footprint: co2footprint,
C02Neutrality: co2neutrality,
UUID:uuid,
Extra:extra
});
_ogSerialNumberMetadata[newItemId] = _metadata;
return newItemId;
}
function MetadataCO2Offset(uint256 tokenID) public view returns (uint256) {
require(tokenID > 0, 'RED SustainabilityCertificate TOKEN: tokenID should be higher than 0');
require(tokenID <= _sustainabilityCertificateTracker.current(), 'RED SustainabilityCertificate: tokenID should be lower than max generatedIDS');
return _ogSerialNumberMetadata[tokenID].CO2Offset;
}
function MetadataREOGBurned(uint256 tokenID) public view returns (uint256) {
require(tokenID > 0, 'RED GREEN TOKEN: tokenID should be higher than 0');
require(tokenID <= _sustainabilityCertificateTracker.current(), 'RED SustainabilityCertificate: tokenID should be lower than max generatedIDS');
return _ogSerialNumberMetadata[tokenID].REOGBurned;
}
function MetadataGTKBurned(uint256 tokenID) public view returns (uint256) {
require(tokenID > 0, 'RED SustainabilityCertificate TOKEN: tokenID should be higher than 0');
require(tokenID <= _sustainabilityCertificateTracker.current(), 'RED SustainabilityCertificate: tokenID should be lower than max generatedIDS');
return _ogSerialNumberMetadata[tokenID].GTKBurned;
}
function MetadataC02Footprint(uint256 tokenID) public view returns (uint256) {
require(tokenID > 0, 'RED SustainabilityCertificate TOKEN: tokenID should be higher than 0');
require(tokenID <= _sustainabilityCertificateTracker.current(), 'RED SustainabilityCertificate: tokenID should be lower than max generatedIDS');
return _ogSerialNumberMetadata[tokenID].C02Footprint;
}
function MetadataC02Neutrality(uint256 tokenID) public view returns (uint256) {
require(tokenID > 0, 'RED SustainabilityCertificate TOKEN: tokenID should be higher than 0');
require(tokenID <= _sustainabilityCertificateTracker.current(), 'RED SustainabilityCertificate: tokenID should be lower than max generatedIDS');
return _ogSerialNumberMetadata[tokenID].C02Footprint;
}
function MetadataStatus(uint256 tokenID) public view returns (string memory) {
require(tokenID > 0, 'RED SustainabilityCertificate TOKEN: tokenID should be higher than 0');
require(tokenID <= _sustainabilityCertificateTracker.current(), 'RED SustainabilityCertificate: tokenID should be lower than max generatedIDS');
return _ogSerialNumberMetadata[tokenID].Status;
}
function MetadataEntity(uint256 tokenID) public view returns (string memory) {
require(tokenID > 0, 'RED SustainabilityCertificate TOKEN: tokenID should be higher than 0');
require(tokenID <= _sustainabilityCertificateTracker.current(), 'RED SustainabilityCertificate: tokenID should be lower than max generatedIDS');
return _ogSerialNumberMetadata[tokenID].Entity;
}
function MetadataUUID(uint256 tokenID) public view returns (string memory) {
require(tokenID > 0, 'RED SustainabilityCertificate TOKEN: tokenID should be higher than 0');
require(tokenID <= _sustainabilityCertificateTracker.current(), 'RED SustainabilityCertificate: tokenID should be lower than max generatedIDS');
return _ogSerialNumberMetadata[tokenID].UUID;
}
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override(ERC721, ERC721Pausable) {
super._beforeTokenTransfer(from, to, tokenId);
}
function unpause() public virtual {
require(hasRole(OPERATOR_ROLE, _msgSender()), 'RED SustainabilityCertificate TOKEN: must have pauser role to unpause');
_unpause();
}
function pause() public virtual {
require(hasRole(OPERATOR_ROLE, _msgSender()), 'RED SustainabilityCertificate TOKEN: must have pauser role to pause');
_pause();
}
function burn(uint256 tokenId) public override {
require(hasRole(OPERATOR_ROLE, _msgSender()), 'RED SustainabilityCertificate TOKEN: must have operator role to mint');
_burn(tokenId);
}
}
| contract REDSustainabilityCertificate is ERC721, AccessControl, ERC721Pausable, ERC721Burnable {
using Counters for Counters.Counter;
Counters.Counter private _sustainabilityCertificateTracker;
bytes32 public constant OPERATOR_ROLE = keccak256('OPERATOR_ROLE');
struct SustainabilityCertificateMetadata {
uint256 REOGBurned;
uint256 GTKBurned;
uint256 CO2Offset;
uint256 C02Footprint;
uint256 C02Neutrality;
string EmitingEntity;
string Status;
string Entity;
string UUID;
string Extra;
}
mapping(uint256 => SustainabilityCertificateMetadata) _ogSerialNumberMetadata;
constructor() ERC721('Restart Energy Democracy SustainabilityCertificate', 'REDSustainabilityCertificate') {
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
_setupRole(OPERATOR_ROLE, _msgSender());
_setBaseURI('http://redplatform.com/nftTokens/sustainabilityCertificate');
}
function setBaseURI(string memory baseURI_) public virtual {
require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), 'RED SustainabilityCertificate TOKEN: must have admin role to set a new base uri');
_setBaseURI(baseURI_);
}
function createCertificate(
address owner,
uint256 reogBurned,
uint256 gtkBurned,
uint256 co2footprint,
uint256 co2neutrality,
string memory tokenURI,
string memory status,
string memory entity,
string memory uuid,
string memory emitingEntity,
string memory extra
)
public
returns (
//Tara-Regiune-Oras, Tara-Regiune-Localitate, Planeta-Tara-Regiune-Localitate
uint256
)
{
require(hasRole(OPERATOR_ROLE, _msgSender()), 'RED SustainabilityCertificate TOKEN: must have minter role to mint');
require(reogBurned >= 0, 'RED SustainabilityCertificate TOKEN: REOGBurned should be positive.');
require(gtkBurned >= 0, 'RED SustainabilityCertificate TOKEN: GTKBurned should be positive.');
require(gtkBurned>0 || reogBurned>0,'RED SustainabilityCertificate TOKEN: reogBurned or gtkBurned must be bigger than 0');
_sustainabilityCertificateTracker.increment();
uint256 newItemId = _sustainabilityCertificateTracker.current();
_mint(owner, newItemId);
_setTokenURI(newItemId, tokenURI);
uint256 _co2offset = 750 * reogBurned + gtkBurned;
SustainabilityCertificateMetadata memory _metadata =
SustainabilityCertificateMetadata({
EmitingEntity:emitingEntity,
REOGBurned: reogBurned,
GTKBurned: gtkBurned,
CO2Offset: _co2offset,
Status: status,
Entity: entity,
C02Footprint: co2footprint,
C02Neutrality: co2neutrality,
UUID:uuid,
Extra:extra
});
_ogSerialNumberMetadata[newItemId] = _metadata;
return newItemId;
}
function MetadataCO2Offset(uint256 tokenID) public view returns (uint256) {
require(tokenID > 0, 'RED SustainabilityCertificate TOKEN: tokenID should be higher than 0');
require(tokenID <= _sustainabilityCertificateTracker.current(), 'RED SustainabilityCertificate: tokenID should be lower than max generatedIDS');
return _ogSerialNumberMetadata[tokenID].CO2Offset;
}
function MetadataREOGBurned(uint256 tokenID) public view returns (uint256) {
require(tokenID > 0, 'RED GREEN TOKEN: tokenID should be higher than 0');
require(tokenID <= _sustainabilityCertificateTracker.current(), 'RED SustainabilityCertificate: tokenID should be lower than max generatedIDS');
return _ogSerialNumberMetadata[tokenID].REOGBurned;
}
function MetadataGTKBurned(uint256 tokenID) public view returns (uint256) {
require(tokenID > 0, 'RED SustainabilityCertificate TOKEN: tokenID should be higher than 0');
require(tokenID <= _sustainabilityCertificateTracker.current(), 'RED SustainabilityCertificate: tokenID should be lower than max generatedIDS');
return _ogSerialNumberMetadata[tokenID].GTKBurned;
}
function MetadataC02Footprint(uint256 tokenID) public view returns (uint256) {
require(tokenID > 0, 'RED SustainabilityCertificate TOKEN: tokenID should be higher than 0');
require(tokenID <= _sustainabilityCertificateTracker.current(), 'RED SustainabilityCertificate: tokenID should be lower than max generatedIDS');
return _ogSerialNumberMetadata[tokenID].C02Footprint;
}
function MetadataC02Neutrality(uint256 tokenID) public view returns (uint256) {
require(tokenID > 0, 'RED SustainabilityCertificate TOKEN: tokenID should be higher than 0');
require(tokenID <= _sustainabilityCertificateTracker.current(), 'RED SustainabilityCertificate: tokenID should be lower than max generatedIDS');
return _ogSerialNumberMetadata[tokenID].C02Footprint;
}
function MetadataStatus(uint256 tokenID) public view returns (string memory) {
require(tokenID > 0, 'RED SustainabilityCertificate TOKEN: tokenID should be higher than 0');
require(tokenID <= _sustainabilityCertificateTracker.current(), 'RED SustainabilityCertificate: tokenID should be lower than max generatedIDS');
return _ogSerialNumberMetadata[tokenID].Status;
}
function MetadataEntity(uint256 tokenID) public view returns (string memory) {
require(tokenID > 0, 'RED SustainabilityCertificate TOKEN: tokenID should be higher than 0');
require(tokenID <= _sustainabilityCertificateTracker.current(), 'RED SustainabilityCertificate: tokenID should be lower than max generatedIDS');
return _ogSerialNumberMetadata[tokenID].Entity;
}
function MetadataUUID(uint256 tokenID) public view returns (string memory) {
require(tokenID > 0, 'RED SustainabilityCertificate TOKEN: tokenID should be higher than 0');
require(tokenID <= _sustainabilityCertificateTracker.current(), 'RED SustainabilityCertificate: tokenID should be lower than max generatedIDS');
return _ogSerialNumberMetadata[tokenID].UUID;
}
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override(ERC721, ERC721Pausable) {
super._beforeTokenTransfer(from, to, tokenId);
}
function unpause() public virtual {
require(hasRole(OPERATOR_ROLE, _msgSender()), 'RED SustainabilityCertificate TOKEN: must have pauser role to unpause');
_unpause();
}
function pause() public virtual {
require(hasRole(OPERATOR_ROLE, _msgSender()), 'RED SustainabilityCertificate TOKEN: must have pauser role to pause');
_pause();
}
function burn(uint256 tokenId) public override {
require(hasRole(OPERATOR_ROLE, _msgSender()), 'RED SustainabilityCertificate TOKEN: must have operator role to mint');
_burn(tokenId);
}
}
| 38,037 |
1 | // Contract constructor/_initialSupply The number of tokens to mint initially (see TokenERC721) | constructor(uint _initialSupply, string _name, string _symbol, string _uriBase) public TokenERC721(_initialSupply){
__name = _name;
__symbol = _symbol;
__uriBase = bytes(_uriBase);
//Add to ERC165 Interface Check
supportedInterfaces[
this.name.selector ^
this.symbol.selector ^
this.tokenURI.selector
] = true;
}
| constructor(uint _initialSupply, string _name, string _symbol, string _uriBase) public TokenERC721(_initialSupply){
__name = _name;
__symbol = _symbol;
__uriBase = bytes(_uriBase);
//Add to ERC165 Interface Check
supportedInterfaces[
this.name.selector ^
this.symbol.selector ^
this.tokenURI.selector
] = true;
}
| 24,051 |
111 | // Transfer alphabeta tokens [strategy -> alphabetaFarm] | function withdraw(
uint256 _alphabetaAmt
| function withdraw(
uint256 _alphabetaAmt
| 29,963 |
243 | // Set in usage recorder | _updateBorgAttributesUsed(borgAttributeNames[i]);
| _updateBorgAttributesUsed(borgAttributeNames[i]);
| 17,985 |
20 | // cannot underflow if everything correct | function getMintTimesLeft(address addr, bool isPrivate) external view returns (uint256) {
if (!_revelated) {
if (isPrivate) {
if (_addressData[addr].limitPrivateMint > _addressData[addr].numberPrivateMinted) {
return _addressData[addr].limitPrivateMint - _addressData[addr].numberPrivateMinted;
} else {
return 0;
}
} else {
return MAX_MINT_PUBLIC - (_numberMinted(addr) - _addressData[addr].numberPrivateMinted);
}
} else {
if (addr == _productOwnerAddr) {
return TOTAL_CAN_MINT_NFT - (_canMintNFTMinted + _canMintNFTMintedAfterRevelation);
} else {
return 0;
}
}
}
| function getMintTimesLeft(address addr, bool isPrivate) external view returns (uint256) {
if (!_revelated) {
if (isPrivate) {
if (_addressData[addr].limitPrivateMint > _addressData[addr].numberPrivateMinted) {
return _addressData[addr].limitPrivateMint - _addressData[addr].numberPrivateMinted;
} else {
return 0;
}
} else {
return MAX_MINT_PUBLIC - (_numberMinted(addr) - _addressData[addr].numberPrivateMinted);
}
} else {
if (addr == _productOwnerAddr) {
return TOTAL_CAN_MINT_NFT - (_canMintNFTMinted + _canMintNFTMintedAfterRevelation);
} else {
return 0;
}
}
}
| 36,642 |
84 | // Remove user address from blocklist Requirements - `user` address of user. / | function removeBlockList(address user) external {
require(
hasRole(ADMIN_ROLE, msg.sender),
"You should have an admin role"
);
isBlockListed[user] = false;
emit RemovedBlockList(user);
}
| function removeBlockList(address user) external {
require(
hasRole(ADMIN_ROLE, msg.sender),
"You should have an admin role"
);
isBlockListed[user] = false;
emit RemovedBlockList(user);
}
| 20,383 |
188 | // This function allows users to withdraw their stake after a 7 day waitingperiod from request / | function withdrawStake() external {
StakeInfo storage stakes = stakerDetails[msg.sender];
//Require the staker has locked for withdraw(currentStatus ==2) and that 7 days have
//passed by since they locked for withdraw
require(
block.timestamp - (block.timestamp % 86400) - stakes.startDate >=
7 days,
"7 days didn't pass"
);
require(
stakes.currentStatus == 2,
"Miner was not locked for withdrawal"
);
stakes.currentStatus = 0;
emit StakeWithdrawn(msg.sender);
}
| function withdrawStake() external {
StakeInfo storage stakes = stakerDetails[msg.sender];
//Require the staker has locked for withdraw(currentStatus ==2) and that 7 days have
//passed by since they locked for withdraw
require(
block.timestamp - (block.timestamp % 86400) - stakes.startDate >=
7 days,
"7 days didn't pass"
);
require(
stakes.currentStatus == 2,
"Miner was not locked for withdrawal"
);
stakes.currentStatus = 0;
emit StakeWithdrawn(msg.sender);
}
| 7,364 |
360 | // Initiate a 100% burn from the contract | burn(cost, 100);
| burn(cost, 100);
| 16,615 |
197 | // If you only want to increase the balance, the release_time must be specified in advance. |
function increaseLockBalance(address _holder, uint256 _value)
public
onlyOwner
returns (bool)
|
function increaseLockBalance(address _holder, uint256 _value)
public
onlyOwner
returns (bool)
| 53,188 |
6 | // Collects crv tokens Don't bother voting in v1 | ICurveMintr(mintr).mint(gauge);
uint256 _crv = IERC20Lib(crv).balanceOf(address(this));
if (_crv > 0) {
| ICurveMintr(mintr).mint(gauge);
uint256 _crv = IERC20Lib(crv).balanceOf(address(this));
if (_crv > 0) {
| 28,994 |
317 | // Amount of net local currency asset cash before haircuts and buffers available | int256 localAssetAvailable;
| int256 localAssetAvailable;
| 5,944 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.