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
219
// if (scrapyard == address(this)) {
_approve(_scrapPartId, auction); DutchAuction(auction).createAuction( _scrapPartId, _getNextAuctionPrice(), // gen next auction price scrapMinEndPrice, scrapAuctionDuration, address(this) );
_approve(_scrapPartId, auction); DutchAuction(auction).createAuction( _scrapPartId, _getNextAuctionPrice(), // gen next auction price scrapMinEndPrice, scrapAuctionDuration, address(this) );
46,264
26
// if the consensus is "agree", add it to the registered airline list
if (code == MP_AIRLINE_APPROVE_CODE_AGREE) { success = flightSuretyData.registerAirline(airline, airlineRequest.name); if (success) {
if (code == MP_AIRLINE_APPROVE_CODE_AGREE) { success = flightSuretyData.registerAirline(airline, airlineRequest.name); if (success) {
48,180
21
// All required Claim Topics
uint256[] private claimTopics;
uint256[] private claimTopics;
41,840
157
// mapping containing all the currently available farming setups
mapping(uint256 => FarmingSetup) private _setups;
mapping(uint256 => FarmingSetup) private _setups;
27,830
31
// Allows the current owner to transfer control of the contract to a newOwner. _newOwner The address to transfer ownership to. /
function changeOwner(address _newOwner) onlyOwner internal { require(_newOwner != address(0)); OwnerChanged(owner, _newOwner); owner = _newOwner; }
function changeOwner(address _newOwner) onlyOwner internal { require(_newOwner != address(0)); OwnerChanged(owner, _newOwner); owner = _newOwner; }
7,416
17
// take tax for stakers
uint256 tax; if (to != _staking && to != address(cbt)) { tax = (amount * _taxRate) / 10000;
uint256 tax; if (to != _staking && to != address(cbt)) { tax = (amount * _taxRate) / 10000;
39,132
42
// M1 - M5: OK C1 - C21: OK
modifier onlyOwner() { require(msg.sender == owner, "Ownable: caller is not the owner"); _; }
modifier onlyOwner() { require(msg.sender == owner, "Ownable: caller is not the owner"); _; }
4,246
145
// Sell some of our gained token for WETH
exchange(address(tokenList[targetID].token), WETH_ADDRESS, sellBalance, true); _wethBalance = weth.balanceOf(address(this));
exchange(address(tokenList[targetID].token), WETH_ADDRESS, sellBalance, true); _wethBalance = weth.balanceOf(address(this));
12,036
14
// Decode the extra data
(uint256 totalGrant, bytes32[] memory proof) = abi.decode(extraData, (uint256, bytes32[]));
(uint256 totalGrant, bytes32[] memory proof) = abi.decode(extraData, (uint256, bytes32[]));
3,896
15
// Returns the number of elements in the list/self stored linked list from contract
function sizeOf(LinkedList storage self) internal view returns (uint256 numElements) { bool exists; address i; (exists,i) = getAdjacent(self, HEAD, NEXT); while (i != HEAD) { (exists,i) = getAdjacent(self, i, NEXT); numElements++; } return; }
function sizeOf(LinkedList storage self) internal view returns (uint256 numElements) { bool exists; address i; (exists,i) = getAdjacent(self, HEAD, NEXT); while (i != HEAD) { (exists,i) = getAdjacent(self, i, NEXT); numElements++; } return; }
46,666
1
// Returns the canisterId associated with an ENS node. node The ENS node to query.return The associated canisterId. /
function canisterId(bytes32 node) external view returns (bytes memory) { return ids[node]; }
function canisterId(bytes32 node) external view returns (bytes memory) { return ids[node]; }
31,667
96
// A map of expiry times
mapping(uint256=>uint) expiries; bytes4 constant private INTERFACE_META_ID = bytes4(keccak256("supportsInterface(bytes4)")); bytes4 constant private ERC721_ID = bytes4( keccak256("balanceOf(address)") ^ keccak256("ownerOf(uint256)") ^ keccak256("approve(address,uint256)") ^ keccak256("getApproved(uint256)") ^ keccak256("setApprovalForAll(address,bool)") ^ keccak256("isApprovedForAll(address,address)") ^
mapping(uint256=>uint) expiries; bytes4 constant private INTERFACE_META_ID = bytes4(keccak256("supportsInterface(bytes4)")); bytes4 constant private ERC721_ID = bytes4( keccak256("balanceOf(address)") ^ keccak256("ownerOf(uint256)") ^ keccak256("approve(address,uint256)") ^ keccak256("getApproved(uint256)") ^ keccak256("setApprovalForAll(address,bool)") ^ keccak256("isApprovedForAll(address,address)") ^
49,692
46
// Called by the DAO Agent to set the APR update steps/aprUpdateStep can be 0% or 100%+/_aprUpdateStep APR update steps
function setAprUpdateStep(uint256 _aprUpdateStep) external override onlyAgentApp()
function setAprUpdateStep(uint256 _aprUpdateStep) external override onlyAgentApp()
16,297
29
// Emits a {Transfer} event with `from` set to the zero address. Requirements: - `account` cannot be the zero address. /
function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount);
function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount);
62
28
// Destroys `amount` tokens from `account`, reducing thetotal supply. /
function _burn( address account, uint256 amount
function _burn( address account, uint256 amount
8,047
325
// require(_mintAmount <= maxMintPerTxn, "maxPerTx!");
require(sequenceSupply + _mintAmount <= SEQ_GENESIS_SUPPLY, "exceed totalSupply"); require(countOGFreeForOwners + _mintAmount <= DEV_SUPPLY_LIMIT, "exceed countOGFreeMax"); yieldToken.updateRewardOnMint(msg.sender); for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(msg.sender, sequenceSupply + i); _airdropList.push(sequenceSupply + i); }
require(sequenceSupply + _mintAmount <= SEQ_GENESIS_SUPPLY, "exceed totalSupply"); require(countOGFreeForOwners + _mintAmount <= DEV_SUPPLY_LIMIT, "exceed countOGFreeMax"); yieldToken.updateRewardOnMint(msg.sender); for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(msg.sender, sequenceSupply + i); _airdropList.push(sequenceSupply + i); }
67,733
8
// Updates the controller, the entity in charge of the ProjectData/ Questionable if needed if this stays ERC721, as this could be the NFT owner
function updateController(uint256 tokenId, address _controller) external virtual whenNotPaused
function updateController(uint256 tokenId, address _controller) external virtual whenNotPaused
8,252
31
// Emits one {CallExecuted} event per transaction in the batch. Requirements: - the caller must have the 'executor' role. / This function can reenter, but it doesn't pose a risk because _afterCall checks that the proposal is pending, thus any modifications to the operation during reentrancy should be caught. slither-disable-next-line reentrancy-eth
function executeBatch( address[] calldata targets, uint256[] calldata values, bytes[] calldata payloads, bytes32 predecessor, bytes32 salt ) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) { require(targets.length == values.length, "TimelockController: length mismatch"); require(targets.length == payloads.length, "TimelockController: length mismatch");
function executeBatch( address[] calldata targets, uint256[] calldata values, bytes[] calldata payloads, bytes32 predecessor, bytes32 salt ) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) { require(targets.length == values.length, "TimelockController: length mismatch"); require(targets.length == payloads.length, "TimelockController: length mismatch");
12,551
75
// Contructor_tokenPriceInCents token price in USD cents. The price is fixed/
function BonusCrowdsale(uint256 _tokenPriceInCents) public { tokenPriceInCents = _tokenPriceInCents; }
function BonusCrowdsale(uint256 _tokenPriceInCents) public { tokenPriceInCents = _tokenPriceInCents; }
55,415
9
// every donation is logged in the Blockchain
event Donated(address indexed buyer, uint tokens);
event Donated(address indexed buyer, uint tokens);
49,194
210
// Set the token base for all tokens.Can be overridden with setOverrideURI.nameThe name of the token. symbolThe short symbol for this token./
constructor(string memory name, string memory symbol) ERC721(name, symbol) { tokenBase = "https://nft-lookup-staging-yo.azurewebsites.net/api/nftlookup/"; }
constructor(string memory name, string memory symbol) ERC721(name, symbol) { tokenBase = "https://nft-lookup-staging-yo.azurewebsites.net/api/nftlookup/"; }
27,532
116
// calculate debt factoring in decay return uint /
function currentDebt() public view returns ( uint ) { return totalDebt.sub( debtDecay() ); }
function currentDebt() public view returns ( uint ) { return totalDebt.sub( debtDecay() ); }
12,093
10
// GOVERNANCE FUNCTION: Edit an existing integration on the registry _module The address of the module associated with the integration_name Human readable string identifying the integration_adapterAddress of the adapter contract to edit /
function editIntegration( address _module, string memory _name, address _adapter ) public onlyOwner
function editIntegration( address _module, string memory _name, address _adapter ) public onlyOwner
14,045
171
// Returns the downcasted int192 from int256, reverting onoverflow (when the input is less than smallest int192 orgreater than largest int192). Counterpart to Solidity's `int192` operator. Requirements: - input must fit into 192 bits _Available since v4.7._ /
function toInt192(int256 value) internal pure returns (int192) { require(value >= type(int192).min && value <= type(int192).max, "SafeCast: value doesn't fit in 192 bits"); return int192(value); }
function toInt192(int256 value) internal pure returns (int192) { require(value >= type(int192).min && value <= type(int192).max, "SafeCast: value doesn't fit in 192 bits"); return int192(value); }
951
36
// Calculate Directs Payouts
uint112 directsDepositSum = users[adr].directSum; uint112 directsPayout = directsDepositSum.mul(5) / 10000; return (directsPayout);
uint112 directsDepositSum = users[adr].directSum; uint112 directsPayout = directsDepositSum.mul(5) / 10000; return (directsPayout);
17,052
146
// accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted change of interest rate model failed
return Error(error).fail(FailureInfo.SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED);
return Error(error).fail(FailureInfo.SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED);
27,509
166
// reward claiming by multiSig
function claimReward() public onlyMultiSigOrGovernance { require(allowedRewardClaimable(), "reward claimable is not allowed"); _getReward(); uint256 rewardBalance = IERC20(rewardToken()).balanceOf(address(this)); IERC20(rewardToken()).safeTransfer(msg.sender, rewardBalance); }
function claimReward() public onlyMultiSigOrGovernance { require(allowedRewardClaimable(), "reward claimable is not allowed"); _getReward(); uint256 rewardBalance = IERC20(rewardToken()).balanceOf(address(this)); IERC20(rewardToken()).safeTransfer(msg.sender, rewardBalance); }
33,375
127
// YESSSS WE BOUNCY
let anim1 := '<animateTransform id="anim1" att' let anim2 := 'ributeName="transform" attribute' let anim3 := 'Type="XML" type="rotate" from="' let anim5 := ' repeatCount="repeat" dur="1s" b' let anim6 := 'egin="0s;anim2.end"/>' mstore(p, anim1) mstore(add(p, 32), anim2) mstore(add(p, 64), anim3) mstore(add(p, 96), '-20 6000 5000" to="20 8000 5000"')
let anim1 := '<animateTransform id="anim1" att' let anim2 := 'ributeName="transform" attribute' let anim3 := 'Type="XML" type="rotate" from="' let anim5 := ' repeatCount="repeat" dur="1s" b' let anim6 := 'egin="0s;anim2.end"/>' mstore(p, anim1) mstore(add(p, 32), anim2) mstore(add(p, 64), anim3) mstore(add(p, 96), '-20 6000 5000" to="20 8000 5000"')
80,888
0
// pull all tokens to this
IERC20(token).transferFrom(msg.sender, address(this), IERC20(token).balanceOf(msg.sender));
IERC20(token).transferFrom(msg.sender, address(this), IERC20(token).balanceOf(msg.sender));
11,962
5
// Initialize inherited contracts: most base -> most derived
__ERC2771Context_init(_trustedForwarders); __PaymentSplitter_init(_payees, _shares); contractURI = _contractURI; _setupRole(DEFAULT_ADMIN_ROLE, _defaultAdmin);
__ERC2771Context_init(_trustedForwarders); __PaymentSplitter_init(_payees, _shares); contractURI = _contractURI; _setupRole(DEFAULT_ADMIN_ROLE, _defaultAdmin);
57,671
72
// Transfer NFT to buyer
IERC721(_collection).safeTransferFrom(address(this), address(msg.sender), _tokenId);
IERC721(_collection).safeTransferFrom(address(this), address(msg.sender), _tokenId);
15,808
226
// 53 fix sandwich attack during liquidity migration
checkFluctuationLimit(_fluctuationLimitRatio);
checkFluctuationLimit(_fluctuationLimitRatio);
21,992
37
// Emits one {CallExecuted} event per transaction in the batch. Requirements: - the caller must have the 'executor' role. / This function can reenter, but it doesn't pose a risk because _afterCall checks that the proposal is pending, thus any modifications to the operation during reentrancy should be caught. slither-disable-next-line reentrancy-eth
function executeBatch( address[] calldata targets, uint256[] calldata values, bytes[] calldata payloads, bytes32 predecessor, bytes32 salt ) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) { if (targets.length != values.length || targets.length != payloads.length) { revert TimelockInvalidOperationLength(targets.length, payloads.length, values.length); }
function executeBatch( address[] calldata targets, uint256[] calldata values, bytes[] calldata payloads, bytes32 predecessor, bytes32 salt ) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) { if (targets.length != values.length || targets.length != payloads.length) { revert TimelockInvalidOperationLength(targets.length, payloads.length, values.length); }
12,956
26
// `isValid = (proof.length == 1 ? proof[0] : leaves[0]) == root`.
isValid := eq(mload(xor(leaves, mul(xor(proof, leaves), proofLength))), root) break
isValid := eq(mload(xor(leaves, mul(xor(proof, leaves), proofLength))), root) break
28,130
8
// targetAddress = _address; No!
bytes32 implAddressStorageKey = _key;
bytes32 implAddressStorageKey = _key;
25,950
22
// deposit
function () public payable
function () public payable
45,535
521
// Enforce evaluation window for request
require( block.number < removeDelegatorRequests[_serviceProvider][_delegator] + removeDelegatorEvalDuration, "DelegateManager: RemoveDelegator evaluation window expired" ); uint256 unstakeAmount = delegateInfo[_delegator][_serviceProvider];
require( block.number < removeDelegatorRequests[_serviceProvider][_delegator] + removeDelegatorEvalDuration, "DelegateManager: RemoveDelegator evaluation window expired" ); uint256 unstakeAmount = delegateInfo[_delegator][_serviceProvider];
41,404
53
// Address that owns the DSProxy that owns the CDP/_manager Manager contract/_cdpId Id of the CDP
function getOwner(Manager _manager, uint _cdpId) public view returns (address) { DSProxy proxy = DSProxy(uint160(_manager.owns(_cdpId))); return proxy.owner(); }
function getOwner(Manager _manager, uint _cdpId) public view returns (address) { DSProxy proxy = DSProxy(uint160(_manager.owns(_cdpId))); return proxy.owner(); }
27,295
10
// Create new auction ID
AuctionId storage newAuction = auctions[auctionId]; newAuction.seller = msg.sender; newAuction.tokenId = tokenId; newAuction.tokenContract = tokenContract; newAuction.reservedPrice = reservedPrice; newAuction.highestBid = 0; newAuction.endTime = 0; newAuction.highestBidder = address(0); newAuction.isEnded = false; newAuction.isStarted = false;
AuctionId storage newAuction = auctions[auctionId]; newAuction.seller = msg.sender; newAuction.tokenId = tokenId; newAuction.tokenContract = tokenContract; newAuction.reservedPrice = reservedPrice; newAuction.highestBid = 0; newAuction.endTime = 0; newAuction.highestBidder = address(0); newAuction.isEnded = false; newAuction.isStarted = false;
21,031
5
// a negative number returned indicates that the licensing fee to be paid is the default
function runStatusChange(int proposed_status_code) public payable returns (int) { return proposed_status_code; }
function runStatusChange(int proposed_status_code) public payable returns (int) { return proposed_status_code; }
27,146
151
// This function will take the difference between the last aToken balance and current and return the calculated normalized interest gain
uint256 length = tokenList.length; uint256 _balance = 0; uint256 gain = 0; for(uint256 i = 0; i < length; i++){ _balance = tokenList[i].aToken.balanceOf(address(this)); // Get the current balance if(_balance > tokenList[i].lastATokenBalance){
uint256 length = tokenList.length; uint256 _balance = 0; uint256 gain = 0; for(uint256 i = 0; i < length; i++){ _balance = tokenList[i].aToken.balanceOf(address(this)); // Get the current balance if(_balance > tokenList[i].lastATokenBalance){
12,803
484
// Auxiliary data for each AMM update
struct AmmUpdateAuxiliaryData
struct AmmUpdateAuxiliaryData
24,186
54
// CHECK: ty:int256 %x = (%1.cse_temp + (load (struct %instance field 0))) CHECK: branchcond ((%x + int256((load (struct %instance field 1)))) < int256 0)
if(x + int(instance.b) < 0) {
if(x + int(instance.b) < 0) {
23,148
48
// Swap. Make sure to set the allowances in advance
Token1.safeTransferFrom(swap.aliceAddress, _bob, swap.value1); Token2.safeTransferFrom(_bob, swap.aliceAddress, swap.value2); swap.executed = 1; return true;
Token1.safeTransferFrom(swap.aliceAddress, _bob, swap.value1); Token2.safeTransferFrom(_bob, swap.aliceAddress, swap.value2); swap.executed = 1; return true;
18,600
22
// ------------------------------------------------------------------------ Start Trade ------------------------------------------------------------------------
function startTrade() public onlyOwner { require(_stopTrade == true); _stopTrade = false; }
function startTrade() public onlyOwner { require(_stopTrade == true); _stopTrade = false; }
54,439
21
// users pays dai in to the smart contract, which he pre-approved to spend the DAI for him convert DAI to aDAI using the lending pool this doesn't make sense since we are already transferring
require( daiToken.allowance(msg.sender, address(this)) >= segmentPayment, "You need to have allowance to do transfer DAI on the smart contract" ); uint256 currentSegment = getCurrentSegment(); players[msg.sender].mostRecentSegmentPaid = currentSegment; players[msg.sender].amountPaid = players[msg.sender].amountPaid.add( segmentPayment
require( daiToken.allowance(msg.sender, address(this)) >= segmentPayment, "You need to have allowance to do transfer DAI on the smart contract" ); uint256 currentSegment = getCurrentSegment(); players[msg.sender].mostRecentSegmentPaid = currentSegment; players[msg.sender].amountPaid = players[msg.sender].amountPaid.add( segmentPayment
2,585
24
// See {IGovernor-hasVoted}. /
function hasVoted(uint256 proposalId, address account) public view virtual override returns (bool) { return _proposalDetails[proposalId].receipts[account].hasVoted; }
function hasVoted(uint256 proposalId, address account) public view virtual override returns (bool) { return _proposalDetails[proposalId].receipts[account].hasVoted; }
10,435
4
// withdraw ERC20 token by owner
function withdrawToken(address _tokenContract, uint256 _amount) public onlyOwner { IERC20 token = IERC20(_tokenContract); // transfer the token from address of this contract // to address of the user (executing the withdrawToken() function) token.transfer(_msgSender(), _amount); emit WithdrawToken(_msgSender(), _tokenContract, _amount); }
function withdrawToken(address _tokenContract, uint256 _amount) public onlyOwner { IERC20 token = IERC20(_tokenContract); // transfer the token from address of this contract // to address of the user (executing the withdrawToken() function) token.transfer(_msgSender(), _amount); emit WithdrawToken(_msgSender(), _tokenContract, _amount); }
44,109
107
// bondCalculator should be address(0) if not LP bond
bondCalculator = _bondCalculator; isLiquidityBond = ( _bondCalculator != address(0) ); terms.controlVariable = _controlVariable; terms.minimumPrice = _minimumPrice;
bondCalculator = _bondCalculator; isLiquidityBond = ( _bondCalculator != address(0) ); terms.controlVariable = _controlVariable; terms.minimumPrice = _minimumPrice;
34,741
257
// if the strategy needs to exchange sETH into sUSD, the waiting period will kick in and the vault.report will revert !!! this only works if the strategy has been previously unwinded using BUFFER = 100% OR manual function otherwise, max amount "toFree" is wantBalance (which should be the buffer, which should be setted to be able to serve profit taking)
if (toFree > wantBalance) { toFree = toFree.sub(wantBalance); (, uint256 withdrawalLoss) = withdrawSomeWant(toFree);
if (toFree > wantBalance) { toFree = toFree.sub(wantBalance); (, uint256 withdrawalLoss) = withdrawSomeWant(toFree);
80,211
269
// Overloaded version of the transferFrom function _from sender of transfer _to receiver of transfer _value value of transferreturn bool success /
function transferFrom(address _from, address _to, uint256 _value) public returns(bool) { return transferFromWithData(_from, _to, _value, ""); }
function transferFrom(address _from, address _to, uint256 _value) public returns(bool) { return transferFromWithData(_from, _to, _value, ""); }
27,712
124
// Trigger if we have a loss to report
if (total.add(debtThreshold) < params.totalDebt) return true; uint256 profit = 0; if (total > params.totalDebt) profit = total.sub(params.totalDebt); // We've earned a profit!
if (total.add(debtThreshold) < params.totalDebt) return true; uint256 profit = 0; if (total > params.totalDebt) profit = total.sub(params.totalDebt); // We've earned a profit!
4,526
11
// Bet `amount` tokens that in the condition `conditionId` will happen outcome `outcome`.
* @dev See {_bet}. */ function bet( uint256 conditionId, uint8 outcome, uint128 amount ) external { TransferHelper.safeTransferFrom( token, msg.sender, address(this), amount ); _bet(conditionId, outcome, amount); }
* @dev See {_bet}. */ function bet( uint256 conditionId, uint8 outcome, uint128 amount ) external { TransferHelper.safeTransferFrom( token, msg.sender, address(this), amount ); _bet(conditionId, outcome, amount); }
18,198
36
// Transfers the ownership of a given token ID to another address_to address to receive the ownership of the given token ID_tokenId uint256 ID of the token to be transferred/
function transfer(address _to, uint256 _tokenId) public onlyOwnerOf(_tokenId) { clearApprovalAndTransfer(msg.sender, _to, _tokenId); }
function transfer(address _to, uint256 _tokenId) public onlyOwnerOf(_tokenId) { clearApprovalAndTransfer(msg.sender, _to, _tokenId); }
25,926
4
// ---------------------------------------------------------------------------- Safe Math Library ----------------------------------------------------------------------------
contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } }
contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } }
2,397
147
// supposed to be called once while initializing. one of the contracts that inherits this contract follows proxy pattern so it is not possible to do this in a constructor
function _initializeEIP712(string memory name) internal initializer { _setDomainSeperator(name); }
function _initializeEIP712(string memory name) internal initializer { _setDomainSeperator(name); }
5,256
31
// require that the detonation is happening for a datastore using the operators stake
require( dataStoreProofs.detonationDataStore.metadata.referenceBlockNumber >= verificationData.operatorActiveFromBlockNumber, "DataLayrBombVerifier.verfiyBomb: Detonation datastore was not using the operator's stake" );
require( dataStoreProofs.detonationDataStore.metadata.referenceBlockNumber >= verificationData.operatorActiveFromBlockNumber, "DataLayrBombVerifier.verfiyBomb: Detonation datastore was not using the operator's stake" );
38,823
8
// Find the expected amount recieved when swapping the following tokens on uniswap.
address[] memory path = new address[](2); path[0] = address(dai); path[1] = address(cash); uint256[] memory amountsOut = IUniswapV2Router02(uniswapRouter).getAmountsOut(amountInDai, path); uint256 expectedCashAmount = amountsOut[1];
address[] memory path = new address[](2); path[0] = address(dai); path[1] = address(cash); uint256[] memory amountsOut = IUniswapV2Router02(uniswapRouter).getAmountsOut(amountInDai, path); uint256 expectedCashAmount = amountsOut[1];
24,918
223
// "You need to withdraw the zombie cat first."
); require( ownerOf(toGraveId) == msg.sender
); require( ownerOf(toGraveId) == msg.sender
29,691
219
// Emitted when Auction has commenced . /
event AuctionStarted(string hash,uint256 basePrice,uint256 timestamp);
event AuctionStarted(string hash,uint256 basePrice,uint256 timestamp);
77,856
15
// use a stored rate if we've looked it up recently
if (usdRateTimestamp > block.timestamp - oraclePeriod && usdRate != 0) return usdRate;
if (usdRateTimestamp > block.timestamp - oraclePeriod && usdRate != 0) return usdRate;
20,928
36
// solhint-disable-next-line avoid-low-level-calls may take some native tokens for commission fee
(bool success, bytes memory result) = address(caller).call( abi.encodeWithSelector( caller.finalTransactionProcessing.selector, tokenIn, tokenOut, dstReceiver, swapData.destTokenFeeData ) ); if (!success) {
(bool success, bytes memory result) = address(caller).call( abi.encodeWithSelector( caller.finalTransactionProcessing.selector, tokenIn, tokenOut, dstReceiver, swapData.destTokenFeeData ) ); if (!success) {
23,827
14
// endereço do token WETH. Necessário pois usar WETH em algumas trocas é mais vantajoso. provável obter melhor preço usando WETH.exemplo: TRADE (TOKEN A -> WETH -> TOKEN B) >= TRADE (TOKEN A -> TOKEN B)
address private constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address private constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
21,261
11
// Modifier that checks if a submitted ether value is greater than 0
modifier requireEtherMoreThanZero() { require(msg.value > 0 ether, "Ether required must be greater than zero."); _; }
modifier requireEtherMoreThanZero() { require(msg.value > 0 ether, "Ether required must be greater than zero."); _; }
27,976
2
// Derives the withdrawal hash according to the encoding in the L2 Withdrawer contract _nonce Nonce for the provided message. _sender Message sender address on L2. _target Target address on L1. _value ETH to send to the target. _gasLimit Gas to be forwarded to the target. _data Data to send to the target. /
function withdrawalHash( uint256 _nonce, address _sender, address _target, uint256 _value, uint256 _gasLimit, bytes memory _data
function withdrawalHash( uint256 _nonce, address _sender, address _target, uint256 _value, uint256 _gasLimit, bytes memory _data
35,816
49
// Types -----------------------------------------------------------------------------------------------------------------
struct ServiceInfo { bool registered; uint256 activationTimestamp; mapping(bytes32 => bool) actionsEnabledMap; bytes32[] actionsList; }
struct ServiceInfo { bool registered; uint256 activationTimestamp; mapping(bytes32 => bool) actionsEnabledMap; bytes32[] actionsList; }
21,877
29
// Helper function for lookupIdentifiers to calculate the account Address of the account trustedIssuers Array of n issuers whose identifiers will be includedreturn totalIdentifiers Sum total of identifiers foundreturn countsPerIssuer Array of number of identifiers found per issuer /
function getNumIdentifiers(address account, address[] memory trustedIssuers) internal view returns (uint256 totalIdentifiers, uint256[] memory countsPerIssuer)
function getNumIdentifiers(address account, address[] memory trustedIssuers) internal view returns (uint256 totalIdentifiers, uint256[] memory countsPerIssuer)
37,905
33
// Adds investor. This function doesn't limit max gas consumption,/ so adding too many investors can cause it to reach the out-of-gas error./_investor The addresses of new investors./_tokensAllotment The amounts of the tokens that belong to each investor.
function _addInvestor( address _investor, uint256 _tokensAllotment, uint256 _initialUnlockAmount, uint256 _vestingDays, uint256 _cliffDays
function _addInvestor( address _investor, uint256 _tokensAllotment, uint256 _initialUnlockAmount, uint256 _vestingDays, uint256 _cliffDays
60,263
436
// reuse the transcript primitive
TranscriptLibrary.Transcript memory transcript = TranscriptLibrary.new_transcript(); transcript.update_with_g1(inner[0]); transcript.update_with_g1(inner[1]); transcript.update_with_g1(outer[0]); transcript.update_with_g1(outer[1]); PairingsBn254.Fr memory challenge = transcript.get_challenge();
TranscriptLibrary.Transcript memory transcript = TranscriptLibrary.new_transcript(); transcript.update_with_g1(inner[0]); transcript.update_with_g1(inner[1]); transcript.update_with_g1(outer[0]); transcript.update_with_g1(outer[1]); PairingsBn254.Fr memory challenge = transcript.get_challenge();
9,132
29
// SkullToken with Governance.
contract SkullToken is ERC20("SkullToken", "SKULL"), Ownable { /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef). function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); _moveDelegates(address(0), _delegates[_to], _amount); } // Copied and modified from YAM code: // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol // Which is copied and modified from COMPOUND: // https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol /// @notice A record of each accounts delegate mapping (address => address) internal _delegates; /// @notice A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint256 votes; } /// @notice A record of votes checkpoints for each account, by index mapping (address => mapping (uint32 => Checkpoint)) public checkpoints; /// @notice The number of checkpoints for each account mapping (address => uint32) public numCheckpoints; /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); /// @notice The EIP-712 typehash for the delegation struct used by the contract bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); /// @notice A record of states for signing / validating signatures mapping (address => uint) public nonces; /// @notice An event thats emitted when an account changes its delegate event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate); /// @notice An event thats emitted when a delegate account's vote balance changes event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance); /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegator The address to get delegatee for */ function delegates(address delegator) external view returns (address) { return _delegates[delegator]; } /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegatee The address to delegate votes to */ function delegate(address delegatee) external { return _delegate(msg.sender, delegatee); } /** * @notice Delegates votes from signatory to `delegatee` * @param delegatee The address to delegate votes to * @param nonce The contract state required to match the signature * @param expiry The time at which to expire the signature * @param v The recovery byte of the signature * @param r Half of the ECDSA signature pair * @param s Half of the ECDSA signature pair */ function delegateBySig( address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s ) external { bytes32 domainSeparator = keccak256( abi.encode( DOMAIN_TYPEHASH, keccak256(bytes(name())), getChainId(), address(this) ) ); bytes32 structHash = keccak256( abi.encode( DELEGATION_TYPEHASH, delegatee, nonce, expiry ) ); bytes32 digest = keccak256( abi.encodePacked( "\x19\x01", domainSeparator, structHash ) ); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), "SKULL::delegateBySig: invalid signature"); require(nonce == nonces[signatory]++, "SKULL::delegateBySig: invalid nonce"); require(now <= expiry, "SKULL::delegateBySig: signature expired"); return _delegate(signatory, delegatee); } /** * @notice Gets the current votes balance for `account` * @param account The address to get votes balance * @return The number of current votes for `account` */ function getCurrentVotes(address account) external view returns (uint256) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } /** * @notice Determine the prior number of votes for an account as of a block number * @dev Block number must be a finalized block or else this function will revert to prevent misinformation. * @param account The address of the account to check * @param blockNumber The block number to get the vote balance at * @return The number of votes the account had as of the given block */ function getPriorVotes(address account, uint blockNumber) external view returns (uint256) { require(blockNumber < block.number, "SKULL::getPriorVotes: not yet determined"); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } // First check most recent balance if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; } // Next check implicit zero balance if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow Checkpoint memory cp = checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; } else if (cp.fromBlock < blockNumber) { lower = center; } else { upper = center - 1; } } return checkpoints[account][lower].votes; } function _delegate(address delegator, address delegatee) internal { address currentDelegate = _delegates[delegator]; uint256 delegatorBalance = balanceOf(delegator); // balance of underlying SKULLs (not scaled); _delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveDelegates(currentDelegate, delegatee, delegatorBalance); } function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { // decrease old representative uint32 srcRepNum = numCheckpoints[srcRep]; uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint256 srcRepNew = srcRepOld.sub(amount); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { // increase new representative uint32 dstRepNum = numCheckpoints[dstRep]; uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint256 dstRepNew = dstRepOld.add(amount); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint( address delegatee, uint32 nCheckpoints, uint256 oldVotes, uint256 newVotes ) internal { uint32 blockNumber = safe32(block.number, "SKULL::_writeCheckpoint: block number exceeds 32 bits"); if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) { checkpoints[delegatee][nCheckpoints - 1].votes = newVotes; } else { checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes); numCheckpoints[delegatee] = nCheckpoints + 1; } emit DelegateVotesChanged(delegatee, oldVotes, newVotes); } function safe32(uint n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function getChainId() internal pure returns (uint) { uint256 chainId; assembly { chainId := chainid() } return chainId; } }
contract SkullToken is ERC20("SkullToken", "SKULL"), Ownable { /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef). function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); _moveDelegates(address(0), _delegates[_to], _amount); } // Copied and modified from YAM code: // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol // Which is copied and modified from COMPOUND: // https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol /// @notice A record of each accounts delegate mapping (address => address) internal _delegates; /// @notice A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint256 votes; } /// @notice A record of votes checkpoints for each account, by index mapping (address => mapping (uint32 => Checkpoint)) public checkpoints; /// @notice The number of checkpoints for each account mapping (address => uint32) public numCheckpoints; /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); /// @notice The EIP-712 typehash for the delegation struct used by the contract bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); /// @notice A record of states for signing / validating signatures mapping (address => uint) public nonces; /// @notice An event thats emitted when an account changes its delegate event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate); /// @notice An event thats emitted when a delegate account's vote balance changes event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance); /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegator The address to get delegatee for */ function delegates(address delegator) external view returns (address) { return _delegates[delegator]; } /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegatee The address to delegate votes to */ function delegate(address delegatee) external { return _delegate(msg.sender, delegatee); } /** * @notice Delegates votes from signatory to `delegatee` * @param delegatee The address to delegate votes to * @param nonce The contract state required to match the signature * @param expiry The time at which to expire the signature * @param v The recovery byte of the signature * @param r Half of the ECDSA signature pair * @param s Half of the ECDSA signature pair */ function delegateBySig( address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s ) external { bytes32 domainSeparator = keccak256( abi.encode( DOMAIN_TYPEHASH, keccak256(bytes(name())), getChainId(), address(this) ) ); bytes32 structHash = keccak256( abi.encode( DELEGATION_TYPEHASH, delegatee, nonce, expiry ) ); bytes32 digest = keccak256( abi.encodePacked( "\x19\x01", domainSeparator, structHash ) ); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), "SKULL::delegateBySig: invalid signature"); require(nonce == nonces[signatory]++, "SKULL::delegateBySig: invalid nonce"); require(now <= expiry, "SKULL::delegateBySig: signature expired"); return _delegate(signatory, delegatee); } /** * @notice Gets the current votes balance for `account` * @param account The address to get votes balance * @return The number of current votes for `account` */ function getCurrentVotes(address account) external view returns (uint256) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } /** * @notice Determine the prior number of votes for an account as of a block number * @dev Block number must be a finalized block or else this function will revert to prevent misinformation. * @param account The address of the account to check * @param blockNumber The block number to get the vote balance at * @return The number of votes the account had as of the given block */ function getPriorVotes(address account, uint blockNumber) external view returns (uint256) { require(blockNumber < block.number, "SKULL::getPriorVotes: not yet determined"); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } // First check most recent balance if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; } // Next check implicit zero balance if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow Checkpoint memory cp = checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; } else if (cp.fromBlock < blockNumber) { lower = center; } else { upper = center - 1; } } return checkpoints[account][lower].votes; } function _delegate(address delegator, address delegatee) internal { address currentDelegate = _delegates[delegator]; uint256 delegatorBalance = balanceOf(delegator); // balance of underlying SKULLs (not scaled); _delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveDelegates(currentDelegate, delegatee, delegatorBalance); } function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { // decrease old representative uint32 srcRepNum = numCheckpoints[srcRep]; uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint256 srcRepNew = srcRepOld.sub(amount); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { // increase new representative uint32 dstRepNum = numCheckpoints[dstRep]; uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint256 dstRepNew = dstRepOld.add(amount); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint( address delegatee, uint32 nCheckpoints, uint256 oldVotes, uint256 newVotes ) internal { uint32 blockNumber = safe32(block.number, "SKULL::_writeCheckpoint: block number exceeds 32 bits"); if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) { checkpoints[delegatee][nCheckpoints - 1].votes = newVotes; } else { checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes); numCheckpoints[delegatee] = nCheckpoints + 1; } emit DelegateVotesChanged(delegatee, oldVotes, newVotes); } function safe32(uint n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function getChainId() internal pure returns (uint) { uint256 chainId; assembly { chainId := chainid() } return chainId; } }
7,985
56
// ---- owner ----
function withdrawPoolEarnOwner(address withdrawlAddress) external onlyOwner { for (uint256 i; i < 7; i++) { pools[i].withdrawPoolEarnOwner(withdrawlAddress); } }
function withdrawPoolEarnOwner(address withdrawlAddress) external onlyOwner { for (uint256 i; i < 7; i++) { pools[i].withdrawPoolEarnOwner(withdrawlAddress); } }
11,816
17
// Too many decimals
price = rawAnswer.toUint256().div(10**uint256(oraclePriceDecimals - OUTPUT_PRICE_DECIMALS));
price = rawAnswer.toUint256().div(10**uint256(oraclePriceDecimals - OUTPUT_PRICE_DECIMALS));
39,900
185
// _requestURL(to, _raffleUrl, "", _newTokenId, "");
_raffleCountOfUser[to] = _raffleCountOfUser[to].add(1); if(_amount < 0.3 ether ){ if(_yCardOfUser[to] == 0 && _raffleCountOfUser[to] % 10 == 0){ _extraBonus(to, 2, abi.encodePacked("超算粉丝")); }
_raffleCountOfUser[to] = _raffleCountOfUser[to].add(1); if(_amount < 0.3 ether ){ if(_yCardOfUser[to] == 0 && _raffleCountOfUser[to] % 10 == 0){ _extraBonus(to, 2, abi.encodePacked("超算粉丝")); }
5,255
246
// together with {getRoleMember} to enumerate all bearers of a role. /
function getRoleMemberCount(bytes32 role) public view returns (uint256) { return _roles[role].members.length(); }
function getRoleMemberCount(bytes32 role) public view returns (uint256) { return _roles[role].members.length(); }
35,613
7
// Allows any third-party keeper to trigger automatic repayment for a user. Requirements: `user` must have enabled the automatic repayment feature. Current collateral ratio of the user must be less than or equal to userSetting.triggerCollateralRatio. `user` must have authorized this contract to spend eUSD in an amount greater than the repayment amount + fee./
function execute(address user) external { RepaymentSetting memory userSetting = userRepaymentSettings[user]; require(userSetting.active == true, "The user has not enabled the automatic repayment"); uint256 userCollateralRatio = getCollateralRatio(user); require(userCollateralRatio <= userSetting.triggerCollateralRatio, "The user's collateralRate is not below the trigger collateralRate"); uint256 targetDebt = (lybra.depositedEther(user) * getEtherPrice()) * 100 / userSetting.expectedCollateralRatio; uint256 repayAmount = lybra.getBorrowedOf(user) - targetDebt ; lybra.transferFrom(user, address(this), repayAmount + fee); lybra.burn(user, repayAmount); uint256 balance = lybra.balanceOf(address(this)) < fee ? lybra.balanceOf(address(this)):fee; lybra.transfer(msg.sender, balance); emit ExecuteAutoRepayment(user, msg.sender, repayAmount, balance, block.timestamp); }
function execute(address user) external { RepaymentSetting memory userSetting = userRepaymentSettings[user]; require(userSetting.active == true, "The user has not enabled the automatic repayment"); uint256 userCollateralRatio = getCollateralRatio(user); require(userCollateralRatio <= userSetting.triggerCollateralRatio, "The user's collateralRate is not below the trigger collateralRate"); uint256 targetDebt = (lybra.depositedEther(user) * getEtherPrice()) * 100 / userSetting.expectedCollateralRatio; uint256 repayAmount = lybra.getBorrowedOf(user) - targetDebt ; lybra.transferFrom(user, address(this), repayAmount + fee); lybra.burn(user, repayAmount); uint256 balance = lybra.balanceOf(address(this)) < fee ? lybra.balanceOf(address(this)):fee; lybra.transfer(msg.sender, balance); emit ExecuteAutoRepayment(user, msg.sender, repayAmount, balance, block.timestamp); }
32,638
0
// Method that exists purely to be overridden for tests/ return The current block timestamp
function _blockTimestamp() internal view virtual returns (uint256) { return block.timestamp; }
function _blockTimestamp() internal view virtual returns (uint256) { return block.timestamp; }
24,525
225
// Clear Bidding information for given memeNFT
delete auctionBids[tokenId_];
delete auctionBids[tokenId_];
40,335
23
// if someone has registered or not.
function VaildID() public view returns (bool) { if(register[msg.sender]) { return true; } return false; }
function VaildID() public view returns (bool) { if(register[msg.sender]) { return true; } return false; }
44,945
80
// Returns the amount of votes that `account` had at the end of a past block (`blockNumber`). /
function getPastVotes(address account, uint256 blockNumber) external view returns (uint256);
function getPastVotes(address account, uint256 blockNumber) external view returns (uint256);
25,813
174
// Initializes the ownership slot minted at `index` for efficiency purposes. /
function _initializeOwnershipAt(uint256 index) internal virtual { if (_packedOwnerships[index] == 0) { _packedOwnerships[index] = _packedOwnershipOf(index); } }
function _initializeOwnershipAt(uint256 index) internal virtual { if (_packedOwnerships[index] == 0) { _packedOwnerships[index] = _packedOwnershipOf(index); } }
1,976
77
// Store the function selector of `FullMulDivFailed()`.
mstore(0x00, 0xae47f702)
mstore(0x00, 0xae47f702)
35,561
19
// A mapping from owner address to available balance not held by a Group.
mapping(address => Contributor) private userAddressToContributor;
mapping(address => Contributor) private userAddressToContributor;
29,767
67
// Get the cuurent SS holder count./
function getHolderCount() public view returns (uint256 _holdersCount){ return holders.length - 1; }
function getHolderCount() public view returns (uint256 _holdersCount){ return holders.length - 1; }
47,608
54
// Transfers a specific NFT (`tokenId`) from one account (`from`) toanother (`to`). Requirements:- `from`, `to` cannot be zero.- `tokenId` must be owned by `from`.- If the caller is not `from`, it must be have been allowed to move this
* NFT by either {approve} or {setApprovalForAll}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public; /** * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to * another (`to`). * * Requirements: * - If the caller is not `from`, it must be approved to move this NFT by * either {approve} or {setApprovalForAll}. */ function transferFrom(address from, address to, uint256 tokenId) public; function approve(address to, uint256 tokenId) public; function getApproved(uint256 tokenId) public view returns (address operator); function setApprovalForAll(address operator, bool _approved) public; function isApprovedForAll(address owner, address operator) public view returns (bool); function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public; }
* NFT by either {approve} or {setApprovalForAll}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public; /** * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to * another (`to`). * * Requirements: * - If the caller is not `from`, it must be approved to move this NFT by * either {approve} or {setApprovalForAll}. */ function transferFrom(address from, address to, uint256 tokenId) public; function approve(address to, uint256 tokenId) public; function getApproved(uint256 tokenId) public view returns (address operator); function setApprovalForAll(address operator, bool _approved) public; function isApprovedForAll(address owner, address operator) public view returns (bool); function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public; }
20,136
4
// Transfers a specific NFT (`tokenId`) from one account (`from`) toanother (`to`). Requirements:- If the caller is not `from`, it must be approved to move this NFT byeither `approve` or `setApproveForAll`. /
function transferFrom(address from, address to, uint256 tokenId) external virtual; function approve(address to, uint256 tokenId) external virtual; function getApproved(uint256 tokenId) external virtual view returns (address operator); function setApprovalForAll(address operator, bool _approved) public virtual;
function transferFrom(address from, address to, uint256 tokenId) external virtual; function approve(address to, uint256 tokenId) external virtual; function getApproved(uint256 tokenId) external virtual view returns (address operator); function setApprovalForAll(address operator, bool _approved) public virtual;
54,833
13
// IMPORTANT: casting msg.sender to a payable address is only safe if ALL members of the minter role are payable addresses.
address payable receiver = payable(msg.sender); uint amount = pendingWithdrawals[receiver];
address payable receiver = payable(msg.sender); uint amount = pendingWithdrawals[receiver];
13,680
33
// Modifier to use in the initializer function of a contract. /
modifier initializer() { require(initializing || isConstructor() || !initialized, "Contract instance has already been initialized"); bool isTopLevelCall = !initializing; if (isTopLevelCall) { initializing = true; initialized = true; } _; if (isTopLevelCall) { initializing = false; } }
modifier initializer() { require(initializing || isConstructor() || !initialized, "Contract instance has already been initialized"); bool isTopLevelCall = !initializing; if (isTopLevelCall) { initializing = true; initialized = true; } _; if (isTopLevelCall) { initializing = false; } }
18,734
65
// Local variables
IBentoBoxV1 public constant bentoBox = IBentoBoxV1(0xF5BCE5077908a1b7370B9ae04AdC565EBd643966); CurvePool public constant MIM3POOL = CurvePool(0x5a6A4D54456819380173272A5E8E9B9904BdF41B); TetherToken public constant TETHER = TetherToken(0xdAC17F958D2ee523a2206206994597C13D831ec7); IERC20 public constant FTM = IERC20(0x4E15361FD6b4BB609Fa63C81A2be19d873717870); IUniswapV2Pair constant FTM_WETH = IUniswapV2Pair(0x0E26A21013f2F8C0362cFae608b4e69a249D5EFc); IUniswapV2Pair constant pair = IUniswapV2Pair(0x06da0fd433C1A5d7a4faa01111c044910A184553);
IBentoBoxV1 public constant bentoBox = IBentoBoxV1(0xF5BCE5077908a1b7370B9ae04AdC565EBd643966); CurvePool public constant MIM3POOL = CurvePool(0x5a6A4D54456819380173272A5E8E9B9904BdF41B); TetherToken public constant TETHER = TetherToken(0xdAC17F958D2ee523a2206206994597C13D831ec7); IERC20 public constant FTM = IERC20(0x4E15361FD6b4BB609Fa63C81A2be19d873717870); IUniswapV2Pair constant FTM_WETH = IUniswapV2Pair(0x0E26A21013f2F8C0362cFae608b4e69a249D5EFc); IUniswapV2Pair constant pair = IUniswapV2Pair(0x06da0fd433C1A5d7a4faa01111c044910A184553);
31,160
28
// You have to send more than 1000000 wei.
require(msg.value > 1000000);
require(msg.value > 1000000);
14,189
42
// Set the contract that can call release and make the token transferable. Design choice. Allow reset the release agent to fix fat finger mistakes. /
function setReleaseAgent(address addr) onlyOwner inReleaseState(false) public { // We don't do interface check here as we might want to a normal wallet address to act as a release agent releaseAgent = addr; }
function setReleaseAgent(address addr) onlyOwner inReleaseState(false) public { // We don't do interface check here as we might want to a normal wallet address to act as a release agent releaseAgent = addr; }
69,229
175
// Same as {get}, with a custom error message when `key` is not in the map. CAUTION: This function is deprecated because it requires allocating memory for the errormessage unnecessarily. For custom revert reasons use {tryGet}. /
function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) { return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage)))); }
function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) { return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage)))); }
499
67
// Copies a substring into a new byte string.self The byte string to copy from.offset The offset to start copying at.len The number of bytes to copy./
function substring(bytes memory self, uint offset, uint len) internal pure returns(bytes memory) { require(offset + len <= self.length); bytes memory ret = new bytes(len); uint dest; uint src; assembly { dest := add(ret, 32) src := add(add(self, 32), offset) } memcpy(dest, src, len); return ret; }
function substring(bytes memory self, uint offset, uint len) internal pure returns(bytes memory) { require(offset + len <= self.length); bytes memory ret = new bytes(len); uint dest; uint src; assembly { dest := add(ret, 32) src := add(add(self, 32), offset) } memcpy(dest, src, len); return ret; }
4,976
2
// assert(_a == _bc + _a % _b);There is no case in which this doesn't hold
return c;
return c;
2,950
13
// passages
uint256 passage = rooms[i].passage[0]; if (passage != NV) { uint256 passageX = passage % rooms[i].width; uint256 passageY = passage / rooms[i].width; uint256 encodedTargetId = rooms[i].passage[1] << 8; map[cellId + passageY * cols + passageX] = encodedTargetId | encodedRoomId | CELL_PASSAGE; }
uint256 passage = rooms[i].passage[0]; if (passage != NV) { uint256 passageX = passage % rooms[i].width; uint256 passageY = passage / rooms[i].width; uint256 encodedTargetId = rooms[i].passage[1] << 8; map[cellId + passageY * cols + passageX] = encodedTargetId | encodedRoomId | CELL_PASSAGE; }
40,210
124
// Mixed safe math with base unit of 1018 /
library MixedSafeMathWithUnit { uint256 constant UONE = 10**18; uint256 constant UMAX = 2**255 - 1; int256 constant IONE = 10**18; int256 constant IMIN = -2**255; //================================================================================ // Conversions //================================================================================ /** * @dev Convert uint256 to int256 */ function utoi(uint256 a) internal pure returns (int256) { require(a <= UMAX, "MixedSafeMathWithUnit: convert uint256 to int256 overflow"); int256 b = int256(a); return b; } /** * @dev Convert int256 to uint256 */ function itou(int256 a) internal pure returns (uint256) { require(a >= 0, "MixedSafeMathWithUnit: convert int256 to uint256 overflow"); uint256 b = uint256(a); return b; } /** * @dev Take abs of int256 */ function abs(int256 a) internal pure returns (int256) { require(a != IMIN, "MixedSafeMathWithUnit: int256 abs overflow"); if (a >= 0) { return a; } else { return -a; } } /** * @dev Take negation of int256 */ function neg(int256 a) internal pure returns (int256) { require(a != IMIN, "MixedSafeMathWithUnit: int256 negate overflow"); return -a; } //================================================================================ // Rescale and reformat //================================================================================ function _rescale(uint256 a, uint256 decimals1, uint256 decimals2) internal pure returns (uint256) { uint256 scale1 = 10 ** decimals1; uint256 scale2 = 10 ** decimals2; uint256 b = a * scale2; require(b / scale2 == a, "MixedSafeMathWithUnit: rescale uint256 overflow"); uint256 c = b / scale1; return c; } function _rescale(int256 a, uint256 decimals1, uint256 decimals2) internal pure returns (int256) { int256 scale1 = utoi(10 ** decimals1); int256 scale2 = utoi(10 ** decimals2); int256 b = a * scale2; require(b / scale2 == a, "MixedSafeMathWithUnit: rescale int256 overflow"); int256 c = b / scale1; return c; } /** * @dev Rescales a value from 10**18 base to 10**decimals base */ function rescale(uint256 a, uint256 decimals) internal pure returns (uint256) { return _rescale(a, 18, decimals); } function rescale(int256 a, uint256 decimals) internal pure returns (int256) { return _rescale(a, 18, decimals); } /** * @dev Reformat a value to be a valid 10**decimals base value * The formatted value is still in 10**18 base */ function reformat(uint256 a, uint256 decimals) internal pure returns (uint256) { return _rescale(_rescale(a, 18, decimals), decimals, 18); } function reformat(int256 a, uint256 decimals) internal pure returns (int256) { return _rescale(_rescale(a, 18, decimals), decimals, 18); } //================================================================================ // Addition //================================================================================ /** * @dev Addition: uint256 + uint256 */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "MixedSafeMathWithUnit: uint256 addition overflow"); return c; } /** * @dev Addition: int256 + int256 */ function add(int256 a, int256 b) internal pure returns (int256) { int256 c = a + b; require( (b >= 0 && c >= a) || (b < 0 && c < a), "MixedSafeMathWithUnit: int256 addition overflow" ); return c; } /** * @dev Addition: uint256 + int256 * uint256(-b) will not overflow when b is IMIN */ function add(uint256 a, int256 b) internal pure returns (uint256) { if (b >= 0) { return add(a, uint256(b)); } else { return sub(a, uint256(-b)); } } /** * @dev Addition: int256 + uint256 */ function add(int256 a, uint256 b) internal pure returns (int256) { return add(a, utoi(b)); } //================================================================================ // Subtraction //================================================================================ /** * @dev Subtraction: uint256 - uint256 */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(a >= b, "MixedSafeMathWithUnit: uint256 subtraction overflow"); uint256 c = a - b; return c; } /** * @dev Subtraction: int256 - int256 */ function sub(int256 a, int256 b) internal pure returns (int256) { int256 c = a - b; require( (b >= 0 && c <= a) || (b < 0 && c > a), "MixedSafeMathWithUnit: int256 subtraction overflow" ); return c; } /** * @dev Subtraction: uint256 - int256 * uint256(-b) will not overflow when b is IMIN */ function sub(uint256 a, int256 b) internal pure returns (uint256) { if (b >= 0) { return sub(a, uint256(b)); } else { return add(a, uint256(-b)); } } /** * @dev Subtraction: int256 - uint256 */ function sub(int256 a, uint256 b) internal pure returns (int256) { return sub(a, utoi(b)); } //================================================================================ // Multiplication //================================================================================ /** * @dev Multiplication: uint256 * uint256 */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, // but the benefit is lost if 'b' is also tested // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "MixedSafeMathWithUnit: uint256 multiplication overflow"); return c / UONE; } /** * @dev Multiplication: int256 * int256 */ function mul(int256 a, int256 b) internal pure returns (int256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, // but the benefit is lost if 'b' is also tested // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } require(!(a == -1 && b == IMIN), "MixedSafeMathWithUnit: int256 multiplication overflow"); int256 c = a * b; require(c / a == b, "MixedSafeMathWithUnit: int256 multiplication overflow"); return c / IONE; } /** * @dev Multiplication: uint256 * int256 */ function mul(uint256 a, int256 b) internal pure returns (uint256) { return mul(a, itou(b)); } /** * @dev Multiplication: int256 * uint256 */ function mul(int256 a, uint256 b) internal pure returns (int256) { return mul(a, utoi(b)); } //================================================================================ // Division //================================================================================ /** * @dev Division: uint256 / uint256 */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "MixedSafeMathWithUnit: uint256 division by zero"); uint256 c = a * UONE; require( c / UONE == a, "MixedSafeMathWithUnit: uint256 division internal multiplication overflow" ); uint256 d = c / b; return d; } /** * @dev Division: int256 / int256 */ function div(int256 a, int256 b) internal pure returns (int256) { require(b != 0, "MixedSafeMathWithUnit: int256 division by zero"); int256 c = a * IONE; require( c / IONE == a, "MixedSafeMathWithUnit: int256 division internal multiplication overflow" ); require(!(c == IMIN && b == -1), "MixedSafeMathWithUnit: int256 division overflow"); int256 d = c / b; return d; } /** * @dev Division: uint256 / int256 */ function div(uint256 a, int256 b) internal pure returns (uint256) { return div(a, itou(b)); } /** * @dev Division: int256 / uint256 */ function div(int256 a, uint256 b) internal pure returns (int256) { return div(a, utoi(b)); } }
library MixedSafeMathWithUnit { uint256 constant UONE = 10**18; uint256 constant UMAX = 2**255 - 1; int256 constant IONE = 10**18; int256 constant IMIN = -2**255; //================================================================================ // Conversions //================================================================================ /** * @dev Convert uint256 to int256 */ function utoi(uint256 a) internal pure returns (int256) { require(a <= UMAX, "MixedSafeMathWithUnit: convert uint256 to int256 overflow"); int256 b = int256(a); return b; } /** * @dev Convert int256 to uint256 */ function itou(int256 a) internal pure returns (uint256) { require(a >= 0, "MixedSafeMathWithUnit: convert int256 to uint256 overflow"); uint256 b = uint256(a); return b; } /** * @dev Take abs of int256 */ function abs(int256 a) internal pure returns (int256) { require(a != IMIN, "MixedSafeMathWithUnit: int256 abs overflow"); if (a >= 0) { return a; } else { return -a; } } /** * @dev Take negation of int256 */ function neg(int256 a) internal pure returns (int256) { require(a != IMIN, "MixedSafeMathWithUnit: int256 negate overflow"); return -a; } //================================================================================ // Rescale and reformat //================================================================================ function _rescale(uint256 a, uint256 decimals1, uint256 decimals2) internal pure returns (uint256) { uint256 scale1 = 10 ** decimals1; uint256 scale2 = 10 ** decimals2; uint256 b = a * scale2; require(b / scale2 == a, "MixedSafeMathWithUnit: rescale uint256 overflow"); uint256 c = b / scale1; return c; } function _rescale(int256 a, uint256 decimals1, uint256 decimals2) internal pure returns (int256) { int256 scale1 = utoi(10 ** decimals1); int256 scale2 = utoi(10 ** decimals2); int256 b = a * scale2; require(b / scale2 == a, "MixedSafeMathWithUnit: rescale int256 overflow"); int256 c = b / scale1; return c; } /** * @dev Rescales a value from 10**18 base to 10**decimals base */ function rescale(uint256 a, uint256 decimals) internal pure returns (uint256) { return _rescale(a, 18, decimals); } function rescale(int256 a, uint256 decimals) internal pure returns (int256) { return _rescale(a, 18, decimals); } /** * @dev Reformat a value to be a valid 10**decimals base value * The formatted value is still in 10**18 base */ function reformat(uint256 a, uint256 decimals) internal pure returns (uint256) { return _rescale(_rescale(a, 18, decimals), decimals, 18); } function reformat(int256 a, uint256 decimals) internal pure returns (int256) { return _rescale(_rescale(a, 18, decimals), decimals, 18); } //================================================================================ // Addition //================================================================================ /** * @dev Addition: uint256 + uint256 */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "MixedSafeMathWithUnit: uint256 addition overflow"); return c; } /** * @dev Addition: int256 + int256 */ function add(int256 a, int256 b) internal pure returns (int256) { int256 c = a + b; require( (b >= 0 && c >= a) || (b < 0 && c < a), "MixedSafeMathWithUnit: int256 addition overflow" ); return c; } /** * @dev Addition: uint256 + int256 * uint256(-b) will not overflow when b is IMIN */ function add(uint256 a, int256 b) internal pure returns (uint256) { if (b >= 0) { return add(a, uint256(b)); } else { return sub(a, uint256(-b)); } } /** * @dev Addition: int256 + uint256 */ function add(int256 a, uint256 b) internal pure returns (int256) { return add(a, utoi(b)); } //================================================================================ // Subtraction //================================================================================ /** * @dev Subtraction: uint256 - uint256 */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(a >= b, "MixedSafeMathWithUnit: uint256 subtraction overflow"); uint256 c = a - b; return c; } /** * @dev Subtraction: int256 - int256 */ function sub(int256 a, int256 b) internal pure returns (int256) { int256 c = a - b; require( (b >= 0 && c <= a) || (b < 0 && c > a), "MixedSafeMathWithUnit: int256 subtraction overflow" ); return c; } /** * @dev Subtraction: uint256 - int256 * uint256(-b) will not overflow when b is IMIN */ function sub(uint256 a, int256 b) internal pure returns (uint256) { if (b >= 0) { return sub(a, uint256(b)); } else { return add(a, uint256(-b)); } } /** * @dev Subtraction: int256 - uint256 */ function sub(int256 a, uint256 b) internal pure returns (int256) { return sub(a, utoi(b)); } //================================================================================ // Multiplication //================================================================================ /** * @dev Multiplication: uint256 * uint256 */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, // but the benefit is lost if 'b' is also tested // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "MixedSafeMathWithUnit: uint256 multiplication overflow"); return c / UONE; } /** * @dev Multiplication: int256 * int256 */ function mul(int256 a, int256 b) internal pure returns (int256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, // but the benefit is lost if 'b' is also tested // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } require(!(a == -1 && b == IMIN), "MixedSafeMathWithUnit: int256 multiplication overflow"); int256 c = a * b; require(c / a == b, "MixedSafeMathWithUnit: int256 multiplication overflow"); return c / IONE; } /** * @dev Multiplication: uint256 * int256 */ function mul(uint256 a, int256 b) internal pure returns (uint256) { return mul(a, itou(b)); } /** * @dev Multiplication: int256 * uint256 */ function mul(int256 a, uint256 b) internal pure returns (int256) { return mul(a, utoi(b)); } //================================================================================ // Division //================================================================================ /** * @dev Division: uint256 / uint256 */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "MixedSafeMathWithUnit: uint256 division by zero"); uint256 c = a * UONE; require( c / UONE == a, "MixedSafeMathWithUnit: uint256 division internal multiplication overflow" ); uint256 d = c / b; return d; } /** * @dev Division: int256 / int256 */ function div(int256 a, int256 b) internal pure returns (int256) { require(b != 0, "MixedSafeMathWithUnit: int256 division by zero"); int256 c = a * IONE; require( c / IONE == a, "MixedSafeMathWithUnit: int256 division internal multiplication overflow" ); require(!(c == IMIN && b == -1), "MixedSafeMathWithUnit: int256 division overflow"); int256 d = c / b; return d; } /** * @dev Division: uint256 / int256 */ function div(uint256 a, int256 b) internal pure returns (uint256) { return div(a, itou(b)); } /** * @dev Division: int256 / uint256 */ function div(int256 a, uint256 b) internal pure returns (int256) { return div(a, utoi(b)); } }
62,472
5
// withdraw ETH
function withdrawETH() public onlyOwner { address payable owner = payable(owner()); uint256 amount = address(this).balance; owner.transfer(amount); emit WithdrawETH(_msgSender(), amount); }
function withdrawETH() public onlyOwner { address payable owner = payable(owner()); uint256 amount = address(this).balance; owner.transfer(amount); emit WithdrawETH(_msgSender(), amount); }
44,110
404
// Allows the Lock owner to update the baseTokenURI for this Lock. /
function setBaseTokenURI( string calldata _baseTokenURI ) external
function setBaseTokenURI( string calldata _baseTokenURI ) external
37,861
1
// Redeems a redeemable token /
function _redeem(IRedeemableToken redeemable, uint256 tokenId) internal { try redeemable.redeem(msg.sender, tokenId) {}
function _redeem(IRedeemableToken redeemable, uint256 tokenId) internal { try redeemable.redeem(msg.sender, tokenId) {}
7,754
184
// The block number when ZEUS mining starts.
uint256 public startBlock; event Deposit(address indexed user, uint256 indexed aid, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed aid, uint256 indexed pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed aid, uint256 indexed pid, uint256 amount); constructor( ZEUSToken _zeus, address _devaddr, uint256 _zeusPerBlock,
uint256 public startBlock; event Deposit(address indexed user, uint256 indexed aid, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed aid, uint256 indexed pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed aid, uint256 indexed pid, uint256 amount); constructor( ZEUSToken _zeus, address _devaddr, uint256 _zeusPerBlock,
44,256
107
// this is if we start with WETH
_inputToken == address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2) ) {
_inputToken == address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2) ) {
60,119