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
54
// No initial TX limit
uint256 public _maxTxAmount = 100 * 10**6 * 10**9;
uint256 public _maxTxAmount = 100 * 10**6 * 10**9;
52,967
12
// ---------------------------------------------------------------------------- Owned contract ----------------------------------------------------------------------------
contract Owned { address payable public owner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address payable _newOwner) public onlyOwner { owner = _newOwner; emit OwnershipTransferred(msg.sender, _newOwner); } }
contract Owned { address payable public owner; event OwnershipTransferred(address indexed _from, address indexed _to); constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address payable _newOwner) public onlyOwner { owner = _newOwner; emit OwnershipTransferred(msg.sender, _newOwner); } }
4,138
12
// Check if proof length is a multiple of 32
if (_proof.length % 32 != 0) return false; bytes32 proofElement; bytes32 computedHash = _leaf; for (uint256 i = 32; i <= _proof.length; i += 32) { assembly {
if (_proof.length % 32 != 0) return false; bytes32 proofElement; bytes32 computedHash = _leaf; for (uint256 i = 32; i <= _proof.length; i += 32) { assembly {
58,106
65
// generate tokens for purchser
token.mint(msg.sender, tokens.add(refTokens)); TokenPurchase(msg.sender, msg.sender, amount, tokens.add(refTokens)); token.mint(referrer, refTokens); ReferralBonus(msg.sender, referrer, refTokens);
token.mint(msg.sender, tokens.add(refTokens)); TokenPurchase(msg.sender, msg.sender, amount, tokens.add(refTokens)); token.mint(referrer, refTokens); ReferralBonus(msg.sender, referrer, refTokens);
45,791
65
// verify targetContract is a valid ERC721
require(ERC165(targetContract).supportsInterface(type(ERC721).interfaceId), "target NFT is not ERC721");
require(ERC165(targetContract).supportsInterface(type(ERC721).interfaceId), "target NFT is not ERC721");
40,513
35
// see Spigot.isWhitelisted/
function isWhitelisted(SpigotState storage self, bytes4 func) external view returns (bool) { return self.whitelistedFunctions[func]; }
function isWhitelisted(SpigotState storage self, bytes4 func) external view returns (bool) { return self.whitelistedFunctions[func]; }
15,697
54
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
if (returndata.length > 0) {
18,576
84
// Sets the CVX pool information. _pId The pool ID of the CVX pool. _token The address of the CLP token. _rewards The address of the CVX reward pool.Only the contract owner can call this function. /
function setCvxPoolInfo( uint32 _pId, address _token, address _rewards
function setCvxPoolInfo( uint32 _pId, address _token, address _rewards
42,565
383
// See {IERC777-revokeOperator}. /
function revokeOperator(address operator) public override { require(operator != _msgSender(), "ERC777: revoking self as operator"); if (_defaultOperators[operator]) { _revokedDefaultOperators[_msgSender()][operator] = true;
function revokeOperator(address operator) public override { require(operator != _msgSender(), "ERC777: revoking self as operator"); if (_defaultOperators[operator]) { _revokedDefaultOperators[_msgSender()][operator] = true;
76
6
// Deposits ether value into the smart contract.
if (msg.value != value) revert ValueMismatch();
if (msg.value != value) revert ValueMismatch();
38,295
0
// function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-function initialize}./ Modifier to protect an initializer function from being invoked twice. /
modifier initializerERC721A() {
modifier initializerERC721A() {
15,613
98
// Change group status/ Can be called only by contract owner//_groupName group name/_blocked block status// return code
function changeGroupActiveStatus(bytes32 _groupName, bool _blocked) external onlyContractOwner returns (uint) { require(isGroupExists(_groupName)); groupsBlocked[_groupName] = _blocked; return OK; }
function changeGroupActiveStatus(bytes32 _groupName, bool _blocked) external onlyContractOwner returns (uint) { require(isGroupExists(_groupName)); groupsBlocked[_groupName] = _blocked; return OK; }
16,990
112
// transfer all comp from pool to self
rewardToken.safeTransferFrom(pool, address(this), rewardToken.balanceOf(pool)); uint256 compRewardTotal = rewardToken.balanceOf(address(this)); // COMP
rewardToken.safeTransferFrom(pool, address(this), rewardToken.balanceOf(pool)); uint256 compRewardTotal = rewardToken.balanceOf(address(this)); // COMP
78,053
0
// All of the Components /
Component[] public components;
Component[] public components;
223
68
// Function called by the reward contract to start new distribution cycles supplyDelta_ Supply delta of the rebase to happen rebaseLag_ Rebase lag applied to the supply delta exchangeRate_ Exchange rate at which the rebase is happening debasePolicyBalance Current balance of the policy contractreturn Amount of debase to be claimed from the reward contract /
function checkStabilizerAndGetReward( int256 supplyDelta_, int256 rebaseLag_, uint256 exchangeRate_, uint256 debasePolicyBalance
function checkStabilizerAndGetReward( int256 supplyDelta_, int256 rebaseLag_, uint256 exchangeRate_, uint256 debasePolicyBalance
15,608
101
// Must be called after crowdsale ends, to do some extra finalization work. Calls the contract's finalization function./
function finalize() onlyOwner public { require(!isFinalized); require(hasClosed()); // Finalize finalization(); emit Finalized(); isFinalized = true; }
function finalize() onlyOwner public { require(!isFinalized); require(hasClosed()); // Finalize finalization(); emit Finalized(); isFinalized = true; }
8,367
15
// ================= Test-net Events =============
if ((s.testDuration + s.initTimestamp) >= block.timestamp) { emit tnCloseBank(_bankID, LibMeta.msgSender()); }
if ((s.testDuration + s.initTimestamp) >= block.timestamp) { emit tnCloseBank(_bankID, LibMeta.msgSender()); }
48,782
18
// Custom Overrides /
function transferFrom(address from, address to, uint256 tokenId) public override(ERC721Upgradeable) { super.transferFrom(from, to, tokenId); uint256 _mintingRate = mintingInfo[tokenId].rate; mintingRate[from] -= _mintingRate; mintingRate[to] += _mintingRate; YieldToken.updateReward(from, to, collectionIndex); }
function transferFrom(address from, address to, uint256 tokenId) public override(ERC721Upgradeable) { super.transferFrom(from, to, tokenId); uint256 _mintingRate = mintingInfo[tokenId].rate; mintingRate[from] -= _mintingRate; mintingRate[to] += _mintingRate; YieldToken.updateReward(from, to, collectionIndex); }
68,583
177
// Emits an {OutgoingMessage} event. Requirements:- Target chain must be initialized.- Target chain must be registered as external contract. /
function postOutgoingMessage( bytes32 targetChainHash, address targetContract, bytes memory data ) public override virtual { require(connectedChains[targetChainHash].inited, "Destination chain is not initialized");
function postOutgoingMessage( bytes32 targetChainHash, address targetContract, bytes memory data ) public override virtual { require(connectedChains[targetChainHash].inited, "Destination chain is not initialized");
36,807
19
// Transfer funds to output wallet
IERC20(paymentERC20TokenAddress).transferFrom( msg.sender, address(projectWallet), totalStake + (feePerCard * _numberOfCards) ); emit TokenSale(msg.sender, _receiver, _numberOfCards, totalStake);
IERC20(paymentERC20TokenAddress).transferFrom( msg.sender, address(projectWallet), totalStake + (feePerCard * _numberOfCards) ); emit TokenSale(msg.sender, _receiver, _numberOfCards, totalStake);
28,616
6
// Give the change back to the payer, in both currencies (only spent token should remain)
if (IERC20(_uniswapPath[0]).balanceOf(address(this)) > 0) { IERC20(_uniswapPath[0]).safeTransfer(msg.sender, IERC20(_uniswapPath[0]).balanceOf(address(this))); }
if (IERC20(_uniswapPath[0]).balanceOf(address(this)) > 0) { IERC20(_uniswapPath[0]).safeTransfer(msg.sender, IERC20(_uniswapPath[0]).balanceOf(address(this))); }
37,483
6
// vaults used by the member to gain membership
address[] vaults;
address[] vaults;
80,237
112
// Maximum tx size and wallet size
maxTransaction = totalSupply * 4 / 100; maxWallet = totalSupply * 4 / 100; swapAmountsAt = totalSupply * 1 / 10000; address uniswapRouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(uniswapRouter); taxWallet = address(owner()); // set as marketing wallet
maxTransaction = totalSupply * 4 / 100; maxWallet = totalSupply * 4 / 100; swapAmountsAt = totalSupply * 1 / 10000; address uniswapRouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(uniswapRouter); taxWallet = address(owner()); // set as marketing wallet
2,949
22
// Deposit to Yearn Vault after fee
if (_vaultAmount > 0) { _vaultNetworkFee = _vaultAmount.mul(_networkFeePercentage).div(DENOMINATOR); _vaultAmount = _vaultAmount.sub(_vaultNetworkFee); vault.deposit(_vaultAmount); vaultDepositBalance[tx.origin] = vaultDepositBalance[tx.origin].add(_vaultAmount); }
if (_vaultAmount > 0) { _vaultNetworkFee = _vaultAmount.mul(_networkFeePercentage).div(DENOMINATOR); _vaultAmount = _vaultAmount.sub(_vaultNetworkFee); vault.deposit(_vaultAmount); vaultDepositBalance[tx.origin] = vaultDepositBalance[tx.origin].add(_vaultAmount); }
17,791
37
// if the node is the left child of it's parent, then the parent is the next one.
Node storage parent = index.nodes[currentNode.parent]; child = currentNode; while (true) { if (parent.left == child.id) { return parent.id; }
Node storage parent = index.nodes[currentNode.parent]; child = currentNode; while (true) { if (parent.left == child.id) { return parent.id; }
50,532
430
// returns true if Exp is exactly zero /
function isZeroExp(Exp memory value) internal pure returns (bool) { return value.mantissa == 0; }
function isZeroExp(Exp memory value) internal pure returns (bool) { return value.mantissa == 0; }
66,087
4
// Emitted when the price oracle is updated. oldAddress The old address of the PriceOracle newAddress The new address of the PriceOracle /
event PriceOracleUpdated(address indexed oldAddress, address indexed newAddress);
event PriceOracleUpdated(address indexed oldAddress, address indexed newAddress);
50,112
513
// Processes new price and invariant data, updating the latest sample or creating a new one. Receives the new logarithms of values to store: `logPairPrice`, `logBptPrice` and `logInvariant`, as well theindex of the latest sample and the timestamp of its creation. Returns the index of the latest sample. If different from `latestIndex`, the caller should also store thetimestamp, and pass it on future calls to this function. /
function _processPriceData( uint256 latestSampleCreationTimestamp, uint256 latestIndex, int256 logPairPrice, int256 logBptPrice, int256 logInvariant
function _processPriceData( uint256 latestSampleCreationTimestamp, uint256 latestIndex, int256 logPairPrice, int256 logBptPrice, int256 logInvariant
24,278
32
// Registers the exist layer2 on DAO by owner/_operator Operator address of the layer2 contract/_layer2 Layer2 contract address to be registered/_memo A memo for the candidate
function registerLayer2CandidateByOwner( address _operator, address _layer2, string memory _memo ) external override onlyOwner validSeigManager validLayer2Registry
function registerLayer2CandidateByOwner( address _operator, address _layer2, string memory _memo ) external override onlyOwner validSeigManager validLayer2Registry
5,111
47
// Gets the approved address for a token ID, or zero if no address set _tokenId uint256 ID of the token to query the approval ofreturn address currently approved for a the given token ID /
function getApproved(uint256 _tokenId) public view returns (address) { return tokenApprovals[_tokenId]; }
function getApproved(uint256 _tokenId) public view returns (address) { return tokenApprovals[_tokenId]; }
4,525
17
// Return Curve Token Address /
function getCurveTokenAddr() internal pure returns (address) { return 0xC25a3A3b969415c80451098fa907EC722572917F; }
function getCurveTokenAddr() internal pure returns (address) { return 0xC25a3A3b969415c80451098fa907EC722572917F; }
17,056
119
// Internal function to vote for a parameter proposal Must be used in DPoS contract _proposalId the proposal id _voter the voter address _vote the vote type /
function internalVoteParam(
function internalVoteParam(
58,700
28
// return all tokens to the applicant
require( approvedToken.transfer(proposal.applicant, proposal.tokenTribute), "Moloch::processProposal - failing vote token transfer failed" );
require( approvedToken.transfer(proposal.applicant, proposal.tokenTribute), "Moloch::processProposal - failing vote token transfer failed" );
20,348
40
// Allows to replace an owner with a new owner. Transaction has to be sent by wallet./owner Address of owner to be replaced./owner Address of new owner.
function replaceOwner(address owner, address newOwner) public onlyWallet ownerExists(owner) ownerDoesNotExist(newOwner)
function replaceOwner(address owner, address newOwner) public onlyWallet ownerExists(owner) ownerDoesNotExist(newOwner)
50,599
342
// 基金本币全部兑换成t1
if(params.amount > 0){ if(params.token1 == params.token){ amount1Max = amount1Max.add(params.amount); } else {
if(params.amount > 0){ if(params.token1 == params.token){ amount1Max = amount1Max.add(params.amount); } else {
61,334
6
// Sets `baseURI` as the `_baseURI` for all tokens /
function _setBaseURI(string memory baseURI) internal virtual { _baseURI = baseURI; }
function _setBaseURI(string memory baseURI) internal virtual { _baseURI = baseURI; }
30,733
912
// SURVEY /
function _installSurveyApp(Kernel _dao, MiniMeToken _token, uint64 _minParticipationPct, uint64 _surveyTime) internal returns (Survey) { bytes memory initializeData = abi.encodeWithSelector(Survey(0).initialize.selector, _token, _minParticipationPct, _surveyTime); return Survey(_installNonDefaultApp(_dao, SURVEY_APP_ID, initializeData)); }
function _installSurveyApp(Kernel _dao, MiniMeToken _token, uint64 _minParticipationPct, uint64 _surveyTime) internal returns (Survey) { bytes memory initializeData = abi.encodeWithSelector(Survey(0).initialize.selector, _token, _minParticipationPct, _surveyTime); return Survey(_installNonDefaultApp(_dao, SURVEY_APP_ID, initializeData)); }
62,933
31
// solidity does not support decoding uint[2][2] yet
(uint[2] memory a, uint[2] memory b1, uint[2] memory b2, uint[2] memory c) = abi.decode(proof, (uint[2], uint[2], uint[2], uint[2])); return verifyProof(a, [b1, b2], c, inputs);
(uint[2] memory a, uint[2] memory b1, uint[2] memory b2, uint[2] memory c) = abi.decode(proof, (uint[2], uint[2], uint[2], uint[2])); return verifyProof(a, [b1, b2], c, inputs);
32,608
303
// if this legacy token had never been wrapped, assign it to the register with a new id
if( legacyTokenIdRegister[legacyTokenId] == 0 ){ legacyTokenIdRegister[legacyTokenId] = nextTokenId; legacyTokenIdReverseRegister[nextTokenId] = legacyTokenId; nextTokenId += 1; }
if( legacyTokenIdRegister[legacyTokenId] == 0 ){ legacyTokenIdRegister[legacyTokenId] = nextTokenId; legacyTokenIdReverseRegister[nextTokenId] = legacyTokenId; nextTokenId += 1; }
38,143
167
// Functions: Cost
function setPresaleCost(uint256 _cost) public onlyOwner { presaleCost = _cost; }
function setPresaleCost(uint256 _cost) public onlyOwner { presaleCost = _cost; }
43,028
13
// count of crop
uint[] public leaseArr; uint[] public saleArr; uint[] public seedArr; uint[] public fertilizerArr; uint[] public cropArr; uint[] public distCropArr; uint[] public consumerCropArr; address[] public farmerAdd; address[] public distAdd; address[] public retailAdd;
uint[] public leaseArr; uint[] public saleArr; uint[] public seedArr; uint[] public fertilizerArr; uint[] public cropArr; uint[] public distCropArr; uint[] public consumerCropArr; address[] public farmerAdd; address[] public distAdd; address[] public retailAdd;
10,689
41
// Transfer Cdp ownership to guy's proxy cdp cdp ID guy address, ownership should be transfered to /
function _transferCdpOwnershipToProxy(uint cdp, address guy) internal { DSProxyLike(proxyAddress).execute( proxyLib, abi.encodeWithSignature( "giveToProxy(address,address,uint256,address)", proxyRegistryAddrMD, cdpManagerAddr, cdp, guy)); }
function _transferCdpOwnershipToProxy(uint cdp, address guy) internal { DSProxyLike(proxyAddress).execute( proxyLib, abi.encodeWithSignature( "giveToProxy(address,address,uint256,address)", proxyRegistryAddrMD, cdpManagerAddr, cdp, guy)); }
30,162
18
// Registers a minter minter New minter /
function registerMinter(address minter) external onlyOwner nonReentrant { require(_minters.add(minter), "Already minter"); emit MinterRegistrationChanged(minter, true); observability.emitMinterRegistrationChanged(minter, true); }
function registerMinter(address minter) external onlyOwner nonReentrant { require(_minters.add(minter), "Already minter"); emit MinterRegistrationChanged(minter, true); observability.emitMinterRegistrationChanged(minter, true); }
42,193
13
// See {ERC20Pausable} and {Pausable-_unpause}. Requirements: - the caller must have the `PAUSER_ROLE`. /
function unpause() public virtual { require(hasRole(PAUSER_ROLE, _msgSender()), "must have pauser role to unpause"); _unpause(); }
function unpause() public virtual { require(hasRole(PAUSER_ROLE, _msgSender()), "must have pauser role to unpause"); _unpause(); }
22,807
2,028
// 1015
entry "undefused" : ENG_ADJECTIVE
entry "undefused" : ENG_ADJECTIVE
17,627
82
// control _maximumBuy_USD = 10,000 USD, SPIKE price is 0.01USD maximumBuy_SPIKE = 1000,000 SPIKE = 1000,000,0000000000 unit = 10^16
_maximumBuy = (10**18 * 10**16) /_originalBuyPrice;
_maximumBuy = (10**18 * 10**16) /_originalBuyPrice;
13,483
98
// transfer collateral to LoanContract
PawnLib.safeTransfer( collateral.collateralAddress, address(this), address(pawnLoanContract), collateral.amount );
PawnLib.safeTransfer( collateral.collateralAddress, address(this), address(pawnLoanContract), collateral.amount );
13,700
47
// return proxyAdmin The address of the proxy admin. /
function admin() external ifAdmin returns (address proxyAdmin) { proxyAdmin = _admin(); }
function admin() external ifAdmin returns (address proxyAdmin) { proxyAdmin = _admin(); }
10,091
3
// 购买事件
event onTx ( uint256 indexed playerID, address playerAddress, bytes32 playerName, uint256 teamID, bytes32 teamName, uint256 ethIn, uint256 keysBought );
event onTx ( uint256 indexed playerID, address playerAddress, bytes32 playerName, uint256 teamID, bytes32 teamName, uint256 ethIn, uint256 keysBought );
49,738
24
// Variable tracking how much Ether each token is currently worth. Note that this is scaled by the scaleFactor variable.
int256 earningsPerToken;
int256 earningsPerToken;
839
0
// ================================= only people with tokens
modifier onlyHolders () { require(myTokens() > 0); _; }
modifier onlyHolders () { require(myTokens() > 0); _; }
114
3
// Check the maker ask order
bytes32 orderHash = _verifyOrderHash(order, trustedSign);
bytes32 orderHash = _verifyOrderHash(order, trustedSign);
14,882
4
// if (msg.sender != owner()) {require(msg.value >= cost_mintAmount);
require(msg.sender == owner(), "Only owner allowed to mint");
require(msg.sender == owner(), "Only owner allowed to mint");
32,538
32
// update free-memory pointer tempBytes uses 32 bytes in memory (even when empty) for the length.
mstore(0x40, add(tempBytes, 0x20))
mstore(0x40, add(tempBytes, 0x20))
1,517
225
// Helper to payout specified asset percentages during redeemSharesForSpecificAssets()
function __payoutSpecifiedAssetPercentages( IVault vaultProxyContract, address _recipient, address[] calldata _payoutAssets, uint256[] calldata _payoutAssetPercentages, uint256 _owedGav
function __payoutSpecifiedAssetPercentages( IVault vaultProxyContract, address _recipient, address[] calldata _payoutAssets, uint256[] calldata _payoutAssetPercentages, uint256 _owedGav
25,355
215
// View the number of players in the current pool.
function CurrentPoolPlayer(uint256 _pid) public view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; return pool.currentPlayer; }
function CurrentPoolPlayer(uint256 _pid) public view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; return pool.currentPlayer; }
1,605
50
// Marks an address as being approved for transferFrom(), overwriting any previous approval. Setting _approved to address(0) clears all transfer approval. /
function _approve(uint _tokenId, address _approved) internal { tokenIdToApproved[_tokenId] = _approved; }
function _approve(uint _tokenId, address _approved) internal { tokenIdToApproved[_tokenId] = _approved; }
77,008
365
// calculate increased voting power overflow is not possible by design: max token supply limits the cumulative voting power
uint256 _toVal = _fromVal + _value;
uint256 _toVal = _fromVal + _value;
49,933
77
// The maximum number of seconds between harvest calls. See `setMaxReportDelay()` for more details.
uint256 public maxReportDelay = 86400; // ~ once a day
uint256 public maxReportDelay = 86400; // ~ once a day
32,432
122
// Transfers `amount` tokens of token type `id` from `from` to `to`.
* Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; emit TransferSingle(operator, from, to, id, amount); _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data); }
* Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; emit TransferSingle(operator, from, to, id, amount); _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data); }
9,590
45
// log the minting
Transfer(0x0, _participant, _coins); IcoCoinsIssued(_participant, _coins);
Transfer(0x0, _participant, _coins); IcoCoinsIssued(_participant, _coins);
10,879
8
// determine winner
winner = payable(participatingPlayers[block.timestamp % totalPlayers]);
winner = payable(participatingPlayers[block.timestamp % totalPlayers]);
24,823
486
// Transfer `_value` `_token` from the Vault to `_to`_token Address of the token being transferred_to Address of the recipient of tokens_value Amount of tokens being transferred// solium-disable-next-line function-order /
{ require(_value > 0, ERROR_TRANSFER_VALUE_ZERO); if (_token == ETH) { require(_to.send(_value), ERROR_SEND_REVERTED); } else { require(ERC20(_token).safeTransfer(_to, _value), ERROR_TOKEN_TRANSFER_REVERTED); } emit VaultTransfer(_token, _to, _value); }
{ require(_value > 0, ERROR_TRANSFER_VALUE_ZERO); if (_token == ETH) { require(_to.send(_value), ERROR_SEND_REVERTED); } else { require(ERC20(_token).safeTransfer(_to, _value), ERROR_TOKEN_TRANSFER_REVERTED); } emit VaultTransfer(_token, _to, _value); }
26,705
70
// Don't apply freeze-time for the initial setup.
if (latestVersion == 0x0) { latestVersion = _newVersion; return true; }
if (latestVersion == 0x0) { latestVersion = _newVersion; return true; }
34,495
118
// uniswap router address
address public uni;
address public uni;
44,893
15
// converts block.number ~0.155 ETH
uint256 scale = 10000000000; _setPrice(block.number * scale); _setPublicSaleEnd(uint64(block.timestamp) + HALF_LENGTH_OF_SALE);
uint256 scale = 10000000000; _setPrice(block.number * scale); _setPublicSaleEnd(uint64(block.timestamp) + HALF_LENGTH_OF_SALE);
15,448
15
// Get yield based on strategy and re-deposit- Caller is anyone /
function processYield() external virtual;
function processYield() external virtual;
7,926
28
// Imports a token from the Devcon2Token contract.
function upgrade() public returns (bool success);
function upgrade() public returns (bool success);
33,375
83
// Percentage that a resolver gets when he resolves bets for the house
uint resolverPercentage;
uint resolverPercentage;
57,814
2
// Init the value of {nonWhitelistedDustThresholdUpperBound}(recommend1017, 1017 0.1 of the coin)If the input value > {nonWhitelistedDustThresholdUpperBound}, it will set as {nonWhitelistedDustThresholdUpperBound} Requirements: - the caller must be admin - {onlyAdmin} modifier is applied. /
function initNonWhitelistedDustThresholdUpperBound(uint256 _upperBound) external virtual onlyAdmin { require(nonWhitelistedDustThresholdUpperBound == 0, "HDO: nonWhitelistedDustThresholdUpperBound has been initialized"); nonWhitelistedDustThresholdUpperBound = _upperBound; }
function initNonWhitelistedDustThresholdUpperBound(uint256 _upperBound) external virtual onlyAdmin { require(nonWhitelistedDustThresholdUpperBound == 0, "HDO: nonWhitelistedDustThresholdUpperBound has been initialized"); nonWhitelistedDustThresholdUpperBound = _upperBound; }
11,781
284
// Update recent players list.
if (!isPlayerInQueue(_myAddress)) {
if (!isPlayerInQueue(_myAddress)) {
12,069
34
// Check if a token has been wrapped before/collectionAddress the address of the collection/tokenID the id of the NFT to release
function underlyingTokenExists(address collectionAddress, uint256 tokenID) public view returns ( bool tokenExists )
function underlyingTokenExists(address collectionAddress, uint256 tokenID) public view returns ( bool tokenExists )
20,152
568
// the new lend amount is the new reserve with leverage applied
uint256 _newLendAmount; uint256 _minNewLendAmount; uint256 _maxNewLendAmount; { (uint256 _collateralizationRatio, uint256 _minCollateralizationRatio, uint256 _maxCollateralizationRatio) = _self._calcCollateralizationRatio(); _newLendAmount = _newReserveAmount.mul(1e18).div(uint256(1e18).sub(_collateralizationRatio)); _minNewLendAmount = _newReserveAmount.mul(1e18).div(uint256(1e18).sub(_minCollateralizationRatio)); _maxNewLendAmount = _newReserveAmount.mul(1e18).div(uint256(1e18).sub(_maxCollateralizationRatio)); }
uint256 _newLendAmount; uint256 _minNewLendAmount; uint256 _maxNewLendAmount; { (uint256 _collateralizationRatio, uint256 _minCollateralizationRatio, uint256 _maxCollateralizationRatio) = _self._calcCollateralizationRatio(); _newLendAmount = _newReserveAmount.mul(1e18).div(uint256(1e18).sub(_collateralizationRatio)); _minNewLendAmount = _newReserveAmount.mul(1e18).div(uint256(1e18).sub(_minCollateralizationRatio)); _maxNewLendAmount = _newReserveAmount.mul(1e18).div(uint256(1e18).sub(_maxCollateralizationRatio)); }
14,565
19
// Reject the new Property.
function rejectProperty(uint _propId) public verifiedSuperAdmin { require(properties[_propId].currOwner != msg.sender); properties[_propId].status = Status.Rejected; emit LandAvailabilityChanged ( _propId ,properties[_propId].status ); landRejectedCounter++; }
function rejectProperty(uint _propId) public verifiedSuperAdmin { require(properties[_propId].currOwner != msg.sender); properties[_propId].status = Status.Rejected; emit LandAvailabilityChanged ( _propId ,properties[_propId].status ); landRejectedCounter++; }
22,135
345
// check on curve
uint256 lhs = mulmod(y, y, q_mod); // y^2 uint256 rhs = mulmod(x, x, q_mod); // x^2 rhs = mulmod(rhs, x, q_mod); // x^3 rhs = addmod(rhs, bn254_b_coeff, q_mod); // x^3 + b require(lhs == rhs); return G1Point(x, y);
uint256 lhs = mulmod(y, y, q_mod); // y^2 uint256 rhs = mulmod(x, x, q_mod); // x^2 rhs = mulmod(rhs, x, q_mod); // x^3 rhs = addmod(rhs, bn254_b_coeff, q_mod); // x^3 + b require(lhs == rhs); return G1Point(x, y);
9,088
20
// Only encrypt letters
if (letter >= 65 && letter <= 90) { uint8 keyLetter = uint8(key[keyIndex]); if (keyLetter >= 65 && keyLetter <= 90) { keyLetter = keyLetter + 32; }
if (letter >= 65 && letter <= 90) { uint8 keyLetter = uint8(key[keyIndex]); if (keyLetter >= 65 && keyLetter <= 90) { keyLetter = keyLetter + 32; }
20,066
276
// Internal Functions//Calculates a merkle root for a list of 32-byte leaf hashes.WARNING: If the numberof leaves passed in is not a power of two, it pads out the tree with zero hashes.If you do not know the original length of elements for the tree you are verifying,then this may allow empty leaves past _elements.length to pass a verification check down the line. _elements Array of hashes from which to generate a merkle root.return Merkle root of the leaves, with zero hashes for non-powers-of-two (see above). /
function getMerkleRoot(bytes32[] memory _elements) internal pure returns (bytes32) { require(_elements.length > 0, "MerkleTree: Must provide at least one leaf hash."); if (_elements.length == 1) { return _elements[0]; } uint256[32] memory defaults = [ 0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563, 0x633dc4d7da7256660a892f8f1604a44b5432649cc8ec5cb3ced4c4e6ac94dd1d, 0x890740a8eb06ce9be422cb8da5cdafc2b58c0a5e24036c578de2a433c828ff7d, 0x3b8ec09e026fdc305365dfc94e189a81b38c7597b3d941c279f042e8206e0bd8, 0xecd50eee38e386bd62be9bedb990706951b65fe053bd9d8a521af753d139e2da, 0xdefff6d330bb5403f63b14f33b578274160de3a50df4efecf0e0db73bcdd3da5, 0x617bdd11f7c0a11f49db22f629387a12da7596f9d1704d7465177c63d88ec7d7, 0x292c23a9aa1d8bea7e2435e555a4a60e379a5a35f3f452bae60121073fb6eead, 0xe1cea92ed99acdcb045a6726b2f87107e8a61620a232cf4d7d5b5766b3952e10, 0x7ad66c0a68c72cb89e4fb4303841966e4062a76ab97451e3b9fb526a5ceb7f82, 0xe026cc5a4aed3c22a58cbd3d2ac754c9352c5436f638042dca99034e83636516, 0x3d04cffd8b46a874edf5cfae63077de85f849a660426697b06a829c70dd1409c, 0xad676aa337a485e4728a0b240d92b3ef7b3c372d06d189322bfd5f61f1e7203e, 0xa2fca4a49658f9fab7aa63289c91b7c7b6c832a6d0e69334ff5b0a3483d09dab, 0x4ebfd9cd7bca2505f7bef59cc1c12ecc708fff26ae4af19abe852afe9e20c862, 0x2def10d13dd169f550f578bda343d9717a138562e0093b380a1120789d53cf10, 0x776a31db34a1a0a7caaf862cffdfff1789297ffadc380bd3d39281d340abd3ad, 0xe2e7610b87a5fdf3a72ebe271287d923ab990eefac64b6e59d79f8b7e08c46e3, 0x504364a5c6858bf98fff714ab5be9de19ed31a976860efbd0e772a2efe23e2e0, 0x4f05f4acb83f5b65168d9fef89d56d4d77b8944015e6b1eed81b0238e2d0dba3, 0x44a6d974c75b07423e1d6d33f481916fdd45830aea11b6347e700cd8b9f0767c, 0xedf260291f734ddac396a956127dde4c34c0cfb8d8052f88ac139658ccf2d507, 0x6075c657a105351e7f0fce53bc320113324a522e8fd52dc878c762551e01a46e, 0x6ca6a3f763a9395f7da16014725ca7ee17e4815c0ff8119bf33f273dee11833b, 0x1c25ef10ffeb3c7d08aa707d17286e0b0d3cbcb50f1bd3b6523b63ba3b52dd0f, 0xfffc43bd08273ccf135fd3cacbeef055418e09eb728d727c4d5d5c556cdea7e3, 0xc5ab8111456b1f28f3c7a0a604b4553ce905cb019c463ee159137af83c350b22, 0x0ff273fcbf4ae0f2bd88d6cf319ff4004f8d7dca70d4ced4e74d2c74139739e6, 0x7fa06ba11241ddd5efdc65d4e39c9f6991b74fd4b81b62230808216c876f827c, 0x7e275adf313a996c7e2950cac67caba02a5ff925ebf9906b58949f3e77aec5b9, 0x8f6162fa308d2b3a15dc33cffac85f13ab349173121645aedf00f471663108be, 0x78ccaaab73373552f207a63599de54d7d8d0c1805f86ce7da15818d09f4cff62 ]; // Reserve memory space for our hashes. bytes memory buf = new bytes(64); // We'll need to keep track of left and right siblings. bytes32 leftSibling; bytes32 rightSibling; // Number of non-empty nodes at the current depth. uint256 rowSize = _elements.length; // Current depth, counting from 0 at the leaves uint256 depth = 0; // Common sub-expressions uint256 halfRowSize; // rowSize / 2 bool rowSizeIsOdd; // rowSize % 2 == 1 while (rowSize > 1) { halfRowSize = rowSize / 2; rowSizeIsOdd = rowSize % 2 == 1; for (uint256 i = 0; i < halfRowSize; i++) { leftSibling = _elements[(2 * i)]; rightSibling = _elements[(2 * i) + 1]; assembly { mstore(add(buf, 32), leftSibling) mstore(add(buf, 64), rightSibling) } _elements[i] = keccak256(buf); } if (rowSizeIsOdd) { leftSibling = _elements[rowSize - 1]; rightSibling = bytes32(defaults[depth]); assembly { mstore(add(buf, 32), leftSibling) mstore(add(buf, 64), rightSibling) } _elements[halfRowSize] = keccak256(buf); } rowSize = halfRowSize + (rowSizeIsOdd ? 1 : 0); depth++; } return _elements[0]; }
function getMerkleRoot(bytes32[] memory _elements) internal pure returns (bytes32) { require(_elements.length > 0, "MerkleTree: Must provide at least one leaf hash."); if (_elements.length == 1) { return _elements[0]; } uint256[32] memory defaults = [ 0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563, 0x633dc4d7da7256660a892f8f1604a44b5432649cc8ec5cb3ced4c4e6ac94dd1d, 0x890740a8eb06ce9be422cb8da5cdafc2b58c0a5e24036c578de2a433c828ff7d, 0x3b8ec09e026fdc305365dfc94e189a81b38c7597b3d941c279f042e8206e0bd8, 0xecd50eee38e386bd62be9bedb990706951b65fe053bd9d8a521af753d139e2da, 0xdefff6d330bb5403f63b14f33b578274160de3a50df4efecf0e0db73bcdd3da5, 0x617bdd11f7c0a11f49db22f629387a12da7596f9d1704d7465177c63d88ec7d7, 0x292c23a9aa1d8bea7e2435e555a4a60e379a5a35f3f452bae60121073fb6eead, 0xe1cea92ed99acdcb045a6726b2f87107e8a61620a232cf4d7d5b5766b3952e10, 0x7ad66c0a68c72cb89e4fb4303841966e4062a76ab97451e3b9fb526a5ceb7f82, 0xe026cc5a4aed3c22a58cbd3d2ac754c9352c5436f638042dca99034e83636516, 0x3d04cffd8b46a874edf5cfae63077de85f849a660426697b06a829c70dd1409c, 0xad676aa337a485e4728a0b240d92b3ef7b3c372d06d189322bfd5f61f1e7203e, 0xa2fca4a49658f9fab7aa63289c91b7c7b6c832a6d0e69334ff5b0a3483d09dab, 0x4ebfd9cd7bca2505f7bef59cc1c12ecc708fff26ae4af19abe852afe9e20c862, 0x2def10d13dd169f550f578bda343d9717a138562e0093b380a1120789d53cf10, 0x776a31db34a1a0a7caaf862cffdfff1789297ffadc380bd3d39281d340abd3ad, 0xe2e7610b87a5fdf3a72ebe271287d923ab990eefac64b6e59d79f8b7e08c46e3, 0x504364a5c6858bf98fff714ab5be9de19ed31a976860efbd0e772a2efe23e2e0, 0x4f05f4acb83f5b65168d9fef89d56d4d77b8944015e6b1eed81b0238e2d0dba3, 0x44a6d974c75b07423e1d6d33f481916fdd45830aea11b6347e700cd8b9f0767c, 0xedf260291f734ddac396a956127dde4c34c0cfb8d8052f88ac139658ccf2d507, 0x6075c657a105351e7f0fce53bc320113324a522e8fd52dc878c762551e01a46e, 0x6ca6a3f763a9395f7da16014725ca7ee17e4815c0ff8119bf33f273dee11833b, 0x1c25ef10ffeb3c7d08aa707d17286e0b0d3cbcb50f1bd3b6523b63ba3b52dd0f, 0xfffc43bd08273ccf135fd3cacbeef055418e09eb728d727c4d5d5c556cdea7e3, 0xc5ab8111456b1f28f3c7a0a604b4553ce905cb019c463ee159137af83c350b22, 0x0ff273fcbf4ae0f2bd88d6cf319ff4004f8d7dca70d4ced4e74d2c74139739e6, 0x7fa06ba11241ddd5efdc65d4e39c9f6991b74fd4b81b62230808216c876f827c, 0x7e275adf313a996c7e2950cac67caba02a5ff925ebf9906b58949f3e77aec5b9, 0x8f6162fa308d2b3a15dc33cffac85f13ab349173121645aedf00f471663108be, 0x78ccaaab73373552f207a63599de54d7d8d0c1805f86ce7da15818d09f4cff62 ]; // Reserve memory space for our hashes. bytes memory buf = new bytes(64); // We'll need to keep track of left and right siblings. bytes32 leftSibling; bytes32 rightSibling; // Number of non-empty nodes at the current depth. uint256 rowSize = _elements.length; // Current depth, counting from 0 at the leaves uint256 depth = 0; // Common sub-expressions uint256 halfRowSize; // rowSize / 2 bool rowSizeIsOdd; // rowSize % 2 == 1 while (rowSize > 1) { halfRowSize = rowSize / 2; rowSizeIsOdd = rowSize % 2 == 1; for (uint256 i = 0; i < halfRowSize; i++) { leftSibling = _elements[(2 * i)]; rightSibling = _elements[(2 * i) + 1]; assembly { mstore(add(buf, 32), leftSibling) mstore(add(buf, 64), rightSibling) } _elements[i] = keccak256(buf); } if (rowSizeIsOdd) { leftSibling = _elements[rowSize - 1]; rightSibling = bytes32(defaults[depth]); assembly { mstore(add(buf, 32), leftSibling) mstore(add(buf, 64), rightSibling) } _elements[halfRowSize] = keccak256(buf); } rowSize = halfRowSize + (rowSizeIsOdd ? 1 : 0); depth++; } return _elements[0]; }
34,055
26
// Return the accrued rewards for an user over a list of distribution user The address of the user stakes List of structs of the user data related with his stakereturn The accrued rewards for the user until the moment /
function _getUnclaimedRewards(address user, DistributionTypes.UserStakeInput[] memory stakes) internal view returns (uint256)
function _getUnclaimedRewards(address user, DistributionTypes.UserStakeInput[] memory stakes) internal view returns (uint256)
5,935
13
// Check that the product exists
require(product.id == _id, "Product does not exist"); return (product.id, product.materialType, product.category, product.totalQuantity,product.utilizedQuantity, product.owner);
require(product.id == _id, "Product does not exist"); return (product.id, product.materialType, product.category, product.totalQuantity,product.utilizedQuantity, product.owner);
2,195
18
// rounds to zero if xy < WAD / 2
function wmul(uint x, uint y) internal pure returns (uint z) { z = add(mul(x, y), WAD / 2) / WAD; }
function wmul(uint x, uint y) internal pure returns (uint z) { z = add(mul(x, y), WAD / 2) / WAD; }
5,874
11
// Claims and direct mints rely on zero-mint parent genes
bytes32 mGene; bytes32 dGene; (mGene, dGene) = generateParentGenes(); HyperBeetle storage hb = hyperBeetles[tokenId]; hb.gene = bytes32(generateChildGenes(mGene, dGene)); hb.momGene = mGene; hb.dadGene = dGene; _safeMint(_to, tokenId);
bytes32 mGene; bytes32 dGene; (mGene, dGene) = generateParentGenes(); HyperBeetle storage hb = hyperBeetles[tokenId]; hb.gene = bytes32(generateChildGenes(mGene, dGene)); hb.momGene = mGene; hb.dadGene = dGene; _safeMint(_to, tokenId);
68,567
115
// add ibToken to farm contract
uint256 ibWantAmt = IERC20(vaultContractAddress).balanceOf(address(this)); IERC20(vaultContractAddress).safeIncreaseAllowance(farmContractAddress, ibWantAmt); IFairLaunch(farmContractAddress).deposit(address(this), pid, ibWantAmt); emit Farm(wantAmt);
uint256 ibWantAmt = IERC20(vaultContractAddress).balanceOf(address(this)); IERC20(vaultContractAddress).safeIncreaseAllowance(farmContractAddress, ibWantAmt); IFairLaunch(farmContractAddress).deposit(address(this), pid, ibWantAmt); emit Farm(wantAmt);
17,705
29
// Emits an {Approval} event. Requirements: - `owner` cannot be the zero address.- `spender` cannot be the zero address. /
function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount);
function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount);
1,787
89
// Destroys `amount` tokens of token type `id` from `account` Requirements: - `account` cannot be the zero address.- `account` must have at least `amount` tokens of token type `id`. /
function _burn(address account, uint256 id, uint256 amount) internal virtual { require(account != address(0), "ERC1155: burn from the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, account, address(0), _asSingletonArray(id), _asSingletonArray(amount), ""); uint256 accountBalance = _balances[id][account]; require(accountBalance >= amount, "ERC1155: burn amount exceeds balance"); _balances[id][account] = accountBalance - amount; emit TransferSingle(operator, account, address(0), id, amount); }
function _burn(address account, uint256 id, uint256 amount) internal virtual { require(account != address(0), "ERC1155: burn from the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, account, address(0), _asSingletonArray(id), _asSingletonArray(amount), ""); uint256 accountBalance = _balances[id][account]; require(accountBalance >= amount, "ERC1155: burn amount exceeds balance"); _balances[id][account] = accountBalance - amount; emit TransferSingle(operator, account, address(0), id, amount); }
37,922
42
// Trackers
uint public totalSpins; uint public totalZTHWagered; mapping (uint => uint) public contractBalance;
uint public totalSpins; uint public totalZTHWagered; mapping (uint => uint) public contractBalance;
57,345
104
// 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 = now;
updateAccounting(); uint256 lockedTokens = totalLocked(); uint256 mintedLockedShares = (lockedTokens > 0) ? totalLockedShares.mul(amount).div(lockedTokens) : amount.mul(_initialSharesPerToken); UnlockSchedule memory schedule; schedule.initialLockedShares = mintedLockedShares; schedule.lastUnlockTimestampSec = now;
3,884
4
// keep all the ether sent to this address
function() payable public { emit Received(msg.sender, msg.value); }
function() payable public { emit Received(msg.sender, msg.value); }
22,552
119
// The block number when YFIN mining ends.
uint256 public endBlock; event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount); constructor( YfinToken _yfin, address _devaddr, uint256 _yfinPerBlock,
uint256 public endBlock; event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount); constructor( YfinToken _yfin, address _devaddr, uint256 _yfinPerBlock,
84,840
40
// Safe value transfer function, just in case if rounding error causes pool to not have enough VALUEs.
function safeValueTransfer(address _to, uint256 _amount) internal { uint256 valueBal = value.balanceOf(address(this)); if (_amount > valueBal) { value.transfer(_to, valueBal); } else { value.transfer(_to, _amount); } }
function safeValueTransfer(address _to, uint256 _amount) internal { uint256 valueBal = value.balanceOf(address(this)); if (_amount > valueBal) { value.transfer(_to, valueBal); } else { value.transfer(_to, _amount); } }
12,869
11
// AllowanceTarget contract /
contract AllowanceTarget is IAllowanceTarget { using Address for address; uint256 constant private TIME_LOCK_DURATION = 1 days; address public spender; address public newSpender; uint256 public timelockExpirationTime; modifier onlySpender() { require(spender == msg.sender, "AllowanceTarget: not the spender"); _; } constructor(address _spender) public { require(_spender != address(0), "AllowanceTarget: _spender should not be 0"); // Set spender spender = _spender; } function setSpenderWithTimelock(address _newSpender) override external onlySpender { require(_newSpender.isContract(), "AllowanceTarget: new spender not a contract"); require(newSpender == address(0) && timelockExpirationTime == 0, "AllowanceTarget: SetSpender in progress"); timelockExpirationTime = now + TIME_LOCK_DURATION; newSpender = _newSpender; } function completeSetSpender() override external { require(timelockExpirationTime != 0, "AllowanceTarget: no pending SetSpender"); require(now >= timelockExpirationTime, "AllowanceTarget: time lock not expired yet"); // Set new spender spender = newSpender; // Reset timelockExpirationTime = 0; newSpender = address(0); } function teardown() override external onlySpender { selfdestruct(payable(spender)); } /// @dev Execute an arbitrary call. Only an authority can call this. /// @param target The call target. /// @param callData The call data. /// @return resultData The data returned by the call. function executeCall( address payable target, bytes calldata callData ) override external onlySpender returns (bytes memory resultData) { bool success; (success, resultData) = target.call(callData); if (!success) { // Get the error message returned assembly { let ptr := mload(0x40) let size := returndatasize() returndatacopy(ptr, 0, size) revert(ptr, size) } } } }
contract AllowanceTarget is IAllowanceTarget { using Address for address; uint256 constant private TIME_LOCK_DURATION = 1 days; address public spender; address public newSpender; uint256 public timelockExpirationTime; modifier onlySpender() { require(spender == msg.sender, "AllowanceTarget: not the spender"); _; } constructor(address _spender) public { require(_spender != address(0), "AllowanceTarget: _spender should not be 0"); // Set spender spender = _spender; } function setSpenderWithTimelock(address _newSpender) override external onlySpender { require(_newSpender.isContract(), "AllowanceTarget: new spender not a contract"); require(newSpender == address(0) && timelockExpirationTime == 0, "AllowanceTarget: SetSpender in progress"); timelockExpirationTime = now + TIME_LOCK_DURATION; newSpender = _newSpender; } function completeSetSpender() override external { require(timelockExpirationTime != 0, "AllowanceTarget: no pending SetSpender"); require(now >= timelockExpirationTime, "AllowanceTarget: time lock not expired yet"); // Set new spender spender = newSpender; // Reset timelockExpirationTime = 0; newSpender = address(0); } function teardown() override external onlySpender { selfdestruct(payable(spender)); } /// @dev Execute an arbitrary call. Only an authority can call this. /// @param target The call target. /// @param callData The call data. /// @return resultData The data returned by the call. function executeCall( address payable target, bytes calldata callData ) override external onlySpender returns (bytes memory resultData) { bool success; (success, resultData) = target.call(callData); if (!success) { // Get the error message returned assembly { let ptr := mload(0x40) let size := returndatasize() returndatacopy(ptr, 0, size) revert(ptr, size) } } } }
5,257
83
// METHOD: Emit a Transfer event in proxy contract. /
function emitTransfer(address _from, address _to, uint256 _value) public onlyLogic { emit Transfer(_from, _to, _value); }
function emitTransfer(address _from, address _to, uint256 _value) public onlyLogic { emit Transfer(_from, _to, _value); }
5,174
27
// The rate at which the flywheel distributes COMP, per block
uint256 public compRate;
uint256 public compRate;
28,123
11
// calculate fee growth above
uint256 feeGrowthAbove0X128; uint256 feeGrowthAbove1X128; if (tickCurrent < tickUpper) { feeGrowthAbove0X128 = upper.feeGrowthOutside0X128; feeGrowthAbove1X128 = upper.feeGrowthOutside1X128; } else {
uint256 feeGrowthAbove0X128; uint256 feeGrowthAbove1X128; if (tickCurrent < tickUpper) { feeGrowthAbove0X128 = upper.feeGrowthOutside0X128; feeGrowthAbove1X128 = upper.feeGrowthOutside1X128; } else {
26,645
1,534
// 768
entry "unguillotined" : ENG_ADJECTIVE
entry "unguillotined" : ENG_ADJECTIVE
17,380
101
// Sets MasterChef PID
function setPID(uint _pid) external { require(msg.sender == governance, "!gov"); require(pid == 0, "pid has already been set"); require(_pid > 0, "invalid pid"); pid = _pid; }
function setPID(uint _pid) external { require(msg.sender == governance, "!gov"); require(pid == 0, "pid has already been set"); require(_pid > 0, "invalid pid"); pid = _pid; }
20,153
206
// returns the DAI to ether price on uniswap, that is, how many ether for 1 DAI /
function DAI_ETH_price() public view returns (uint256) { uint256 _amountDAI = 1e18; // 1 KTY (uint256 _reserveDAI, uint256 _reserveETH) = getReserve(daiAddr, wethAddr, daiWethPair); return UniswapV2Library.getAmountIn(_amountDAI, _reserveETH, _reserveDAI); }
function DAI_ETH_price() public view returns (uint256) { uint256 _amountDAI = 1e18; // 1 KTY (uint256 _reserveDAI, uint256 _reserveETH) = getReserve(daiAddr, wethAddr, daiWethPair); return UniswapV2Library.getAmountIn(_amountDAI, _reserveETH, _reserveDAI); }
79,625
17
// Calculates the ETH gain earned by the deposit since its last snapshots were taken. /
function getDepositorETHGain(address _depositor) external view returns (uint);
function getDepositorETHGain(address _depositor) external view returns (uint);
7,685
37
// Check state
require( proposalState(proposalId) == ProposalState.AwaitingExecution, ExceptionsLibrary.WRONG_STATE );
require( proposalState(proposalId) == ProposalState.AwaitingExecution, ExceptionsLibrary.WRONG_STATE );
34,146
1
// the time of last call
uint256 public lastCall;
uint256 public lastCall;
26,214
27
// Set the expiry to now so people can withdraw their contributions.
expiry = uint40(block.timestamp); emit Lost();
expiry = uint40(block.timestamp); emit Lost();
31,371