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
24
// Fields:
string public constant name = "Grand Marche Token"; string public constant symbol = "GMT"; uint public constant decimals = 18; uint public constant TOTAL_SUPPLY = 1000000 * (1 ether / 1 wei); uint public constant AIRDROP_SHARE = 50000 * (1 ether / 1 wei); uint public constant PRESALE_PRICE...
string public constant name = "Grand Marche Token"; string public constant symbol = "GMT"; uint public constant decimals = 18; uint public constant TOTAL_SUPPLY = 1000000 * (1 ether / 1 wei); uint public constant AIRDROP_SHARE = 50000 * (1 ether / 1 wei); uint public constant PRESALE_PRICE...
32,965
106
// Check made maximum babies
require(getData().doneMaxBabies(male, female), "You need to make maximum amount of babies before you leave");
require(getData().doneMaxBabies(male, female), "You need to make maximum amount of babies before you leave");
43,819
2
// get the article
function getArticle() public view returns ( address _seller, string memory _name, string memory _description,
function getArticle() public view returns ( address _seller, string memory _name, string memory _description,
12,389
10
// Mints tokenIds into 'to' account Emits SftTokenTransfer Event Throws if sender has no MINTER_ROLE'data' holds the CFolioItemHandler if CFI's are minted /
function mintBatch( address to, uint256[] calldata tokenIds, bytes calldata data ) external;
function mintBatch( address to, uint256[] calldata tokenIds, bytes calldata data ) external;
30,814
31
// gas savings
if (feeOn) { if (_kLast != 0) { uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1)); uint rootKLast = Math.sqrt(_kLast); if (rootK > rootKLast) { uint numeratorTeam = totalSupply.mul(rootK.sub(rootKLast)).mul(2); ...
if (feeOn) { if (_kLast != 0) { uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1)); uint rootKLast = Math.sqrt(_kLast); if (rootK > rootKLast) { uint numeratorTeam = totalSupply.mul(rootK.sub(rootKLast)).mul(2); ...
56,829
109
// Standard ERC223 function that will handle incoming token transfers._fromToken sender address. _value Amount of tokens. _dataTransaction metadata. /
function tokenFallback(address _from, uint _value, bytes memory _data) public;
function tokenFallback(address _from, uint _value, bytes memory _data) public;
7,360
116
// This abstract contract provides getters and event emitting update functions for _Available since v4.1._ /
abstract contract ERC1967UpgradeUpgradeable is Initializable, IERC1967Upgradeable { function __ERC1967Upgrade_init() internal onlyInitializing { } function __ERC1967Upgrade_init_unchained() internal onlyInitializing { } // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1 ...
abstract contract ERC1967UpgradeUpgradeable is Initializable, IERC1967Upgradeable { function __ERC1967Upgrade_init() internal onlyInitializing { } function __ERC1967Upgrade_init_unchained() internal onlyInitializing { } // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1 ...
9,347
5
// Check if an extension can mint /
function _checkMintPermissions(address[] memory to, uint256[] memory tokenIds, uint256[] memory amounts) internal { if (_extensionPermissions[msg.sender] != address(0)) { IERC1155CreatorMintPermissions(_extensionPermissions[msg.sender]).approveMint(msg.sender, to, tokenIds, amounts); } ...
function _checkMintPermissions(address[] memory to, uint256[] memory tokenIds, uint256[] memory amounts) internal { if (_extensionPermissions[msg.sender] != address(0)) { IERC1155CreatorMintPermissions(_extensionPermissions[msg.sender]).approveMint(msg.sender, to, tokenIds, amounts); } ...
14,027
63
// fallback function - do not accept payment/
function () external payable { revert(); }
function () external payable { revert(); }
40,535
83
// 1 week as a timestamp.
uint256 private oneWeek = 604800;
uint256 private oneWeek = 604800;
77,708
114
// Max supply.
uint256 public constant SUPPLY_MAX = 10000;
uint256 public constant SUPPLY_MAX = 10000;
24,688
72
// IUniMexPool(pool).repay(owed);
IUniMexPool(pool).distribute(fees.div(2)); IUniMexStaking(staking).distribute(fees.sub(fees.div(2))); transferEscrowToUser(position.owner, position.owner, commitment.add(profitMinusFees)); position.is...
IUniMexPool(pool).distribute(fees.div(2)); IUniMexStaking(staking).distribute(fees.sub(fees.div(2))); transferEscrowToUser(position.owner, position.owner, commitment.add(profitMinusFees)); position.is...
19,468
36
// Address must not already be a solver and must not be a null address
require(!isSolver[_solvers[i]] && _solvers[i] != address(0)); isSolver[_solvers[i]] = true;
require(!isSolver[_solvers[i]] && _solvers[i] != address(0)); isSolver[_solvers[i]] = true;
57,262
106
// /Calculates the auction price parameters, targetting 1% slippage every 10 minutes. Fair valueplaced in middle of price range. _currentSetDollarAmountThe 18 decimal value of one currenSet_nextSetDollarAmount The 18 decimal value of one nextSet_timeIncrement Amount of time to explore 1% of fair value price change_auct...
function calculateAuctionPriceParameters( uint256 _currentSetDollarAmount, uint256 _nextSetDollarAmount, uint256 _timeIncrement, uint256 _auctionLibraryPriceDivisor, uint256 _auctionTimeToPivot ) internal view returns (uint256, uint256)
function calculateAuctionPriceParameters( uint256 _currentSetDollarAmount, uint256 _nextSetDollarAmount, uint256 _timeIncrement, uint256 _auctionLibraryPriceDivisor, uint256 _auctionTimeToPivot ) internal view returns (uint256, uint256)
8,707
22
// sets config AccessControllerInterface contract only owner can call this accessController new AccessControllerInterface contract address /
function setConfigAC(address accessController) external onlyOwner { _setConfigAC(accessController); }
function setConfigAC(address accessController) external onlyOwner { _setConfigAC(accessController); }
42,883
285
// Used to collect accumulated protocol fees. /
function collectProtocol( uint256 amount0, uint256 amount1, address to
function collectProtocol( uint256 amount0, uint256 amount1, address to
53,926
7
// Send to multiple addresses using two arrays whichincludes the address and the amount. addresses Array of addresses to send to amounts Array of amounts to send feeAmount Amount of fee to collect /
function multiTransfer( uint256 feeAmount, address[] memory addresses, uint256[] memory amounts
function multiTransfer( uint256 feeAmount, address[] memory addresses, uint256[] memory amounts
10,790
3
// Callback function /
function fulfillStockPrice(bytes32 _requestId, bytes32 _result) public recordChainlinkFulfillment(_requestId) { readData(_result); }
function fulfillStockPrice(bytes32 _requestId, bytes32 _result) public recordChainlinkFulfillment(_requestId) { readData(_result); }
3,324
72
// This will assign ownership, and also emit the Transfer event as per ERC721 draft
_transfer(0, _owner, newDogId); return newDogId;
_transfer(0, _owner, newDogId); return newDogId;
15,084
58
// unstaking possible after 0 days
uint256 public cliffTime = 0 days; uint256 public farmEnableat; uint256 public totalClaimedRewards = 0; uint256 private stakingAndDaoTokens = 100000e18; bool public farmEnabled = false; EnumerableSet.AddressSet private holders;
uint256 public cliffTime = 0 days; uint256 public farmEnableat; uint256 public totalClaimedRewards = 0; uint256 private stakingAndDaoTokens = 100000e18; bool public farmEnabled = false; EnumerableSet.AddressSet private holders;
40,970
168
// import { Address } from "@openzeppelin/contracts/utils/Address.sol"; import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import { Math } from "@openzeppelin/contracts/math/Math.sol"; import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol"; import { AddressArrayUtils } from "contracts/...
using Address for address; using AddressArrayUtils for address[]; using PreciseUnitMath for uint256; using SafeMath for uint256;
using Address for address; using AddressArrayUtils for address[]; using PreciseUnitMath for uint256; using SafeMath for uint256;
15,879
120
// See: {AccessController.hasRole} /
modifier onlyRole(bytes32 role) { require(MarketClientLib.hasRole(role), "Caller doesn't have role"); _; }
modifier onlyRole(bytes32 role) { require(MarketClientLib.hasRole(role), "Caller doesn't have role"); _; }
15,612
2
// send `_value` token to `_to` from `msg.sender`/_to The address of the recipient/_value The amount of token to be transferred/ return success Whether the transfer was successful or not
function transfer(address _to, uint256 _value) external returns (bool success);
function transfer(address _to, uint256 _value) external returns (bool success);
3,451
99
// Create an iterator. Reverts if item is not a list.self The RLP item. return An 'Iterator' over the item./
function iterator(RLPItem memory self) internal pure returns (Iterator memory) { require(isList(self)); uint ptr = self.memPtr + _payloadOffset(self.memPtr); return Iterator(self, ptr); }
function iterator(RLPItem memory self) internal pure returns (Iterator memory) { require(isList(self)); uint ptr = self.memPtr + _payloadOffset(self.memPtr); return Iterator(self, ptr); }
24,764
85
// Restricted access function which updates base URI used to construct ERC721Metadata.tokenURIRequires executor to have ROLE_URI_MANAGER permission_baseURI new base URI to set /
function setBaseURI(string memory _baseURI) public virtual { // verify the access permission require(isSenderInRole(ROLE_URI_MANAGER), "access denied"); // emit an event first - to log both old and new values emit BaseURIUpdated(msg.sender, baseURI, _baseURI); // and update base URI baseURI = _baseURI; ...
function setBaseURI(string memory _baseURI) public virtual { // verify the access permission require(isSenderInRole(ROLE_URI_MANAGER), "access denied"); // emit an event first - to log both old and new values emit BaseURIUpdated(msg.sender, baseURI, _baseURI); // and update base URI baseURI = _baseURI; ...
24,737
11
// Validation: ensure that the required stack depth is not above theMAX_STACK_DEPTH_REQUIREMENT /
function validateRequiredStackDepth(uint requiredStackDepth) returns (bool) { return requiredStackDepth <= _MAX_STACK_DEPTH_REQUIREMENT; }
function validateRequiredStackDepth(uint requiredStackDepth) returns (bool) { return requiredStackDepth <= _MAX_STACK_DEPTH_REQUIREMENT; }
19,000
18
// uint256 updatedTimestamp = now;
bytes32 flightKey = getFlightKey(airline, flightName, departureTime); require(!flightInList(flightsList, flightKey), 'Flight already exists!'); flights[flightKey].flightName = flightName; flights[flightKey].isRegistered = true; flights[flightKey].statusCode = STATUS_CODE_UNKNOWN...
bytes32 flightKey = getFlightKey(airline, flightName, departureTime); require(!flightInList(flightsList, flightKey), 'Flight already exists!'); flights[flightKey].flightName = flightName; flights[flightKey].isRegistered = true; flights[flightKey].statusCode = STATUS_CODE_UNKNOWN...
47,700
151
// NOVA tokens created per block.
uint256 public novaPerBlock;
uint256 public novaPerBlock;
11,336
31
// Decode an RLPItem into a boolean. This will not work if the / RLPItem is a list. /self The RLPItem. / return The decoded string.
function toBool(RLPItem memory self) internal constant returns (bool data) { if(!isData(self)) revert(); var (rStartPos, len) = _decode(self); if (len != 1) revert(); uint temp; assembly { temp := byte(0, mload(rStartPos)) } if (temp > 1) revert();...
function toBool(RLPItem memory self) internal constant returns (bool data) { if(!isData(self)) revert(); var (rStartPos, len) = _decode(self); if (len != 1) revert(); uint temp; assembly { temp := byte(0, mload(rStartPos)) } if (temp > 1) revert();...
53,490
6
// withdraw
actionsWithdraw[0] = Dydx.ActionArgs( { actionType: 1, accountId: 0, amount: Dydx.AssetAmount( { sign: false, denomination: 0, ref: 0, value: amount.value
actionsWithdraw[0] = Dydx.ActionArgs( { actionType: 1, accountId: 0, amount: Dydx.AssetAmount( { sign: false, denomination: 0, ref: 0, value: amount.value
17,241
36
// Transfers ownership of the contract to a new account (`newOwner`).Can only be called by the current owner. /
function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); }
function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); }
1,795
15
// Function to pick a winner in a specific raffle
function pickWinner() public raffleOwnerExists { Raffle storage currentRaffle = raffles[msg.sender]; require(!currentRaffle.lotteryStatus, "Lottery is still running"); require(currentRaffle.playerSelector.length > 0, "No players in the lottery"); require(currentRaffle.nftContract != ...
function pickWinner() public raffleOwnerExists { Raffle storage currentRaffle = raffles[msg.sender]; require(!currentRaffle.lotteryStatus, "Lottery is still running"); require(currentRaffle.playerSelector.length > 0, "No players in the lottery"); require(currentRaffle.nftContract != ...
35
33
// if we have it in the PublicSale add it
if (PSaleGroup > 0){ whiteListedStatus = PSaleGroup; }else{
if (PSaleGroup > 0){ whiteListedStatus = PSaleGroup; }else{
11,914
9
// transfer : Transfer token to another etherum address /
function transfer(address to, uint tokens) virtual override public returns (bool success) { require(to != address(0), "Null address"); require(tokens > 0, "Invalid Value"); balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances...
function transfer(address to, uint tokens) virtual override public returns (bool success) { require(to != address(0), "Null address"); require(tokens > 0, "Invalid Value"); balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances...
18,690
118
// split the contract balance into thirds
uint256 liqPart = contractTokenBalance.mul(_marketingDivisor).div(_liquidityFee); uint256 halfOfLiquify = liqPart.div(2); uint256 otherHalfOfLiquify = liqPart.div(2); uint256 marketingPart = contractTokenBalance.sub(halfOfLiquify).sub(otherHalfOfLiquify);
uint256 liqPart = contractTokenBalance.mul(_marketingDivisor).div(_liquidityFee); uint256 halfOfLiquify = liqPart.div(2); uint256 otherHalfOfLiquify = liqPart.div(2); uint256 marketingPart = contractTokenBalance.sub(halfOfLiquify).sub(otherHalfOfLiquify);
41,183
24
// investing contract address change
// function setInvContract(address _addr) onlyManager public { // inv_contract = _addr; // }
// function setInvContract(address _addr) onlyManager public { // inv_contract = _addr; // }
45,037
625
// Enables or disables the oracle in `data`, returning the updated value. /
function setOracleEnabled(bytes32 data, bool _oracleEnabled) internal pure returns (bytes32) { return data.insertBool(_oracleEnabled, _ORACLE_ENABLED_OFFSET); }
function setOracleEnabled(bytes32 data, bool _oracleEnabled) internal pure returns (bytes32) { return data.insertBool(_oracleEnabled, _ORACLE_ENABLED_OFFSET); }
24,300
23
// F3GDatasets library /
library F3GDatasets { struct EventReturns { uint256 compressedData; uint256 compressedIDs; address winnerAddr; // winner address bytes32 winnerName; // winner name uint256 amountWon; // amount won uint256 newPot; // amount in new p...
library F3GDatasets { struct EventReturns { uint256 compressedData; uint256 compressedIDs; address winnerAddr; // winner address bytes32 winnerName; // winner name uint256 amountWon; // amount won uint256 newPot; // amount in new p...
50,618
51
// Returns the number of decimals used to get its user representation.For example, if `decimals` equals `2`, a balance of `505` tokens shouldbe displayed to a user as `5,05` (`505 / 102`). Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function dec...
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function dec...
42,006
44
// Collect outstanding management fee/The outstanding management fee is calculated from the time the last fee is collected.
function takeOutstandingManagementFee() public returns (uint256){ SmartPoolStorage.Fee storage fee = SmartPoolStorage.load().fees[SmartPoolStorage.FeeType.MANAGEMENT_FEE]; uint256 outstandingFee = calcManagementFee(); if (outstandingFee == 0 || outstandingFee < fee.minLine) return 0; ...
function takeOutstandingManagementFee() public returns (uint256){ SmartPoolStorage.Fee storage fee = SmartPoolStorage.load().fees[SmartPoolStorage.FeeType.MANAGEMENT_FEE]; uint256 outstandingFee = calcManagementFee(); if (outstandingFee == 0 || outstandingFee < fee.minLine) return 0; ...
43,385
32
// mapping from EIN to resolver to allowance
mapping (uint => mapping (address => uint)) public resolverAllowances;
mapping (uint => mapping (address => uint)) public resolverAllowances;
13,533
14
// if(accumulateStake[msg.sender] > 0){
if(firstMinStakeValue > 0 && poolInfo[_pid].accumulateStake[msg.sender] == 0){ require(amount >= firstMinStakeValue, "FROG-POOL: Cannot stake 0"); } else{
if(firstMinStakeValue > 0 && poolInfo[_pid].accumulateStake[msg.sender] == 0){ require(amount >= firstMinStakeValue, "FROG-POOL: Cannot stake 0"); } else{
12,779
21
// _depositDelta Number to calculate deposit ratio
function setDepositDelta(uint256 _depositDelta) external onlyOwner { depositDelta = _depositDelta; emit DepositDeltaSet(_depositDelta); }
function setDepositDelta(uint256 _depositDelta) external onlyOwner { depositDelta = _depositDelta; emit DepositDeltaSet(_depositDelta); }
46,689
152
// 소유하고 있는 암놈과 숫놈을 이용하여 교배를 시키는 method _matronId 암놈의 아이디 _sireId 숫놈의 아이디
function breedWithAuto(uint256 _matronId, uint256 _sireId) external payable whenNotPaused
function breedWithAuto(uint256 _matronId, uint256 _sireId) external payable whenNotPaused
22,811
31
// send the remaining sale tokens to the collection wallet
uint256 saleBal = _tokenContract.balanceOf(address(this)); _tokenContract.transfer(_wallet,saleBal); _vestor.setVestingDates(firstListingDate); _finalized = true;
uint256 saleBal = _tokenContract.balanceOf(address(this)); _tokenContract.transfer(_wallet,saleBal); _vestor.setVestingDates(firstListingDate); _finalized = true;
27,952
9
// TODO:加入超级管理员修改用户信息的功能
function SuperdminModify(string memory _name, uint256 _stuNo, uint256 _grade, Identity _identity, address ModifiedUser) public returns (bool){ require((msg.sender == superAdmin), "you aren't superadmin"); //要求拥有管理员权限 modifyUserInfo(_name, _stuNo, _grade, _identity, ModifiedUser); iLo...
function SuperdminModify(string memory _name, uint256 _stuNo, uint256 _grade, Identity _identity, address ModifiedUser) public returns (bool){ require((msg.sender == superAdmin), "you aren't superadmin"); //要求拥有管理员权限 modifyUserInfo(_name, _stuNo, _grade, _identity, ModifiedUser); iLo...
50,451
31
// validate retired emissions and set total emissions
trackerData.totalEmissions = _verifyRetired(inIds[i], trackerData.trackee, tokenTypeId, carbonTrackerIn.idAmount[inIds[i]], inAmounts[i], trackerData.totalEmissions);
trackerData.totalEmissions = _verifyRetired(inIds[i], trackerData.trackee, tokenTypeId, carbonTrackerIn.idAmount[inIds[i]], inAmounts[i], trackerData.totalEmissions);
51,674
17
// test Randomizer /
function testRandom() external view returns (bytes32) { onlyRole(ADMIN_ROLE); return entropySource.returnValue(); }
function testRandom() external view returns (bytes32) { onlyRole(ADMIN_ROLE); return entropySource.returnValue(); }
42,278
212
// Burn the provided amount of avTokens. This will revert if the user does not have enough avTokens.
_burn(msg.sender, avTokenAmount); emit Withdraw(msg.sender, underlyingAmount);
_burn(msg.sender, avTokenAmount); emit Withdraw(msg.sender, underlyingAmount);
21,391
24
// Whitelist OpenSea proxy contract for easy trading.ProxyRegistry proxyRegistry = ProxyRegistry(proxyRegistryAddress);if (address(proxyRegistry.proxies(_owner)) == _operator) {return true;}
return operatorApproval[_owner][_operator];
return operatorApproval[_owner][_operator];
20,208
30
// LXL `client` can confirm after `registerLocker()` is called to deposit `sum` for `provider`. If LXL `token` is wETH, msg.value can be wrapped into wETH in single call. registration Registered LXL number. /
function confirmLocker(uint256 registration) external nonReentrant payable { // PROVIDER-TRACK Locker storage locker = lockers[registration]; require(_msgSender() == locker.client, "!client"); require(locker.confirmed == 0, "confirmed"); address token = locker.token...
function confirmLocker(uint256 registration) external nonReentrant payable { // PROVIDER-TRACK Locker storage locker = lockers[registration]; require(_msgSender() == locker.client, "!client"); require(locker.confirmed == 0, "confirmed"); address token = locker.token...
14,610
463
// The Pause Window and Buffer Period are timestamp-based: they should not be relied upon for sub-minute accuracy. solhint-disable not-rely-on-time
uint256 private constant _MAX_PAUSE_WINDOW_DURATION = 90 days; uint256 private constant _MAX_BUFFER_PERIOD_DURATION = 30 days; uint256 private immutable _pauseWindowEndTime; uint256 private immutable _bufferPeriodEndTime; bool private _paused;
uint256 private constant _MAX_PAUSE_WINDOW_DURATION = 90 days; uint256 private constant _MAX_BUFFER_PERIOD_DURATION = 30 days; uint256 private immutable _pauseWindowEndTime; uint256 private immutable _bufferPeriodEndTime; bool private _paused;
48,971
53
// PLEASE READ BEFORE CHANGING ANY ACCOUNTING OR MATH Anytime there is division, there is a risk of numerical instability from rounding errors. In order to minimize this risk, we adhere to the following guidelines: 1) The conversion rate adopted is the number of gons that equals 1 fragment.The inverse rate must not be ...
using SafeMath for uint256; using SafeMathInt for int256; event LogRebase(uint256 indexed epoch, uint256 totalSupply); event LogRebasePaused(bool paused); event LogTokenPaused(bool paused); event LogSATOPolicyUpdated(address SATOPolicy);
using SafeMath for uint256; using SafeMathInt for int256; event LogRebase(uint256 indexed epoch, uint256 totalSupply); event LogRebasePaused(bool paused); event LogTokenPaused(bool paused); event LogSATOPolicyUpdated(address SATOPolicy);
54,853
5
// ignore dust
if(nonEscrowedRewardAmount > 1) { rewardToken.safeTransfer(_receiver, nonEscrowedRewardAmount); }
if(nonEscrowedRewardAmount > 1) { rewardToken.safeTransfer(_receiver, nonEscrowedRewardAmount); }
16,453
56
// Owner can withdraw funds not exceeding balance minus potential win prizes by open bets
function withdrawFunds(address payable beneficiary, uint withdrawAmount) external onlyOwner { require (withdrawAmount <= address(this).balance, "Withdrawal amount larger than balance."); require (withdrawAmount <= address(this).balance - lockedInBets, "Withdrawal amount larger than balance minus loc...
function withdrawFunds(address payable beneficiary, uint withdrawAmount) external onlyOwner { require (withdrawAmount <= address(this).balance, "Withdrawal amount larger than balance."); require (withdrawAmount <= address(this).balance - lockedInBets, "Withdrawal amount larger than balance minus loc...
44,440
52
// if (validate) { pool.finalizeTransfer(underlyingAsset, from, to, amount, fromBalanceBefore, toBalanceBefore); }
emit BalanceTransfer(from, to, amount, index);
emit BalanceTransfer(from, to, amount, index);
37,710
20
// ------ EVENTS ------
event CratesPurchased(address indexed _from, uint8 _quantity); event CratesOpened(address indexed _from, uint8 _quantity);
event CratesPurchased(address indexed _from, uint8 _quantity); event CratesOpened(address indexed _from, uint8 _quantity);
40,530
209
// Withdraw partial funds from the strategy, unrolling from strategy positions as necessary/Processes withdrawal fee if present/If it fails to recover sufficient funds (defined by withdrawalMaxDeviationThreshold), the withdrawal should fail so that this unexpected behavior can be investigated
function withdraw(uint256 _amount) external virtual whenNotPaused { _onlyController(); // Withdraw from strategy positions, typically taking from any idle want first. _withdrawSome(_amount); uint256 _postWithdraw = IERC20Upgradeable(want).balanceOf(address(this)); ...
function withdraw(uint256 _amount) external virtual whenNotPaused { _onlyController(); // Withdraw from strategy positions, typically taking from any idle want first. _withdrawSome(_amount); uint256 _postWithdraw = IERC20Upgradeable(want).balanceOf(address(this)); ...
13,463
16
// Get the dynamic fee weight decay per round/ return The dynamic fee weight decay per round
function exchangeDynamicFeeWeightDecay() external view returns (uint) { return getExchangeDynamicFeeConfig().weightDecay; }
function exchangeDynamicFeeWeightDecay() external view returns (uint) { return getExchangeDynamicFeeConfig().weightDecay; }
44,063
22
// 必须至少经过2652000(lockBlockLimit+60000=2592000+60000=2652000) 个区块才能kill锁仓合约必须是状态是3,到期解锁 /
function kill() onlyOwner payable public returns(bool) { require(lockStatus==3); require(beginLockBlock.add(lockBlockLimit).add(60000)<block.number); selfdestruct(owner); return true; }
function kill() onlyOwner payable public returns(bool) { require(lockStatus==3); require(beginLockBlock.add(lockBlockLimit).add(60000)<block.number); selfdestruct(owner); return true; }
14,777
196
// Internal function that transfer tokens from one address to another./ Update magnifiedRewardCorrections to keep dividends unchanged./from The address to transfer from./to The address to transfer to./value The amount to be transferred.
function _transfer(address from, address to, uint256 value) internal override { require(block.timestamp > timelock[from], "User locked"); super._transfer(from, to, value); int256 _magCorrection = magnifiedRewardPerShare.mul(value).toInt256(); magnifiedRewardCorrections[from] = magnifiedRewardCorrecti...
function _transfer(address from, address to, uint256 value) internal override { require(block.timestamp > timelock[from], "User locked"); super._transfer(from, to, value); int256 _magCorrection = magnifiedRewardPerShare.mul(value).toInt256(); magnifiedRewardCorrections[from] = magnifiedRewardCorrecti...
55,635
78
// A descriptive name for a collection of NFTs in this contract
function name() public pure returns(string) { return "Pirate Conquest Token"; }
function name() public pure returns(string) { return "Pirate Conquest Token"; }
27,342
75
// reset data
delete contributorList[contributor];
delete contributorList[contributor];
46,765
316
// Approve maximum value to spender
function _approveMax(address tkn, address spender) internal { uint256 max = uint256(- 1); IERC20(tkn).safeApprove(spender, max); }
function _approveMax(address tkn, address spender) internal { uint256 max = uint256(- 1); IERC20(tkn).safeApprove(spender, max); }
80,788
80
// Child contract can override to provide the condition in which the upgrade can begin. /
function canUpgrade() public view returns(bool) { return true; }
function canUpgrade() public view returns(bool) { return true; }
44,301
2
// Data structures // Events // Read and write storage functions //Transfers sender's tokens to a given address. Returns success./_to Address of token receiver./_value Number of tokens to transfer.
function transfer(address _to, uint256 _value) returns (bool success) { if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { ...
function transfer(address _to, uint256 _value) returns (bool success) { if (balances[msg.sender] >= _value && _value > 0) { balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } else { ...
27,727
22
// Safely manipulate unsigned fixed-point decimals at a given precision level. Functions accepting uints in this contract and derived contractsare taken to be such fixed point decimals (including fiat, ether, and nomin quantities). /
contract SafeDecimalMath { /* Number of decimal places in the representation. */ uint8 public constant decimals = 18; /* The number representing 1.0. */ uint public constant UNIT = 10 ** uint(decimals); /** * @return True iff adding x and y will not overflow. */ function addIsSaf...
contract SafeDecimalMath { /* Number of decimal places in the representation. */ uint8 public constant decimals = 18; /* The number representing 1.0. */ uint public constant UNIT = 10 ** uint(decimals); /** * @return True iff adding x and y will not overflow. */ function addIsSaf...
64,820
24
// Views how many remaining credibytes there are for purchase, with the total eth value of the remaining
function viewRemainingCreditsForPurchase() external view returns ( uint256 remainingCredibytesForPurchase, uint256 ethValueOfRemainingCredibytesForPurchase
function viewRemainingCreditsForPurchase() external view returns ( uint256 remainingCredibytesForPurchase, uint256 ethValueOfRemainingCredibytesForPurchase
39,974
26
// Exploiting the fact that 'tgt' was the last thing to be allocated,we can write entire words, and just overwrite any excess.
assembly { { let i := 0 // Start at arr + 0x20 let words := div(add(btsLen, 31), 32) let rOffset := btsPtr let wOffset := add(tgt, 0x20) tag_loop: jumpi(end, eq(i, words)) { ...
assembly { { let i := 0 // Start at arr + 0x20 let words := div(add(btsLen, 31), 32) let rOffset := btsPtr let wOffset := add(tgt, 0x20) tag_loop: jumpi(end, eq(i, words)) { ...
149
0
// Place a bid to the contract and if it is the highest bid/ send the previous leader the current bid and set the leader/ to the sender with the new highest bid
function bid() external payable { require(msg.value > highestBid); refunds[leader] += highestBid; leader = payable(msg.sender); highestBid = msg.value; }
function bid() external payable { require(msg.value > highestBid); refunds[leader] += highestBid; leader = payable(msg.sender); highestBid = msg.value; }
34,506
23
// The constructor() function is the contract constructor that is executed when the contract is deployed. It sets the owner variable to the address of the contract deployer.
contract UniCertify { constructor() { owner = msg.sender; } address public owner; // Public variable that stores the address of the contract owner. uint16 public countAdmins = 0; // Public variable that keep track of the number of admins. uint16 public countCertificates = 0; // Public varia...
contract UniCertify { constructor() { owner = msg.sender; } address public owner; // Public variable that stores the address of the contract owner. uint16 public countAdmins = 0; // Public variable that keep track of the number of admins. uint16 public countCertificates = 0; // Public varia...
25,501
66
// return the PEAKDEFI tokens amount being locked here /
function tokenBalance() external view returns (uint256) { return _token.balanceOf(address(this)); }
function tokenBalance() external view returns (uint256) { return _token.balanceOf(address(this)); }
65,411
1
// solhint-disable no-simple-event-func-name
event Transfer( address indexed from, address indexed to, uint256 value ); event Approval( address indexed owner, address indexed spender, uint256 value
event Transfer( address indexed from, address indexed to, uint256 value ); event Approval( address indexed owner, address indexed spender, uint256 value
37,368
234
// ========== KEEP3RS ========== /
{ // trigger if we want to manually harvest if (forceHarvestTriggerOnce) { return true; } // Should not trigger if strategy is not active (no assets and no debtRatio). This means we don't need to adjust keeper job. if (!isActive()) { return false; ...
{ // trigger if we want to manually harvest if (forceHarvestTriggerOnce) { return true; } // Should not trigger if strategy is not active (no assets and no debtRatio). This means we don't need to adjust keeper job. if (!isActive()) { return false; ...
34,908
31
// To donate to a campaign of a specific ID
function donateToCampaign(uint256 _id, bool _agree) public payable { uint256 amount = msg.value; // Get the campaign which the user is willing to fund. Campaign storage campaign = campaigns[_id]; // check if the campaign was successfully completed. require( camp...
function donateToCampaign(uint256 _id, bool _agree) public payable { uint256 amount = msg.value; // Get the campaign which the user is willing to fund. Campaign storage campaign = campaigns[_id]; // check if the campaign was successfully completed. require( camp...
16,576
103
// init internal variables at creation /
function init() public virtual { RATES = [ 1000000000000000000, 1000000000000000000000000000000, 1000000000000000000000000000000 ]; PRECISION_MUL = [1, 1000000000000, 1000000000000]; curveIndex[DAI_ADDRESS] = 1; // actual index is 1 less c...
function init() public virtual { RATES = [ 1000000000000000000, 1000000000000000000000000000000, 1000000000000000000000000000000 ]; PRECISION_MUL = [1, 1000000000000, 1000000000000]; curveIndex[DAI_ADDRESS] = 1; // actual index is 1 less c...
55,666
8
// public minting
function mint(uint16 mintAmount) external payable nonReentrant { uint16 available = unclaimed(msg.sender); uint16[] memory ids; uint16 i; uint256 stakeBalance; uint256 burnBalance; require(Address.isContract(msg.sender) == false, "Warrior: no contracts"); requir...
function mint(uint16 mintAmount) external payable nonReentrant { uint16 available = unclaimed(msg.sender); uint16[] memory ids; uint16 i; uint256 stakeBalance; uint256 burnBalance; require(Address.isContract(msg.sender) == false, "Warrior: no contracts"); requir...
30,068
33
// special case for equal weights
if (_sourceReserveWeight == _targetReserveWeight) return _targetReserveBalance.mul(_amount) / _sourceReserveBalance.add(_amount); uint256 result; uint8 precision; uint256 baseN = _sourceReserveBalance.add(_amount); (result, precision) = power(baseN, _sourceReserveBal...
if (_sourceReserveWeight == _targetReserveWeight) return _targetReserveBalance.mul(_amount) / _sourceReserveBalance.add(_amount); uint256 result; uint8 precision; uint256 baseN = _sourceReserveBalance.add(_amount); (result, precision) = power(baseN, _sourceReserveBal...
10,377
22
// Get sslp token for using in constructor /
function getSsLpToken(ITopDog _topDog, uint256 _topDogPoolId) private view returns (address) { (IERC20 _sslpToken,,,) = _topDog.poolInfo(_topDogPoolId); return address(_sslpToken); }
function getSsLpToken(ITopDog _topDog, uint256 _topDogPoolId) private view returns (address) { (IERC20 _sslpToken,,,) = _topDog.poolInfo(_topDogPoolId); return address(_sslpToken); }
24,509
103
// Returns sales info for an CSLCollectibles (ERC721) on sale. Fetches the details related to the Sale_tokenIdID of the token on sale /
function getSale(uint256 _tokenId) external view returns (address seller, uint256 startingPrice, uint256 endingPrice, uint256 duration, uint256 startedAt, uint256[9] tokenIds) { Sale memory sale = tokenIdToSale[_tokenId]; require(_isOnSale(sale)); return ( sale.seller, ...
function getSale(uint256 _tokenId) external view returns (address seller, uint256 startingPrice, uint256 endingPrice, uint256 duration, uint256 startedAt, uint256[9] tokenIds) { Sale memory sale = tokenIdToSale[_tokenId]; require(_isOnSale(sale)); return ( sale.seller, ...
54,813
6
// immutable variables, initialized here it to facilitate etherscan verification addresses are same on all networks
address payable immutable private UNISWAP_V3_NPM_ADDRESS = payable(address(0xC36442b4a4522E871399CD717aBDD847Ab11FE88)); bytes4 immutable private APPROVE_SELECTOR = bytes4(keccak256(bytes("approve(address,uint256)")));
address payable immutable private UNISWAP_V3_NPM_ADDRESS = payable(address(0xC36442b4a4522E871399CD717aBDD847Ab11FE88)); bytes4 immutable private APPROVE_SELECTOR = bytes4(keccak256(bytes("approve(address,uint256)")));
24,680
50
// End the offering
approve(tokenOfferingAddr, 0);
approve(tokenOfferingAddr, 0);
42,226
17
// The granularity of the redistribution is 0.001%. 100 000 = all the money
uint256 internal publisherCut; uint256 internal charityCut; uint256 internal thirdPartyCut; uint256 internal perpetualAltruismCut;
uint256 internal publisherCut; uint256 internal charityCut; uint256 internal thirdPartyCut; uint256 internal perpetualAltruismCut;
11,421
4
// [desc] Get policy brief info. [param] _key: policy key. [param] _addr: info address. [return] error code and info for json data. 0: success/
function _getBriefInfo(string _key, address _addr) private pure returns (int, string) { string memory str = "{\"Size\":2,"; string memory policy = "0x"; policy = policy.concat(_addr.addrToAsciiString()); str = str.concat(_key.toKeyValue("Key"), ","); str = str.concat(policy...
function _getBriefInfo(string _key, address _addr) private pure returns (int, string) { string memory str = "{\"Size\":2,"; string memory policy = "0x"; policy = policy.concat(_addr.addrToAsciiString()); str = str.concat(_key.toKeyValue("Key"), ","); str = str.concat(policy...
1,853
6
// A periodic contract. Enables any contract to change state on a periodic basis/
contract PeriodicStages is Ownable { using SafeMath for uint256; // Set of stages inside a Period Period public period; Stack public stack; /** * Constructor. Sets up a new period, initializes the offset. * @param _T Initial number of blocks for the period **/ constructor(uint256 ...
contract PeriodicStages is Ownable { using SafeMath for uint256; // Set of stages inside a Period Period public period; Stack public stack; /** * Constructor. Sets up a new period, initializes the offset. * @param _T Initial number of blocks for the period **/ constructor(uint256 ...
47,139
503
// variablereset the user stable rate, and store the new borrow index
user.stableBorrowRate = 0; user.lastVariableBorrowCumulativeIndex = reserve.lastVariableBorrowCumulativeIndex;
user.stableBorrowRate = 0; user.lastVariableBorrowCumulativeIndex = reserve.lastVariableBorrowCumulativeIndex;
16,378
24
// Transfer remaining to creator
if(forCreator > 0) IERC20(_ubi).transferFrom(_msgSender(), ownerOf(tokenId), forCreator); _addSupport(tokenId, ubiAmount, _msgSender());
if(forCreator > 0) IERC20(_ubi).transferFrom(_msgSender(), ownerOf(tokenId), forCreator); _addSupport(tokenId, ubiAmount, _msgSender());
39,032
24
// Event emitted when status of the currency is set
event CurrencySet(address currency, bool allowed);
event CurrencySet(address currency, bool allowed);
32,424
64
// check result against bet and pay if win
checkBetResult(wheelResult, gambles[gambleIndex[msg.sender]].betType); updateFirstActiveGamble();
checkBetResult(wheelResult, gambles[gambleIndex[msg.sender]].betType); updateFirstActiveGamble();
44,241
17
// Deposit collateral pool Pool address collateralAmount Amount of collateral to deposit pricePrice of the bucket /
function depositCollateral(IERC20Pool pool, uint256 collateralAmount, uint256 price) public payable { address collateralToken = pool.collateralAddress(); _pull(collateralToken, collateralAmount); uint256 index = convertPriceToIndex(price); IERC20(collateralToken).safeApprove(address...
function depositCollateral(IERC20Pool pool, uint256 collateralAmount, uint256 price) public payable { address collateralToken = pool.collateralAddress(); _pull(collateralToken, collateralAmount); uint256 index = convertPriceToIndex(price); IERC20(collateralToken).safeApprove(address...
33,312
24
// Select the k1-th and k2-th element from list of length at most 7 Uses an optimal sorting network /
function shortSelectTwo( int256[] memory list, uint256 lo, uint256 hi, uint256 k1, uint256 k2 ) private
function shortSelectTwo( int256[] memory list, uint256 lo, uint256 hi, uint256 k1, uint256 k2 ) private
22,447
70
// use token address 0xeee...eee for ethermakes a trade between Ether to token by tradingProxyIndextradingProxyIndex index of trading proxysrcAmount amount of source tokensdest Destination token return amount of actual destination tokens/
function _tradeEtherToToken( uint256 tradingProxyIndex, uint256 srcAmount, ERC20 dest ) private returns(uint256)
function _tradeEtherToToken( uint256 tradingProxyIndex, uint256 srcAmount, ERC20 dest ) private returns(uint256)
8,585
2
// array is created to store the student object
Student[] public student;
Student[] public student;
932
56
// if names already has been used, require that current msg sender owns the name
if (pIDxName_[_name] != 0) require(plyrNames_[_pID][_name] == true, "sorry that names already taken");
if (pIDxName_[_name] != 0) require(plyrNames_[_pID][_name] == true, "sorry that names already taken");
10,318
334
// ensure emergency exit is active
EmergencyExitStatus memory status = emergencyExitStatusOfVault[vault]; if (!status.activated) { revert Error_EmergencyExitNotActivated(); }
EmergencyExitStatus memory status = emergencyExitStatusOfVault[vault]; if (!status.activated) { revert Error_EmergencyExitNotActivated(); }
43,053
32
// default payable function executed after receiving ether /
function () public payable { // contract does not accept ether revert(); }
function () public payable { // contract does not accept ether revert(); }
57,289
2
// Try calling this function along with some ether. The balance of this contract will be automatically updated.
function deposit() public payable { emit Deposit(msg.sender, msg.value, address(this).balance); }
function deposit() public payable { emit Deposit(msg.sender, msg.value, address(this).balance); }
52,939
14
// returns leaf index upon successfull append
uint256 accID = accountsTree.appendDataBlock(_pubkey);
uint256 accID = accountsTree.appendDataBlock(_pubkey);
53,418
310
// ... we store the token that was stored for the last token
indices[index] = lastTokenAvailable;
indices[index] = lastTokenAvailable;
38,538
0
// State variable
string private _greeting = "Hello, World!"; address private _owner;
string private _greeting = "Hello, World!"; address private _owner;
30,776