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
52
// TokenMintERC20TokenStandard ERC20 token with burning and optional functions implemented.For full specification of ERC-20 standard see: /
contract TokenMintERC20Token is ERC20 { string private _name; string private _symbol; uint8 private _decimals; /** * @dev Constructor. * @param name name of the token * @param symbol symbol of the token, 3-4 chars is recommended * @param decimals number of decimal places of one tok...
contract TokenMintERC20Token is ERC20 { string private _name; string private _symbol; uint8 private _decimals; /** * @dev Constructor. * @param name name of the token * @param symbol symbol of the token, 3-4 chars is recommended * @param decimals number of decimal places of one tok...
1,802
157
// Burns `tokenId`. See {ERC721-_burn}. The caller must own `tokenId` or be an approved operator.tokenId The ID of the token to burn/
function burn(uint256 tokenId) public virtual { require(_isApprovedOrOwner(_msgSender(), tokenId), "caller is not owner nor approved"); _burn(tokenId); }
function burn(uint256 tokenId) public virtual { require(_isApprovedOrOwner(_msgSender(), tokenId), "caller is not owner nor approved"); _burn(tokenId); }
30,211
20
// Returns an array of contract-level delegates for a given vault and contract vault The cold wallet who issued the delegation contract_ The address for the contract you're delegatingreturn addresses Array of contract-level delegates for a given vault and contract /
function getDelegatesForContract(
function getDelegatesForContract(
26,711
118
// Only emit an `AdharmaContingencyExited` if it is actually activated.
if (_adharma.activated) { emit AdharmaContingencyExited(); }
if (_adharma.activated) { emit AdharmaContingencyExited(); }
39,522
40
// EIP-712 typehash for this contract's {permit} struct.
bytes32 public constant PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
bytes32 public constant PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
3,984
94
// Irrevocably turns off admin recovery.
function turnOffAdminRecovery() external onlyAdminRecovery { _adminRecoveryEnabled = false; }
function turnOffAdminRecovery() external onlyAdminRecovery { _adminRecoveryEnabled = false; }
7,266
254
// Update position units on index. Emit event. /
function _updatePositionState( address _sellComponent, address _buyComponent, uint256 _preTradeSellComponentAmount, uint256 _preTradeBuyComponentAmount ) internal returns (uint256 sellAmount, uint256 buyAmount)
function _updatePositionState( address _sellComponent, address _buyComponent, uint256 _preTradeSellComponentAmount, uint256 _preTradeBuyComponentAmount ) internal returns (uint256 sellAmount, uint256 buyAmount)
43,593
18
// set the initial expected token supply
maxSupply = _maxSupply;
maxSupply = _maxSupply;
33,091
63
// Approves adapter to take the token amount
GemJoinLike(apt).gem().approve(apt, amt);
GemJoinLike(apt).gem().approve(apt, amt);
32,591
45
// optional - change the baseTokenURI for late-reveal purposes
function setBaseTokenURI(string memory uri) public onlyOwner { baseTokenURI = uri; }
function setBaseTokenURI(string memory uri) public onlyOwner { baseTokenURI = uri; }
5,362
103
// calculate ppt for round mask
uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys); uint256 _dust = _gen.sub((_ppt.mul(round_[_rID].keys)) / 1000000000000000000); if (_dust > 0){ _gen = _gen.sub(_dust); _res = _res.add(_dust); }
uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys); uint256 _dust = _gen.sub((_ppt.mul(round_[_rID].keys)) / 1000000000000000000); if (_dust > 0){ _gen = _gen.sub(_dust); _res = _res.add(_dust); }
18,667
1
// used for testing the logic of token naming
contract BabylonianTest { function sqrt(uint256 num) public pure returns (uint256) { return Babylonian.sqrt(num); } }
contract BabylonianTest { function sqrt(uint256 num) public pure returns (uint256) { return Babylonian.sqrt(num); } }
21,162
13
// in our smart contract every new admin should have a verified identity on cryptonomica.net/
contract CryptonomicaVerification { // returns 0 if verification is not revoked function revokedOn(address _address) external view returns (uint unixTime); function keyCertificateValidUntil(address _address) external view returns (uint unixTime); }
contract CryptonomicaVerification { // returns 0 if verification is not revoked function revokedOn(address _address) external view returns (uint unixTime); function keyCertificateValidUntil(address _address) external view returns (uint unixTime); }
49,235
58
// Update total burned for this item.
itemBurnedTotal[itemId] += amount;
itemBurnedTotal[itemId] += amount;
6,015
44
// e.g. "King of the Ether"
string public kingdomName;
string public kingdomName;
42,351
8
// 리뷰 결과 로그
event reviewResult(address indexed to);
event reviewResult(address indexed to);
54,570
2
// psirex/A helper contract contains logic to validate that only a trusted caller has access to certain methods./Trusted caller set once on deployment and can't be changed.
contract TrustedCaller { string private constant ERROR_TRUSTED_CALLER_IS_ZERO_ADDRESS = "TRUSTED_CALLER_IS_ZERO_ADDRESS"; string private constant ERROR_CALLER_IS_FORBIDDEN = "CALLER_IS_FORBIDDEN"; address public immutable trustedCaller; constructor(address _trustedCaller) { require(_trustedCal...
contract TrustedCaller { string private constant ERROR_TRUSTED_CALLER_IS_ZERO_ADDRESS = "TRUSTED_CALLER_IS_ZERO_ADDRESS"; string private constant ERROR_CALLER_IS_FORBIDDEN = "CALLER_IS_FORBIDDEN"; address public immutable trustedCaller; constructor(address _trustedCaller) { require(_trustedCal...
34,616
55
// Returns whether the given spender can transfer a given token ID spender address of the spender to query tokenId uint256 ID of the token to be transferredreturn bool whether the msg.sender is approved for the given token ID, is an operator of the owner, or is the owner of the token /
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view returns (bool) { address owner = ownerOf(tokenId); // Disable solium check because of // https://github.com/duaraghav8/Solium/issues/175 // solium-disable-next-line operator-whitespace return (spender...
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view returns (bool) { address owner = ownerOf(tokenId); // Disable solium check because of // https://github.com/duaraghav8/Solium/issues/175 // solium-disable-next-line operator-whitespace return (spender...
38,516
42
// This function handles deposits of Ethereum based tokens to the contract. Does not allow Ether. If token transfer fails, transaction is reverted and remaining gas is refunded. Emits a Deposit event. Note: Remember to call IERC20(address).safeApprove(this, amount) or this contract will not be able to do the transfer o...
function depositToken(address token, uint amount) { //remember to call IERC20(address).safeApprove(this, amount) or this contract will not be able to do the transfer on your behalf. if (token == 0) throw; if (!IERC20(token).safeTransferFrom(msg.sender, this, amount)) throw; tokens[to...
function depositToken(address token, uint amount) { //remember to call IERC20(address).safeApprove(this, amount) or this contract will not be able to do the transfer on your behalf. if (token == 0) throw; if (!IERC20(token).safeTransferFrom(msg.sender, this, amount)) throw; tokens[to...
49,943
267
// Issue Set with traded tokens from Uniswap
debtIssuanceModule.issue(_issueArbData.setToken, _issueArbData.setTokenQuantity, address(this));
debtIssuanceModule.issue(_issueArbData.setToken, _issueArbData.setTokenQuantity, address(this));
40,921
28
// / Destroys `amount` tokens from `account`, reducing thetotal supply. Emits a `Transfer` event with `to` set to the zero address. Requirements - `account` cannot be the zero address.- `account` must have at least `amount` tokens. /
function burn(address account, uint256 value) public returns (bool) { _burnFrom(account, value); return true; }
function burn(address account, uint256 value) public returns (bool) { _burnFrom(account, value); return true; }
57,555
232
// stake for SDG
stakeInternal(msg.sender, mintAmount); emit Transfer(address(0), msg.sender, mintAmount);
stakeInternal(msg.sender, mintAmount); emit Transfer(address(0), msg.sender, mintAmount);
10,503
108
// Delegate can be unset for the split recipient if they never contribute. Self-delegate if this occurs.
delegate = contributor;
delegate = contributor;
38,870
269
// PRICELESS POSITION DATA STRUCTURES / Stores the state of the PricelessPositionManager. Set on expiration, emergency shutdown, or settlement.
enum ContractState { Open, ExpiredPriceRequested, ExpiredPriceReceived } ContractState public contractState; // Represents a single sponsor's position. All collateral is held by this contract. // This struct acts as bookkeeping for how much of that collateral is allocated to each sponsor. struct Po...
enum ContractState { Open, ExpiredPriceRequested, ExpiredPriceReceived } ContractState public contractState; // Represents a single sponsor's position. All collateral is held by this contract. // This struct acts as bookkeeping for how much of that collateral is allocated to each sponsor. struct Po...
5,383
16
// METRICS PERSISTENCE /
function updateCurrentIterForModel(string memory modelId, uint iter) private { if (iter > models[modelId].currIter) { models[modelId].currIter = iter; } }
function updateCurrentIterForModel(string memory modelId, uint iter) private { if (iter > models[modelId].currIter) { models[modelId].currIter = iter; } }
1,952
11
// Get user's total Dividends (Total Earned)
function getUserDividends(address userAddress) public view returns (uint256) { User storage user = users[userAddress]; uint256 userTotalRate = getUserTotalRate(userAddress); uint256 totalDividends; uint256 dividends; for (uint256 i = 0; i < user.deposits.length; i++) { if (user.deposits[i].withdrawn <...
function getUserDividends(address userAddress) public view returns (uint256) { User storage user = users[userAddress]; uint256 userTotalRate = getUserTotalRate(userAddress); uint256 totalDividends; uint256 dividends; for (uint256 i = 0; i < user.deposits.length; i++) { if (user.deposits[i].withdrawn <...
265
364
// Clear decrease stake request
decreaseStakeRequests[_account] = DecreaseStakeRequest({ decreaseAmount: 0, lockupExpiryBlock: 0 });
decreaseStakeRequests[_account] = DecreaseStakeRequest({ decreaseAmount: 0, lockupExpiryBlock: 0 });
38,476
8
// Execute membership action to mint or burn votes against whitelisted `minions` in consideration of `msg.sender` & given `amount`./minion Whitelisted contract to trigger action./amount Number to submit in action - e.g., votes to mint for tribute or to burn in asset claim./mint Confirm whether action involves vote requ...
function guildAction(IBaalBank minion, uint amount, bool mint) external lock payable returns (uint96 reaction) { require(minions[address(minion)], '!minion'); // check `minion` is approved if (mint) { reaction = minion.guildAction{value: msg.value}(msg.sender, amount); // mint per `msg.s...
function guildAction(IBaalBank minion, uint amount, bool mint) external lock payable returns (uint96 reaction) { require(minions[address(minion)], '!minion'); // check `minion` is approved if (mint) { reaction = minion.guildAction{value: msg.value}(msg.sender, amount); // mint per `msg.s...
3,734
141
// Max fee percentage must be between borrowing spread and 100%.
error InvalidMaxFeePercentage();
error InvalidMaxFeePercentage();
35,821
4
// 一辆汽车的信息结构
struct CarInfo { uint locStart; uint locEnd; uint crowded; uint[] route; uint errorCount; uint timeStamp; uint token; bool used; }
struct CarInfo { uint locStart; uint locEnd; uint crowded; uint[] route; uint errorCount; uint timeStamp; uint token; bool used; }
48,781
345
// Calculate how much the user would receive when withdrawing via single token self Swap struct to read from metaSwapStorage MetaSwap struct to read from tokenAmount the amount to withdraw in the pool's precision tokenIndex which token will be withdrawnreturn dy the amount of token user will receive /
function calculateWithdrawOneToken( SwapUtils.Swap storage self, MetaSwap storage metaSwapStorage, uint256 tokenAmount, uint8 tokenIndex
function calculateWithdrawOneToken( SwapUtils.Swap storage self, MetaSwap storage metaSwapStorage, uint256 tokenAmount, uint8 tokenIndex
17,263
2
// Multiply two decimal numbers and use normal rounding rules: -round product up if 19'th mantissa digit >= 5 -round product down if 19'th mantissa digit < 5 Used only inside the exponentiation, _decPow(). /
function decMul(uint256 x, uint256 y) internal pure returns (uint256 decProd) { uint256 prod_xy = x * y; decProd = (prod_xy + (DECIMAL_PRECISION / 2)) / DECIMAL_PRECISION; }
function decMul(uint256 x, uint256 y) internal pure returns (uint256 decProd) { uint256 prod_xy = x * y; decProd = (prod_xy + (DECIMAL_PRECISION / 2)) / DECIMAL_PRECISION; }
31,587
179
// Function to activate or deactivate the presale
function setPresaleActive(bool _start) public onlyOwner { presaleActive = _start; }
function setPresaleActive(bool _start) public onlyOwner { presaleActive = _start; }
22,947
1
// Returns the penalty in SKL tokens for a given offense. /
function getPenalty(string calldata offense) external view returns (uint) { uint penalty = _penalties[uint(keccak256(abi.encodePacked(offense)))]; return penalty; }
function getPenalty(string calldata offense) external view returns (uint) { uint penalty = _penalties[uint(keccak256(abi.encodePacked(offense)))]; return penalty; }
8,397
38
// Helper fn that can also be called to query taskSpecHash off-chain
function hashTaskSpec(TaskSpec memory _taskSpec) public view override returns(bytes32) { NoDataAction[] memory noDataActions = new NoDataAction[](_taskSpec.actions.length); for (uint i = 0; i < _taskSpec.actions.length; i++) { NoDataAction memory noDataAction = NoDataAction({ ...
function hashTaskSpec(TaskSpec memory _taskSpec) public view override returns(bytes32) { NoDataAction[] memory noDataActions = new NoDataAction[](_taskSpec.actions.length); for (uint i = 0; i < _taskSpec.actions.length; i++) { NoDataAction memory noDataAction = NoDataAction({ ...
42,523
7
// Event for dispatching when an admin has been removed from the DAO./admin address of the admin that's been removed.
event RemoveAdmin(address admin);
event RemoveAdmin(address admin);
10,772
0
// ERC223 basic interface /
contract IERC223 is IERC20Basic { function transfer(address to, uint256 value, bytes32 data) public returns (bool); event Transfer( address indexed from, address indexed to, uint256 value, bytes32 indexed data ); }
contract IERC223 is IERC20Basic { function transfer(address to, uint256 value, bytes32 data) public returns (bool); event Transfer( address indexed from, address indexed to, uint256 value, bytes32 indexed data ); }
11,931
39
// Returns whether or not a reference module is whitelisted.referenceModule The address of the reference module to check. return bool True if the the reference module is whitelisted, false otherwise. /
function isReferenceModuleWhitelisted(
function isReferenceModuleWhitelisted(
3,930
195
// Deposit LP tokens to MasterChef for Sakura allocation.
function deposit(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accSakuraPerShare).div(1e12).sub(user.rewar...
function deposit(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accSakuraPerShare).div(1e12).sub(user.rewar...
58,249
17
// Gets grant stake details of the given operator./operator The operator address./ return grantId ID of the token grant./ return amount The amount of tokens the given operator delegated./ return stakingContract The address of staking contract.
function getGrantStakeDetails(address operator) public view returns (uint256 grantId, uint256 amount, address stakingContract) { return grantStakes[operator].getDetails(); }
function getGrantStakeDetails(address operator) public view returns (uint256 grantId, uint256 amount, address stakingContract) { return grantStakes[operator].getDetails(); }
25,184
49
// Caches dYdX pool balances returned by `getPoolBalance` for the duration of the function. /
modifier cacheDydxBalances() { bool cacheSetPreviously = _cacheDydxBalances; _cacheDydxBalances = true; _; if (!cacheSetPreviously) { _cacheDydxBalances = false; if (!_cachePoolBalances) _dydxBalancesCache.length = 0; } }
modifier cacheDydxBalances() { bool cacheSetPreviously = _cacheDydxBalances; _cacheDydxBalances = true; _; if (!cacheSetPreviously) { _cacheDydxBalances = false; if (!_cachePoolBalances) _dydxBalancesCache.length = 0; } }
12,075
13
// Permet l'ajout d'un NFT au sein de la collection /
function addNFT (string memory newuri, bool mintable) public onlyRole(ROLE_NFT_MANAGER) nonReentrant returns (uint256) { maxId++; NFTCitems[maxId].uri = newuri; if (mintable) { NFTCitems[maxId].step = Step.Mintable; } else { NFTCitems[maxId].step = Step.NotMi...
function addNFT (string memory newuri, bool mintable) public onlyRole(ROLE_NFT_MANAGER) nonReentrant returns (uint256) { maxId++; NFTCitems[maxId].uri = newuri; if (mintable) { NFTCitems[maxId].step = Step.Mintable; } else { NFTCitems[maxId].step = Step.NotMi...
26,176
16
// Mint an NFT defined by its metadata path and approves the provided operator address. This is only callable by the collection creator/owner.It can be used the first time they mint to save having to issue a separate approvaltransaction before listing the NFT for sale. tokenCID The CID for the metadata json of the NFT ...
function mintWithCreatorPaymentAddressAndApprove( string calldata tokenCID, address payable tokenCreatorPaymentAddress, address operator
function mintWithCreatorPaymentAddressAndApprove( string calldata tokenCID, address payable tokenCreatorPaymentAddress, address operator
42,116
74
// Get number of YES votes for a specific account and loan id Loan ID voter Voter account /
function getYesVote(address id, address voter) public view returns (uint256) { return loans[id].votes[voter][true]; }
function getYesVote(address id, address voter) public view returns (uint256) { return loans[id].votes[voter][true]; }
15,941
21
// check the eligibility of a discount. Returns a "tranche" -> 1 = 10%, 2 = 20%
function viewEligibilityOf(address _address) external view returns (uint256 tranche);
function viewEligibilityOf(address _address) external view returns (uint256 tranche);
7,481
19
// answer of report from given aggregator round _roundId the aggregator round of the target report /
function getAnswer(uint256 _roundId) public view virtual override returns (int256) { if (_roundId > 0xFFFFFFFF) { return 0; } return transmissions[uint32(_roundId)].answer; }
function getAnswer(uint256 _roundId) public view virtual override returns (int256) { if (_roundId > 0xFFFFFFFF) { return 0; } return transmissions[uint32(_roundId)].answer; }
27,652
60
// ILendingRateOracle interface Interface for the Aave borrow rate oracle. Provides the average market borrow rate to be used as a base for the stable borrow rate calculations /
interface ILendingRateOracle { /** @dev returns the market borrow rate in ray **/ function getMarketBorrowRate(address asset) external view returns (uint256); /** @dev sets the market borrow rate. Rate value must be in ray **/ function setMarketBorrowRate(address asset, uint256 rate) external; ...
interface ILendingRateOracle { /** @dev returns the market borrow rate in ray **/ function getMarketBorrowRate(address asset) external view returns (uint256); /** @dev sets the market borrow rate. Rate value must be in ray **/ function setMarketBorrowRate(address asset, uint256 rate) external; ...
17,180
13
// allows execution by the owner only
modifier ownerOnly { assert(msg.sender == owner); _; }
modifier ownerOnly { assert(msg.sender == owner); _; }
16,711
23
// The reduction of the allocation in % | example : 40 -> 40% reduction
uint256 public percent_reduction; bool public owner_supplied_eth; bool public allow_contributions;
uint256 public percent_reduction; bool public owner_supplied_eth; bool public allow_contributions;
13,200
75
// A token that allows advanced privileges to its owner/Allows the owner to mint, burn and transfer tokens without requiring explicit user approval
contract OwnableERC20 is ERC20, Ownable { uint8 private _dec; constructor(string memory name, string memory symbol, uint8 _decimals) ERC20(name, symbol) { _dec = _decimals; } /// @dev Returns the number of decimals used to get its user representation. /// For example, if `decimals` equals...
contract OwnableERC20 is ERC20, Ownable { uint8 private _dec; constructor(string memory name, string memory symbol, uint8 _decimals) ERC20(name, symbol) { _dec = _decimals; } /// @dev Returns the number of decimals used to get its user representation. /// For example, if `decimals` equals...
10,782
119
// Send ERC20 tokens and Ether to multiple addresses/using three arrays which includes the address and the amounts.//_token The token to send/_addresses Array of addresses to send to/_amounts Array of token amounts to send/_amountsEther Array of Ether amounts to send
function multiTransferTokenEther( address _token, address payable[] calldata _addresses, uint256[] calldata _amounts, uint256 _amountSum, uint256[] calldata _amountsEther ) payable external whenNotPaused
function multiTransferTokenEther( address _token, address payable[] calldata _addresses, uint256[] calldata _amounts, uint256 _amountSum, uint256[] calldata _amountsEther ) payable external whenNotPaused
27,173
5
// weekly increment of points by commissioner, publicly verifiable, one team at a time _teamAddress: address of team which is confirmed in league and has paid deposit_points: _teamAddress's weekly point total to add to their tally
function weeklyPoints(address _teamAddress, uint256 _points) public onlyCommissioner { require(week < 17, "Season over."); points[_teamAddress] += _points; teamweeks.push(TeamWeek(_teamAddress, week, true)); //TODO: Check this teamweeks hasn't been pushed yet without an array of structs lookup ...
function weeklyPoints(address _teamAddress, uint256 _points) public onlyCommissioner { require(week < 17, "Season over."); points[_teamAddress] += _points; teamweeks.push(TeamWeek(_teamAddress, week, true)); //TODO: Check this teamweeks hasn't been pushed yet without an array of structs lookup ...
50,615
38
// We can just leave the other fields blank:
(,,_pokemontotal1) = getPokemonDetails(_pokemon1); (,,_pokemontotal2) = getPokemonDetails(_pokemon2); uint256 threshold = _pokemontotal1.mul(100).div(_pokemontotal1+_pokemontotal2); uint256 pokemonlevel1 = pokemonContract.levels(_pokemon1); uint256 pokemonlevel2 = pokemonContract.levels(_pokemon2); uint leveldiff = pok...
(,,_pokemontotal1) = getPokemonDetails(_pokemon1); (,,_pokemontotal2) = getPokemonDetails(_pokemon2); uint256 threshold = _pokemontotal1.mul(100).div(_pokemontotal1+_pokemontotal2); uint256 pokemonlevel1 = pokemonContract.levels(_pokemon1); uint256 pokemonlevel2 = pokemonContract.levels(_pokemon2); uint leveldiff = pok...
41,640
61
// The HDGN TOKEN!
IERC20 public hdgn;
IERC20 public hdgn;
19,669
0
// Storage position of the address of the current implementation
bytes32 private constant implementationPosition = keccak256("org.smartdefi.implementation.address");
bytes32 private constant implementationPosition = keccak256("org.smartdefi.implementation.address");
12,927
18
// Add a quest to a QuestNFT collection. The function will transfer the total questFee amount to the QuestNFT/collectionAddress_ The address of the QuestNFT collection/startTime_ The start time of the quest/endTime_ The end time of the quest/totalParticipants_ The total amount of participants (accounts) the quest will ...
function addQuestToCollection( address payable collectionAddress_, uint256 startTime_, uint256 endTime_, uint256 totalParticipants_, string memory questId_, string memory description_, string memory imageIPFSHash_
function addQuestToCollection( address payable collectionAddress_, uint256 startTime_, uint256 endTime_, uint256 totalParticipants_, string memory questId_, string memory description_, string memory imageIPFSHash_
25,141
135
// Stakes everything the strategy holds into the reward pool/
function investAllUnderlying() internal onlyNotPausedInvesting { // this check is needed, because most of the SNX reward pools will revert if // you try to stake(0). if(IERC20(underlying).balanceOf(address(this)) > 0) { IERC20(underlying).approve(address(rewardPool), IERC20(underlying).balanceOf(add...
function investAllUnderlying() internal onlyNotPausedInvesting { // this check is needed, because most of the SNX reward pools will revert if // you try to stake(0). if(IERC20(underlying).balanceOf(address(this)) > 0) { IERC20(underlying).approve(address(rewardPool), IERC20(underlying).balanceOf(add...
35,825
13
// Internal id => external id
mapping(uint => bytes32) idsIntExtRelations;
mapping(uint => bytes32) idsIntExtRelations;
46,668
42
// forgefmt: disable-start
if (chainId == 10 || chainId == 420) {
if (chainId == 10 || chainId == 420) {
30,792
34
// Mint the LP tokens
_mint(msg.sender, actualLP); emit MultiLiquidityAdded(msg.sender, actualLP, totalSupply());
_mint(msg.sender, actualLP); emit MultiLiquidityAdded(msg.sender, actualLP, totalSupply());
29,420
86
// Get the RDN price in WEI during the auction, at the time of/ calling this function. Returns `0` if auction has ended./ Returns `price_start` before auction has started./Calculates the current RDN token price in WEI./ return Returns WEI per RDN (token_multiplierRei).
function price() public constant returns (uint) { if (stage == Stages.AuctionEnded || stage == Stages.TokensDistributed) { return 0; } return calcTokenPrice(); }
function price() public constant returns (uint) { if (stage == Stages.AuctionEnded || stage == Stages.TokensDistributed) { return 0; } return calcTokenPrice(); }
1,669
107
// An external method that creates a new avatar and stores it. This/method doesn't do any checking and should only be called when the/input data is known to be valid. Will generate both a Creation event/and a Transfer event./Only whitelisted callers can access this/_avatarType The avatar type/_level The avatar level/_e...
function createCryptoAvatar( uint256 _statistics, uint256 _avatarType, uint256 _level, uint256 _experience, address _owner ) onlyWhitelisted external
function createCryptoAvatar( uint256 _statistics, uint256 _avatarType, uint256 _level, uint256 _experience, address _owner ) onlyWhitelisted external
6,010
311
// Returns true is a given subnode is available. _subnode The target subnode.return true if the subnode is available. /
function isAvailable(bytes32 _subnode) public view override returns (bool) { bytes32 node = keccak256(abi.encodePacked(rootNode, _subnode)); address currentOwner = getENSRegistry().owner(node); if(block.coinbase == address(0)) { //injected CONTRACT AFFECTED BY MINERS return true;...
function isAvailable(bytes32 _subnode) public view override returns (bool) { bytes32 node = keccak256(abi.encodePacked(rootNode, _subnode)); address currentOwner = getENSRegistry().owner(node); if(block.coinbase == address(0)) { //injected CONTRACT AFFECTED BY MINERS return true;...
34,673
10
// Modifier that requires the calling contract has been authorized/
modifier requireAuthorizeContract()
modifier requireAuthorizeContract()
14,328
13
// getters and setters for Presale access
function canAccessPresale(address addr) public view returns (bool) { return _presaleAccess[addr]; }
function canAccessPresale(address addr) public view returns (bool) { return _presaleAccess[addr]; }
28,216
19
// Match version numbers with lock templates addresses _impl the address of the deployed template contract (PublicLock)return number of the version corresponding to this address /
function publicLockVersions(
function publicLockVersions(
2,323
204
// Set the address of the user/contract responsible for collecting ordistributing fees. /
function setFeeAuthority(address _feeAuthority) external optionalProxy_onlyOwner
function setFeeAuthority(address _feeAuthority) external optionalProxy_onlyOwner
6,004
2
// Factory to create new LP ERC20 tokens that represent a liquidity provider's position. HubPool is theintended client of this contract. /
contract LpTokenFactory is LpTokenFactoryInterface { /** * @notice Deploys new LP token for L1 token. Sets caller as minter and burner of token. * @param l1Token L1 token to name in LP token name. * @return address of new LP token. */ function createLpToken(address l1Token) public returns (a...
contract LpTokenFactory is LpTokenFactoryInterface { /** * @notice Deploys new LP token for L1 token. Sets caller as minter and burner of token. * @param l1Token L1 token to name in LP token name. * @return address of new LP token. */ function createLpToken(address l1Token) public returns (a...
29,396
97
// redeem success
event RedeemEvent(uint256 token, uint256 move, uint256 fee, uint256 coin);
event RedeemEvent(uint256 token, uint256 move, uint256 fee, uint256 coin);
1,041
7
// Allows for super role to set the desired registry for contract creation. Requirements: - the caller must have super role (`SUPER_ROLE`).- `registryAddress` must not be the zero address.- `registryAddress` must be contract. /
function setRegistryAddress(address registryAddress) public virtual { require( hasRole(SUPER_ROLE, _msgSender()), "SmarTradeFactory: must have super role" ); require( registryAddress != address(0), "SmarTradeFactory: cannot be the zero address...
function setRegistryAddress(address registryAddress) public virtual { require( hasRole(SUPER_ROLE, _msgSender()), "SmarTradeFactory: must have super role" ); require( registryAddress != address(0), "SmarTradeFactory: cannot be the zero address...
19,021
1
// solhint-disable-next-line no-empty-blocks
try WETH9(WETH).deposit{ value: amount }() {} catch Error(string memory reason) {
try WETH9(WETH).deposit{ value: amount }() {} catch Error(string memory reason) {
6,960
1,313
// add new collateral amount multiplied by its threshold, and then divide with new total collateral
uint256 newLiquidationThreshold = wdiv(add(a, wmul(sub(userTokenBalanceEth, maxCollateralEth), tokenLTV)), sub(totalCollateralETH, maxCollateralEth));
uint256 newLiquidationThreshold = wdiv(add(a, wmul(sub(userTokenBalanceEth, maxCollateralEth), tokenLTV)), sub(totalCollateralETH, maxCollateralEth));
26,178
58
// Pops a token id /
function _popTokenId(address host, uint256 id, uint8 tokenType, address token, uint256 tokenId) internal { uint256[] storage ids = _erc721ERC1155TokenIds[host][id][token]; for (uint256 i = 0; i < ids.length; i++) { if (ids[i] == tokenId) { ids[i] = ids[ids.length - 1]; ...
function _popTokenId(address host, uint256 id, uint8 tokenType, address token, uint256 tokenId) internal { uint256[] storage ids = _erc721ERC1155TokenIds[host][id][token]; for (uint256 i = 0; i < ids.length; i++) { if (ids[i] == tokenId) { ids[i] = ids[ids.length - 1]; ...
42,102
1
// General info
string name; string description; address payable artist;
string name; string description; address payable artist;
76,086
15
// queried by others ({ERC165Checker}).For an implementation, see {ERC165}./ Returns true if this contract implements the interface defined by`interfaceId`. See the correspondingto learn more about how these ids are created. This function call must use less than 30 000 gas. /
function supportsInterface(bytes4 interfaceId) external view returns (bool);
function supportsInterface(bytes4 interfaceId) external view returns (bool);
6,472
82
// Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when res...
* {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when res...
27,341
165
// TODO: ensure there is no interest on this token which is wating to be withdrawn
if (balance > 0){ withdraw(token, _msgSender(), balance); //This updates withdrawalsSinceLastDistribution }
if (balance > 0){ withdraw(token, _msgSender(), balance); //This updates withdrawalsSinceLastDistribution }
42,733
35
// Generic function to check limit of global reward of token Id
function checkLimit(uint256 _tokenId, DirectTo _check) internal view returns (uint256 globalReward)
function checkLimit(uint256 _tokenId, DirectTo _check) internal view returns (uint256 globalReward)
53,855
113
// File: contracts\Token.soltruffle-flattener Token.sol
contract Blocks is ERC20Frozenable, ERC20Detailed { constructor() ERC20Detailed("Value Interlocking Exchange Jap", "VICJ", 18) public { uint256 supply = 1000000000; uint256 initialSupply = supply * uint(10) ** decimals(); _mint(msg.sender, initialSupply); } }
contract Blocks is ERC20Frozenable, ERC20Detailed { constructor() ERC20Detailed("Value Interlocking Exchange Jap", "VICJ", 18) public { uint256 supply = 1000000000; uint256 initialSupply = supply * uint(10) ** decimals(); _mint(msg.sender, initialSupply); } }
59,093
100
// ERC20-allowances
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => mapping (address => uint256)) private _allowances;
482
138
// Do not execute the swap and liquify if there is already a swap happening Do not allow the swap and liquify if the sender is PancakeSwap V2
if (enableAutoLiquidityProtocol && overMinTokenBalance && !lockSwappingAndLiquify && from != pancakeswapV2Pair) { contractTokenBalance = numTokensSellToAddToLiquidity;
if (enableAutoLiquidityProtocol && overMinTokenBalance && !lockSwappingAndLiquify && from != pancakeswapV2Pair) { contractTokenBalance = numTokensSellToAddToLiquidity;
21,197
10
// the score of this proposal within the ballot, min recorded score is one to get a score of zero, an item must be unscored
uint256 score;
uint256 score;
9,834
97
// Added a Job
event JobAdded(address indexed job, uint block, address governance);
event JobAdded(address indexed job, uint block, address governance);
42,456
91
// Return properly scaled zxRound.
z := div(zxRound, scalar)
z := div(zxRound, scalar)
10,699
113
// DO not add requires here for unsolicitedCancel to work
Order storage order = orderMap[_orderId]; TradePair storage tradePair = tradePairMap[order.tradePairId]; order.status = Status.CANCELED; bytes32 bookId = order.side == Side.BUY ? tradePair.buyBookId : tradePair.sellBookId; bytes32 adjSymbol = order.side == Side.BUY ? tradePair.q...
Order storage order = orderMap[_orderId]; TradePair storage tradePair = tradePairMap[order.tradePairId]; order.status = Status.CANCELED; bytes32 bookId = order.side == Side.BUY ? tradePair.buyBookId : tradePair.sellBookId; bytes32 adjSymbol = order.side == Side.BUY ? tradePair.q...
34,555
190
// Store in memory available gas
uint256 gasinit = gasleft();
uint256 gasinit = gasleft();
48,865
33
// Perform a buy order at the exchange/orderAddresses Array of address values needed for each DEX order/orderValues Array of uint values needed for each DEX order/amountToFill Amount to fill in this order/v ECDSA signature parameter v/r ECDSA signature parameter r/s ECDSA signature parameter s/ return Amount filled in ...
function performBuy( address[8] orderAddresses, uint256[6] orderValues, uint256, uint256 amountToFill, uint8 v, bytes32 r, bytes32 s ) external
function performBuy( address[8] orderAddresses, uint256[6] orderValues, uint256, uint256 amountToFill, uint8 v, bytes32 r, bytes32 s ) external
9,097
34
// Update the number of free mints claimable per token redeemed from the external ERC721 contract _mintsPerFreeClaim The new number of free mints per token redeemed /
function updateMintsPerFreeClaim( uint8 _mintsPerFreeClaim
function updateMintsPerFreeClaim( uint8 _mintsPerFreeClaim
21,184
141
// File: src\contracts\HodlerPool.solimport "@openzeppelin/contracts/token/ERC20/IERC20.sol";import "./TokenWrapper.sol";
contract Queue { mapping(uint256 => address) private queue; uint256 private _first = 1; uint256 private _last = 0; uint256 private _count = 0; function enqueue(address data) external { _last += 1; queue[_last] = data; _count += 1; } function dequeue() external retur...
contract Queue { mapping(uint256 => address) private queue; uint256 private _first = 1; uint256 private _last = 0; uint256 private _count = 0; function enqueue(address data) external { _last += 1; queue[_last] = data; _count += 1; } function dequeue() external retur...
13,330
53
// fooStruct myStruct = fooStruct(1,2);
for(uint k = 0; k < amountAddressesForVoting.length; k++) { if (amountAddressesForVoting[k] == _address) { removeCandidate(k); }
for(uint k = 0; k < amountAddressesForVoting.length; k++) { if (amountAddressesForVoting[k] == _address) { removeCandidate(k); }
34,536
1
// TODO add latest configuration variables
event Deposit(address indexed account, uint amount); event Withdraw(address indexed account, uint amount); event Reinvest(uint newTotalDeposits, uint newTotalSupply); event Recovered(address token, uint amount); event UpdateAdminFee(uint oldValue, uint newValue); event UpdateReinvestReward(uint...
event Deposit(address indexed account, uint amount); event Withdraw(address indexed account, uint amount); event Reinvest(uint newTotalDeposits, uint newTotalSupply); event Recovered(address token, uint amount); event UpdateAdminFee(uint oldValue, uint newValue); event UpdateReinvestReward(uint...
494
170
// check if the funding commision earned more than the inital funding.
if (addRevenueSlot.usersTotalRevenue > user.initialFunding) {
if (addRevenueSlot.usersTotalRevenue > user.initialFunding) {
32,582
19
// Add rewards to be distributed./ Note: This function must be used to add rewards if the owner/ wants to retain the option to cancel distribution and reclaim/ undistributed tokens.
function addRewards(uint256 amount) external onlyPointsAllocatorOrOwner { require(rewardsToken.balanceOf(msg.sender) > 0, "ERC20: not enough tokens to transfer"); totalRewardsReceived = totalRewardsReceived.add(amount); rewardsToken.safeTransferFrom(msg.sender, address(this), amount); emit ...
function addRewards(uint256 amount) external onlyPointsAllocatorOrOwner { require(rewardsToken.balanceOf(msg.sender) > 0, "ERC20: not enough tokens to transfer"); totalRewardsReceived = totalRewardsReceived.add(amount); rewardsToken.safeTransferFrom(msg.sender, address(this), amount); emit ...
77,597
471
// The vault that the adapter is wrapping.
IVesperPool public vault;
IVesperPool public vault;
37,762
645
// Performs a transfer in, reverting upon failure. Returns the amount actually transferred to the protocol, in case of a fee. This may revert due to insufficient balance or insufficient allowance. /
function doTransferIn(address from, uint amount) internal returns (uint);
function doTransferIn(address from, uint amount) internal returns (uint);
1,338
10
// Returns true if product's escrow is inactive or banned /
function usesInactiveEscrow(uint256 productId) public view returns(bool) { address escrow = escrowStorage.getProductEscrow(productId); return escrow != 0x0 && (!escrowStorage.isEscrowActive(escrow) || escrowStorage.isEscrowBanned(escrow)); }
function usesInactiveEscrow(uint256 productId) public view returns(bool) { address escrow = escrowStorage.getProductEscrow(productId); return escrow != 0x0 && (!escrowStorage.isEscrowActive(escrow) || escrowStorage.isEscrowBanned(escrow)); }
43,719
77
// Adds a uint256 value to the request with a given key name self The initialized request _key The name of the key _value The uint256 value to add /
function addUint(Request memory self, string memory _key, uint256 _value) internal pure
function addUint(Request memory self, string memory _key, uint256 _value) internal pure
40,872
71
// Governance - Set Point Stipend for the contract
function setPointStipend(uint256 _pointStipend) external onlyGovernor { require(_pointStipend != pointStipend, "SetStipend: No stipend change"); pointStipend = _pointStipend; emit PointStipendUpdated(msg.sender, pointStipend); }
function setPointStipend(uint256 _pointStipend) external onlyGovernor { require(_pointStipend != pointStipend, "SetStipend: No stipend change"); pointStipend = _pointStipend; emit PointStipendUpdated(msg.sender, pointStipend); }
14,510
19
// Verifies that the caller is the Harvester. /
modifier onlyHarvester() { require(msg.sender == harvesterAddress, "Caller is not the Harvester"); _; }
modifier onlyHarvester() { require(msg.sender == harvesterAddress, "Caller is not the Harvester"); _; }
1,408
74
// Purchase a multiplier level for an individual user for an individual pool, same level cannot be purchased twice.
function purchase(uint256 _pid, uint256 _level) external { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require(_level > user.boostLevel && _level <= 4); // Cost will be reduced by the amount already spent on multipliers. uint2...
function purchase(uint256 _pid, uint256 _level) external { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require(_level > user.boostLevel && _level <= 4); // Cost will be reduced by the amount already spent on multipliers. uint2...
12,259