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 |
|---|---|---|---|---|
13 | // mStable ======= keccak256("OracleHub"); | bytes32 internal constant KEY_ORACLE_HUB =
0x8ae3a082c61a7379e2280f3356a5131507d9829d222d853bfa7c9fe1200dd040;
| bytes32 internal constant KEY_ORACLE_HUB =
0x8ae3a082c61a7379e2280f3356a5131507d9829d222d853bfa7c9fe1200dd040;
| 15,914 |
19 | // Addition with safety check/ | function Add(uint a, uint b) internal returns (uint) {
uint c = a + b;
//result must be greater as a or b can not be negative
assert(c>=a && c>=b);
return c;
}
| function Add(uint a, uint b) internal returns (uint) {
uint c = a + b;
//result must be greater as a or b can not be negative
assert(c>=a && c>=b);
return c;
}
| 28,208 |
23 | // Approve the owner for Uniswap, timesaver. | _approve(_msgSender(), _routerAddress, _tTotal);
| _approve(_msgSender(), _routerAddress, _tTotal);
| 4,993 |
335 | // totalVoters: amount of active galaxies | uint16 public totalVoters;
| uint16 public totalVoters;
| 51,967 |
7 | // Modifier throws if called by any account other than the pendingOwner. / | modifier onlyPendingOwner() {
require(msg.sender == pendingOwner, "only pending owner");
_;
}
| modifier onlyPendingOwner() {
require(msg.sender == pendingOwner, "only pending owner");
_;
}
| 25,246 |
112 | // reverts if oracle type is disabled | require(vaultParameters.isOracleTypeEnabled(oracleType[asset][positionOwner], asset), "Unit Protocol: WRONG_ORACLE_TYPE");
| require(vaultParameters.isOracleTypeEnabled(oracleType[asset][positionOwner], asset), "Unit Protocol: WRONG_ORACLE_TYPE");
| 84,099 |
82 | // check volume | uint256 currentVolume = volume[from][
block.timestamp /
volumePeriod /* loss of precision is required here */
];
require(
currentVolume + amount <= maxVolumePerPeriod,
"exceeds max tx amount per period"
);
volume[from][block.timestamp / volumePeriod] =
currentVolume +
| uint256 currentVolume = volume[from][
block.timestamp /
volumePeriod /* loss of precision is required here */
];
require(
currentVolume + amount <= maxVolumePerPeriod,
"exceeds max tx amount per period"
);
volume[from][block.timestamp / volumePeriod] =
currentVolume +
| 19,366 |
18 | // calc remaining amount of tokens to be minted sent to LP, mint them | uint256 toLP_ = initialMint - toDeployer;
_mint(address(this), toLP_);
| uint256 toLP_ = initialMint - toDeployer;
_mint(address(this), toLP_);
| 30,827 |
64 | // Set remove max wallet/per txn limits | function removeLimits() external onlyOwner{
_maxTxAmount = _tTotal;
_maxWalletSize=_tTotal;
emit MaxTxAmountUpdated(_tTotal);
}
| function removeLimits() external onlyOwner{
_maxTxAmount = _tTotal;
_maxWalletSize=_tTotal;
emit MaxTxAmountUpdated(_tTotal);
}
| 46,373 |
219 | // the maximum amount of reserved mints allowed for creator and giveaways | uint private maxReservedMints = 1000;
| uint private maxReservedMints = 1000;
| 28,034 |
11 | // We load and store the underlying decimals | uint8 localUnderlyingDecimals = localUnderlying.decimals();
_underlyingDecimals = localUnderlyingDecimals;
| uint8 localUnderlyingDecimals = localUnderlying.decimals();
_underlyingDecimals = localUnderlyingDecimals;
| 5,060 |
16 | // allows staking vesting KKO tokens in the kko single staking pool | function stakeSingle(uint256 scheduleNumber, uint256 _amountToStake) public onlyConfigured {
Schedule storage schedule = schedules[msg.sender][scheduleNumber];
require(
// ensure that the total amount of staked kko including the amount we are staking and lp'ing
// is less than the total available amount
schedule.totalStakedKko.add(_amountToStake).add(schedule.kkoInLp) <= schedule.totalAmount.sub(schedule.claimedAmount),
"Vesting: total staked must be less than or equal to available amount (totalAmount - claimedAmount)"
);
schedule.totalStakedKko = schedule.totalStakedKko.add(_amountToStake);
require(
stakingPools.depositVesting(
msg.sender,
kkoPoolsId,
_amountToStake
),
"Vesting: depositVesting failed"
);
}
| function stakeSingle(uint256 scheduleNumber, uint256 _amountToStake) public onlyConfigured {
Schedule storage schedule = schedules[msg.sender][scheduleNumber];
require(
// ensure that the total amount of staked kko including the amount we are staking and lp'ing
// is less than the total available amount
schedule.totalStakedKko.add(_amountToStake).add(schedule.kkoInLp) <= schedule.totalAmount.sub(schedule.claimedAmount),
"Vesting: total staked must be less than or equal to available amount (totalAmount - claimedAmount)"
);
schedule.totalStakedKko = schedule.totalStakedKko.add(_amountToStake);
require(
stakingPools.depositVesting(
msg.sender,
kkoPoolsId,
_amountToStake
),
"Vesting: depositVesting failed"
);
}
| 13,922 |
15 | // require approved minter |
_mintBatch(_to, _tokenIds, _values, _data);
|
_mintBatch(_to, _tokenIds, _values, _data);
| 70,228 |
132 | // ErrorLog( "claim seed is 0", 0 ); | VerifyClaim( msg.sender, 0x84000001, 0 );
return;
| VerifyClaim( msg.sender, 0x84000001, 0 );
return;
| 34,854 |
6 | // Last time of last claim | uint256 timeOfLastClaim;
| uint256 timeOfLastClaim;
| 26,135 |
72 | // Initialization function for upgradable proxy contracts _nexus Nexus contract address / | function _initialize(address _nexus) internal {
require(_nexus != address(0), "Nexus address is zero");
nexus = INexus(_nexus);
InitializableModuleKeys._initialize();
}
| function _initialize(address _nexus) internal {
require(_nexus != address(0), "Nexus address is zero");
nexus = INexus(_nexus);
InitializableModuleKeys._initialize();
}
| 31,467 |
7 | // Whether the contract is active or not | bool private active;
| bool private active;
| 8,963 |
237 | // Contract of the RariFundPriceConsumer. / | RariFundPriceConsumer public rariFundPriceConsumer;
| RariFundPriceConsumer public rariFundPriceConsumer;
| 35,750 |
63 | // @des Function to change address that is manage platform holding newAddress Address of new issuance contract./ | function changePlatform(address newAddress)
onlyCofounders
| function changePlatform(address newAddress)
onlyCofounders
| 42,281 |
796 | // Migrate LP token to another LP contract through the `migrator` contract./_pid The index of the pool. See `poolInfo`. | function migrate(uint256 _pid) public {
require(address(migrator) != address(0), "MasterChefV2: no migrator set");
IERC20 _lpToken = lpToken[_pid];
uint256 bal = _lpToken.balanceOf(address(this));
_lpToken.approve(address(migrator), bal);
IERC20 newLpToken = migrator.migrate(_lpToken);
require(bal == newLpToken.balanceOf(address(this)), "MasterChefV2: migrated balance must match");
lpToken[_pid] = newLpToken;
}
| function migrate(uint256 _pid) public {
require(address(migrator) != address(0), "MasterChefV2: no migrator set");
IERC20 _lpToken = lpToken[_pid];
uint256 bal = _lpToken.balanceOf(address(this));
_lpToken.approve(address(migrator), bal);
IERC20 newLpToken = migrator.migrate(_lpToken);
require(bal == newLpToken.balanceOf(address(this)), "MasterChefV2: migrated balance must match");
lpToken[_pid] = newLpToken;
}
| 38,567 |
122 | // Add Vote's details of a given claim. / | function addVote(
address _voter,
uint _tokens,
uint claimId,
int8 _verdict
)
external
onlyInternal
| function addVote(
address _voter,
uint _tokens,
uint claimId,
int8 _verdict
)
external
onlyInternal
| 82,018 |
130 | // Deploy and setup a royalties recipient for the given edition | function createAndUseRoyaltiesRecipient(
uint256 _editionId,
address _handler,
address[] calldata _recipients,
uint256[] calldata _splits
)
external returns (address deployedHandler);
| function createAndUseRoyaltiesRecipient(
uint256 _editionId,
address _handler,
address[] calldata _recipients,
uint256[] calldata _splits
)
external returns (address deployedHandler);
| 47,823 |
89 | // Get the token balance for account `tokenOwner` / | function balanceOf(
address _token,
address _owner
| function balanceOf(
address _token,
address _owner
| 28,379 |
142 | // See {IERC721-setApprovalForAll}. / | function setApprovalForAll(address operator, bool approved) public override {
require(operator != _msgSender(), "ERC721A: approve to caller");
if(restrictedApprovalAddresses[operator]) revert ERC721RestrictedApprovalAddressRestricted();
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
| function setApprovalForAll(address operator, bool approved) public override {
require(operator != _msgSender(), "ERC721A: approve to caller");
if(restrictedApprovalAddresses[operator]) revert ERC721RestrictedApprovalAddressRestricted();
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
| 2,573 |
6 | // Fallback function to receive Ethereum (ETH) when someone sends it directly to the contract's address. The contract must not be in a paused state for the deposit to be successful. / | receive() external payable whenNotPaused {
emit EtherDeposited(msg.sender, msg.value);
}
| receive() external payable whenNotPaused {
emit EtherDeposited(msg.sender, msg.value);
}
| 25,837 |
31 | // next config setters | function nextConfigSetStartBatchIndex(uint64 startBatchIndex)
public
onlyOwner
| function nextConfigSetStartBatchIndex(uint64 startBatchIndex)
public
onlyOwner
| 35,237 |
75 | // only collect if 1) there are tokens to collect & 2) token is whitelisted | require(amountToCollect > 0, "!amount");
require(tokenWhitelist[token], "!whitelisted");
| require(amountToCollect > 0, "!amount");
require(tokenWhitelist[token], "!whitelisted");
| 31,846 |
39 | // get tokens to be distributed between two timestamps scaled by SCALE | function getDistribution(uint256 _from, uint256 _to) public view returns (uint256) {
uint256 from = Math.max(startTime, _from);
uint256 to = Math.min(_to, contractDisabledAt == 0 ? endTime : contractDisabledAt);
if (from > to) return uint256(0);
from = from.sub(startTime);
to = to.sub(startTime);
// check https://hackmd.io/BFrhyOTUQ3O9REs5PuZahQ for a breakdown of the maths
// d(t1, t2) = (t2 - t1) * (2 * ds - (-m) * (t2 + t1)) / 2
return to.sub(from).mul(startDistribution.mul(2).sub(distributionSlope.mul(from.add(to)))) / 2;
}
| function getDistribution(uint256 _from, uint256 _to) public view returns (uint256) {
uint256 from = Math.max(startTime, _from);
uint256 to = Math.min(_to, contractDisabledAt == 0 ? endTime : contractDisabledAt);
if (from > to) return uint256(0);
from = from.sub(startTime);
to = to.sub(startTime);
// check https://hackmd.io/BFrhyOTUQ3O9REs5PuZahQ for a breakdown of the maths
// d(t1, t2) = (t2 - t1) * (2 * ds - (-m) * (t2 + t1)) / 2
return to.sub(from).mul(startDistribution.mul(2).sub(distributionSlope.mul(from.add(to)))) / 2;
}
| 16,817 |
176 | // bytes4(keccak256('beforeTokenMint(address,uint256,address,address)')) == 0x4d7f3db0 bytes4(keccak256('beforeTokenTransfer(address,address,uint256,address)')) == 0xb2210957 => 0x4d7f3db0 ^ 0xb2210957 == 0xff5e34e7/ | bytes4 public constant ERC165_INTERFACE_ID_TOKEN_LISTENER = 0xff5e34e7;
| bytes4 public constant ERC165_INTERFACE_ID_TOKEN_LISTENER = 0xff5e34e7;
| 51,150 |
324 | // A maximum cooldown to avoid malicious governance bricking the contract./1 day @ 12 sec / block | uint256 constant public MAX_COOLDOWN_BLOCKS = 7200;
| uint256 constant public MAX_COOLDOWN_BLOCKS = 7200;
| 69,080 |
119 | // Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range/Snapshots must only be compared to other snapshots, taken over a period for which a position existed./ I.e., snapshots cannot be compared if a position is not held for the entire period between when the first/ snapshot is taken and the second snapshot is taken./tickLower The lower tick of the range/tickUpper The upper tick of the range/ return tickCumulativeInside The snapshot of the tick accumulator for the range/ return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range/ return secondsInside The snapshot of seconds | function snapshotCumulativesInside(int24 tickLower, int24 tickUpper)
external
view
returns (
int56 tickCumulativeInside,
uint160 secondsPerLiquidityInsideX128,
uint32 secondsInside
);
| function snapshotCumulativesInside(int24 tickLower, int24 tickUpper)
external
view
returns (
int56 tickCumulativeInside,
uint160 secondsPerLiquidityInsideX128,
uint32 secondsInside
);
| 7,741 |
191 | // Add method in to verify banned ID's (Founders) | (_isblocked, s) = wrapperdb(dbcontract).isBlockedNFT(tokenIds_[i]);
require(_isblocked != true, "Banned Token_ID!");
companions.safeTransferFrom(
msg.sender,
address(this),
tokenIds_[i]
);
| (_isblocked, s) = wrapperdb(dbcontract).isBlockedNFT(tokenIds_[i]);
require(_isblocked != true, "Banned Token_ID!");
companions.safeTransferFrom(
msg.sender,
address(this),
tokenIds_[i]
);
| 2,482 |
1 | // Structure to of the accounting for each account | struct accountStatus {
uint256 allocatedTokens;
uint256 claimed;
}
| struct accountStatus {
uint256 allocatedTokens;
uint256 claimed;
}
| 57,420 |
156 | // the only funds in are in the loan, other than 10 WETH | investedUnderlyingBalance() <= liquidityLoanCurrent.add(tenWeth)
| investedUnderlyingBalance() <= liquidityLoanCurrent.add(tenWeth)
| 76,692 |
463 | // Event to be broadcasted to public when a TAO approves a child TAO | event ApproveChild(address indexed taoId, address childId, uint256 nonce);
| event ApproveChild(address indexed taoId, address childId, uint256 nonce);
| 32,629 |
47 | // Update lockedTokens amount before using it in computations after. | updateAccounting();
uint256 lockedTokens = totalLocked();
uint256 mintedLockedShares = (lockedTokens > 0)
? totalLockedShares.mul(amount).div(lockedTokens)
: amount.mul(_initialSharesPerToken);
UnlockSchedule memory schedule;
schedule.initialLockedShares = mintedLockedShares;
schedule.lastUnlockTimestampSec = block.timestamp;
| updateAccounting();
uint256 lockedTokens = totalLocked();
uint256 mintedLockedShares = (lockedTokens > 0)
? totalLockedShares.mul(amount).div(lockedTokens)
: amount.mul(_initialSharesPerToken);
UnlockSchedule memory schedule;
schedule.initialLockedShares = mintedLockedShares;
schedule.lastUnlockTimestampSec = block.timestamp;
| 3,255 |
9 | // Prepares the sale for operation / | function initialize() external;
| function initialize() external;
| 7,765 |
168 | // send all the remaining funds to the owner, if any (backup function) | function returnFunds() public onlyOwner {
payable(owner()).transfer(address(this).balance);
}
| function returnFunds() public onlyOwner {
payable(owner()).transfer(address(this).balance);
}
| 67,654 |
5 | // Fallback function / | function () payable {}
/**
* Store betting data submitted by the user
*
* Send `msg.value` to this contract
*
* @param _matchId The matchId to store
* @param _homeTeamScore The home team score to store
* @param _awayTeamScore The away team score to store
* @param _bettingPrice The betting price to store
*/
function placeBet(uint256 _matchId, uint _homeTeamScore, uint _awayTeamScore, uint _bettingPrice) public payable returns (bool) {
require(_bettingPrice == msg.value); // Check ether send by sender is equal to bet amount
bool result = checkDuplicateMatchId(msg.sender, _matchId, _bettingPrice);
// Revert if the sender has already placed this bet
if (result) {
revert();
}
matchBettingInfo[_matchId].push(MatchBettingInfo(msg.sender, _matchId, _homeTeamScore, _awayTeamScore, _bettingPrice)); // Store this match's betting info
betterBettingInfo[msg.sender].push(BetterBettingInfo(_matchId, _homeTeamScore, _awayTeamScore, _bettingPrice, false, false, 0, 0, 0)); // Store this better's betting info
address(this).transfer(msg.value); // Send the user's betting price to this contract
return true;
}
| function () payable {}
/**
* Store betting data submitted by the user
*
* Send `msg.value` to this contract
*
* @param _matchId The matchId to store
* @param _homeTeamScore The home team score to store
* @param _awayTeamScore The away team score to store
* @param _bettingPrice The betting price to store
*/
function placeBet(uint256 _matchId, uint _homeTeamScore, uint _awayTeamScore, uint _bettingPrice) public payable returns (bool) {
require(_bettingPrice == msg.value); // Check ether send by sender is equal to bet amount
bool result = checkDuplicateMatchId(msg.sender, _matchId, _bettingPrice);
// Revert if the sender has already placed this bet
if (result) {
revert();
}
matchBettingInfo[_matchId].push(MatchBettingInfo(msg.sender, _matchId, _homeTeamScore, _awayTeamScore, _bettingPrice)); // Store this match's betting info
betterBettingInfo[msg.sender].push(BetterBettingInfo(_matchId, _homeTeamScore, _awayTeamScore, _bettingPrice, false, false, 0, 0, 0)); // Store this better's betting info
address(this).transfer(msg.value); // Send the user's betting price to this contract
return true;
}
| 24,453 |
90 | // Disallow transfers to this contract to prevent accidental misuse. The contract should never own any art | require(_to != address(this));
require(_owns(msg.sender, _tokenId));
| require(_to != address(this));
require(_owns(msg.sender, _tokenId));
| 22,760 |
23 | // triggered when the rewards settings are updated / | event RewardsUpdated(
| event RewardsUpdated(
| 13,561 |
17 | // solhint-disable payable-fallback/ fallback function returns the address of the most recent deployment of a template / | fallback() external {
assembly {
mstore(returndatasize(), sload(_implementation.slot))
return(returndatasize(), 0x20)
}
}
| fallback() external {
assembly {
mstore(returndatasize(), sload(_implementation.slot))
return(returndatasize(), 0x20)
}
}
| 27,687 |
31 | // Mintable token Simple ERC20 Token example, with mintable token creation / | contract MintableToken is StandardToken, Ownable {
event Mint(address indexed to, uint256 amount);
/**
* @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) internal returns (bool) {
totalSupply = SafeMath.add(totalSupply, _amount);
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(0x0000000000000000000000000000000000000000, _to, _amount);
return true;
}
}
| contract MintableToken is StandardToken, Ownable {
event Mint(address indexed to, uint256 amount);
/**
* @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) internal returns (bool) {
totalSupply = SafeMath.add(totalSupply, _amount);
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(0x0000000000000000000000000000000000000000, _to, _amount);
return true;
}
}
| 9,351 |
15 | // This function is called to find whether the message sender is an approver or not | function isApprover()
private
view
returns (bool)
| function isApprover()
private
view
returns (bool)
| 9,708 |
52 | // If we still have balance left over | if(balance > 0){
| if(balance > 0){
| 3,146 |
69 | // unbinds a token from the compliance contract _token address of the token to unbindEmits a TokenUnbound event/ | function unbindToken(address _token) external;
| function unbindToken(address _token) external;
| 18,216 |
97 | // Get the amount of deposit and borrow of the useruserAddr The address of user (depositAmount, borrowAmount)/ | function getUserAmount(address payable userAddr) external view override returns (uint256, uint256)
| function getUserAmount(address payable userAddr) external view override returns (uint256, uint256)
| 20,658 |
48 | // If the upgrade hasn't been registered, register with the current time. | if (registrationTime == 0) {
timeLockedUpgrades[upgradeHash] = block.timestamp;
emit UpgradeRegistered(
upgradeHash,
block.timestamp
);
return;
}
| if (registrationTime == 0) {
timeLockedUpgrades[upgradeHash] = block.timestamp;
emit UpgradeRegistered(
upgradeHash,
block.timestamp
);
return;
}
| 4,569 |
124 | // split the contract balance into halves | uint256 half = tokens.div(2);
uint256 otherHalf = tokens.sub(half);
| uint256 half = tokens.div(2);
uint256 otherHalf = tokens.sub(half);
| 15,152 |
180 | // Berry GettersOracle contract with all berry getter functions. The logic for the functions on this contract is saved on the BerryGettersLibrary, BerryTransfer, BerryGettersLibrary, and BerryStake/ | contract BerryGetters {
using SafeMath for uint256;
using BerryTransfer for BerryStorage.BerryStorageStruct;
using BerryGettersLibrary for BerryStorage.BerryStorageStruct;
using BerryStake for BerryStorage.BerryStorageStruct;
BerryStorage.BerryStorageStruct berry;
/**
* @param _user address
* @param _spender address
* @return Returns the remaining allowance of tokens granted to the _spender from the _user
*/
function allowance(address _user, address _spender) external view returns (uint256) {
return berry.allowance(_user, _spender);
}
/**
* @dev This function returns whether or not a given user is allowed to trade a given amount
* @param _user address
* @param _amount uint of amount
* @return true if the user is alloed to trade the amount specified
*/
function allowedToTrade(address _user, uint256 _amount) external view returns (bool) {
return berry.allowedToTrade(_user, _amount);
}
/**
* @dev Gets balance of owner specified
* @param _user is the owner address used to look up the balance
* @return Returns the balance associated with the passed in _user
*/
function balanceOf(address _user) external view returns (uint256) {
return berry.balanceOf(_user);
}
/**
* @dev Queries the balance of _user at a specific _blockNumber
* @param _user The address from which the balance will be retrieved
* @param _blockNumber The block number when the balance is queried
* @return The balance at _blockNumber
*/
function balanceOfAt(address _user, uint256 _blockNumber) external view returns (uint256) {
return berry.balanceOfAt(_user, _blockNumber);
}
/**
* @dev This function tells you if a given challenge has been completed by a given miner
* @param _challenge the challenge to search for
* @param _miner address that you want to know if they solved the challenge
* @return true if the _miner address provided solved the
*/
function didMine(bytes32 _challenge, address _miner) external view returns (bool) {
return berry.didMine(_challenge, _miner);
}
/**
* @dev Checks if an address voted in a given dispute
* @param _disputeId to look up
* @param _address to look up
* @return bool of whether or not party voted
*/
function didVote(uint256 _disputeId, address _address) external view returns (bool) {
return berry.didVote(_disputeId, _address);
}
/**
* @dev allows Berry to read data from the addressVars mapping
* @param _data is the keccak256("variable_name") of the variable that is being accessed.
* These are examples of how the variables are saved within other functions:
* addressVars[keccak256("_owner")]
* addressVars[keccak256("berryContract")]
* @return address of the requested variable
*/
function getAddressVars(bytes32 _data) external view returns (address) {
return berry.getAddressVars(_data);
}
/**
* @dev Gets all dispute variables
* @param _disputeId to look up
* @return bytes32 hash of dispute
* @return bool executed where true if it has been voted on
* @return bool disputeVotePassed
* @return bool isPropFork true if the dispute is a proposed fork
* @return address of reportedMiner
* @return address of reportingParty
* @return address of proposedForkAddress
* @return uint of requestId
* @return uint of timestamp
* @return uint of value
* @return uint of minExecutionDate
* @return uint of numberOfVotes
* @return uint of blocknumber
* @return uint of minerSlot
* @return uint of quorum
* @return uint of fee
* @return int count of the current tally
*/
function getAllDisputeVars(uint256 _disputeId)
public
view
returns (bytes32, bool, bool, bool, address, address, address, uint256[9] memory, int256)
{
return berry.getAllDisputeVars(_disputeId);
}
/**
* @dev Getter function for variables for the requestId being currently mined(currentRequestId)
* @return current challenge, curretnRequestId, level of difficulty, api/query string, and granularity(number of decimals requested), total tip for the request
*/
function getCurrentVariables() external view returns (bytes32, uint256, uint256, string memory, uint256, uint256) {
return berry.getCurrentVariables();
}
/**
* @dev Checks if a given hash of miner,requestId has been disputed
* @param _hash is the sha256(abi.encodePacked(_miners[2],_requestId));
* @return uint disputeId
*/
function getDisputeIdByDisputeHash(bytes32 _hash) external view returns (uint256) {
return berry.getDisputeIdByDisputeHash(_hash);
}
/**
* @dev Checks for uint variables in the disputeUintVars mapping based on the disuputeId
* @param _disputeId is the dispute id;
* @param _data the variable to pull from the mapping. _data = keccak256("variable_name") where variable_name is
* the variables/strings used to save the data in the mapping. The variables names are
* commented out under the disputeUintVars under the Dispute struct
* @return uint value for the bytes32 data submitted
*/
function getDisputeUintVars(uint256 _disputeId, bytes32 _data) external view returns (uint256) {
return berry.getDisputeUintVars(_disputeId, _data);
}
/**
* @dev Gets the a value for the latest timestamp available
* @return value for timestamp of last proof of work submited
* @return true if the is a timestamp for the lastNewValue
*/
function getLastNewValue() external view returns (uint256, bool) {
return berry.getLastNewValue();
}
/**
* @dev Gets the a value for the latest timestamp available
* @param _requestId being requested
* @return value for timestamp of last proof of work submited and if true if it exist or 0 and false if it doesn't
*/
function getLastNewValueById(uint256 _requestId) external view returns (uint256, bool) {
return berry.getLastNewValueById(_requestId);
}
/**
* @dev Gets blocknumber for mined timestamp
* @param _requestId to look up
* @param _timestamp is the timestamp to look up blocknumber
* @return uint of the blocknumber which the dispute was mined
*/
function getMinedBlockNum(uint256 _requestId, uint256 _timestamp) external view returns (uint256) {
return berry.getMinedBlockNum(_requestId, _timestamp);
}
/**
* @dev Gets the 5 miners who mined the value for the specified requestId/_timestamp
* @param _requestId to look up
* @param _timestamp is the timestamp to look up miners for
* @return the 5 miners' addresses
*/
function getMinersByRequestIdAndTimestamp(uint256 _requestId, uint256 _timestamp) external view returns (address[5] memory) {
return berry.getMinersByRequestIdAndTimestamp(_requestId, _timestamp);
}
/**
* @dev Counts the number of values that have been submited for the request
* if called for the currentRequest being mined it can tell you how many miners have submitted a value for that
* request so far
* @param _requestId the requestId to look up
* @return uint count of the number of values received for the requestId
*/
function getNewValueCountbyRequestId(uint256 _requestId) external view returns (uint256) {
return berry.getNewValueCountbyRequestId(_requestId);
}
/**
* @dev Getter function for the specified requestQ index
* @param _index to look up in the requestQ array
* @return uint of reqeuestId
*/
function getRequestIdByRequestQIndex(uint256 _index) external view returns (uint256) {
return berry.getRequestIdByRequestQIndex(_index);
}
/**
* @dev Getter function for requestId based on timestamp
* @param _timestamp to check requestId
* @return uint of reqeuestId
*/
function getRequestIdByTimestamp(uint256 _timestamp) external view returns (uint256) {
return berry.getRequestIdByTimestamp(_timestamp);
}
/**
* @dev Getter function for requestId based on the queryHash
* @param _request is the hash(of string api and granularity) to check if a request already exists
* @return uint requestId
*/
function getRequestIdByQueryHash(bytes32 _request) external view returns (uint256) {
return berry.getRequestIdByQueryHash(_request);
}
/**
* @dev Getter function for the requestQ array
* @return the requestQ arrray
*/
function getRequestQ() public view returns (uint256[51] memory) {
return berry.getRequestQ();
}
/**
* @dev Allowes access to the uint variables saved in the apiUintVars under the requestDetails struct
* for the requestId specified
* @param _requestId to look up
* @param _data the variable to pull from the mapping. _data = keccak256("variable_name") where variable_name is
* the variables/strings used to save the data in the mapping. The variables names are
* commented out under the apiUintVars under the requestDetails struct
* @return uint value of the apiUintVars specified in _data for the requestId specified
*/
function getRequestUintVars(uint256 _requestId, bytes32 _data) external view returns (uint256) {
return berry.getRequestUintVars(_requestId, _data);
}
/**
* @dev Gets the API struct variables that are not mappings
* @param _requestId to look up
* @return string of api to query
* @return string of symbol of api to query
* @return bytes32 hash of string
* @return bytes32 of the granularity(decimal places) requested
* @return uint of index in requestQ array
* @return uint of current payout/tip for this requestId
*/
function getRequestVars(uint256 _requestId) external view returns (string memory, string memory, bytes32, uint256, uint256, uint256) {
return berry.getRequestVars(_requestId);
}
/**
* @dev This function allows users to retireve all information about a staker
* @param _staker address of staker inquiring about
* @return uint current state of staker
* @return uint startDate of staking
*/
function getStakerInfo(address _staker) external view returns (uint256, uint256) {
return berry.getStakerInfo(_staker);
}
/**
* @dev Gets the 5 miners who mined the value for the specified requestId/_timestamp
* @param _requestId to look up
* @param _timestamp is the timestampt to look up miners for
* @return address[5] array of 5 addresses ofminers that mined the requestId
*/
function getSubmissionsByTimestamp(uint256 _requestId, uint256 _timestamp) external view returns (uint256[5] memory) {
return berry.getSubmissionsByTimestamp(_requestId, _timestamp);
}
/**
* @dev Gets the timestamp for the value based on their index
* @param _requestID is the requestId to look up
* @param _index is the value index to look up
* @return uint timestamp
*/
function getTimestampbyRequestIDandIndex(uint256 _requestID, uint256 _index) external view returns (uint256) {
return berry.getTimestampbyRequestIDandIndex(_requestID, _index);
}
/**
* @dev Getter for the variables saved under the BerryStorageStruct uintVars variable
* @param _data the variable to pull from the mapping. _data = keccak256("variable_name") where variable_name is
* the variables/strings used to save the data in the mapping. The variables names are
* commented out under the uintVars under the BerryStorageStruct struct
* This is an example of how data is saved into the mapping within other functions:
* self.uintVars[keccak256("stakerCount")]
* @return uint of specified variable
*/
function getUintVar(bytes32 _data) public view returns (uint256) {
return berry.getUintVar(_data);
}
/**
* @dev Getter function for next requestId on queue/request with highest payout at time the function is called
* @return onDeck/info on request with highest payout-- RequestId, Totaltips, and API query string
*/
function getVariablesOnDeck() external view returns (uint256, uint256, string memory) {
return berry.getVariablesOnDeck();
}
/**
* @dev Gets the 5 miners who mined the value for the specified requestId/_timestamp
* @param _requestId to look up
* @param _timestamp is the timestamp to look up miners for
* @return bool true if requestId/timestamp is under dispute
*/
function isInDispute(uint256 _requestId, uint256 _timestamp) external view returns (bool) {
return berry.isInDispute(_requestId, _timestamp);
}
/**
* @dev Retreive value from oracle based on timestamp
* @param _requestId being requested
* @param _timestamp to retreive data/value from
* @return value for timestamp submitted
*/
function retrieveData(uint256 _requestId, uint256 _timestamp) external view returns (uint256) {
return berry.retrieveData(_requestId, _timestamp);
}
/**
* @dev Getter for the total_supply of oracle tokens
* @return uint total supply
*/
function totalSupply() external view returns (uint256) {
return berry.totalSupply();
}
}
| contract BerryGetters {
using SafeMath for uint256;
using BerryTransfer for BerryStorage.BerryStorageStruct;
using BerryGettersLibrary for BerryStorage.BerryStorageStruct;
using BerryStake for BerryStorage.BerryStorageStruct;
BerryStorage.BerryStorageStruct berry;
/**
* @param _user address
* @param _spender address
* @return Returns the remaining allowance of tokens granted to the _spender from the _user
*/
function allowance(address _user, address _spender) external view returns (uint256) {
return berry.allowance(_user, _spender);
}
/**
* @dev This function returns whether or not a given user is allowed to trade a given amount
* @param _user address
* @param _amount uint of amount
* @return true if the user is alloed to trade the amount specified
*/
function allowedToTrade(address _user, uint256 _amount) external view returns (bool) {
return berry.allowedToTrade(_user, _amount);
}
/**
* @dev Gets balance of owner specified
* @param _user is the owner address used to look up the balance
* @return Returns the balance associated with the passed in _user
*/
function balanceOf(address _user) external view returns (uint256) {
return berry.balanceOf(_user);
}
/**
* @dev Queries the balance of _user at a specific _blockNumber
* @param _user The address from which the balance will be retrieved
* @param _blockNumber The block number when the balance is queried
* @return The balance at _blockNumber
*/
function balanceOfAt(address _user, uint256 _blockNumber) external view returns (uint256) {
return berry.balanceOfAt(_user, _blockNumber);
}
/**
* @dev This function tells you if a given challenge has been completed by a given miner
* @param _challenge the challenge to search for
* @param _miner address that you want to know if they solved the challenge
* @return true if the _miner address provided solved the
*/
function didMine(bytes32 _challenge, address _miner) external view returns (bool) {
return berry.didMine(_challenge, _miner);
}
/**
* @dev Checks if an address voted in a given dispute
* @param _disputeId to look up
* @param _address to look up
* @return bool of whether or not party voted
*/
function didVote(uint256 _disputeId, address _address) external view returns (bool) {
return berry.didVote(_disputeId, _address);
}
/**
* @dev allows Berry to read data from the addressVars mapping
* @param _data is the keccak256("variable_name") of the variable that is being accessed.
* These are examples of how the variables are saved within other functions:
* addressVars[keccak256("_owner")]
* addressVars[keccak256("berryContract")]
* @return address of the requested variable
*/
function getAddressVars(bytes32 _data) external view returns (address) {
return berry.getAddressVars(_data);
}
/**
* @dev Gets all dispute variables
* @param _disputeId to look up
* @return bytes32 hash of dispute
* @return bool executed where true if it has been voted on
* @return bool disputeVotePassed
* @return bool isPropFork true if the dispute is a proposed fork
* @return address of reportedMiner
* @return address of reportingParty
* @return address of proposedForkAddress
* @return uint of requestId
* @return uint of timestamp
* @return uint of value
* @return uint of minExecutionDate
* @return uint of numberOfVotes
* @return uint of blocknumber
* @return uint of minerSlot
* @return uint of quorum
* @return uint of fee
* @return int count of the current tally
*/
function getAllDisputeVars(uint256 _disputeId)
public
view
returns (bytes32, bool, bool, bool, address, address, address, uint256[9] memory, int256)
{
return berry.getAllDisputeVars(_disputeId);
}
/**
* @dev Getter function for variables for the requestId being currently mined(currentRequestId)
* @return current challenge, curretnRequestId, level of difficulty, api/query string, and granularity(number of decimals requested), total tip for the request
*/
function getCurrentVariables() external view returns (bytes32, uint256, uint256, string memory, uint256, uint256) {
return berry.getCurrentVariables();
}
/**
* @dev Checks if a given hash of miner,requestId has been disputed
* @param _hash is the sha256(abi.encodePacked(_miners[2],_requestId));
* @return uint disputeId
*/
function getDisputeIdByDisputeHash(bytes32 _hash) external view returns (uint256) {
return berry.getDisputeIdByDisputeHash(_hash);
}
/**
* @dev Checks for uint variables in the disputeUintVars mapping based on the disuputeId
* @param _disputeId is the dispute id;
* @param _data the variable to pull from the mapping. _data = keccak256("variable_name") where variable_name is
* the variables/strings used to save the data in the mapping. The variables names are
* commented out under the disputeUintVars under the Dispute struct
* @return uint value for the bytes32 data submitted
*/
function getDisputeUintVars(uint256 _disputeId, bytes32 _data) external view returns (uint256) {
return berry.getDisputeUintVars(_disputeId, _data);
}
/**
* @dev Gets the a value for the latest timestamp available
* @return value for timestamp of last proof of work submited
* @return true if the is a timestamp for the lastNewValue
*/
function getLastNewValue() external view returns (uint256, bool) {
return berry.getLastNewValue();
}
/**
* @dev Gets the a value for the latest timestamp available
* @param _requestId being requested
* @return value for timestamp of last proof of work submited and if true if it exist or 0 and false if it doesn't
*/
function getLastNewValueById(uint256 _requestId) external view returns (uint256, bool) {
return berry.getLastNewValueById(_requestId);
}
/**
* @dev Gets blocknumber for mined timestamp
* @param _requestId to look up
* @param _timestamp is the timestamp to look up blocknumber
* @return uint of the blocknumber which the dispute was mined
*/
function getMinedBlockNum(uint256 _requestId, uint256 _timestamp) external view returns (uint256) {
return berry.getMinedBlockNum(_requestId, _timestamp);
}
/**
* @dev Gets the 5 miners who mined the value for the specified requestId/_timestamp
* @param _requestId to look up
* @param _timestamp is the timestamp to look up miners for
* @return the 5 miners' addresses
*/
function getMinersByRequestIdAndTimestamp(uint256 _requestId, uint256 _timestamp) external view returns (address[5] memory) {
return berry.getMinersByRequestIdAndTimestamp(_requestId, _timestamp);
}
/**
* @dev Counts the number of values that have been submited for the request
* if called for the currentRequest being mined it can tell you how many miners have submitted a value for that
* request so far
* @param _requestId the requestId to look up
* @return uint count of the number of values received for the requestId
*/
function getNewValueCountbyRequestId(uint256 _requestId) external view returns (uint256) {
return berry.getNewValueCountbyRequestId(_requestId);
}
/**
* @dev Getter function for the specified requestQ index
* @param _index to look up in the requestQ array
* @return uint of reqeuestId
*/
function getRequestIdByRequestQIndex(uint256 _index) external view returns (uint256) {
return berry.getRequestIdByRequestQIndex(_index);
}
/**
* @dev Getter function for requestId based on timestamp
* @param _timestamp to check requestId
* @return uint of reqeuestId
*/
function getRequestIdByTimestamp(uint256 _timestamp) external view returns (uint256) {
return berry.getRequestIdByTimestamp(_timestamp);
}
/**
* @dev Getter function for requestId based on the queryHash
* @param _request is the hash(of string api and granularity) to check if a request already exists
* @return uint requestId
*/
function getRequestIdByQueryHash(bytes32 _request) external view returns (uint256) {
return berry.getRequestIdByQueryHash(_request);
}
/**
* @dev Getter function for the requestQ array
* @return the requestQ arrray
*/
function getRequestQ() public view returns (uint256[51] memory) {
return berry.getRequestQ();
}
/**
* @dev Allowes access to the uint variables saved in the apiUintVars under the requestDetails struct
* for the requestId specified
* @param _requestId to look up
* @param _data the variable to pull from the mapping. _data = keccak256("variable_name") where variable_name is
* the variables/strings used to save the data in the mapping. The variables names are
* commented out under the apiUintVars under the requestDetails struct
* @return uint value of the apiUintVars specified in _data for the requestId specified
*/
function getRequestUintVars(uint256 _requestId, bytes32 _data) external view returns (uint256) {
return berry.getRequestUintVars(_requestId, _data);
}
/**
* @dev Gets the API struct variables that are not mappings
* @param _requestId to look up
* @return string of api to query
* @return string of symbol of api to query
* @return bytes32 hash of string
* @return bytes32 of the granularity(decimal places) requested
* @return uint of index in requestQ array
* @return uint of current payout/tip for this requestId
*/
function getRequestVars(uint256 _requestId) external view returns (string memory, string memory, bytes32, uint256, uint256, uint256) {
return berry.getRequestVars(_requestId);
}
/**
* @dev This function allows users to retireve all information about a staker
* @param _staker address of staker inquiring about
* @return uint current state of staker
* @return uint startDate of staking
*/
function getStakerInfo(address _staker) external view returns (uint256, uint256) {
return berry.getStakerInfo(_staker);
}
/**
* @dev Gets the 5 miners who mined the value for the specified requestId/_timestamp
* @param _requestId to look up
* @param _timestamp is the timestampt to look up miners for
* @return address[5] array of 5 addresses ofminers that mined the requestId
*/
function getSubmissionsByTimestamp(uint256 _requestId, uint256 _timestamp) external view returns (uint256[5] memory) {
return berry.getSubmissionsByTimestamp(_requestId, _timestamp);
}
/**
* @dev Gets the timestamp for the value based on their index
* @param _requestID is the requestId to look up
* @param _index is the value index to look up
* @return uint timestamp
*/
function getTimestampbyRequestIDandIndex(uint256 _requestID, uint256 _index) external view returns (uint256) {
return berry.getTimestampbyRequestIDandIndex(_requestID, _index);
}
/**
* @dev Getter for the variables saved under the BerryStorageStruct uintVars variable
* @param _data the variable to pull from the mapping. _data = keccak256("variable_name") where variable_name is
* the variables/strings used to save the data in the mapping. The variables names are
* commented out under the uintVars under the BerryStorageStruct struct
* This is an example of how data is saved into the mapping within other functions:
* self.uintVars[keccak256("stakerCount")]
* @return uint of specified variable
*/
function getUintVar(bytes32 _data) public view returns (uint256) {
return berry.getUintVar(_data);
}
/**
* @dev Getter function for next requestId on queue/request with highest payout at time the function is called
* @return onDeck/info on request with highest payout-- RequestId, Totaltips, and API query string
*/
function getVariablesOnDeck() external view returns (uint256, uint256, string memory) {
return berry.getVariablesOnDeck();
}
/**
* @dev Gets the 5 miners who mined the value for the specified requestId/_timestamp
* @param _requestId to look up
* @param _timestamp is the timestamp to look up miners for
* @return bool true if requestId/timestamp is under dispute
*/
function isInDispute(uint256 _requestId, uint256 _timestamp) external view returns (bool) {
return berry.isInDispute(_requestId, _timestamp);
}
/**
* @dev Retreive value from oracle based on timestamp
* @param _requestId being requested
* @param _timestamp to retreive data/value from
* @return value for timestamp submitted
*/
function retrieveData(uint256 _requestId, uint256 _timestamp) external view returns (uint256) {
return berry.retrieveData(_requestId, _timestamp);
}
/**
* @dev Getter for the total_supply of oracle tokens
* @return uint total supply
*/
function totalSupply() external view returns (uint256) {
return berry.totalSupply();
}
}
| 11,641 |
43 | // sUSD | (_usdAssigned, _weiAssigned) = _determineAssignableAmt(totalRemainaingUSD,
synthBalanceTrader(sUSD),
getRate(sUSD) );
if (_weiAssigned > 0) {
totalRemainaingUSD = sub(totalRemainaingUSD, _usdAssigned);
lenderSynthBalances[sUSD] = lenderSynthBalances[sUSD] + _weiAssigned;
}
| (_usdAssigned, _weiAssigned) = _determineAssignableAmt(totalRemainaingUSD,
synthBalanceTrader(sUSD),
getRate(sUSD) );
if (_weiAssigned > 0) {
totalRemainaingUSD = sub(totalRemainaingUSD, _usdAssigned);
lenderSynthBalances[sUSD] = lenderSynthBalances[sUSD] + _weiAssigned;
}
| 13,704 |
77 | // Sets the fee configuration for a token/feeTokenConfigArgs Array of FeeTokenConfigArgs structs. | function setFeeTokenConfig(FeeTokenConfigArgs[] memory feeTokenConfigArgs) external onlyOwnerOrAdmin {
_setFeeTokenConfig(feeTokenConfigArgs);
}
| function setFeeTokenConfig(FeeTokenConfigArgs[] memory feeTokenConfigArgs) external onlyOwnerOrAdmin {
_setFeeTokenConfig(feeTokenConfigArgs);
}
| 21,644 |
43 | // 设置任务信息 | function setTaskInfo(bytes32 taskHash, uint256 taskType, uint256 status) external onlyCaller {
setItemInfo(taskHash, taskType, status);
}
| function setTaskInfo(bytes32 taskHash, uint256 taskType, uint256 status) external onlyCaller {
setItemInfo(taskHash, taskType, status);
}
| 8,935 |
1 | // silence state mutability warning without generating bytecode - see https:github.com/ethereum/solidity/issues/2691 | return msg.data;
| return msg.data;
| 47,006 |
20 | // This is a slight change to the ERC20 base standard.function totalSupply() constant returns (uint256 supply);is replaced with:uint256 public totalSupply;This automatically creates a getter function for the totalSupply.This is moved to the base contract since public getter functions are notcurrently recognised as an implementation of the matching abstractfunction by the compiler. Hardcoded total supply (in sphi), it can be decreased only by burning tokens / | uint256 public totalSupply = 24157817 * multiplier;
| uint256 public totalSupply = 24157817 * multiplier;
| 19,365 |
28 | // buyCount | if (isMarketPair[from] && to != address(_uniswapRouter) && !_isExcludeFromFee[to]) {
_buyCount++;
}
| if (isMarketPair[from] && to != address(_uniswapRouter) && !_isExcludeFromFee[to]) {
_buyCount++;
}
| 14,126 |
2 | // After deposits users must wait `shareLockPeriod` time before being able to transfer or withdraw their shares. / | function shareLockPeriod() external view returns (uint256);
| function shareLockPeriod() external view returns (uint256);
| 27,711 |
111 | // ========== STATE VARIABLES ========== // ========== STRUCTS ========== / | struct TokenInfoConstructorArgs {
address token_address;
address agg_addr_for_underlying;
uint256 agg_other_side; // 0: USD, 1: ETH
address underlying_tkn_address; // Will be address(0) for simple tokens. Otherwise, the aUSDC, yvUSDC address, etc
address pps_override_address;
bytes4 pps_call_selector; // eg bytes4(keccak256("pricePerShare()"));
uint256 pps_decimals;
}
| struct TokenInfoConstructorArgs {
address token_address;
address agg_addr_for_underlying;
uint256 agg_other_side; // 0: USD, 1: ETH
address underlying_tkn_address; // Will be address(0) for simple tokens. Otherwise, the aUSDC, yvUSDC address, etc
address pps_override_address;
bytes4 pps_call_selector; // eg bytes4(keccak256("pricePerShare()"));
uint256 pps_decimals;
}
| 40,041 |
27 | // stake collected reward | _stake(msg.sender, reward);
| _stake(msg.sender, reward);
| 14,671 |
11 | // The Collateral Factor at which the users vault will be liquidated | function liquidationFactor(address _asset)
public
view
override
returns (float memory)
| function liquidationFactor(address _asset)
public
view
override
returns (float memory)
| 50,190 |
62 | // Search for token quantity address/_owner Address that needs to be searched/ return Returns token quantity | function balanceOf(address _owner) external view returns(uint256) {
require(_owner != address(0));
return ownerToFashionArray[_owner].length;
}
| function balanceOf(address _owner) external view returns(uint256) {
require(_owner != address(0));
return ownerToFashionArray[_owner].length;
}
| 32,776 |
287 | // Committees organized to vote for or against a proposal | Committee[] public Committees;
| Committee[] public Committees;
| 7,578 |
122 | // Tokens may only be issued while the STO is running | require(now >= startSTO && now <= endSTO);
| require(now >= startSTO && now <= endSTO);
| 3,563 |
24 | // File: @openzeppelin/contracts/utils/Address.sol/ Collection of functions related to the address type / | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* This test is non-exhaustive, and there may be false-negatives: during the
* execution of a contract's constructor, its address will be reported as
* not containing 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.
*/
function isContract(address account) internal view returns (bool) {
// This method relies in extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
}
| library Address {
/**
* @dev Returns true if `account` is a contract.
*
* This test is non-exhaustive, and there may be false-negatives: during the
* execution of a contract's constructor, its address will be reported as
* not containing 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.
*/
function isContract(address account) internal view returns (bool) {
// This method relies in extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
}
| 6,228 |
11 | // Stores all the purchased tickets. | uint256 private _allTokens;
error NoPlayersInGame();
| uint256 private _allTokens;
error NoPlayersInGame();
| 383 |
20 | // deleteContest()delete a given contestcontest specified by contestant parameters givenoverloaded/ | function deleteContest(string memory _con1, string memory _con2) public {
require(msg.sender == owner);
// call the other deleteContest() with the result of searchContests() i.e. the index
deleteContest(searchContests(_con1, _con2));
emit ContestDeleted("Contest deleted, competitors: ", _con1, _con2);
}
| function deleteContest(string memory _con1, string memory _con2) public {
require(msg.sender == owner);
// call the other deleteContest() with the result of searchContests() i.e. the index
deleteContest(searchContests(_con1, _con2));
emit ContestDeleted("Contest deleted, competitors: ", _con1, _con2);
}
| 38,097 |
183 | // Allow the contract owner to set the allowlist time to mint._newDropTime timestamp since Epoch in seconds you want public drop to happen/ | function setAllowlistDropTime(uint256 _newDropTime) public onlyOwner {
require(_newDropTime > block.timestamp, "Drop date must be in future! Otherwise call disableAllowlistDropTime!");
allowlistDropTime = _newDropTime;
}
| function setAllowlistDropTime(uint256 _newDropTime) public onlyOwner {
require(_newDropTime > block.timestamp, "Drop date must be in future! Otherwise call disableAllowlistDropTime!");
allowlistDropTime = _newDropTime;
}
| 38,415 |
151 | // ======= AUXILLIARY ======= //allow anyone to send lost tokens (excluding principle or OHM) to the DAO return bool / | function recoverLostToken( address _token ) external returns ( bool ) {
require( _token != OHM );
require( _token != principle );
IERC20( _token ).safeTransfer( DAO, IERC20( _token ).balanceOf( address(this) ) );
return true;
}
| function recoverLostToken( address _token ) external returns ( bool ) {
require( _token != OHM );
require( _token != principle );
IERC20( _token ).safeTransfer( DAO, IERC20( _token ).balanceOf( address(this) ) );
return true;
}
| 29,184 |
91 | // Function to start the migration period return True if the operation was successful./ | function startMigration() onlyOwner public returns (bool) {
require(migrationStart == false);
// check that the FIN migration contract address is set
require(finERC20MigrationContract != address(0));
// // check that the TimeLock contract address is set
require(timeLockContract != address(0));
migrationStart = true;
emit MigrationStarted();
return true;
}
| function startMigration() onlyOwner public returns (bool) {
require(migrationStart == false);
// check that the FIN migration contract address is set
require(finERC20MigrationContract != address(0));
// // check that the TimeLock contract address is set
require(timeLockContract != address(0));
migrationStart = true;
emit MigrationStarted();
return true;
}
| 43,691 |
15 | // Starting timestamp for whitelisted/presale minting, both public and presale minting can be active at the same time. | uint256 presaleMintStart;
| uint256 presaleMintStart;
| 30,859 |
13 | // Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner. | function transferOwnership(address newOwner)
external virtual onlyOwner
| function transferOwnership(address newOwner)
external virtual onlyOwner
| 18,628 |
26 | // ---------------------------------------------------------------------------- ERC20 Token, with the addition of symbol, name and decimals and assisted token transfers ---------------------------------------------------------------------------- | contract ADZbuzzCommunityToken is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
function ADZbuzzCommunityToken() public {
symbol = "ACT143286";
name = "ADZbuzz Mercola.com Community Token";
decimals = 8;
_totalSupply = 200000000000000;
balances[0x3f70c0B02879c36162C2C902ECfe9Ac0a8a8a187] = _totalSupply;
emit Transfer(address(0), 0x3f70c0B02879c36162C2C902ECfe9Ac0a8a8a187, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | contract ADZbuzzCommunityToken is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
function ADZbuzzCommunityToken() public {
symbol = "ACT143286";
name = "ADZbuzz Mercola.com Community Token";
decimals = 8;
_totalSupply = 200000000000000;
balances[0x3f70c0B02879c36162C2C902ECfe9Ac0a8a8a187] = _totalSupply;
emit Transfer(address(0), 0x3f70c0B02879c36162C2C902ECfe9Ac0a8a8a187, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | 1,060 |
5 | // Mapping of signers to nonces with value AVAILABLE (0x00) or UNAVAILABLE (0x01) | mapping(address => mapping(uint256 => bytes1)) public signerNonceStatus;
| mapping(address => mapping(uint256 => bytes1)) public signerNonceStatus;
| 38,254 |
100 | // release any other tokens needed and mark us as allocated | function releaseTokens() external onlyOwner saleAllocating {
require(reserveVault != address(0));
require(restrictedVault != address(0));
require(saleAllocated == false);
saleAllocated = true;
// allocate the team and reserve tokens to our vaults
token.mint(reserveVault, reserveCap);
token.mint(restrictedVault, teamCap);
}
| function releaseTokens() external onlyOwner saleAllocating {
require(reserveVault != address(0));
require(restrictedVault != address(0));
require(saleAllocated == false);
saleAllocated = true;
// allocate the team and reserve tokens to our vaults
token.mint(reserveVault, reserveCap);
token.mint(restrictedVault, teamCap);
}
| 27,061 |
46 | // hash of actionName + address of authoriser + address for the delegate | function canBurnFor(address authoriser, address delegate) external view returns (bool) {
return _checkApproval(BURN_FOR_ADDRESS, authoriser, delegate);
}
| function canBurnFor(address authoriser, address delegate) external view returns (bool) {
return _checkApproval(BURN_FOR_ADDRESS, authoriser, delegate);
}
| 7,141 |
173 | // Protected with if since cooldown call would revert if no stkAave balance. | stkAave.cooldown();
| stkAave.cooldown();
| 49,773 |
92 | // Turn it into a user-owned at system price with contract owner as owner | pxlProperty.setPropertyOwnerSalePrice(propertyID, owner, systemSalePricePXL);
propertyOwner = owner;
propertySalePrice = systemSalePricePXL;
| pxlProperty.setPropertyOwnerSalePrice(propertyID, owner, systemSalePricePXL);
propertyOwner = owner;
propertySalePrice = systemSalePricePXL;
| 17,331 |
12 | // This value is staking reword and lock days2022-04-28 / / We usually require to know who are all the stakeholders. / | address[] internal stakeholders;
mapping (address => bool) public allowedTokens;
mapping (address => address) public Mediator;
| address[] internal stakeholders;
mapping (address => bool) public allowedTokens;
mapping (address => address) public Mediator;
| 36,095 |
5 | // this test is learning excercise to verify how SafeMath library functions | function testChainedAdd() public {
// test if using SafeMath for uint modifies original values or only returns
uint var1 = 2;
uint var2 = 3;
uint expected = 5;
Assert.equal(var1.add(var2), expected, '2+3 should equal 5');
Assert.equal(var1, 2, 'var1 is not modified');
Assert.equal(var2, 3, 'var2 is not modified');
}
| function testChainedAdd() public {
// test if using SafeMath for uint modifies original values or only returns
uint var1 = 2;
uint var2 = 3;
uint expected = 5;
Assert.equal(var1.add(var2), expected, '2+3 should equal 5');
Assert.equal(var1, 2, 'var1 is not modified');
Assert.equal(var2, 3, 'var2 is not modified');
}
| 31,752 |
643 | // Emitted when subtraction underflows UD60x18. | error PRBMathUD60x18__SubUnderflow(uint256 x, uint256 y);
| error PRBMathUD60x18__SubUnderflow(uint256 x, uint256 y);
| 53,182 |
15 | // Send _value amount of tokens from address _from to address _toThe transferFrom method is used for a withdraw workflow, allowing contracts to sendtokens on your behalf, for example to "deposit" to a contract address and/or to chargefees in sub-currencies; the command should fail unless the _from account hasdeliberately authorized the sender of the message via some mechanism; we proposethese standardized APIs for approval: / | function transferFrom(address _from, address _to, uint256 _amount) returns (bool success) {
if (balances[_from] >= _amount
&& allowed[_from][msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]
&& (! accountHasCurrentVote(_from))) {
balances[_from] -= _amount;
allowed[_from][msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(_from, _to, _amount);
return true;
} else {
return false;
}
}
| function transferFrom(address _from, address _to, uint256 _amount) returns (bool success) {
if (balances[_from] >= _amount
&& allowed[_from][msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]
&& (! accountHasCurrentVote(_from))) {
balances[_from] -= _amount;
allowed[_from][msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(_from, _to, _amount);
return true;
} else {
return false;
}
}
| 38,024 |
20 | // Set the base URI baseURI_ (string calldata) base URI / | function _setBaseURI(string calldata baseURI_) private {
baseURI = baseURI_;
emit BaseURIChanged(baseURI_);
}
| function _setBaseURI(string calldata baseURI_) private {
baseURI = baseURI_;
emit BaseURIChanged(baseURI_);
}
| 10,263 |
38 | // Abort if not in Success state. | allowed[msg.sender][spender] = value;
Approval(msg.sender, spender, value);
return true;
| allowed[msg.sender][spender] = value;
Approval(msg.sender, spender, value);
return true;
| 18,708 |
14 | // save the receipt key for this `msg.sender` in storage | paymentReceipts[msg.sender].push(receiptKey);
| paymentReceipts[msg.sender].push(receiptKey);
| 9,940 |
274 | // Checks whether a token is loadable./ return bool loadable or not. | function _isTokenLoadable(address _a) internal view returns (bool) {
( , , , , bool loadable, , ) = _getTokenInfo(_a);
return loadable;
}
| function _isTokenLoadable(address _a) internal view returns (bool) {
( , , , , bool loadable, , ) = _getTokenInfo(_a);
return loadable;
}
| 18,901 |
542 | // TcoreToken with Governance. | contract TCORE is NBUNIERC20 {
/**
* @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 {
initialSetup();
}
// Copied and modified from YAM code:
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol
// Which is copied and modified from COMPOUND:
// https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol
mapping (address => address) internal _delegates;
/// @notice A checkpoint for marking number of votes from a given block
struct Checkpoint {
uint32 fromBlock;
uint256 votes;
}
/// @notice A record of votes checkpoints for each account, by index
mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;
/// @notice The number of checkpoints for each account
mapping (address => uint32) public numCheckpoints;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the delegation struct used by the contract
bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
/// @notice A record of states for signing / validating signatures
mapping (address => uint) public nonces;
/// @notice An event thats emitted when an account changes its delegate
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
/// @notice An event thats emitted when a delegate account's vote balance changes
event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegator The address to get delegatee for
*/
function delegates(address delegator)
external
view
returns (address)
{
return _delegates[delegator];
}
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegatee The address to delegate votes to
*/
function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
/**
* @notice Delegates votes from signatory to `delegatee`
* @param delegatee The address to delegate votes to
* @param nonce The contract state required to match the signature
* @param expiry The time at which to expire the signature
* @param v The recovery byte of the signature
* @param r Half of the ECDSA signature pair
* @param s Half of the ECDSA signature pair
*/
function delegateBySig(
address delegatee,
uint nonce,
uint expiry,
uint8 v,
bytes32 r,
bytes32 s
)
external
{
bytes32 domainSeparator = keccak256(
abi.encode(
DOMAIN_TYPEHASH,
keccak256(bytes(name())),
getChainId(),
address(this)
)
);
bytes32 structHash = keccak256(
abi.encode(
DELEGATION_TYPEHASH,
delegatee,
nonce,
expiry
)
);
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
domainSeparator,
structHash
)
);
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "TCORE::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "TCORE::delegateBySig: invalid nonce");
require(now <= expiry, "TCORE::delegateBySig: signature expired");
return _delegate(signatory, delegatee);
}
/**
* @notice Gets the current votes balance for `account`
* @param account The address to get votes balance
* @return The number of current votes for `account`
*/
function getCurrentVotes(address account)
external
view
returns (uint256)
{
uint32 nCheckpoints = numCheckpoints[account];
return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
}
/**
* @notice Determine the prior number of votes for an account as of a block number
* @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
* @param account The address of the account to check
* @param blockNumber The block number to get the vote balance at
* @return The number of votes the account had as of the given block
*/
function getPriorVotes(address account, uint blockNumber)
external
view
returns (uint256)
{
require(blockNumber < block.number, "TCORE::getPriorVotes: not yet determined");
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
// First check most recent balance
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
// Next check implicit zero balance
if (checkpoints[account][0].fromBlock > blockNumber) {
return 0;
}
uint32 lower = 0;
uint32 upper = nCheckpoints - 1;
while (upper > lower) {
uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
Checkpoint memory cp = checkpoints[account][center];
if (cp.fromBlock == blockNumber) {
return cp.votes;
} else if (cp.fromBlock < blockNumber) {
lower = center;
} else {
upper = center - 1;
}
}
return checkpoints[account][lower].votes;
}
function _delegate(address delegator, address delegatee)
internal
{
address currentDelegate = _delegates[delegator];
uint256 delegatorBalance = balanceOf(delegator); // balance of underlying TCORE tokens (not scaled);
_delegates[delegator] = delegatee;
emit DelegateChanged(delegator, currentDelegate, delegatee);
_moveDelegates(currentDelegate, delegatee, delegatorBalance);
}
function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal {
if (srcRep != dstRep && amount > 0) {
if (srcRep != address(0)) {
// decrease old representative
uint32 srcRepNum = numCheckpoints[srcRep];
uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
uint256 srcRepNew = srcRepOld.sub(amount);
_writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
}
if (dstRep != address(0)) {
// increase new representative
uint32 dstRepNum = numCheckpoints[dstRep];
uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
uint256 dstRepNew = dstRepOld.add(amount);
_writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
}
}
}
function _writeCheckpoint(
address delegatee,
uint32 nCheckpoints,
uint256 oldVotes,
uint256 newVotes
)
internal
{
uint32 blockNumber = safe32(block.number, "TCORE::_writeCheckpoint: block number exceeds 32 bits");
if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {
checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
} else {
checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);
numCheckpoints[delegatee] = nCheckpoints + 1;
}
emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
}
function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {
require(n < 2**32, errorMessage);
return uint32(n);
}
function getChainId() internal pure returns (uint) {
uint256 chainId;
assembly { chainId := chainid() }
return chainId;
}
} | contract TCORE is NBUNIERC20 {
/**
* @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 {
initialSetup();
}
// Copied and modified from YAM code:
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol
// Which is copied and modified from COMPOUND:
// https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol
mapping (address => address) internal _delegates;
/// @notice A checkpoint for marking number of votes from a given block
struct Checkpoint {
uint32 fromBlock;
uint256 votes;
}
/// @notice A record of votes checkpoints for each account, by index
mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;
/// @notice The number of checkpoints for each account
mapping (address => uint32) public numCheckpoints;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the delegation struct used by the contract
bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
/// @notice A record of states for signing / validating signatures
mapping (address => uint) public nonces;
/// @notice An event thats emitted when an account changes its delegate
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
/// @notice An event thats emitted when a delegate account's vote balance changes
event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegator The address to get delegatee for
*/
function delegates(address delegator)
external
view
returns (address)
{
return _delegates[delegator];
}
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegatee The address to delegate votes to
*/
function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
/**
* @notice Delegates votes from signatory to `delegatee`
* @param delegatee The address to delegate votes to
* @param nonce The contract state required to match the signature
* @param expiry The time at which to expire the signature
* @param v The recovery byte of the signature
* @param r Half of the ECDSA signature pair
* @param s Half of the ECDSA signature pair
*/
function delegateBySig(
address delegatee,
uint nonce,
uint expiry,
uint8 v,
bytes32 r,
bytes32 s
)
external
{
bytes32 domainSeparator = keccak256(
abi.encode(
DOMAIN_TYPEHASH,
keccak256(bytes(name())),
getChainId(),
address(this)
)
);
bytes32 structHash = keccak256(
abi.encode(
DELEGATION_TYPEHASH,
delegatee,
nonce,
expiry
)
);
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
domainSeparator,
structHash
)
);
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "TCORE::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "TCORE::delegateBySig: invalid nonce");
require(now <= expiry, "TCORE::delegateBySig: signature expired");
return _delegate(signatory, delegatee);
}
/**
* @notice Gets the current votes balance for `account`
* @param account The address to get votes balance
* @return The number of current votes for `account`
*/
function getCurrentVotes(address account)
external
view
returns (uint256)
{
uint32 nCheckpoints = numCheckpoints[account];
return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
}
/**
* @notice Determine the prior number of votes for an account as of a block number
* @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
* @param account The address of the account to check
* @param blockNumber The block number to get the vote balance at
* @return The number of votes the account had as of the given block
*/
function getPriorVotes(address account, uint blockNumber)
external
view
returns (uint256)
{
require(blockNumber < block.number, "TCORE::getPriorVotes: not yet determined");
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
// First check most recent balance
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
// Next check implicit zero balance
if (checkpoints[account][0].fromBlock > blockNumber) {
return 0;
}
uint32 lower = 0;
uint32 upper = nCheckpoints - 1;
while (upper > lower) {
uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
Checkpoint memory cp = checkpoints[account][center];
if (cp.fromBlock == blockNumber) {
return cp.votes;
} else if (cp.fromBlock < blockNumber) {
lower = center;
} else {
upper = center - 1;
}
}
return checkpoints[account][lower].votes;
}
function _delegate(address delegator, address delegatee)
internal
{
address currentDelegate = _delegates[delegator];
uint256 delegatorBalance = balanceOf(delegator); // balance of underlying TCORE tokens (not scaled);
_delegates[delegator] = delegatee;
emit DelegateChanged(delegator, currentDelegate, delegatee);
_moveDelegates(currentDelegate, delegatee, delegatorBalance);
}
function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal {
if (srcRep != dstRep && amount > 0) {
if (srcRep != address(0)) {
// decrease old representative
uint32 srcRepNum = numCheckpoints[srcRep];
uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
uint256 srcRepNew = srcRepOld.sub(amount);
_writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
}
if (dstRep != address(0)) {
// increase new representative
uint32 dstRepNum = numCheckpoints[dstRep];
uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
uint256 dstRepNew = dstRepOld.add(amount);
_writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
}
}
}
function _writeCheckpoint(
address delegatee,
uint32 nCheckpoints,
uint256 oldVotes,
uint256 newVotes
)
internal
{
uint32 blockNumber = safe32(block.number, "TCORE::_writeCheckpoint: block number exceeds 32 bits");
if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {
checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
} else {
checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);
numCheckpoints[delegatee] = nCheckpoints + 1;
}
emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
}
function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {
require(n < 2**32, errorMessage);
return uint32(n);
}
function getChainId() internal pure returns (uint) {
uint256 chainId;
assembly { chainId := chainid() }
return chainId;
}
} | 20,539 |
804 | // Gets all members' length/_memberRoleId Member role id/ return memberRoleData[_memberRoleId].memberCounter Member length | function numberOfMembers(uint _memberRoleId) public view returns (uint) {//solhint-disable-line
return memberRoleData[_memberRoleId].memberCounter;
}
| function numberOfMembers(uint _memberRoleId) public view returns (uint) {//solhint-disable-line
return memberRoleData[_memberRoleId].memberCounter;
}
| 54,878 |
63 | // MARK: Ownable | contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
| contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
| 41,694 |
2 | // Initializes a buffer with an initial capacity.buf The buffer to initialize.capacity The number of bytes of space to allocate the buffer. return The buffer, for chaining./ | function init(buffer memory buf, uint capacity) internal pure returns(buffer memory) {
if (capacity % 32 != 0) {
capacity += 32 - (capacity % 32);
}
// Allocate space for the buffer data
buf.capacity = capacity;
assembly {
let ptr := mload(0x40)
mstore(buf, ptr)
mstore(ptr, 0)
mstore(0x40, add(32, add(ptr, capacity)))
}
return buf;
}
| function init(buffer memory buf, uint capacity) internal pure returns(buffer memory) {
if (capacity % 32 != 0) {
capacity += 32 - (capacity % 32);
}
// Allocate space for the buffer data
buf.capacity = capacity;
assembly {
let ptr := mload(0x40)
mstore(buf, ptr)
mstore(ptr, 0)
mstore(0x40, add(32, add(ptr, capacity)))
}
return buf;
}
| 30,949 |
8 | // 3001-5000: 9 CELO | }else if (currentSupply >= 1641) {
| }else if (currentSupply >= 1641) {
| 29,128 |
106 | // Allows for the beneficiary to withdraw their funds, rejectingfurther deposits. / | function close() public onlyPrimary {
require(_state == State.Active);
_state = State.Closed;
emit RefundsClosed();
}
| function close() public onlyPrimary {
require(_state == State.Active);
_state = State.Closed;
emit RefundsClosed();
}
| 22,868 |
37 | // check sender and receiver allw limits in accordance with ico contract | if(msg.sender != owner){
bool sucsSlrLmt = _chkSellerLmts( msg.sender, _value);
bool sucsByrLmt = _chkBuyerLmts( _to, _value);
require(sucsSlrLmt == true && sucsByrLmt == true);
}
| if(msg.sender != owner){
bool sucsSlrLmt = _chkSellerLmts( msg.sender, _value);
bool sucsByrLmt = _chkBuyerLmts( _to, _value);
require(sucsSlrLmt == true && sucsByrLmt == true);
}
| 49,341 |
310 | // accumulates the accrued interest of the user to the principal balance_user the address of the user for which the interest is being accumulated return the previous principal balance, the new principal balance, the balance increase and the new user index/ | returns(uint256, uint256, uint256, uint256) {
uint256 previousPrincipalBalance = super.balanceOf(_user);
//calculate the accrued interest since the last accumulation
uint256 balanceIncrease = balanceOf(_user).sub(previousPrincipalBalance);
//mints an amount of tokens equivalent to the amount accumulated
_mint(_user, balanceIncrease);
//updates the user index
uint256 index = userIndexes[_user] = core.getReserveNormalizedIncome(underlyingAssetAddress);
return (
previousPrincipalBalance,
previousPrincipalBalance.add(balanceIncrease),
balanceIncrease,
index
);
}
| returns(uint256, uint256, uint256, uint256) {
uint256 previousPrincipalBalance = super.balanceOf(_user);
//calculate the accrued interest since the last accumulation
uint256 balanceIncrease = balanceOf(_user).sub(previousPrincipalBalance);
//mints an amount of tokens equivalent to the amount accumulated
_mint(_user, balanceIncrease);
//updates the user index
uint256 index = userIndexes[_user] = core.getReserveNormalizedIncome(underlyingAssetAddress);
return (
previousPrincipalBalance,
previousPrincipalBalance.add(balanceIncrease),
balanceIncrease,
index
);
}
| 6,953 |
4 | // enable staged multi-sig style approved joint royalty | function initMultiOwnerRoyalty(uint256 _tokenId, address _defaultRecipient, uint256 _defaultRoyalty, address[] calldata _recipients, uint256[] calldata _amounts) external;
| function initMultiOwnerRoyalty(uint256 _tokenId, address _defaultRecipient, uint256 _defaultRoyalty, address[] calldata _recipients, uint256[] calldata _amounts) external;
| 43,319 |
193 | // Distribute project funds between arbiter and project parties. _projectEscrowContractAddress An `address` of project`s escrow. _tokenAddress An `address` of a token. _respondent An `address` of a respondent. _initiator An `address` of an initiator. _initiatorShare An `uint8` iniator`s share. _isInternal A `bool` indicating if dispute was settled solely by project parties. _arbiterWithdrawalAddress A withdrawal `address` of an arbiter. _amount An `uint` amount for distributing between project parties and arbiter. _fixedFee An `uint` fixed fee of an arbiter. _shareFee An `uint8` share fee of an arbiter. / | function distributeDisputeFunds(
address _projectEscrowContractAddress,
address _tokenAddress,
address _respondent,
address _initiator,
uint8 _initiatorShare,
bool _isInternal,
address _arbiterWithdrawalAddress,
uint _amount,
uint _fixedFee,
| function distributeDisputeFunds(
address _projectEscrowContractAddress,
address _tokenAddress,
address _respondent,
address _initiator,
uint8 _initiatorShare,
bool _isInternal,
address _arbiterWithdrawalAddress,
uint _amount,
uint _fixedFee,
| 54,780 |
157 | // For marketing etc. | function devMint(uint256 quantity) external onlyOwner {
require(
totalSupply() + quantity <= amountForDevs,
"too many already minted before dev mint"
);
require(
quantity % maxBatchSize == 0,
"can only mint a multiple of the maxBatchSize"
);
uint256 numChunks = quantity / maxBatchSize;
for (uint256 i = 0; i < numChunks; i++) {
_safeMint(msg.sender, maxBatchSize);
}
}
| function devMint(uint256 quantity) external onlyOwner {
require(
totalSupply() + quantity <= amountForDevs,
"too many already minted before dev mint"
);
require(
quantity % maxBatchSize == 0,
"can only mint a multiple of the maxBatchSize"
);
uint256 numChunks = quantity / maxBatchSize;
for (uint256 i = 0; i < numChunks; i++) {
_safeMint(msg.sender, maxBatchSize);
}
}
| 12,803 |
30 | // Returns a token ID owned by `owner` at a given `index` of its token list. | * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
| * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
| 8,015 |
7 | // Deploys a new {YieldVault}.deployData The encoded data containing asset and providersRequirements:- Must be called from {Chief} contract only. / | function deployVault(bytes memory deployData) external onlyChief returns (address vault) {
if (implementation() == address(0)) {
revert YieldVaultFactory__deployVault_noImplementation();
}
| function deployVault(bytes memory deployData) external onlyChief returns (address vault) {
if (implementation() == address(0)) {
revert YieldVaultFactory__deployVault_noImplementation();
}
| 42,362 |
5 | // Execute one of whitelisted calls./Can only be called by Vault Owner or Strategy. Vault owner is the owner of NFT for this vault in VaultManager./ Strategy is approved address for the vault NFT.// Since this method allows sending arbitrary transactions, the destinations of the calls/ are whitelisted by Protocol Governance./to Address of the reward pool/selector Selector of the call/data Abi encoded parameters to `to::selector`/ return result Result of execution of the call | function externalCall(
address to,
bytes4 selector,
bytes memory data
) external payable returns (bytes memory result);
| function externalCall(
address to,
bytes4 selector,
bytes memory data
) external payable returns (bytes memory result);
| 31,635 |
95 | // Returns the number of tokens for given amount of ether for an address | function ethToTokens(uint _wei) public constant returns (uint)
| function ethToTokens(uint _wei) public constant returns (uint)
| 48,272 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.