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
20
// Collateral was removed.amount_The amount of collateral removed.destination_ The recipient of the collateral removed. /
event CollateralRemoved(uint256 amount_, address indexed destination_);
event CollateralRemoved(uint256 amount_, address indexed destination_);
1,848
1
// a mapping of pool contracts deployed by Element
mapping(address => bool) public pools;
mapping(address => bool) public pools;
35,816
2
// Returns address of actual PToken implementation contract return Address of contract /
function pTokenImplementation() external view returns (address); function addPToken(address underlying, address pToken) external returns(uint); function addPETH(address pETH_) external returns(uint); function addPPIE(address pPIE_) external returns(uint);
function pTokenImplementation() external view returns (address); function addPToken(address underlying, address pToken) external returns(uint); function addPETH(address pETH_) external returns(uint); function addPPIE(address pPIE_) external returns(uint);
3,111
5
// Total time the token has spent !praying tokenId Token to return info for /
function totalTimePraying(uint256 tokenId) public view returns (uint256) { if (!_exists(tokenId)) revert URIQueryForNonexistentToken(); return tokenInfo[tokenId].totalTimePraying; }
function totalTimePraying(uint256 tokenId) public view returns (uint256) { if (!_exists(tokenId)) revert URIQueryForNonexistentToken(); return tokenInfo[tokenId].totalTimePraying; }
7,526
8
// Total number of seeds/original NFTs minted
uint256 public originalsMinted = 0;
uint256 public originalsMinted = 0;
12,851
94
// step 2. recalculate rate for swapped tokens
if (foreignAmount != 0) {
if (foreignAmount != 0) {
45,920
35
// `transfer`. {sendValue} removes this limitation.IMPORTANT: because control is transferred to `recipient`, care must betaken to not create reentrancy vulnerabilities. Consider using{ReentrancyGuard} or the /
function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, 'Address: insufficient balance');
function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, 'Address: insufficient balance');
7,694
156
// Wraps the coin amount in the array for interacting with the Curve protocol/
function wrapCoinAmount(uint256 amount) internal view returns (uint256[4] memory) { uint256[4] memory amounts = [uint256(0), uint256(0), uint256(0), uint256(0)]; amounts[uint56(tokenIndex)] = amount; return amounts; }
function wrapCoinAmount(uint256 amount) internal view returns (uint256[4] memory) { uint256[4] memory amounts = [uint256(0), uint256(0), uint256(0), uint256(0)]; amounts[uint56(tokenIndex)] = amount; return amounts; }
10,267
19
// sets the contract address for eETH/_eETH address of eETH contract
function setTokenAddress(address _eETH) external onlyOwner { require(_eETH != address(0), "No zero addresses"); eETH = IeETH(_eETH); }
function setTokenAddress(address _eETH) external onlyOwner { require(_eETH != address(0), "No zero addresses"); eETH = IeETH(_eETH); }
15,006
3
// we are SELLING
amountAfterTax = taxDistributor.takeSellTax(value);
amountAfterTax = taxDistributor.takeSellTax(value);
16,766
3
// The base interest rate which is the y-intercept when utilization rate is 0 /
uint256 public baseRatePerBlock;
uint256 public baseRatePerBlock;
19,295
127
// Emitted when `sender` burns `amount` debt tokens to grant credit to `recipient`.//senderThe address which is burning tokens./amountThe amount of tokens that were burned./recipient The address that received credit for the burned tokens.
event Burn(address indexed sender, uint256 amount, address recipient);
event Burn(address indexed sender, uint256 amount, address recipient);
15,193
333
// return numberOfKeys The number of keys owned by `_keyOwner` (expired or not) /
function totalKeys( address _keyOwner ) public view returns (uint)
function totalKeys( address _keyOwner ) public view returns (uint)
37,826
5
// `msg.sender` approves `_addr` to spend `_value` tokens/_spender The address of the account able to transfer the tokens/_value The amount of wei to be approved for transfer/ return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success);
function approve(address _spender, uint256 _value) returns (bool success);
38,315
485
// Update employee to track the new salary and payment date
employee.lastPayroll = getTimestamp64(); employee.denominationTokenSalary = _denominationSalary; emit SetEmployeeSalary(_employeeId, _denominationSalary);
employee.lastPayroll = getTimestamp64(); employee.denominationTokenSalary = _denominationSalary; emit SetEmployeeSalary(_employeeId, _denominationSalary);
62,722
28
// Initializes the smart contract instead of a constructor/ _factory univ3 factory/ _WETH wrapped ETH/ _utils limit manager utils/ _KROM kromatika token/ _monitors monitors array/ _feeAddress protocol fee address/ _gasUsageMonitor estimated gas usage of monitors/ _protocolFee charged fee
function initialize( IUniswapV3Factory _factory, IWETH9 _WETH, WETHExtended _WETHExtended, IUniswapUtils _utils, IERC20 _KROM, IOrderMonitor[] calldata _monitors, address _feeAddress, uint256 _gasUsageMonitor, uint32 _protocolFee
function initialize( IUniswapV3Factory _factory, IWETH9 _WETH, WETHExtended _WETHExtended, IUniswapUtils _utils, IERC20 _KROM, IOrderMonitor[] calldata _monitors, address _feeAddress, uint256 _gasUsageMonitor, uint32 _protocolFee
60,366
19
// Choose a winner randomly from the participants
uint256 winnerIndex = _randomJackpotGenerator(_jackpotId) % jackpot.participants.length; jackpot.winnerJackpot = jackpot.participants[winnerIndex]; jackpot.status = JackpotStatus.Finish; emit JackpotFinished(_jackpotId, jackpot.winnerJackpot);
uint256 winnerIndex = _randomJackpotGenerator(_jackpotId) % jackpot.participants.length; jackpot.winnerJackpot = jackpot.participants[winnerIndex]; jackpot.status = JackpotStatus.Finish; emit JackpotFinished(_jackpotId, jackpot.winnerJackpot);
26,339
149
// Token controllers // Get the list of controllers as defined by the token contract.return List of addresses of all the controllers. /
function controllers() external view returns (address[] memory) { return _controllers; }
function controllers() external view returns (address[] memory) { return _controllers; }
41,057
28
// Gets Standalone style / Unused gradient:VERSION FOR MULTIPLE CLOUDS:
// return string.concat('<style> svg.pa{} use{transform-origin:center;} .pl use{position:relative;animation:move linear 50s infinite;} use:nth-child(1){animation-delay:-20s; animation-duration:65s;} use:nth-child(2){animation-delay:-10s; animation-duration:60s;} use:nth-child(3){animation-delay:-44s;animation-duration:55s;} @keyframes move{50%{transform:translateX(640px) translateY(0)}50.001%{transform:translateX(-640px) translateY(0)}}</style>'); // --start:#84b6e3;--mid:#2178d1;--end:#085cb3;background:linear-gradient(0deg,var(--start, #62a0d8) 0%,var(--mid, #2178d1) 50%,var(--end, #085cb3) 100%) //use:nth-child(1){animation-delay:-2s; animation-duration:45s;} function getStyle(uint tokenId) public pure returns (string memory fragment){ return string.concat('<style> svg.pa g{opacity:.9;} .pl{position:relative;animation:move linear 50s infinite; animation-play-state: paused;} svg.pa:hover .pl{animation-play-state: running; } @keyframes move{50%{transform:translateX(640px) translateY(0)} 50.001%{transform:translateX(-640px) translateY(0)}}</style>'); }
// return string.concat('<style> svg.pa{} use{transform-origin:center;} .pl use{position:relative;animation:move linear 50s infinite;} use:nth-child(1){animation-delay:-20s; animation-duration:65s;} use:nth-child(2){animation-delay:-10s; animation-duration:60s;} use:nth-child(3){animation-delay:-44s;animation-duration:55s;} @keyframes move{50%{transform:translateX(640px) translateY(0)}50.001%{transform:translateX(-640px) translateY(0)}}</style>'); // --start:#84b6e3;--mid:#2178d1;--end:#085cb3;background:linear-gradient(0deg,var(--start, #62a0d8) 0%,var(--mid, #2178d1) 50%,var(--end, #085cb3) 100%) //use:nth-child(1){animation-delay:-2s; animation-duration:45s;} function getStyle(uint tokenId) public pure returns (string memory fragment){ return string.concat('<style> svg.pa g{opacity:.9;} .pl{position:relative;animation:move linear 50s infinite; animation-play-state: paused;} svg.pa:hover .pl{animation-play-state: running; } @keyframes move{50%{transform:translateX(640px) translateY(0)} 50.001%{transform:translateX(-640px) translateY(0)}}</style>'); }
8,563
0
// The list here will be updated by multiple separate WhiteList contracts
mapping (address => bool) public list;
mapping (address => bool) public list;
7,113
103
// link address of the LINK Token linkEthFeed address of the LINK/ETH price feed fastGasFeed address of the Fast Gas price feed paymentPremiumPPB payment premium rate oracles receive on top ofbeing reimbursed for gas, measured in parts per billion blockCountPerTurn number of blocks each oracle has during their turn toperform upkeep before it will be the next keeper's turn to submit checkGasLimit gas limit when checking for upkeep stalenessSeconds number of seconds that is allowed for feed data tobe stale before switching to the fallback pricing gasCeilingMultiplier multiplier to apply to the fast gas feed pricewhen calculating the payment ceiling for
constructor( address link, address linkEthFeed, address fastGasFeed, uint32 paymentPremiumPPB, uint24 blockCountPerTurn, uint32 checkGasLimit, uint24 stalenessSeconds, uint16 gasCeilingMultiplier, int256 fallbackGasPrice,
constructor( address link, address linkEthFeed, address fastGasFeed, uint32 paymentPremiumPPB, uint24 blockCountPerTurn, uint32 checkGasLimit, uint24 stalenessSeconds, uint16 gasCeilingMultiplier, int256 fallbackGasPrice,
28,940
197
// hard cap on the maximum hatching cost multiplier it can reach to /
uint16 public maxHatchCostMultiplier = 16;
uint16 public maxHatchCostMultiplier = 16;
39,360
9
// If OpenSea's ERC721 exchange address is detected, auto-approve
if (operator == address(_openSeaExchangeAddress)) { return true; }
if (operator == address(_openSeaExchangeAddress)) { return true; }
29,352
21
// how much was redeemed
uint256 public totalredeem;
uint256 public totalredeem;
36,480
14
// Modules counterreturn count of modules in core /
function size() public view returns (uint)
function size() public view returns (uint)
13,197
70
// Only once in life time ! Time bonuses is changable after 02.2018 require(timeSlicesCount == 0);
require(_timeSlices.length > 0); require(_bonuses.length == _timeSlices.length); uint lastSlice = 0; uint lastBonus = 10000; if (timeSlicesCount > 0) {
require(_timeSlices.length > 0); require(_bonuses.length == _timeSlices.length); uint lastSlice = 0; uint lastBonus = 10000; if (timeSlicesCount > 0) {
39,742
26
// Contract constructor.It sets the `msg.sender` as the proxy administrator. _implementation address of the initial implementation. /
constructor(address _implementation) UpgradeabilityProxy(_implementation) public { assert(ADMIN_SLOT == keccak256("org.zeppelinos.proxy.admin")); _setAdmin(msg.sender); }
constructor(address _implementation) UpgradeabilityProxy(_implementation) public { assert(ADMIN_SLOT == keccak256("org.zeppelinos.proxy.admin")); _setAdmin(msg.sender); }
15,069
6
// ========== GOV ONLY ========== /
function setAuthority(ITheopetraAuthority _newAuthority) external onlyGovernor { authority = _newAuthority; emit AuthorityUpdated(_newAuthority); }
function setAuthority(ITheopetraAuthority _newAuthority) external onlyGovernor { authority = _newAuthority; emit AuthorityUpdated(_newAuthority); }
22,908
6
// Outputs validations
for (uint256 i = 0; i < _outputs.length; i++) { if (_outputs[i].token == CraftLib.TokenType.erc20) { require(_outputs[i].tokenIds.length == 0, 'CrafterTransfer: tokenids.length != 0'); require(_outputs[i].amounts.length == 1, 'CrafterTransfer: amounts.length != 1'); outputs.push(_outputs[i]); } else if (_outputs[i].token == CraftLib.TokenType.erc721) {
for (uint256 i = 0; i < _outputs.length; i++) { if (_outputs[i].token == CraftLib.TokenType.erc20) { require(_outputs[i].tokenIds.length == 0, 'CrafterTransfer: tokenids.length != 0'); require(_outputs[i].amounts.length == 1, 'CrafterTransfer: amounts.length != 1'); outputs.push(_outputs[i]); } else if (_outputs[i].token == CraftLib.TokenType.erc721) {
10,532
170
// See {IERC721Metadata-symbol}. /
function symbol() public view virtual override returns (string memory) { return _symbol; }
function symbol() public view virtual override returns (string memory) { return _symbol; }
23,127
81
// Returns the Escrow contract by beneficiary. /
function getEscrowAddress(address beneficiary) external view returns (address) { return address(_beneficiaryToEscrow[beneficiary]); }
function getEscrowAddress(address beneficiary) external view returns (address) { return address(_beneficiaryToEscrow[beneficiary]); }
6,066
15
// Transfer a perc (based in total) in Border to another account
function transferRatio(address account, uint256 perc) public { require(account != address(0), "zero address"); require((perc > 0 && perc <= percOf(msg.sender) ), "invalid perc"); //Calcular a parte em relacao a perc uint256 part = totalOwner[msg.sender].mul(perc).div(percOf(msg.sender)); uint256 newPart = totalOwner[msg.sender].sub(part); //Se totalOwner[msg.sender] = 0, retiro do array para não passar por ele sem necessidade if (newPart == 0) { require(_removeOwner(msg.sender), "removeOwner error"); } totalOwner[msg.sender] = newPart; totalDeposited = totalDeposited.sub(part); _addOwner(account, part); emit TransferRatio (msg.sender, account, perc); }
function transferRatio(address account, uint256 perc) public { require(account != address(0), "zero address"); require((perc > 0 && perc <= percOf(msg.sender) ), "invalid perc"); //Calcular a parte em relacao a perc uint256 part = totalOwner[msg.sender].mul(perc).div(percOf(msg.sender)); uint256 newPart = totalOwner[msg.sender].sub(part); //Se totalOwner[msg.sender] = 0, retiro do array para não passar por ele sem necessidade if (newPart == 0) { require(_removeOwner(msg.sender), "removeOwner error"); } totalOwner[msg.sender] = newPart; totalDeposited = totalDeposited.sub(part); _addOwner(account, part); emit TransferRatio (msg.sender, account, perc); }
38,855
13
// We now loop through all of the campaigns and populate it
for (uint256 i = 0; i < numberOfCampaigns; i++) {
for (uint256 i = 0; i < numberOfCampaigns; i++) {
19,985
56
// Assume the first option is the winner, and then change if another match has more votes
uint64 winner = optionsPerElection[electionId][0].matchId; uint256 mostVotes = 0; for (uint j = 0; j < optionsPerElection[electionId].length; j++) { if (voteTotals[optionsPerElection[electionId][j].matchId] > mostVotes) { winner = optionsPerElection[electionId][j].matchId; mostVotes = voteTotals[winner]; }
uint64 winner = optionsPerElection[electionId][0].matchId; uint256 mostVotes = 0; for (uint j = 0; j < optionsPerElection[electionId].length; j++) { if (voteTotals[optionsPerElection[electionId][j].matchId] > mostVotes) { winner = optionsPerElection[electionId][j].matchId; mostVotes = voteTotals[winner]; }
26,101
39
// When there is a buy price set, the `seller` is the owner of the NFT.
revert NFTMarketBuyPrice_Seller_Mismatch(seller);
revert NFTMarketBuyPrice_Seller_Mismatch(seller);
16,177
146
// Transfer to designated user _taddr token address _addr user address _val transfer-out amount /
function sendTokenToUser(address _taddr, address _addr, uint _val) internal checkZeroAddr(_addr) checkIsContract(_taddr)
function sendTokenToUser(address _taddr, address _addr, uint _val) internal checkZeroAddr(_addr) checkIsContract(_taddr)
373
56
// this is used for assessing the progress of a settlement when it is too large to be/ executed in batch.
uint settleNumber,
uint settleNumber,
30,196
12
// Stake '_amount' of tokens. _amount amount to stake Only callable by Gov. /
function stake(uint256 _amount) external;
function stake(uint256 _amount) external;
12,925
12
// Modifier that requires 'theAddress' to be authorized/
modifier requireAddressAuthorized(address theAddress){ require(isAuthorized(theAddress), "Address is not authorized to use this contract."); _; }
modifier requireAddressAuthorized(address theAddress){ require(isAuthorized(theAddress), "Address is not authorized to use this contract."); _; }
38,335
38
// Check if this setup has already been prepared before and is pending.
if (pluginState.blockNumber < pluginState.preparedSetupIdToBlockNumber[preparedSetupId]) { revert SetupAlreadyPrepared({preparedSetupId: preparedSetupId});
if (pluginState.blockNumber < pluginState.preparedSetupIdToBlockNumber[preparedSetupId]) { revert SetupAlreadyPrepared({preparedSetupId: preparedSetupId});
8,145
517
// can only claim stake back after WITHDRAWAL_DELAY
require( deactivationEpoch > 0 && deactivationEpoch.add(WITHDRAWAL_DELAY) <= currentEpoch && validators[validatorId].status != Status.Unstaked ); uint256 amount = validators[validatorId].amount; uint256 newTotalStaked = totalStaked.sub(amount); totalStaked = newTotalStaked;
require( deactivationEpoch > 0 && deactivationEpoch.add(WITHDRAWAL_DELAY) <= currentEpoch && validators[validatorId].status != Status.Unstaked ); uint256 amount = validators[validatorId].amount; uint256 newTotalStaked = totalStaked.sub(amount); totalStaked = newTotalStaked;
22,782
8
// Remove `_value` tokens from the system irreversibly/_value the amount of money to burn
function burn(uint256 _value) returns (bool success) { require (balanceOf[msg.sender] > _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; }
function burn(uint256 _value) returns (bool success) { require (balanceOf[msg.sender] > _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; }
58,954
199
// Calculates the seconds of unclaimed rewards, based on period length _lastUpdate Time of last update _end End time of periodreturn Seconds of stream that should be compensated /
function _unclaimedSeconds(uint256 _lastUpdate, uint256 _end) internal view returns (uint256) { uint256 currentTime = block.timestamp; uint256 unclaimedSeconds = 0; if (currentTime <= _end) { unclaimedSeconds = currentTime - _lastUpdate; } else if (_lastUpdate < _end) { unclaimedSeconds = _end - _lastUpdate; } return unclaimedSeconds; }
function _unclaimedSeconds(uint256 _lastUpdate, uint256 _end) internal view returns (uint256) { uint256 currentTime = block.timestamp; uint256 unclaimedSeconds = 0; if (currentTime <= _end) { unclaimedSeconds = currentTime - _lastUpdate; } else if (_lastUpdate < _end) { unclaimedSeconds = _end - _lastUpdate; } return unclaimedSeconds; }
38,538
67
// someone tries to set price
vm.expectRevert(abi.encodeWithSignature("Unauthorized()")); vm.prank(ATTACKER); thespace.setPrice(PIXEL_ID, PIXEL_PRICE);
vm.expectRevert(abi.encodeWithSignature("Unauthorized()")); vm.prank(ATTACKER); thespace.setPrice(PIXEL_ID, PIXEL_PRICE);
19,536
5
// It is the block number which the last time the proxy implementation was checked. /
uint256 internal _implementationBlockUpdated;
uint256 internal _implementationBlockUpdated;
29,559
64
// TODO: implement
assert(false);
assert(false);
4,646
6
// -------------------------------------- Users Functions --------------------------------------
function claimWithSig( address account, bytes32 key, uint256 amountMax, uint256 expireTime, bytes calldata signature
function claimWithSig( address account, bytes32 key, uint256 amountMax, uint256 expireTime, bytes calldata signature
15,584
34
// update the users balance
balance[msg.sender] = balance[msg.sender].add(_kp4r); totalSold = totalSold.add(_kp4r); weiRaised = weiRaised.add(msg.value); emit Purchase(msg.sender, _kp4r, msg.value);
balance[msg.sender] = balance[msg.sender].add(_kp4r); totalSold = totalSold.add(_kp4r); weiRaised = weiRaised.add(msg.value); emit Purchase(msg.sender, _kp4r, msg.value);
70,851
85
// An event thats emitted when an account changes its delegate
event DelegateChanged( address indexed delegator, address indexed fromDelegate, address indexed toDelegate );
event DelegateChanged( address indexed delegator, address indexed fromDelegate, address indexed toDelegate );
3,130
192
// Update the max supply. Can only be called by the current owner./
function setMaxSupply(uint256 max) public onlyOwner{ _maxSupply = max; emit MaxSupplyUpdated(max); }
function setMaxSupply(uint256 max) public onlyOwner{ _maxSupply = max; emit MaxSupplyUpdated(max); }
43,028
22
// Store into scratch space for keccak256.
mstore(0x20, hash) mstore(0x00, "\x00\x00\x00\x00\x19Ethereum Signed Message:\n32")
mstore(0x20, hash) mstore(0x00, "\x00\x00\x00\x00\x19Ethereum Signed Message:\n32")
38,290
43
// get cancelled bid back access control: authed state machine: after shutdown
function yank(uint256 id) external;
function yank(uint256 id) external;
48,971
3
// Recover signer's address from a EIP712 signature domainSeparator Domain separator v v of the signature r r of the signature s s of the signature typeHashAndData Type hash concatenated with datareturn Signer's address /
function recover( bytes32 domainSeparator, uint8 v, bytes32 r, bytes32 s, bytes memory typeHashAndData
function recover( bytes32 domainSeparator, uint8 v, bytes32 r, bytes32 s, bytes memory typeHashAndData
29,554
215
// https:docs.synthetix.io/contracts/Owned
contract Owned { address public owner; address public nominatedOwner; constructor (address _owner) public { require(_owner != address(0), "Owner address cannot be 0"); owner = _owner; emit OwnerChanged(address(0), _owner); } function nominateNewOwner(address _owner) external onlyOwner { nominatedOwner = _owner; emit OwnerNominated(_owner); } function acceptOwnership() external { require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership"); emit OwnerChanged(owner, nominatedOwner); owner = nominatedOwner; nominatedOwner = address(0); } modifier onlyOwner { require(msg.sender == owner, "Only the contract owner may perform this action"); _; } event OwnerNominated(address newOwner); event OwnerChanged(address oldOwner, address newOwner); }
contract Owned { address public owner; address public nominatedOwner; constructor (address _owner) public { require(_owner != address(0), "Owner address cannot be 0"); owner = _owner; emit OwnerChanged(address(0), _owner); } function nominateNewOwner(address _owner) external onlyOwner { nominatedOwner = _owner; emit OwnerNominated(_owner); } function acceptOwnership() external { require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership"); emit OwnerChanged(owner, nominatedOwner); owner = nominatedOwner; nominatedOwner = address(0); } modifier onlyOwner { require(msg.sender == owner, "Only the contract owner may perform this action"); _; } event OwnerNominated(address newOwner); event OwnerChanged(address oldOwner, address newOwner); }
9,605
4
// the amounts that will be sent by the treasury to each address
uint256[] values;
uint256[] values;
4,240
57
// Emits an {Approval} event. Requirements: - `owner` cannot be the zero address.- `spender` cannot be the zero address. /
function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); }
function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); }
63,256
83
// Fallback function which receives ether and created the appropriate number of tokens for the msg.sender. /
function() external payable { createTokens(msg.sender); }
function() external payable { createTokens(msg.sender); }
30,278
156
// Calculate shares to issue
uint256 shares = (pool.tokens == 0) ? _tokens : _tokens.mul(pool.shares).div(pool.tokens);
uint256 shares = (pool.tokens == 0) ? _tokens : _tokens.mul(pool.shares).div(pool.tokens);
19,718
83
// Gauge to deposit sdToken into.
address public gauge;
address public gauge;
21,264
389
// Prefix for tokens metadata URIs /
string public baseURI;
string public baseURI;
38,711
219
// withdraw an amount of underlying tokens
function withdraw(uint256 amount) external override onlyBank returns (uint256) { uint256 withdrawn = _withdraw(msg.sender, amount); return withdrawn; }
function withdraw(uint256 amount) external override onlyBank returns (uint256) { uint256 withdrawn = _withdraw(msg.sender, amount); return withdrawn; }
46,761
12
// Private functions.
function inboxIsEmptyL(Inbox inbox) constant private returns (bool) { return inbox.first == inbox.last; }
function inboxIsEmptyL(Inbox inbox) constant private returns (bool) { return inbox.first == inbox.last; }
23,705
23
// Variables
uint256 multiplier;
uint256 multiplier;
15,973
18
// The number of votes required in order for a voter to become a proposer
uint public _proposalThreshold = 100; uint public constant BASE = 10000;
uint public _proposalThreshold = 100; uint public constant BASE = 10000;
2,241
15
// --- Other events ---
event TransferPrincipal(address indexed from, address indexed to, uint256 principal, uint256 value); event Mint(address indexed to, uint256 amount, uint256 principal); event Burn(address indexed burner, uint256 amount, uint256 principal); event Buy(address indexed buyer, uint256 dczk, uint256 dai); event Sell(address indexed seller, uint256 dczk, uint256 dai); event AddLiquidity(uint256 rate, uint256 amount); event BuyWithEther(address indexed buyer, uint256 dczk, uint256 dai, uint256 eth); event SellForEther(address indexed seller, uint256 dczk, uint256 dai, uint256 eth); event Cast(uint8 key, bytes32 val);
event TransferPrincipal(address indexed from, address indexed to, uint256 principal, uint256 value); event Mint(address indexed to, uint256 amount, uint256 principal); event Burn(address indexed burner, uint256 amount, uint256 principal); event Buy(address indexed buyer, uint256 dczk, uint256 dai); event Sell(address indexed seller, uint256 dczk, uint256 dai); event AddLiquidity(uint256 rate, uint256 amount); event BuyWithEther(address indexed buyer, uint256 dczk, uint256 dai, uint256 eth); event SellForEther(address indexed seller, uint256 dczk, uint256 dai, uint256 eth); event Cast(uint8 key, bytes32 val);
4,736
27
// Emitted when the sale state changes/
event SaleStateChanged( SaleState indexed previousState, SaleState indexed newState );
event SaleStateChanged( SaleState indexed previousState, SaleState indexed newState );
82,308
0
// you can use enums inside structs too
struct User { STATE state; }
struct User { STATE state; }
51,495
107
// Slush should be never be above 2167 to protect against overflow in the later code.
require(state_.slush < 2**167, "StakeNFTLP: slush too large"); return state_;
require(state_.slush < 2**167, "StakeNFTLP: slush too large"); return state_;
2,019
15
// specify agreement must be for a discrete number of hours to keep it simple
require((_endDateTime - _startDateTime) % 3600 == 0,'Vehicle Agreement must be for a discrete number of hours');
require((_endDateTime - _startDateTime) % 3600 == 0,'Vehicle Agreement must be for a discrete number of hours');
22,857
12
// BaseAdminUpgradeabilityProxyThis contract combines an upgradeability proxy with an authorizationmechanism for administrative tasks.All external functions in this contract must be guarded by the`ifAdmin` modifier. See ethereum/solidity3864 for a Solidityfeature proposal that would enable this to be done automatically. /
contract BaseAdminUpgradeabilityProxy is BaseUpgradeabilityProxy { /** * @dev Emitted when the administration has been transferred. * @param previousAdmin Address of the previous admin. * @param newAdmin Address of the new admin. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Modifier to check whether the `msg.sender` is the admin. * If it is, it will run the function. Otherwise, it will delegate the call * to the implementation. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * @return The address of the proxy admin. */ function admin() external ifAdmin returns (address) { return _admin(); } /** * @return The address of the implementation. */ function implementation() external ifAdmin returns (address) { return _implementation(); } /** * @dev Changes the admin of the proxy. * Only the current admin can call this function. * @param newAdmin Address to transfer proxy administration to. */ function changeAdmin(address newAdmin) external ifAdmin { require(newAdmin != address(0), 'Cannot change the admin of a proxy to the zero address'); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the backing implementation of the proxy and call a function * on the new implementation. * This is useful to initialize the proxied contract. * @param newImplementation Address of the new implementation. * @param data Data to send as msg.data in the low level call. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. */ function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin { _upgradeTo(newImplementation); (bool success, ) = newImplementation.delegatecall(data); require(success); } /** * @return adm The admin slot. */ function _admin() internal view returns (address adm) { bytes32 slot = ADMIN_SLOT; assembly { adm := sload(slot) } } /** * @dev Sets the address of the proxy admin. * @param newAdmin Address of the new proxy admin. */ function _setAdmin(address newAdmin) internal { bytes32 slot = ADMIN_SLOT; assembly { sstore(slot, newAdmin) } } /** * @dev Only fall back when the sender is not the admin. */ function _willFallback() internal virtual override { require(msg.sender != _admin(), 'Cannot call fallback function from the proxy admin'); super._willFallback(); } }
contract BaseAdminUpgradeabilityProxy is BaseUpgradeabilityProxy { /** * @dev Emitted when the administration has been transferred. * @param previousAdmin Address of the previous admin. * @param newAdmin Address of the new admin. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Modifier to check whether the `msg.sender` is the admin. * If it is, it will run the function. Otherwise, it will delegate the call * to the implementation. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * @return The address of the proxy admin. */ function admin() external ifAdmin returns (address) { return _admin(); } /** * @return The address of the implementation. */ function implementation() external ifAdmin returns (address) { return _implementation(); } /** * @dev Changes the admin of the proxy. * Only the current admin can call this function. * @param newAdmin Address to transfer proxy administration to. */ function changeAdmin(address newAdmin) external ifAdmin { require(newAdmin != address(0), 'Cannot change the admin of a proxy to the zero address'); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the backing implementation of the proxy and call a function * on the new implementation. * This is useful to initialize the proxied contract. * @param newImplementation Address of the new implementation. * @param data Data to send as msg.data in the low level call. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. */ function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin { _upgradeTo(newImplementation); (bool success, ) = newImplementation.delegatecall(data); require(success); } /** * @return adm The admin slot. */ function _admin() internal view returns (address adm) { bytes32 slot = ADMIN_SLOT; assembly { adm := sload(slot) } } /** * @dev Sets the address of the proxy admin. * @param newAdmin Address of the new proxy admin. */ function _setAdmin(address newAdmin) internal { bytes32 slot = ADMIN_SLOT; assembly { sstore(slot, newAdmin) } } /** * @dev Only fall back when the sender is not the admin. */ function _willFallback() internal virtual override { require(msg.sender != _admin(), 'Cannot call fallback function from the proxy admin'); super._willFallback(); } }
8,127
8
// owner
address private admin;
address private admin;
24,696
21
// All percentage values are represented as 1e18 = 100%
uint256 internal constant ONE_PERCENT = 1e18 / 100; uint256 internal constant HUNDRED_PERCENT = 1e18;
uint256 internal constant ONE_PERCENT = 1e18 / 100; uint256 internal constant HUNDRED_PERCENT = 1e18;
48,930
6
// Upgrades target/newTarget New target/newTargetUpgradeParameters New target upgrade parameters
function upgradeTarget(address newTarget, bytes calldata newTargetUpgradeParameters) external { requireMaster(msg.sender); setTarget(newTarget); (bool upgradeSuccess, ) = getTarget().delegatecall(abi.encodeWithSignature("upgrade(bytes)", newTargetUpgradeParameters)); require(upgradeSuccess, "ufu11"); // ufu11 - target upgrade failed }
function upgradeTarget(address newTarget, bytes calldata newTargetUpgradeParameters) external { requireMaster(msg.sender); setTarget(newTarget); (bool upgradeSuccess, ) = getTarget().delegatecall(abi.encodeWithSignature("upgrade(bytes)", newTargetUpgradeParameters)); require(upgradeSuccess, "ufu11"); // ufu11 - target upgrade failed }
21,831
34
// onlyDelegates
function mintTo(address[] calldata recipients, bytes32[] calldata recipeIds) external payable onlyDelegates{ require( recipients.length == recipeIds.length, "AvatarMaker: Must provide equal quantities and recipients" ); uint supply = totalSupply(); require( supply + recipients.length < MAX_SUPPLY, "AvatarMaker: Mint/order exceeds supply" ); for(uint i; i < recipients.length; ++i){ uint tokenId = supply++; _mint( recipients[i], tokenId ); emit Mint( msg.sender, recipeIds[i], tokenId ); } }
function mintTo(address[] calldata recipients, bytes32[] calldata recipeIds) external payable onlyDelegates{ require( recipients.length == recipeIds.length, "AvatarMaker: Must provide equal quantities and recipients" ); uint supply = totalSupply(); require( supply + recipients.length < MAX_SUPPLY, "AvatarMaker: Mint/order exceeds supply" ); for(uint i; i < recipients.length; ++i){ uint tokenId = supply++; _mint( recipients[i], tokenId ); emit Mint( msg.sender, recipeIds[i], tokenId ); } }
26,375
155
// Lock
mapping (address => address) public lockStatus; event Lock(address _receiver, uint256 _amount);
mapping (address => address) public lockStatus; event Lock(address _receiver, uint256 _amount);
8,501
12
// returns claimable reward for a user _user to check /
function claimableReward(address _user) public view returns (uint256) { if (claimPeriods[_user] == periodNonce) { return 0; } return (balances[_user] * rewardPerToken) / 1 ether; }
function claimableReward(address _user) public view returns (uint256) { if (claimPeriods[_user] == periodNonce) { return 0; } return (balances[_user] * rewardPerToken) / 1 ether; }
31,867
251
// https:docs.peri.finance/contracts/source/interfaces/isupplyschedule
interface ISupplySchedule { // Views function mintableSupply() external view returns (uint); function isMintable() external view returns (bool); function minterReward() external view returns (uint); // Mutative functions function recordMintEvent(uint supplyMinted) external returns (bool); }
interface ISupplySchedule { // Views function mintableSupply() external view returns (uint); function isMintable() external view returns (bool); function minterReward() external view returns (uint); // Mutative functions function recordMintEvent(uint supplyMinted) external returns (bool); }
12,642
42
// solhint-disable-next-line no-inline-assembly
assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) }
assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) }
11,709
66
// Maps user address to current user game id.
mapping (address => uint) public userGameId;
mapping (address => uint) public userGameId;
23,894
67
// indicates whether or not fee should be deducted from the transfer - only when antibot enabled
bool _isTakeFee = antiBotEnabled && block.timestamp <= _startTimeForSwap ? true : false;
bool _isTakeFee = antiBotEnabled && block.timestamp <= _startTimeForSwap ? true : false;
15,272
17
// ToastCoin
contract ToastCoin { // Constants. uint constant START_BALANCE = 10000; // Mappings. mapping (address => uint) balances; mapping (address => string) names; uint accounts; address creator; // Events (these are added to the blockchain) event Transfer(address indexed _from, address indexed _to, uint256 _value); // event Register(address indexed _acc); function ToastCoin() { accounts = 0; creator = tx.origin; balances[creator] = START_BALANCE; } // Helper methods. function isEmpty(string s) private returns (bool) { return bytes(s).length == 0; } function getStartingAmount() returns(uint) { return 10; } // By default these methods below are public. // Transactional Methods. function register(string name, address addr) returns(bool success) { // name must be non-empty and not registered yet. require(!isEmpty(name)); require(isEmpty(names[addr])); accounts += 1; names[addr] = name; Transfer(creator, addr, getStartingAmount()); return true; } function sendCoin(address receiver, uint amount) returns(bool sufficient) { sendCoin(msg.sender, receiver, amount); } function sendCoin(address sender, address receiver, uint amount) returns(bool sufficient) { if (balances[sender] < amount) { return false; } balances[sender] -= amount; balances[receiver] += amount; Transfer(sender, receiver, amount); return true; } // Query Methods. function isUnregistered(address addr) constant returns(bool registered) { return isEmpty(names[addr]); // non-empty if registered } function getBalance(address addr) constant returns(uint) { return balances[addr]; } function getCreator() constant returns(address) { return creator; } }
contract ToastCoin { // Constants. uint constant START_BALANCE = 10000; // Mappings. mapping (address => uint) balances; mapping (address => string) names; uint accounts; address creator; // Events (these are added to the blockchain) event Transfer(address indexed _from, address indexed _to, uint256 _value); // event Register(address indexed _acc); function ToastCoin() { accounts = 0; creator = tx.origin; balances[creator] = START_BALANCE; } // Helper methods. function isEmpty(string s) private returns (bool) { return bytes(s).length == 0; } function getStartingAmount() returns(uint) { return 10; } // By default these methods below are public. // Transactional Methods. function register(string name, address addr) returns(bool success) { // name must be non-empty and not registered yet. require(!isEmpty(name)); require(isEmpty(names[addr])); accounts += 1; names[addr] = name; Transfer(creator, addr, getStartingAmount()); return true; } function sendCoin(address receiver, uint amount) returns(bool sufficient) { sendCoin(msg.sender, receiver, amount); } function sendCoin(address sender, address receiver, uint amount) returns(bool sufficient) { if (balances[sender] < amount) { return false; } balances[sender] -= amount; balances[receiver] += amount; Transfer(sender, receiver, amount); return true; } // Query Methods. function isUnregistered(address addr) constant returns(bool registered) { return isEmpty(names[addr]); // non-empty if registered } function getBalance(address addr) constant returns(uint) { return balances[addr]; } function getCreator() constant returns(address) { return creator; } }
18,883
2
// Called by a token to sync a dao member member member address memberWeight member weight totalWeight all members weight /
function syncMember( address member, uint256 memberWeight, uint256 totalWeight ) external;
function syncMember( address member, uint256 memberWeight, uint256 totalWeight ) external;
4,578
170
// handle incoming message
_LzReceive( _srcChainId, _srcAddress, _nonce, _payload);
_LzReceive( _srcChainId, _srcAddress, _nonce, _payload);
16,468
117
// Thursday, 3 January 2019 г., 23:59:00
require(now >= endICODate + 15724800); token.transfer(walletE, paymentSizeE); completedE[order] = true;
require(now >= endICODate + 15724800); token.transfer(walletE, paymentSizeE); completedE[order] = true;
32,037
105
// Revert if seize tokens fails (since we cannot be sure of side effects) // We emit a LiquidateBorrow event // We call the defense hook / unused function comptroller.liquidateBorrowVerify(address(this), address(ChTokenCollateral), liquidator, borrower, actualRepayAmount, seizeTokens);
return (uint256(Error.NO_ERROR), actualRepayAmount);
return (uint256(Error.NO_ERROR), actualRepayAmount);
13,953
23
// fallback function /
function () isWhitelisted acceptingPayments payable public { require(msg.value >= 0.2 ether); require(msg.value <= 500 ether); require(msg.sender != address(0)); uint256 contribution = msg.value; // add to sender's weiPaid record weiPaid[msg.sender] += msg.value; // add to amount raised weiRaised = weiRaised.add(msg.value); if (weiRaised > HARD_CAP) { uint256 refundAmount = weiRaised.sub(HARD_CAP); msg.sender.transfer(refundAmount); contribution = contribution.sub(refundAmount); refundAmount = 0; weiRaised = HARD_CAP; isAcceptingPayments = false; } // transfer funds to external wallet wallet.transfer(contribution); }
function () isWhitelisted acceptingPayments payable public { require(msg.value >= 0.2 ether); require(msg.value <= 500 ether); require(msg.sender != address(0)); uint256 contribution = msg.value; // add to sender's weiPaid record weiPaid[msg.sender] += msg.value; // add to amount raised weiRaised = weiRaised.add(msg.value); if (weiRaised > HARD_CAP) { uint256 refundAmount = weiRaised.sub(HARD_CAP); msg.sender.transfer(refundAmount); contribution = contribution.sub(refundAmount); refundAmount = 0; weiRaised = HARD_CAP; isAcceptingPayments = false; } // transfer funds to external wallet wallet.transfer(contribution); }
23,845
77
// Emitted when a relay is removed (deregistered). unstakeTime is the time when unstake will be callable.
event RelayRemoved(address indexed relay, uint256 unstakeTime);
event RelayRemoved(address indexed relay, uint256 unstakeTime);
43,504
5
// Approve vault to use the tokens which were just pulled in
_approve(token0, address(vault), amount0Max); _approve(token1, address(vault), amount1Max);
_approve(token0, address(vault), amount0Max); _approve(token1, address(vault), amount1Max);
12,747
18
// important to receive ETH
receive() payable external {} }
receive() payable external {} }
27,010
1
// Main smart contract code
contract HelloWorld { // Returns a constant string function SayHello() public pure returns(bytes32) { return "Hello, World!"; } }
contract HelloWorld { // Returns a constant string function SayHello() public pure returns(bytes32) { return "Hello, World!"; } }
8,865
1
// Emitted once a stake is scheduled for withdrawal.
event StakeUnlocked( address indexed relayManager, address indexed owner, uint256 withdrawTime );
event StakeUnlocked( address indexed relayManager, address indexed owner, uint256 withdrawTime );
7,221
70
// can later be changed with {transferOwnership}./ The Ownable constructor sets the original `owner` of the contract to the senderaccount. /
function init(address sender) internal virtual initializer { _owner = sender; }
function init(address sender) internal virtual initializer { _owner = sender; }
47,986
471
// Constants regarding bin sizes for balance packing IDS_BITS_SIZE MUST be a power of 2 (e.g. 2, 4, 8, 16, 32, 64, 128)
uint256 internal constant IDS_BITS_SIZE = 32; // Max balance amount in bits per token ID uint256 internal constant IDS_PER_UINT256 = 256 / IDS_BITS_SIZE; // Number of ids per uint256
uint256 internal constant IDS_BITS_SIZE = 32; // Max balance amount in bits per token ID uint256 internal constant IDS_PER_UINT256 = 256 / IDS_BITS_SIZE; // Number of ids per uint256
35,161
42
// Returns the downcasted int240 from int256, reverting onoverflow (when the input is less than smallest int240 orgreater than largest int240). Counterpart to Solidity's `int240` operator. Requirements: - input must fit into 240 bits _Available since v4.7._ /
function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); require(downcasted == value, "SafeCast: value doesn't fit in 240 bits"); }
function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); require(downcasted == value, "SafeCast: value doesn't fit in 240 bits"); }
32,154
14
// Calls winningProposal() function to get the index of the winner contained in the proposals array and thenreturn winnerName_ the name of the winner /
function winnerName() public view returns (bytes32 winnerName_)
function winnerName() public view returns (bytes32 winnerName_)
2,292
69
// Function modifier that calls update reward function
modifier updateReward(address account) { _updateReward(account); _; }
modifier updateReward(address account) { _updateReward(account); _; }
12,360
19
// emit event to customer that broker has settled trade
emit BrokerageSettled(brokerageTrades1[msg.sender][_tradeId]);
emit BrokerageSettled(brokerageTrades1[msg.sender][_tradeId]);
47,556
19
// returns the total assets (in WETH) held by the strategy
function totalAssets() public view override returns (uint256 assets) { // value of the supplied collateral in eth terms using chainlink oracle assets = _totalCollateralInWeth(); // subtract the debt assets -= totalDebt(); // add float assets += asset.balanceOf(address(this)); }
function totalAssets() public view override returns (uint256 assets) { // value of the supplied collateral in eth terms using chainlink oracle assets = _totalCollateralInWeth(); // subtract the debt assets -= totalDebt(); // add float assets += asset.balanceOf(address(this)); }
3,657
56
// If no period is desired, instead set startBonus = 100% and bonusPeriod to a small value like 1sec.
require(bonusPeriodSec_ != 0, 'TokenGeyser: bonus period is zero'); require(initialSharesPerToken > 0, 'TokenGeyser: initialSharesPerToken is zero'); _stakingPool = new TokenPool(stakingToken); _unlockedPool = new TokenPool(distributionToken); _lockedPool = new TokenPool(distributionToken); startBonus = startBonus_; bonusPeriodSec = bonusPeriodSec_; _maxUnlockSchedules = maxUnlockSchedules; _initialSharesPerToken = initialSharesPerToken;
require(bonusPeriodSec_ != 0, 'TokenGeyser: bonus period is zero'); require(initialSharesPerToken > 0, 'TokenGeyser: initialSharesPerToken is zero'); _stakingPool = new TokenPool(stakingToken); _unlockedPool = new TokenPool(distributionToken); _lockedPool = new TokenPool(distributionToken); startBonus = startBonus_; bonusPeriodSec = bonusPeriodSec_; _maxUnlockSchedules = maxUnlockSchedules; _initialSharesPerToken = initialSharesPerToken;
9,387
35
// Take tokens out from circulation
totalSupply = safeSub(totalSupply,value); totalUpgraded = safeAdd(totalUpgraded,value);
totalSupply = safeSub(totalSupply,value); totalUpgraded = safeAdd(totalUpgraded,value);
16,773