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
18
// Modifier that requires that 'voterAddress' has not voted for 'airlineAddress'/
modifier requireVoterNotVotedForAirline(address voterAddress, address airlineAddress) { require(!alreadyVotedForAirline(voterAddress, airlineAddress), "Voter has voted for this airline already."); _; }
modifier requireVoterNotVotedForAirline(address voterAddress, address airlineAddress) { require(!alreadyVotedForAirline(voterAddress, airlineAddress), "Voter has voted for this airline already."); _; }
38,341
349
// Withdraw shares Shares to withdrawreturn Withdrawn amount /
function _withdraw(uint128 shares, uint256[] memory) internal override returns(uint128) { uint256 fTokensTotal = pool.balanceOf(address(this)); uint256 fWithdrawAmount = (fTokensTotal * shares) / strategies[self].totalShares; // withdraw staked fTokens from pool pool.withdraw(fWith...
function _withdraw(uint128 shares, uint256[] memory) internal override returns(uint128) { uint256 fTokensTotal = pool.balanceOf(address(this)); uint256 fWithdrawAmount = (fTokensTotal * shares) / strategies[self].totalShares; // withdraw staked fTokens from pool pool.withdraw(fWith...
1,384
189
// Represents a transcoder's current state
struct Transcoder { uint256 lastRewardRound; // Last round that the transcoder called reward uint256 rewardCut; // % of reward paid to transcoder by a delegator uint256 feeShare; ...
struct Transcoder { uint256 lastRewardRound; // Last round that the transcoder called reward uint256 rewardCut; // % of reward paid to transcoder by a delegator uint256 feeShare; ...
12,316
3
// Set maximum mintable tokens
function _setMaxMintable(uint256 _maxMint) public onlyOwner { maxMint = _maxMint; }
function _setMaxMintable(uint256 _maxMint) public onlyOwner { maxMint = _maxMint; }
56,927
267
// If tokens are already locked, then functions extendLock or increaseLockAmount should be used to make any changes
_lock(msg.sender, _reason, _amount, _time); return true;
_lock(msg.sender, _reason, _amount, _time); return true;
22,272
45
// CHECK VALUES
assert(totalIRCAllocated <= totalSupply); assert(totalIRCAllocated > 0); assert(balanceSafe > 0); assert(totalWEIInvested > 0); assert(contributedSafe > 0);
assert(totalIRCAllocated <= totalSupply); assert(totalIRCAllocated > 0); assert(balanceSafe > 0); assert(totalWEIInvested > 0); assert(contributedSafe > 0);
33,918
137
// Set storage
Bet storage newBet = bets[queryId]; newBet.player = player; props = amount; props = props << 64;
Bet storage newBet = bets[queryId]; newBet.player = player; props = amount; props = props << 64;
47,857
9
// The creater of the smart contract
constructor () public payable { address_A = msg.sender; }
constructor () public payable { address_A = msg.sender; }
12,151
27
// Buy NFT listedOnly if the signature and sell order are verified, NFT must be transferred. In case of Dutch auction, _startPricePerItem will be higher than _endPricerPerItem._listItem Sell order listed _signature EIP-712 based signature /
function buyItem(ListItem memory _listItem, bytes memory _signature) external nonReentrant { // validate order _validateList(_listItem, _signature); // mark nonce require(!isUsedNonce[_listItem.owner][_listItem.nonce], "Used nonce"); isUsedNonce[_listItem.owner][_listItem.no...
function buyItem(ListItem memory _listItem, bytes memory _signature) external nonReentrant { // validate order _validateList(_listItem, _signature); // mark nonce require(!isUsedNonce[_listItem.owner][_listItem.nonce], "Used nonce"); isUsedNonce[_listItem.owner][_listItem.no...
17,130
130
// Internal function to invoke {IERC1363Receiver-onApprovalReceived} on a target address. The call is not executed if the target address is not a contract. spender address The address which will spend the funds amount uint256 The amount of tokens to be spent data bytes Optional data to send along with the callreturn wh...
function _checkOnApprovalReceived( address spender, uint256 amount, bytes memory data ) internal virtual returns (bool) { if (!spender.isContract()) { revert("ERC1363: approve a non contract address"); }
function _checkOnApprovalReceived( address spender, uint256 amount, bytes memory data ) internal virtual returns (bool) { if (!spender.isContract()) { revert("ERC1363: approve a non contract address"); }
31,832
6
// Fee owner takes on each sale, measured in basis points (1/100 of a percent). Values 0-10,000 map to 0%-100%
uint256 internal saleFee;
uint256 internal saleFee;
34,394
16
// {SaleEnv-competitionContract}) is stored within the Bundle itself: this allows upgrading thecompetition contract address without affecting the existing bundles; when the contract address is amended,only new bundles will be affected by the change. data Array of arrayfied bundle data; each bundle consists of 9 array e...
function setupBundleMulti( uint256[9][] calldata data, address competitionContract ) external onlyRole(METAWIN_ROLE) { uint256 count = data.length; for(uint i; i<count;){ _setupBundle_kxU( data[i][0], // Bundle Id data[i][1], ...
function setupBundleMulti( uint256[9][] calldata data, address competitionContract ) external onlyRole(METAWIN_ROLE) { uint256 count = data.length; for(uint i; i<count;){ _setupBundle_kxU( data[i][0], // Bundle Id data[i][1], ...
17,900
16
// Curve main registry
address public constant MAIN_REGISTRY = address(0x90E00ACe148ca3b23Ac1bC8C240C2a7Dd9c2d7f5);
address public constant MAIN_REGISTRY = address(0x90E00ACe148ca3b23Ac1bC8C240C2a7Dd9c2d7f5);
82,562
14
// return True iff multiplying x and y would not overflow. /
function mulIsSafe(uint x, uint y) pure internal returns (bool)
function mulIsSafe(uint x, uint y) pure internal returns (bool)
15,033
6
// Contract module which provides access control mechanism, wherethere is an account (an owner) that can be granted exclusive access tospecific functions. By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership} and {acceptOwnership}. * * This module is used through inheritance. It will make available all functions * from parent (Ownable). */ abstract contract Ownable2Step is Ownable { address private s_pendingOwner; /** * @dev Emits in transferOwnership (start...
* can later be changed with {transferOwnership} and {acceptOwnership}. * * This module is used through inheritance. It will make available all functions * from parent (Ownable). */ abstract contract Ownable2Step is Ownable { address private s_pendingOwner; /** * @dev Emits in transferOwnership (start...
5,951
787
// Sender must first invoke requestWithdrawal in a previous cycle/This function will burn the fAsset and transfers underlying asset back to sender/Will execute a partial withdrawal if either available liquidity or previously requested amount is insufficient/amount Amount of fTokens to redeem, value can be in excess of ...
function withdraw(uint256 amount, bool asEth) external;
function withdraw(uint256 amount, bool asEth) external;
47,619
102
// Lender Utility Functions ///
function loanSanityChecks(IMapleGlobals globals, address liquidityAsset, address collateralAsset, uint256[5] calldata specs) external view { require(globals.isValidLiquidityAsset(liquidityAsset), "L:INVALID_LIQ_ASSET"); require(globals.isValidCollateralAsset(collateralAsset), "L:INVALID_COL_ASSET"...
function loanSanityChecks(IMapleGlobals globals, address liquidityAsset, address collateralAsset, uint256[5] calldata specs) external view { require(globals.isValidLiquidityAsset(liquidityAsset), "L:INVALID_LIQ_ASSET"); require(globals.isValidCollateralAsset(collateralAsset), "L:INVALID_COL_ASSET"...
14,710
214
// Allow spending tokens from addresses with balance Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred from an EOA.
if (from == msg.sender) { _; return; }
if (from == msg.sender) { _; return; }
1,237
9
// VVV These parameters will be governable by the DAO VVV Percentages are multipl1ied by 1,000,000.
uint256 public minApr = 2500000; // 2.5% uint256 public maxApr = 75000000; // 75% uint256 public stakeTarget = 10e6 ether; // 10M API3
uint256 public minApr = 2500000; // 2.5% uint256 public maxApr = 75000000; // 75% uint256 public stakeTarget = 10e6 ether; // 10M API3
26,062
1
// Limit withdrawal amount and time
require(withdraw_amount <= 100000000000000000);
require(withdraw_amount <= 100000000000000000);
31,004
57
// Domain-separation tag for the hash used as the final VRF output. Corresponds to vrfRandomOutputHashPrefix in vrf.go
uint256 internal constant VRF_RANDOM_OUTPUT_HASH_PREFIX = 3;
uint256 internal constant VRF_RANDOM_OUTPUT_HASH_PREFIX = 3;
1,818
25
// Allows an owner to submit and confirm a transaction./destination Transaction target address./value Transaction ether value./data Transaction data payload./ return Returns transaction ID.
function submitTransaction(address destination, uint value, bytes data) public returns (uint transactionId)
function submitTransaction(address destination, uint value, bytes data) public returns (uint transactionId)
37,672
16
// See {IERC1155MetadataUpgradeable-uri}. /
function uri(uint256 id) external view override returns (string memory) { if (!_editionExists(id)) return ""; return _editionURI[id]; }
function uri(uint256 id) external view override returns (string memory) { if (!_editionExists(id)) return ""; return _editionURI[id]; }
28,422
11
// add total OUT staking token
_totalStakes[stakingToken_].totalOutStake = _totalStakes[stakingToken_] .totalOutStake .add(amountStakingToken_);
_totalStakes[stakingToken_].totalOutStake = _totalStakes[stakingToken_] .totalOutStake .add(amountStakingToken_);
12,857
75
// Pays task completer and updates escrow balances
function rewardTaskCompletion(uint uuid, address user) public onlyVoteController { communityAccount.transferTokensOut(address(nativeTokenInstance), user, communityAccount.escrowedTaskBalances(uuid)); communityAccount.setTotalTaskEscrow(SafeMath.sub(communityAccount.totalTaskEscrow(), communityAccoun...
function rewardTaskCompletion(uint uuid, address user) public onlyVoteController { communityAccount.transferTokensOut(address(nativeTokenInstance), user, communityAccount.escrowedTaskBalances(uuid)); communityAccount.setTotalTaskEscrow(SafeMath.sub(communityAccount.totalTaskEscrow(), communityAccoun...
42,734
0
// Mapping from consensus address => weight
mapping(address => uint256) internal _consensusWeight;
mapping(address => uint256) internal _consensusWeight;
23,984
155
// Collect ether from completed Shotgun.Called by Shard Registry after burning caller's Shards.For counterclaimants, returns both the proportional worth of theiralternative: OpenZeppelin PaymentSplitter/
function collectEtherProceeds(uint balance, address payable caller) external { require( msg.sender == address(_shardRegistry), "[collectEtherProceeds] Caller not authorized" ); if (_claimWinner == ClaimWinner.Claimant && caller != _initialClaimantAddress) { uint weiProceeds = (_pricePerShardInWei.mul(ba...
function collectEtherProceeds(uint balance, address payable caller) external { require( msg.sender == address(_shardRegistry), "[collectEtherProceeds] Caller not authorized" ); if (_claimWinner == ClaimWinner.Claimant && caller != _initialClaimantAddress) { uint weiProceeds = (_pricePerShardInWei.mul(ba...
40,502
45
// -------------------------------------------------------------------------- // owners // -------------------------------------------------------------------------- /
function clearStuckBalance() external onlyOwner { (bool success,) = payable(msg.sender).call{value: address(this).balance}(""); require(success); }
function clearStuckBalance() external onlyOwner { (bool success,) = payable(msg.sender).call{value: address(this).balance}(""); require(success); }
19,319
29
// Reward is normal ERC20 token, and is send from `rewardSender`
contract RewardMasterChef is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; // Info of each user. struct UserInfo { uint256 amount; // How many LP tokens the user has provided. uint256 rewardDebt; // Reward debt. } // Info of each pool. struct PoolInf...
contract RewardMasterChef is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; // Info of each user. struct UserInfo { uint256 amount; // How many LP tokens the user has provided. uint256 rewardDebt; // Reward debt. } // Info of each pool. struct PoolInf...
25,257
7
// Offload local vars from stack
uint256 reserveLQFD; uint256 reserveToken; uint256 targetReserveToken; uint256 targetReserveLQFD; uint256 swapTargetToken; uint256 swapTargetLQFD; uint256 tokenSwapped; uint256 LQFDSwapped; uint256 tokenReceived; uint256 LQFDReceived;
uint256 reserveLQFD; uint256 reserveToken; uint256 targetReserveToken; uint256 targetReserveLQFD; uint256 swapTargetToken; uint256 swapTargetLQFD; uint256 tokenSwapped; uint256 LQFDSwapped; uint256 tokenReceived; uint256 LQFDReceived;
5,517
56
// Expects to call only once to create a new lending market. _name Token name. _symbol Token symbol. _controller Core controller contract address. _interestRateModel Token interest rate model contract address. /
function _initialize( string memory _name, string memory _symbol, uint8 _decimals, IControllerInterface _controller, IInterestRateModelInterface _interestRateModel
function _initialize( string memory _name, string memory _symbol, uint8 _decimals, IControllerInterface _controller, IInterestRateModelInterface _interestRateModel
27,307
431
// round 39
ark(i, q, 2781996465394730190470582631099299305677291329609718650018200531245670229393); sbox_partial(i, q); mix(i, q);
ark(i, q, 2781996465394730190470582631099299305677291329609718650018200531245670229393); sbox_partial(i, q); mix(i, q);
48,718
226
// Yearn Base Strategy yearn.finance BaseStrategy implements all of the required functionality to interoperate closely with the Vault contract. This contract should be inherited and the abstract methods implemented to adapt the Strategy to the particular needs it has to create a return.Of special interest is the relati...
abstract contract BaseStrategy { using SafeMath for uint256; /** * @notice * Used to track which version of `StrategyAPI` this Strategy * implements. * @dev The Strategy's version must match the Vault's `API_VERSION`. * @return A string which holds the current API version of this con...
abstract contract BaseStrategy { using SafeMath for uint256; /** * @notice * Used to track which version of `StrategyAPI` this Strategy * implements. * @dev The Strategy's version must match the Vault's `API_VERSION`. * @return A string which holds the current API version of this con...
9,042
1
// On construction, set auth fields.
constructor() public { reserveAddress = _msgSender(); emit ReserveAddressTransferred(address(0), reserveAddress); }
constructor() public { reserveAddress = _msgSender(); emit ReserveAddressTransferred(address(0), reserveAddress); }
27,823
94
// Implementation of the basic standard multi-token. _Available since v3.1._ /
contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { using Address for address; // Mapping from token ID to account balances mapping(uint256 => mapping(address => uint256)) private _balances; // Mapping from account to operator approvals mapping(address => mapping(address => bool))...
contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { using Address for address; // Mapping from token ID to account balances mapping(uint256 => mapping(address => uint256)) private _balances; // Mapping from account to operator approvals mapping(address => mapping(address => bool))...
2,719
12
// Liquidate pool due to funds running too low, distribute funds to all users and send `LIQUIDITY_POOL_LIQUIDATION_FEE` to caller. _pool The MarginLiquidityPool. /
function liquidateLiquidityPool(MarginLiquidityPoolInterface _pool) external nonReentrant poolIsVerified(_pool) { // close positions as much as possible, send fee back to caller (Percentage.Percent memory enp, Percentage.Percent memory ell) = getEnpAndEll(_pool); (uint256 enpThreshold, uint2...
function liquidateLiquidityPool(MarginLiquidityPoolInterface _pool) external nonReentrant poolIsVerified(_pool) { // close positions as much as possible, send fee back to caller (Percentage.Percent memory enp, Percentage.Percent memory ell) = getEnpAndEll(_pool); (uint256 enpThreshold, uint2...
46,145
15
// Creates a new position wrapped in a NFT/Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized/ a method does not exist, i.e. the pool is assumed to be initialized./params The params necessary to mint a position, encoded as `MintParams` in calldata/ return tokenId...
function mint(MintParams calldata params) external payable returns ( uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1 );
function mint(MintParams calldata params) external payable returns ( uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1 );
18,477
59
// tokens purchase
function buyTokens(address beneficiary) public withinCrowdsaleTime withinCap payable { uint256 wei_amount = msg.value; require(beneficiary != address(0)); require(wei_amount != 0); // calculate token amount to be sold uint256 tokens = getTokenAmount(wei_amount); // update state wei...
function buyTokens(address beneficiary) public withinCrowdsaleTime withinCap payable { uint256 wei_amount = msg.value; require(beneficiary != address(0)); require(wei_amount != 0); // calculate token amount to be sold uint256 tokens = getTokenAmount(wei_amount); // update state wei...
8,910
1
// ============ Events ============ // ============ Modifiers ============ //Throws if claim is confined to the manager and caller is not the manager /
modifier onlyValidCaller(ISetToken _setToken) { require(_isValidCaller(_setToken), "Must be valid caller"); _; }
modifier onlyValidCaller(ISetToken _setToken) { require(_isValidCaller(_setToken), "Must be valid caller"); _; }
3,479
5
// Subtracts two unsigned integers, reverts on underflow (i.e. if subtrahend is greater than minuend). /
function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; }
function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; }
903
33
// Increase the amount of Nordic Energy tokens that an owner allowed to a spender.approve should be called when allowed_[_spender] == 0. To incrementallowed value is better to use this function to avoid 2 calls (and wait untilthe first transaction is mined)From MonolithDAO Token.solEmits an Approval event. spender The ...
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = _allowed[msg.sender][spender].add(addedValue); //injected INTEGER OVERFLOW OR UNDERFLOW emit Approval(msg.sender, spender, _allowed[msg.se...
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { require(spender != address(0)); _allowed[msg.sender][spender] = _allowed[msg.sender][spender].add(addedValue); //injected INTEGER OVERFLOW OR UNDERFLOW emit Approval(msg.sender, spender, _allowed[msg.se...
27,695
178
// Remove a issuer from trading availability
function deactivateIssuer(address issuer) external onlyOwnerExecActivator { activeIssuers[issuer] = false; }
function deactivateIssuer(address issuer) external onlyOwnerExecActivator { activeIssuers[issuer] = false; }
7,515
387
// Helper function to read params from storage and apply offset to the given timestamp. Recall that the formula for epoch number is `n = (t - b) / a`.NOTE: Reverts if epoch zero has not started. return The values `a` and `(t - b)`. /
function _getIntervalAndOffsetTimestamp() private view returns (uint256, uint256)
function _getIntervalAndOffsetTimestamp() private view returns (uint256, uint256)
43,947
9
// Downsize the array to fit.
assembly { mstore(tokenIds, tokenIdsIdx) }
assembly { mstore(tokenIds, tokenIdsIdx) }
34,651
87
// Allows {owner} to withdraw all funds from this contract. Note that caller must be {owner}. Emits a {OwnerWithdrawFunds} event. /
function withdrawContractFunds(uint256 _amount) external;
function withdrawContractFunds(uint256 _amount) external;
70,717
4
// moves ether from user to owner
function subtractAmountFromUser(uint amount) private { balances[msg.sender] = balances[msg.sender].sub(amount); balances[owner] = balances[owner].add(amount); }
function subtractAmountFromUser(uint amount) private { balances[msg.sender] = balances[msg.sender].sub(amount); balances[owner] = balances[owner].add(amount); }
3,010
212
// Transfer remaining to Vault to handle withdrawal
_transferToVault(_toWithdraw.sub(_fee));
_transferToVault(_toWithdraw.sub(_fee));
8,848
189
// Owner functions //Reserve a few Goats e.g. for giveaways /
function reserveMint(uint16 numberOfTokens , address _to) external onlyOwner { require(goatsMintedForPromotion.add(numberOfTokens) <= MAX_MintedForPromotion, "Cannot mint more goats for promotion"); require(totalSupply().add(numberOfTokens) < collection_Supply, "Insufficient supply"); goatsM...
function reserveMint(uint16 numberOfTokens , address _to) external onlyOwner { require(goatsMintedForPromotion.add(numberOfTokens) <= MAX_MintedForPromotion, "Cannot mint more goats for promotion"); require(totalSupply().add(numberOfTokens) < collection_Supply, "Insufficient supply"); goatsM...
77,754
24
// Keep track of the old provenance hash for emitting with the event.
bytes32 oldProvenanceHash = ERC721ContractMetadataStorage .layout() ._provenanceHash;
bytes32 oldProvenanceHash = ERC721ContractMetadataStorage .layout() ._provenanceHash;
30,655
9
// --- Variables ---
address public priceSource; uint16 constant ONE_HOUR = uint16(3600); uint16 public updateDelay = ONE_HOUR; uint64 public lastUpdateTime;
address public priceSource; uint16 constant ONE_HOUR = uint16(3600); uint16 public updateDelay = ONE_HOUR; uint64 public lastUpdateTime;
10,828
120
// First check most recent balance
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; }
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; }
186
31
// Unique ID for each different type of signed message in the protocol/
enum MessageTypeId { None, Cashout, Puzzle, Refund }
enum MessageTypeId { None, Cashout, Puzzle, Refund }
39,357
8
// The main decoder for memory bs The bytes array to be decodedreturn The decoded struct /
function decode(bytes memory bs) internal pure returns (Data memory) { (Data memory x, ) = _decode(32, bs, bs.length); return x; }
function decode(bytes memory bs) internal pure returns (Data memory) { (Data memory x, ) = _decode(32, bs, bs.length); return x; }
39,148
66
// Winners can claim their own prizes using this.If they dosomething stupid like use a contract, this gives them aa second chance at withdrawing their funds.Note thatthis shares an interlock with `distributeWinnings`. /
function claimPrize() afterDraw { if (winningsClaimable[msg.sender] == false) { // get. out! throw; } winningsClaimable[msg.sender] = false; if (!msg.sender.send(prizeValue)) { // you really are a dumbshit, aren't you. throw; } }
function claimPrize() afterDraw { if (winningsClaimable[msg.sender] == false) { // get. out! throw; } winningsClaimable[msg.sender] = false; if (!msg.sender.send(prizeValue)) { // you really are a dumbshit, aren't you. throw; } }
11,453
124
// transfer function that sets up the context so that the _tokenTransfer function can do the accounting work to perform the transfer function
function _transfer( address sender, address recipient, uint256 amountOfTokens
function _transfer( address sender, address recipient, uint256 amountOfTokens
9,640
23
// Value of a ticket in each winning tier
mapping (uint256 => uint256) caste;
mapping (uint256 => uint256) caste;
44,648
179
// update the pauser role /
function updatePauser(address _newPauser) external onlyOwner { require( _newPauser != address(0), "Pausable: new pauser is the zero address" ); _pauser = _newPauser; emit PauserChanged(_pauser); }
function updatePauser(address _newPauser) external onlyOwner { require( _newPauser != address(0), "Pausable: new pauser is the zero address" ); _pauser = _newPauser; emit PauserChanged(_pauser); }
28,178
481
// grabBooty sends to message sender his booty in WEI /
function grabBooty() external { uint256 booty = ownerToBooty[msg.sender]; require(booty > 0); require(totalBooty >= booty); ownerToBooty[msg.sender] = 0; totalBooty -= booty; msg.sender.transfer(booty); //emit event BootyGrabbed(msg.s...
function grabBooty() external { uint256 booty = ownerToBooty[msg.sender]; require(booty > 0); require(totalBooty >= booty); ownerToBooty[msg.sender] = 0; totalBooty -= booty; msg.sender.transfer(booty); //emit event BootyGrabbed(msg.s...
40,983
272
// Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal virtual { requir...
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal virtual { requir...
30,541
73
// _mint(_msgSender(), 10001018);for testing lockupPeriods[0] = Lockup(200, 1e15); for testing
lockupPeriods[0] = Lockup(604800, 1e15); lockupPeriods[1] = Lockup(2592000, 4e15); lockupPeriods[2] = Lockup(5184000, 8e15); lockupPeriods[3] = Lockup(7776000, 12e15); lockupPeriods[4] = Lockup(15552000, 24e15); lockupPeriods[5] = Lockup(31104000, 48e15); lockupPe...
lockupPeriods[0] = Lockup(604800, 1e15); lockupPeriods[1] = Lockup(2592000, 4e15); lockupPeriods[2] = Lockup(5184000, 8e15); lockupPeriods[3] = Lockup(7776000, 12e15); lockupPeriods[4] = Lockup(15552000, 24e15); lockupPeriods[5] = Lockup(31104000, 48e15); lockupPe...
16,970
263
// IERC165 getter/interfaceId interfaceId bytes4 to check support for
function supportsInterface(bytes4 interfaceId) public view override(ERC721Upgradeable, IERC165Upgradeable) returns (bool)
function supportsInterface(bytes4 interfaceId) public view override(ERC721Upgradeable, IERC165Upgradeable) returns (bool)
7,371
75
// Find the FROM address
address fromWithSubstitution = _tokenOwnerWithSubstitutions[_tokenId]; address from = fromWithSubstitution; if (fromWithSubstitution == address(0)) { from = address(this); }
address fromWithSubstitution = _tokenOwnerWithSubstitutions[_tokenId]; address from = fromWithSubstitution; if (fromWithSubstitution == address(0)) { from = address(this); }
47,326
24
// UPDATE TOTAL
if (rewardAmount > 0) { curTotalSupply = getValueAt(totalSupplyHistory, block.number); if (curTotalSupply + rewardAmount < curTotalSupply) throw; // Check for overflow updateValueAtNow(totalSupplyHistory, curTotalSupply + rewardAmount); }
if (rewardAmount > 0) { curTotalSupply = getValueAt(totalSupplyHistory, block.number); if (curTotalSupply + rewardAmount < curTotalSupply) throw; // Check for overflow updateValueAtNow(totalSupplyHistory, curTotalSupply + rewardAmount); }
7,960
12
// Kyber Network main contract, takes some fee and reports actual dest amount minus Fees.
contract MaliciousKyberNetwork is KyberNetwork { address public myWallet = 0x1234; uint public myFeeWei = 10; function MaliciousKyberNetwork(address _admin) public KyberNetwork(_admin) { } /* solhint-disable function-max-lines */ /// @notice use token address ETH_TOKEN_ADDRESS for ether /// @...
contract MaliciousKyberNetwork is KyberNetwork { address public myWallet = 0x1234; uint public myFeeWei = 10; function MaliciousKyberNetwork(address _admin) public KyberNetwork(_admin) { } /* solhint-disable function-max-lines */ /// @notice use token address ETH_TOKEN_ADDRESS for ether /// @...
43,946
9
// initialize RewardDestribution
RewardDestribution['twitter'] = 2990000 * 10 ** uint256(18); RewardDestribution['facebook'] = 3450000 * 10 ** uint256(18); RewardDestribution['content'] = 6900000 * 10 ** uint256(18); RewardDestribution['youtube'] = 2760000 * 10 ** uint256(18); RewardDestribution['telegram'] = 46000...
RewardDestribution['twitter'] = 2990000 * 10 ** uint256(18); RewardDestribution['facebook'] = 3450000 * 10 ** uint256(18); RewardDestribution['content'] = 6900000 * 10 ** uint256(18); RewardDestribution['youtube'] = 2760000 * 10 ** uint256(18); RewardDestribution['telegram'] = 46000...
29,948
12
// Lets a contract admin set the royalty recipient and bps for a particular token Id.
function _setupRoyaltyInfoForToken( uint256 _tokenId, address _recipient, uint256 _bps
function _setupRoyaltyInfoForToken( uint256 _tokenId, address _recipient, uint256 _bps
528
109
// turn off Allocator
deactivate(false); emit MigrationExecuted(newAllocator);
deactivate(false); emit MigrationExecuted(newAllocator);
63,696
27
// Administrators can manage the contract/
mapping (address => bool) public administrators;
mapping (address => bool) public administrators;
27,191
7
// Memory address of the buffer data
let bufptr := mload(buf)
let bufptr := mload(buf)
4,699
58
// /
contract FlywheelDynamicRewards is IFlywheelRewards { using SafeTransferLib for ERC20; /// @notice the reward token paid ERC20 public immutable rewardToken; /// @notice the flywheel core contract address public immutable flywheel; constructor(ERC20 _rewardToken, address _flywheel) { r...
contract FlywheelDynamicRewards is IFlywheelRewards { using SafeTransferLib for ERC20; /// @notice the reward token paid ERC20 public immutable rewardToken; /// @notice the flywheel core contract address public immutable flywheel; constructor(ERC20 _rewardToken, address _flywheel) { r...
38,174
2
// store precommits
mapping(uint256 => PreAnchor) internal _preCommits;
mapping(uint256 => PreAnchor) internal _preCommits;
38,433
155
// Otherwise, use the previously stored number from the matrix.
value = tokenMatrix[random];
value = tokenMatrix[random];
26,881
1,402
// Settle null
_settleNull(msg.sender, MonetaryTypesLib.Currency(currencyCt, currencyId), standard);
_settleNull(msg.sender, MonetaryTypesLib.Currency(currencyCt, currencyId), standard);
35,998
1
// Mints debt token to the `onBehalfOf` address user The address receiving the borrowed underlying, being the delegatee in caseof credit delegate, or same as `onBehalfOf` otherwise onBehalfOf The address receiving the debt tokens amount The amount of debt being minted index The variable debt index of the reservereturn ...
function mint( address user, address onBehalfOf, uint256 amount, uint256 index ) external returns (bool, uint256);
function mint( address user, address onBehalfOf, uint256 amount, uint256 index ) external returns (bool, uint256);
2,479
7
// Erase ownership information./ May only be called 6 weeks after/ the contract has been created.
function disown() public onlyBy(owner) onlyAfter(creationTime + 6 weeks)
function disown() public onlyBy(owner) onlyAfter(creationTime + 6 weeks)
12,410
138
// true if the locked tokens have been distributed
bool private lockedTokensDistributed;
bool private lockedTokensDistributed;
37,810
211
// Calculate the maximum token id that can ever be mintedreturn Maximum token id /
function maxTokenId() public view returns (uint256) { uint256 maxOpenMints = maxTotalSupply - reservedAllowance; return MAX_N_TOKEN_ID + maxOpenMints; }
function maxTokenId() public view returns (uint256) { uint256 maxOpenMints = maxTotalSupply - reservedAllowance; return MAX_N_TOKEN_ID + maxOpenMints; }
55,463
37
// empty the storedPayload
sp.payloadLength = 0; sp.dstAddress = address(0); sp.payloadHash = bytes32(0); emit UaForceResumeReceive(_srcChainId, _srcAddress);
sp.payloadLength = 0; sp.dstAddress = address(0); sp.payloadHash = bytes32(0); emit UaForceResumeReceive(_srcChainId, _srcAddress);
24,342
4
// Divides two unsigned 60.18-decimal fixed-point numbers, returning a new unsigned 60.18-decimal fixed-point number.//Uses mulDiv to enable overflow-safe multiplication and division.// Requirements:/ - The denominator cannot be zero.//x The numerator as an unsigned 60.18-decimal fixed-point number./y The denominator a...
function div(uint256 x, uint256 y) internal pure returns (uint256 result) { result = mulDiv(x, SCALE, y); }
function div(uint256 x, uint256 y) internal pure returns (uint256 result) { result = mulDiv(x, SCALE, y); }
25,344
708
// res += valcoefficients[167].
res := addmod(res, mulmod(val, /*coefficients[167]*/ mload(0x1a20), PRIME), PRIME)
res := addmod(res, mulmod(val, /*coefficients[167]*/ mload(0x1a20), PRIME), PRIME)
51,730
52
// TokenVesting A token holder contract that can release its token balance gradually like atypical vesting scheme, with a cliff and vesting period. Optionally revocable by theowner. /
contract TokenVesting is Ownable { // The vesting schedule is time-based (i.e. using block timestamps as opposed to e.g. block numbers), and is // therefore sensitive to timestamp manipulation (which is something miners can do, to a certain degree). Therefore, // it is recommended to avoid using short time ...
contract TokenVesting is Ownable { // The vesting schedule is time-based (i.e. using block timestamps as opposed to e.g. block numbers), and is // therefore sensitive to timestamp manipulation (which is something miners can do, to a certain degree). Therefore, // it is recommended to avoid using short time ...
12,688
211
// SAKE tokens created per block.
uint256 public sakePerBlock;
uint256 public sakePerBlock;
48,033
56
// recovers the signer address from a offer hash and signature
function signerOfHash(bytes32 offer_hash, bytes memory signature) public pure returns (address signer){ require(signature.length == 65, "sig wrong length"); bytes32 geth_modified_hash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", offer_hash)); bytes32 r; bytes32 s...
function signerOfHash(bytes32 offer_hash, bytes memory signature) public pure returns (address signer){ require(signature.length == 65, "sig wrong length"); bytes32 geth_modified_hash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", offer_hash)); bytes32 r; bytes32 s...
26,775
142
// make an internal approve - delegate to `__approve`
__approve(msg.sender, _approved, _tokenId);
__approve(msg.sender, _approved, _tokenId);
50,401
95
// Left > 0 means incomplete
return left > 0 ? ErrorCode.ERR_CONSTRUCT : ErrorCode.ERR_NONE;
return left > 0 ? ErrorCode.ERR_CONSTRUCT : ErrorCode.ERR_NONE;
27,764
82
// Get pending rewards amount
uint256 pendingRewards = _stkAave.getTotalRewardsBalance(address(this)); if (pendingRewards > 0) {
uint256 pendingRewards = _stkAave.getTotalRewardsBalance(address(this)); if (pendingRewards > 0) {
38,078
196
// the total borrows of the reserve at a stable rate. Expressed in the currency decimals
uint256 totalBorrowsStable;
uint256 totalBorrowsStable;
18,530
35
// [1] Total MV supply
totalSupply(),
totalSupply(),
56,095
181
// See {IERC721-transferFrom}. /
function transferFrom( address from, address to, uint256 tokenId ) public virtual override {
function transferFrom( address from, address to, uint256 tokenId ) public virtual override {
6,474
333
// The default OpenSea operator blocklist subscription.
address internal constant _DEFAULT_SUBSCRIPTION = 0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6;
address internal constant _DEFAULT_SUBSCRIPTION = 0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6;
564
220
// fee
uint256 public fee; // 0..100.00% (where 1 is 0.01%) uint256 public feeMax = 5000; // 50.00% uint256 public denominator = 10000; // 100.00%
uint256 public fee; // 0..100.00% (where 1 is 0.01%) uint256 public feeMax = 5000; // 50.00% uint256 public denominator = 10000; // 100.00%
34,357
15
// Reverts if request ID does not exist _requestId The given request ID to check in stored `commitments` /
modifier isValidRequest(bytes32 _requestId) { require(commitments[_requestId].callbackAddr != address(0), "Must have a valid requestId"); _; }
modifier isValidRequest(bytes32 _requestId) { require(commitments[_requestId].callbackAddr != address(0), "Must have a valid requestId"); _; }
21,347
15
// Function to mint tokens/to address to which new minted tokens are sent/amount of tokens to send / return A boolean that indicates if the operation was successful.
function mint(address to, uint256 amount) public isController() returns (bool) { require(to != address(0), "Token:mint - Recipient address can't be 0"); _mint(to, amount); return true; }
function mint(address to, uint256 amount) public isController() returns (bool) { require(to != address(0), "Token:mint - Recipient address can't be 0"); _mint(to, amount); return true; }
44,446
2
// string[] public orders; mapping(string => bool) _orderExists;
uint public nbOrder = 0;
uint public nbOrder = 0;
19,378
42
// transfer extra borrow amount from liquidator to lend pool
if (vars.extraDebtAmount > 0) { IERC20Upgradeable(loanData.reserveAsset).safeTransferFrom(vars.initiator, address(this), vars.extraDebtAmount); }
if (vars.extraDebtAmount > 0) { IERC20Upgradeable(loanData.reserveAsset).safeTransferFrom(vars.initiator, address(this), vars.extraDebtAmount); }
13,668
70
// Only once in life time ! Time bonuses is changable after 02.2018 require(timeSlicesCount == 0);
require(_timeSlices.length > 0); require(_bonuses.length == _timeSlices.length); uint lastSlice = 0; uint lastBonus = 10000; if (timeSlicesCount > 0) {
require(_timeSlices.length > 0); require(_bonuses.length == _timeSlices.length); uint lastSlice = 0; uint lastBonus = 10000; if (timeSlicesCount > 0) {
71,139
12
// biWidth / biHeight
buf.writeUint32LE(0x12, width); buf.writeUint32LE(0x16, height);
buf.writeUint32LE(0x12, width); buf.writeUint32LE(0x16, height);
23,533
22
// Set Gas cost for required transactions after collecting interest in collectInterest functionwe need this to know if caller has enough gas left to keep collecting interest _gasAmount The gas amount that needed for transactions /
function setGasCostExceptInterestCollect(uint256 _gasAmount) public { _onlyAvatar(); gasCostExceptInterestCollect = _gasAmount; emit GasCostExceptInterestCollectSet(_gasAmount); }
function setGasCostExceptInterestCollect(uint256 _gasAmount) public { _onlyAvatar(); gasCostExceptInterestCollect = _gasAmount; emit GasCostExceptInterestCollectSet(_gasAmount); }
4,906
28
// An event emitted when a vault is created
event VaultCreated(address indexed _owner, uint256 indexed _id);
event VaultCreated(address indexed _owner, uint256 indexed _id);
34,429
199
// Emitted when `amount` USDC is supplied to the vault /
event SupplyVault(uint256 amount);
event SupplyVault(uint256 amount);
63,136