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
104
// Returns the fee as a percentage with 2 decimals of percision
function getFee() external view returns (uint256) { return fee; }
function getFee() external view returns (uint256) { return fee; }
57,627
591
// Auto-generated via 'PrintLambertArray.py'
uint256[128] private lambertArray;
uint256[128] private lambertArray;
41,132
90
// Validates parameters and starts crowdsale
function start(uint256 _startTimestamp, uint256 _endTimestamp, address _fundingAddress) public onlyManager() hasntStarted() hasntStopped();
function start(uint256 _startTimestamp, uint256 _endTimestamp, address _fundingAddress) public onlyManager() hasntStarted() hasntStopped();
14,658
104
// add 1 to get the next payment
uint256 nNextUserPayment = nLastPayment.add(1);
uint256 nNextUserPayment = nLastPayment.add(1);
20,386
14
// Returns the integer division of two unsigned integers. Reverts with custom message ondivision by zero. The result is rounded towards zero. Counterpart to Solidity's `/` operator. Note: this function uses a`revert` opcode (which leaves remaining gas untouched) while Solidityuses an invalid opcode to revert (consuming all remaining gas). Requirements:- The divisor cannot be zero. _Available since v2.4.0._ /
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; }
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; }
938
104
// Applies `scalingFactor` to `amount`, resulting in a larger or equal value depending on whether it neededscaling or not. /
function _upscale(uint256 amount, uint256 scalingFactor) internal pure returns (uint256) { return GyroFixedPoint.mulDown(amount, scalingFactor); }
function _upscale(uint256 amount, uint256 scalingFactor) internal pure returns (uint256) { return GyroFixedPoint.mulDown(amount, scalingFactor); }
17,686
21
// Update admin fee Total fees cannot be greater than BIPS_DIVISOR (100%) newValue specified in BIPS /
function updateAdminFee(uint newValue) external onlyOwner { require(newValue.add(REINVEST_REWARD_BIPS) <= BIPS_DIVISOR, "admin fee too high"); emit UpdateAdminFee(ADMIN_FEE_BIPS, newValue); ADMIN_FEE_BIPS = newValue; }
function updateAdminFee(uint newValue) external onlyOwner { require(newValue.add(REINVEST_REWARD_BIPS) <= BIPS_DIVISOR, "admin fee too high"); emit UpdateAdminFee(ADMIN_FEE_BIPS, newValue); ADMIN_FEE_BIPS = newValue; }
5,498
215
// Set the entropy used to shuffle the token IDs. /
function setEntropy( uint256 _entropy
function setEntropy( uint256 _entropy
31,822
57
// Unfreeze the account _accounts Given accounts /
function unfreeze(address[] _accounts) public onlyOwnerOrManager { assert(phase_i != PHASE_NOT_STARTED && phase_i != PHASE_FINISHED); uint i; for (i = 0; i < _accounts.length; i++) { require(_accounts[i] != address(0), "Zero address"); require(_accounts[i] != base_wallet, "Freeze self"); } for (i = 0; i < _accounts.length; i++) { token.unfreeze(_accounts[i]); } }
function unfreeze(address[] _accounts) public onlyOwnerOrManager { assert(phase_i != PHASE_NOT_STARTED && phase_i != PHASE_FINISHED); uint i; for (i = 0; i < _accounts.length; i++) { require(_accounts[i] != address(0), "Zero address"); require(_accounts[i] != base_wallet, "Freeze self"); } for (i = 0; i < _accounts.length; i++) { token.unfreeze(_accounts[i]); } }
46,363
5
// ERC777MintFee Rafael Kallis <rk@rafaelkallis.com> /
contract ERC777MintFee is ERC777FeeIncome { using SafeMath for uint256; uint256 private _mintFee; constructor(uint256 mintFee) public { _mintFee = mintFee; } /** * @dev Returns the mint fee. */ function mintFee() public view returns (uint256) { return _mintFee; } /** * @dev Returns the mint fee relative to `mintAmount`. */ function mintFee(uint256 mintAmount) public view returns (uint256) { return mintAmount.mul(_mintFee).div(10 ** 18); } /** * @dev Charges `account` a mint-fee relative to `mintAmount`. * * @dev Usage example: * ``` * function mint(address account, uint256 amount) public { * super.mint(account, amount); * _chargeMintFee(msg.sender, amount); * } * ``` * * @param account The account to charge. * @param mintAmount The amount to be minted. */ function _chargeMintFee(address account, uint256 mintAmount) internal { _chargeFee(account, mintFee(mintAmount)); } }
contract ERC777MintFee is ERC777FeeIncome { using SafeMath for uint256; uint256 private _mintFee; constructor(uint256 mintFee) public { _mintFee = mintFee; } /** * @dev Returns the mint fee. */ function mintFee() public view returns (uint256) { return _mintFee; } /** * @dev Returns the mint fee relative to `mintAmount`. */ function mintFee(uint256 mintAmount) public view returns (uint256) { return mintAmount.mul(_mintFee).div(10 ** 18); } /** * @dev Charges `account` a mint-fee relative to `mintAmount`. * * @dev Usage example: * ``` * function mint(address account, uint256 amount) public { * super.mint(account, amount); * _chargeMintFee(msg.sender, amount); * } * ``` * * @param account The account to charge. * @param mintAmount The amount to be minted. */ function _chargeMintFee(address account, uint256 mintAmount) internal { _chargeFee(account, mintFee(mintAmount)); } }
34,857
14
// require(amount>=1e18,"vote amount should large than 1");
BXH.safeTransferFrom(msg.sender,address(this),amount); if(userPhaseVotes[msg.sender][_phaseId]==0){ phases[_phaseId].totalAddrCount = phases[_phaseId].totalAddrCount.add(1); projectVotes[_phaseId][_projectAddr].addressCount = projectVotes[_phaseId][_projectAddr].addressCount.add(1); }
BXH.safeTransferFrom(msg.sender,address(this),amount); if(userPhaseVotes[msg.sender][_phaseId]==0){ phases[_phaseId].totalAddrCount = phases[_phaseId].totalAddrCount.add(1); projectVotes[_phaseId][_projectAddr].addressCount = projectVotes[_phaseId][_projectAddr].addressCount.add(1); }
22,190
305
// Set some tokens aside. /
function reserveTokens(uint256 number) public onlyOwner { require( totalSupply().add(number) <= MAX_TOKENS, 'Reservation would exceed max supply' ); uint256 supply = totalSupply(); uint256 i; for (i = 0; i < number; i++) { _safeMint(msg.sender, supply + i); } }
function reserveTokens(uint256 number) public onlyOwner { require( totalSupply().add(number) <= MAX_TOKENS, 'Reservation would exceed max supply' ); uint256 supply = totalSupply(); uint256 i; for (i = 0; i < number; i++) { _safeMint(msg.sender, supply + i); } }
11,738
5
// Łukasiewicz logic values
enum TriState { Unset, Allow, Deny }
enum TriState { Unset, Allow, Deny }
21,643
10
// allow dev to choose for isOptional the user is ask to choose isSelectableByUser to avoid the function signature collision between build(AuthType authType, bool isOptional) and build(AuthType authType, bool isAnon)
function build( AuthType authType, bool isOptional, bool isSelectableByUser
function build( AuthType authType, bool isOptional, bool isSelectableByUser
1,182
13
// a utilitary that removes by value from an array target - targeted array value - value that needs to be removedreturn new array without the value /
function removeByValue(uint256[] memory target, uint256 value) internal pure returns (uint256[] memory) { uint256[] memory newTarget = new uint256[](target.length - 1); uint256 k = 0; unchecked { for (uint256 j; j < target.length; j++) { if (target[j] == value) continue; newTarget[k++] = target[j]; } } return newTarget; }
function removeByValue(uint256[] memory target, uint256 value) internal pure returns (uint256[] memory) { uint256[] memory newTarget = new uint256[](target.length - 1); uint256 k = 0; unchecked { for (uint256 j; j < target.length; j++) { if (target[j] == value) continue; newTarget[k++] = target[j]; } } return newTarget; }
22,486
5
// id serial starts at
uint256 firstReservedToken;
uint256 firstReservedToken;
15,118
405
// cancels a withdrawal request requirements: - the caller must be the network contract- the provider must have already initiated a withdrawal and received the specified id /
function cancelWithdrawal(address provider, uint256 id) external;
function cancelWithdrawal(address provider, uint256 id) external;
66,171
75
// Called by the delegator on a delegate to initialize it for duty Should revert if any issues arise which make it unfit for delegation data The encoded bytes data for any initialization /
function _becomeImplementation(bytes memory data) public;
function _becomeImplementation(bytes memory data) public;
36,993
148
// Holder count simply returns the total number of token holder addresses. /
function holderCount() public view returns (uint) { return shareholders.length; }
function holderCount() public view returns (uint) { return shareholders.length; }
68,300
28
// Address blacklisted check. Function to check address whether get blacklisted, Only callable by contract owner. addr The address that will check whether get blacklisted /
function getBlacklist(address addr) public onlyGuardian view returns(bool) { return isBlackListed[addr]; }
function getBlacklist(address addr) public onlyGuardian view returns(bool) { return isBlackListed[addr]; }
21,564
476
// BootySendFailed event. Emitted every time address.send() function failed to transfer Ether to recipient in this case recipient Ether is recorded to ownerToBooty mapping, so recipient can withdraw their booty manuallyrecipient address for whom send failedamount number of WEI we failed to send /
event BootySendFailed(address recipient, uint256 amount);
event BootySendFailed(address recipient, uint256 amount);
24,205
27
// require(nftAddress.exists(_tokenId));
address tokenSeller = nftAddress.ownerOf(_tokenId); nftAddress.safeTransferFrom(tokenSeller, msg.sender, _tokenId); emit Received(msg.sender, _tokenId, msg.value, address(this).balance);
address tokenSeller = nftAddress.ownerOf(_tokenId); nftAddress.safeTransferFrom(tokenSeller, msg.sender, _tokenId); emit Received(msg.sender, _tokenId, msg.value, address(this).balance);
75,745
48
// case 2.
msg.sender == address(_currentTerminal) ||
msg.sender == address(_currentTerminal) ||
28,271
197
// |/ Mint _amount of tokens of a given id _toThe address to mint tokens to _idToken id to mint _amountThe amount to be minted _dataData to pass if receiver is contract /
function _mint(address _to, uint256 _id, uint256 _amount, bytes memory _data) internal
function _mint(address _to, uint256 _id, uint256 _amount, bytes memory _data) internal
9,694
155
// max 30% so it is always sellable with 49% slippage on Uniswap
if(sellFee >= 3000) { sellFee = 3000; }
if(sellFee >= 3000) { sellFee = 3000; }
10,299
12
// properties for each token
function svgForToken(uint256 tokenId_) public view returns (string memory)
function svgForToken(uint256 tokenId_) public view returns (string memory)
2,306
50
// Stores a new address in the EIP1967 admin slot. /
function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin; }
function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin; }
993
176
// set copyright info
uint256 copyrightLen = _copyrightInfos.length; require(copyrightLen <= 1, "ERC721Base: the length of copyrights must be <= 1"); if (copyrightLen == 1) { require(_copyrightInfos[0].author != address(0), "ERC721Base: the author in copyright can't be zero" ); require(_copyrightInfos[0].feeRateNumerator <= feeRateDenominator, "ERC721Base: the feeRate in copyright must be <= 1" );
uint256 copyrightLen = _copyrightInfos.length; require(copyrightLen <= 1, "ERC721Base: the length of copyrights must be <= 1"); if (copyrightLen == 1) { require(_copyrightInfos[0].author != address(0), "ERC721Base: the author in copyright can't be zero" ); require(_copyrightInfos[0].feeRateNumerator <= feeRateDenominator, "ERC721Base: the feeRate in copyright must be <= 1" );
7,906
19
// Change Governance of the contract to a new account (`newGovernor`). _newGovernor Address of the new Governor /
function _changeGovernor(address _newGovernor) internal { require(_newGovernor != address(0), "New Governor is address(0)"); emit GovernorshipTransferred(_governor(), _newGovernor); _setGovernor(_newGovernor); }
function _changeGovernor(address _newGovernor) internal { require(_newGovernor != address(0), "New Governor is address(0)"); emit GovernorshipTransferred(_governor(), _newGovernor); _setGovernor(_newGovernor); }
28,302
5
// This is a function that if called will toggle the circuit breaker and halt entire contract from progressing. Only admin can call this function.
function toggleCircuitBreaker() external onlyAdmin() { isStopped = !isStopped; }
function toggleCircuitBreaker() external onlyAdmin() { isStopped = !isStopped; }
8,088
12
// maps branch with id to check for duplicacy
mapping(string => mapping(uint128 => bool)) checkSubInBranch;
mapping(string => mapping(uint128 => bool)) checkSubInBranch;
24,558
139
// Returns the balance amount of the Contract address./
function getBalanceOfContract() external view returns (uint256) { return address(this).balance; }
function getBalanceOfContract() external view returns (uint256) { return address(this).balance; }
28,849
25
// Subtract from the sender
balanceOf[_from] -= _value;
balanceOf[_from] -= _value;
5,976
134
// Determine the prior number of votes for an account as of a block number Block number must be a finalized block or else this function will revert to prevent misinformation. account The address of the account to check blockNumber The block number to get the vote balance atreturn The number of votes the account had as of the given block /
function getPriorVotes(address account, uint256 blockNumber) public view returns (uint256)
function getPriorVotes(address account, uint256 blockNumber) public view returns (uint256)
22,081
28
// ERC223 fallback function, make sure to check the msg.sender is from target token contracts _from - person who transfer token in for deposits or claim deposit with penalty KTON. _amount - amount of token. _data - data which indicate the operations. /
function tokenFallback( address _from, uint256 _amount, bytes _data
function tokenFallback( address _from, uint256 _amount, bytes _data
67,704
274
// Emits a {ClaimPaused} event. /
function setClaimPaused(bool state) public onlyOwner { _claimPaused = state; emit ClaimPaused(state); }
function setClaimPaused(bool state) public onlyOwner { _claimPaused = state; emit ClaimPaused(state); }
7,447
392
// Enables a bitmap type portfolio for an account. A bitmap type portfolio allows/ an account to hold more fCash than a normal portfolio, except only in a single currency./ Once enabled, it cannot be disabled or changed. An account can only enable a bitmap if/ it has no assets or debt so that we ensure no assets are left stranded./accountContext refers to the account where the bitmap will be enabled/currencyId the id of the currency to enable/blockTime the current block time to set the next settle time
function enableBitmapForAccount( AccountContext memory accountContext, uint16 currencyId, uint256 blockTime
function enableBitmapForAccount( AccountContext memory accountContext, uint16 currencyId, uint256 blockTime
35,510
497
// Performs a deep copy of a byte array onto another byte array of greater than or equal length./dest Byte array that will be overwritten with source bytes./source Byte array to copy onto dest bytes.
function deepCopyBytes(bytes memory dest, bytes memory source) internal pure { uint256 sourceLen = source.length; // Dest length must be >= source length, or some bytes would not be copied. require(dest.length >= sourceLen, "GREATER_OR_EQUAL_TO_SOURCE_BYTES_LENGTH_REQUIRED"); memCopy(dest.contentAddress(), source.contentAddress(), sourceLen); }
function deepCopyBytes(bytes memory dest, bytes memory source) internal pure { uint256 sourceLen = source.length; // Dest length must be >= source length, or some bytes would not be copied. require(dest.length >= sourceLen, "GREATER_OR_EQUAL_TO_SOURCE_BYTES_LENGTH_REQUIRED"); memCopy(dest.contentAddress(), source.contentAddress(), sourceLen); }
8,082
181
// Bools
bool public paused = true; bool public revealed = false; bool public onlyWhitelisted = true;
bool public paused = true; bool public revealed = false; bool public onlyWhitelisted = true;
20,368
63
// price in ICO: first week: 1 ETH = 2400 NAC second week: 1 ETH = 23000 NAC 3rd week: 1 ETH = 2200 NAC 4th week: 1 ETH = 2100 NAC 5th week: 1 ETH = 2000 NAC 6th week: 1 ETH = 1900 NAC 7th week: 1 ETH = 1800 NAC 8th week: 1 ETH = 1700 nac time:1517443200: Thursday, February 1, 2018 12:00:00 AM 1518048000: Thursday, February 8, 2018 12:00:00 AM 1518652800: Thursday, February 15, 2018 12:00:00 AM 1519257600: Thursday, February 22, 2018 12:00:00 AM 1519862400: Thursday, March 1, 2018 12:00:00 AM 1520467200: Thursday, March 8, 2018 12:00:00
function getPrice() public view returns (uint price) { if (now < 1517443200) { // presale return 3450; } else if (1517443200 < now && now <= 1518048000) { // 1st week return 2400; } else if (1518048000 < now && now <= 1518652800) { // 2nd week return 2300; } else if (1518652800 < now && now <= 1519257600) { // 3rd week return 2200; } else if (1519257600 < now && now <= 1519862400) { // 4th week return 2100; } else if (1519862400 < now && now <= 1520467200) { // 5th week return 2000; } else if (1520467200 < now && now <= 1521072000) { // 6th week return 1900; } else if (1521072000 < now && now <= 1521676800) { // 7th week return 1800; } else if (1521676800 < now && now <= 1522281600) { // 8th week return 1700; } else { return binary; } }
function getPrice() public view returns (uint price) { if (now < 1517443200) { // presale return 3450; } else if (1517443200 < now && now <= 1518048000) { // 1st week return 2400; } else if (1518048000 < now && now <= 1518652800) { // 2nd week return 2300; } else if (1518652800 < now && now <= 1519257600) { // 3rd week return 2200; } else if (1519257600 < now && now <= 1519862400) { // 4th week return 2100; } else if (1519862400 < now && now <= 1520467200) { // 5th week return 2000; } else if (1520467200 < now && now <= 1521072000) { // 6th week return 1900; } else if (1521072000 < now && now <= 1521676800) { // 7th week return 1800; } else if (1521676800 < now && now <= 1522281600) { // 8th week return 1700; } else { return binary; } }
25,513
36
// delete liquidation
delete auctions_.liquidations[borrower_];
delete auctions_.liquidations[borrower_];
40,280
5
// amount must be non zero
require(_bsnAmount > 0, "Invalid amount"); dripSchedule = BSNSchedule({ start: _bsnDripStart, end: _bsnDripEnd, amount: _bsnAmount });
require(_bsnAmount > 0, "Invalid amount"); dripSchedule = BSNSchedule({ start: _bsnDripStart, end: _bsnDripEnd, amount: _bsnAmount });
35,470
70
// Setup behavior check
bool result = false;
bool result = false;
17,314
63
// Update last bid time
loan.lastBidTime = block.timestamp;
loan.lastBidTime = block.timestamp;
8,941
1
// Function to calculate the interest accumulated using a linear interest rate formula rate The interest rate, in ray lastUpdateTimestamp The timestamp of the last update of the interestreturn The interest rate linearly accumulated during the timeDelta, in ray /solium-disable-next-line
uint256 timeDifference = block.timestamp.sub(uint256(lastUpdateTimestamp)); return (rate.mul(timeDifference) / SECONDS_PER_YEAR).add(WadRayMath.ray());
uint256 timeDifference = block.timestamp.sub(uint256(lastUpdateTimestamp)); return (rate.mul(timeDifference) / SECONDS_PER_YEAR).add(WadRayMath.ray());
40,922
214
// quietEndingPeriod
if (proposal.state != ProposalState.QuietEndingPeriod) { proposal.currentBoostedVotePeriodLimit = params.quietEndingPeriod; proposal.state = ProposalState.QuietEndingPeriod; }
if (proposal.state != ProposalState.QuietEndingPeriod) { proposal.currentBoostedVotePeriodLimit = params.quietEndingPeriod; proposal.state = ProposalState.QuietEndingPeriod; }
23,489
26
// called after deployment so that the contract whitelist addresses can mint in low price addressesToAdd the address of the Shelter /
function addToWhitelist(address[] calldata addressesToAdd) public onlyOwner
function addToWhitelist(address[] calldata addressesToAdd) public onlyOwner
65,598
0
// This is the max mint batch size for the optimized ERC721ACH mint contract
uint256 internal constant MAX_MINT_BATCH_SIZE = 8;
uint256 internal constant MAX_MINT_BATCH_SIZE = 8;
17,200
46
// Weeks in UTC
uint public StageTwo; uint public StageThree; uint public StageFour;
uint public StageTwo; uint public StageThree; uint public StageFour;
47,736
341
// redeemCollateralFresh emits redeem-collaterals-specific logs on errors, so we don't need to
return redeemCollateralFresh(msg.sender, redeemAmount);
return redeemCollateralFresh(msg.sender, redeemAmount);
35,327
68
// multiplier duplicated from QuestManager
uint8 questMultiplier;
uint8 questMultiplier;
13,638
6
// Constructor function /
constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721_METADATA); }
constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721_METADATA); }
2,897
27
// Updates the boost for a given address, after the rest of the function has executed /
modifier updateBoost(address _account) { _; _setBoost(_account); }
modifier updateBoost(address _account) { _; _setBoost(_account); }
40,919
1
// ERC20 wallet = new ERC20(owner, address(store));
ERC20 wallet = new ERC20("t", "t"); wallets[msg.sender].push(address(wallet)); walletToOwner[address(wallet)] = msg.sender; numWallets++;
ERC20 wallet = new ERC20("t", "t"); wallets[msg.sender].push(address(wallet)); walletToOwner[address(wallet)] = msg.sender; numWallets++;
17,773
60
// The possible vote types. Abstention: not participating in a motion; This is the default value. Yea: voting in favour of a motion. Nay: voting against a motion.
enum Vote {Abstention, Yea, Nay} // A given account&#39;s vote in some confiscation motion. // This requires the default value of the Vote enum to correspond to an abstention. mapping(address => mapping(uint => Vote)) public vote; /* ========== CONSTRUCTOR ========== */ function Court(Havven _havven, EtherNomin _nomin, address _owner) Owned(_owner) public { havven = _havven; nomin = _nomin; }
enum Vote {Abstention, Yea, Nay} // A given account&#39;s vote in some confiscation motion. // This requires the default value of the Vote enum to correspond to an abstention. mapping(address => mapping(uint => Vote)) public vote; /* ========== CONSTRUCTOR ========== */ function Court(Havven _havven, EtherNomin _nomin, address _owner) Owned(_owner) public { havven = _havven; nomin = _nomin; }
571
17
// commit to storage
_hypervisor.stakingToken = stakingToken; _hypervisor.rewardToken = rewardToken; _hypervisor.rewardPool = rewardPool; _hypervisor.rewardScaling = rewardScaling; stakeLimit = _stakeLimit;
_hypervisor.stakingToken = stakingToken; _hypervisor.rewardToken = rewardToken; _hypervisor.rewardPool = rewardPool; _hypervisor.rewardScaling = rewardScaling; stakeLimit = _stakeLimit;
11,557
96
// 获取用户轮数
function getUserRounds( uint256 ledgerType, address user, uint256 cursor, uint256 size
function getUserRounds( uint256 ledgerType, address user, uint256 cursor, uint256 size
26,705
2
// a key-value pair to store addresses and their account balances
event Transfer(address _from, address _to, uint256 _value);
event Transfer(address _from, address _to, uint256 _value);
14,229
5
// 50% get a kind response to greeting
answer = AnswerType.Kind;
answer = AnswerType.Kind;
43,782
133
// we get lp tokens
require(pair.totalSupply() == 0, "Somehow total supply is higher, sanity fail"); pair.mint(address(this)); require(pair.totalSupply() > 0, "We didn't create tokens!"); totalLPCreated = pair.balanceOf(address(this)); LPPerCOREUnitContributed = totalLPCreated.mul(1e18).div(totalCOREUnitsContributed); // Stored as 1e18 more for round erorrs and change require(LPPerCOREUnitContributed > 0, "LP Per Unit Contribute Must be above Zero"); require(totalLPCreated >= 27379e18, "Didn't create enough lp");
require(pair.totalSupply() == 0, "Somehow total supply is higher, sanity fail"); pair.mint(address(this)); require(pair.totalSupply() > 0, "We didn't create tokens!"); totalLPCreated = pair.balanceOf(address(this)); LPPerCOREUnitContributed = totalLPCreated.mul(1e18).div(totalCOREUnitsContributed); // Stored as 1e18 more for round erorrs and change require(LPPerCOREUnitContributed > 0, "LP Per Unit Contribute Must be above Zero"); require(totalLPCreated >= 27379e18, "Didn't create enough lp");
45,557
44
// swapTarget => approval status
mapping(address => bool) public approvedTargets; address internal constant ETHAddress = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
mapping(address => bool) public approvedTargets; address internal constant ETHAddress = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
63,425
104
// Wallet where funds will be sent
address public wallet; MintableToken public token; DisbursementHandler public disbursementHandler; function Sale( address _wallet, uint256 _contributionCap )
address public wallet; MintableToken public token; DisbursementHandler public disbursementHandler; function Sale( address _wallet, uint256 _contributionCap )
27,154
507
// Valuate the debt amount in loanManagerToken
uint256 obligationTokens = _toToken(_debtId, obligation, _oracleData);
uint256 obligationTokens = _toToken(_debtId, obligation, _oracleData);
25,739
8
// transfer the balance to the winner
winnerAddress.transfer(address(this).balance);
winnerAddress.transfer(address(this).balance);
7,398
64
// convert to ETH
swapTokensForETH(balanceOf(address(this))); return amount.sub(feeAmount);
swapTokensForETH(balanceOf(address(this))); return amount.sub(feeAmount);
15,271
39
// check if SM active
if (shieldMining.getShieldTokenAddress(address(policyBook)) != address(0)) { shieldMining.updateTotalSupply(address(policyBook), address(0), liquidityProvider); }
if (shieldMining.getShieldTokenAddress(address(policyBook)) != address(0)) { shieldMining.updateTotalSupply(address(policyBook), address(0), liquidityProvider); }
24,352
14
// pause or restart the circulaton
function pause() public onlyManager() { paused = !paused; }
function pause() public onlyManager() { paused = !paused; }
28,756
1
// The instance of the refund safe which holds all ETH funds until the fundraiser/ is finalized.
RefundSafe public refundSafe;
RefundSafe public refundSafe;
24,354
1
// Address where funds are collected
address public wallet;
address public wallet;
4,035
14
// OWNER DATA
address public owner; address public proposedOwner;
address public owner; address public proposedOwner;
21,059
81
// Use updated allowance if token and paymentToken are the same
Allowance memory paymentAllowance = paymentToken == token ? allowance : getAllowance(address(safe), delegate, paymentToken); newSpent = paymentAllowance.spent + payment;
Allowance memory paymentAllowance = paymentToken == token ? allowance : getAllowance(address(safe), delegate, paymentToken); newSpent = paymentAllowance.spent + payment;
5,797
192
// Check that the system will allow for the specified amount to be minted.
_checkMintingLimit(amount);
_checkMintingLimit(amount);
15,233
4
// Add a value to set. O(1). Returns true if the value was added to the set, that is if it was notalready present. /
function insert(Map storage map, address account) internal returns (bool) { if (!contains(map, account)) { map._accounts.push(account); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value map._indexes[account] = map._accounts.length; return true; } else { return false; } }
function insert(Map storage map, address account) internal returns (bool) { if (!contains(map, account)) { map._accounts.push(account); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value map._indexes[account] = map._accounts.length; return true; } else { return false; } }
27,695
449
// approve cDai to compound contract
cDaiContract.approve(NEW_CDAI_ADDRESS, uint(-1));
cDaiContract.approve(NEW_CDAI_ADDRESS, uint(-1));
55,052
9
// now we can save proposal
blocks[blockHeight].uniqueBlindedProposals[_blindedProposal] = true; voter.blindedProposal = _blindedProposal; voter.shard = shard; voter.balance = balance; emit LogPropose(msg.sender, blockHeight, _blindedProposal, shard, balance); return true;
blocks[blockHeight].uniqueBlindedProposals[_blindedProposal] = true; voter.blindedProposal = _blindedProposal; voter.shard = shard; voter.balance = balance; emit LogPropose(msg.sender, blockHeight, _blindedProposal, shard, balance); return true;
11,679
2
// A contract for managing the creation of new fundraising projects/Nathan Thomas/This contract is not audited - use at your own risk
contract Manager is Ownable { Project[] public projects; mapping(address => uint256[]) public ownerToProjects; event ProjectCreated( address indexed creator, address indexed projectAddress, uint256 indexed projectIndex ); /// @notice Creates a new fundraising project with ownership of the msg.sender /// @param _name The name of the new fundraising project /// @param _description The description of the new fundraising project /// @param _fundraisingGoal The total ether goal of the new fundraising project /// @dev The event or the tracking variables can be used to get the new project /// address when it's created function createNewProject( string calldata _name, string calldata _description, string calldata _tokenSymbol, uint256 _fundraisingGoal ) external { Project newProject = new Project( _name, _description, _tokenSymbol, _fundraisingGoal, msg.sender ); uint256 newProjectIndex = projects.length; ownerToProjects[msg.sender].push(newProjectIndex); projects.push(newProject); emit ProjectCreated(msg.sender, address(newProject), newProjectIndex); } }
contract Manager is Ownable { Project[] public projects; mapping(address => uint256[]) public ownerToProjects; event ProjectCreated( address indexed creator, address indexed projectAddress, uint256 indexed projectIndex ); /// @notice Creates a new fundraising project with ownership of the msg.sender /// @param _name The name of the new fundraising project /// @param _description The description of the new fundraising project /// @param _fundraisingGoal The total ether goal of the new fundraising project /// @dev The event or the tracking variables can be used to get the new project /// address when it's created function createNewProject( string calldata _name, string calldata _description, string calldata _tokenSymbol, uint256 _fundraisingGoal ) external { Project newProject = new Project( _name, _description, _tokenSymbol, _fundraisingGoal, msg.sender ); uint256 newProjectIndex = projects.length; ownerToProjects[msg.sender].push(newProjectIndex); projects.push(newProject); emit ProjectCreated(msg.sender, address(newProject), newProjectIndex); } }
19,998
10
// This method relies on extcodesize, which returns 0 for contracts in construction, since the code is only stored at the end of the constructor execution.
uint256 size;
uint256 size;
385
43
// _tokenIds - 1 to get the current number of minted tokens (token IDs start at 1)
uint256 currentSupply = _tokenIds.current() - 1; config.doubleBurnTokens = derivativeParams.maxTotalSupply - currentSupply; require(config.doubleBurnTokens >= amount, "SP:NOT_ENOUGH_ORPHANS"); require(currentSupply + amount <= params.maxTotalSupply, "NilPass:MAX_ALLOCATION_REACHED"); for (uint256 i = 0; i < amount; i++) { uint256 tokenId = _tokenIds.current(); require(tokenId <= params.maxTotalSupply, "SP:TOKEN_TOO_HIGH");
uint256 currentSupply = _tokenIds.current() - 1; config.doubleBurnTokens = derivativeParams.maxTotalSupply - currentSupply; require(config.doubleBurnTokens >= amount, "SP:NOT_ENOUGH_ORPHANS"); require(currentSupply + amount <= params.maxTotalSupply, "NilPass:MAX_ALLOCATION_REACHED"); for (uint256 i = 0; i < amount; i++) { uint256 tokenId = _tokenIds.current(); require(tokenId <= params.maxTotalSupply, "SP:TOKEN_TOO_HIGH");
5,527
280
// Transfers ownership of the contract to a new account (`newOwner`).Can only be called by the current owner. /
function transferOwnership(address newOwner) public only(DEFAULT_ADMIN_ROLE) { _transferOwnership(newOwner); }
function transferOwnership(address newOwner) public only(DEFAULT_ADMIN_ROLE) { _transferOwnership(newOwner); }
3,503
79
// The SOCX token
contract Token is ERC20, Ownable { using SafeMath for uint; // Public variables of the token string public name; string public symbol; uint8 public decimals; // How many decimals to show. string public version = "v0.1"; uint public initialSupply; uint public totalSupply; bool public locked; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; address public migrationMaster; address public migrationAgent; address public crowdSaleAddress; uint256 public totalMigrated; // Lock transfer for contributors during the ICO modifier onlyUnlocked() { if (msg.sender != crowdSaleAddress && locked) revert(); _; } modifier onlyAuthorized() { if (msg.sender != owner && msg.sender != crowdSaleAddress) revert(); _; } // The SOCX Token created with the time at which the crowdsale ends function Token(address _crowdSaleAddress, address _migrationMaster) public { // Lock the transfCrowdsaleer function during the crowdsale locked = true; // Lock the transfer of tokens during the crowdsale initialSupply = 90000000e8; totalSupply = initialSupply; name = "SocialX"; // Set the name for display purposes symbol = "SOCX"; // Set the symbol for display purposes decimals = 8; // Amount of decimals for display purposes crowdSaleAddress = _crowdSaleAddress; balances[crowdSaleAddress] = totalSupply; migrationMaster = _migrationMaster; } function unlock() public onlyAuthorized { locked = false; } function lock() public onlyAuthorized { locked = true; } event Migrate(address indexed _from, address indexed _to, uint256 _value); // Token migration support: /// @notice Migrate tokens to the new token contract. /// @dev Required state: Operational Migration /// @param _value The amount of token to be migrated function migrate(uint256 _value) external onlyUnlocked() { // Abort if not in Operational Migration state. if (migrationAgent == 0) revert(); // Validate input value. if (_value == 0) revert(); if (_value > balances[msg.sender]) revert(); balances[msg.sender] -= _value; totalSupply -= _value; totalMigrated += _value; MigrationAgent(migrationAgent).migrateFrom(msg.sender, _value); Migrate(msg.sender, migrationAgent, _value); } /// @notice Set address of migration target contract and enable migration /// process. /// @dev Required state: Operational Normal /// @dev State transition: -> Operational Migration /// @param _agent The address of the MigrationAgent contract function setMigrationAgent(address _agent) external onlyUnlocked() { // Abort if not in Operational Normal state. require(migrationAgent == 0); require(msg.sender == migrationMaster); migrationAgent = _agent; } function resetCrowdSaleAddress(address _newCrowdSaleAddress) external onlyAuthorized() { crowdSaleAddress = _newCrowdSaleAddress; } function setMigrationMaster(address _master) external { require(msg.sender == migrationMaster); require(_master != 0); migrationMaster = _master; } // @notice burn tokens in case campaign failed // @param _member {address} of member // @param _value {uint} amount of tokens to burn // @return {bool} true if successful function burn( address _member, uint256 _value) public onlyAuthorized returns(bool) { balances[_member] = balances[_member].sub(_value); totalSupply = totalSupply.sub(_value); Transfer(_member, 0x0, _value); return true; } // @notice transfer tokens to given address // @param _to {address} address or recipient // @param _value {uint} amount to transfer // @return {bool} true if successful function transfer(address _to, uint _value) public onlyUnlocked returns(bool) { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } // @notice transfer tokens from given address to another address // @param _from {address} from whom tokens are transferred // @param _to {address} to whom tokens are transferred // @parm _value {uint} amount of tokens to transfer // @return {bool} true if successful function transferFrom(address _from, address _to, uint256 _value) public onlyUnlocked returns(bool success) { require(balances[_from] >= _value); // Check if the sender has enough require(_value <= allowed[_from][msg.sender]); // Check if allowed is greater or equal balances[_from] = balances[_from].sub(_value); // Subtract from the sender balances[_to] = balances[_to].add(_value); // Add the same to the recipient allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } // @notice to query balance of account // @return _owner {address} address of user to query balance function balanceOf(address _owner) public view returns(uint balance) { return balances[_owner]; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint _value) public returns(bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } // @notice to query of allowance of one user to the other // @param _owner {address} of the owner of the account // @param _spender {address} of the spender of the account // @return remaining {uint} amount of remaining allowance function allowance(address _owner, address _spender) public view returns(uint remaining) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */ function increaseApproval (address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval (address _spender, uint _subtractedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
contract Token is ERC20, Ownable { using SafeMath for uint; // Public variables of the token string public name; string public symbol; uint8 public decimals; // How many decimals to show. string public version = "v0.1"; uint public initialSupply; uint public totalSupply; bool public locked; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; address public migrationMaster; address public migrationAgent; address public crowdSaleAddress; uint256 public totalMigrated; // Lock transfer for contributors during the ICO modifier onlyUnlocked() { if (msg.sender != crowdSaleAddress && locked) revert(); _; } modifier onlyAuthorized() { if (msg.sender != owner && msg.sender != crowdSaleAddress) revert(); _; } // The SOCX Token created with the time at which the crowdsale ends function Token(address _crowdSaleAddress, address _migrationMaster) public { // Lock the transfCrowdsaleer function during the crowdsale locked = true; // Lock the transfer of tokens during the crowdsale initialSupply = 90000000e8; totalSupply = initialSupply; name = "SocialX"; // Set the name for display purposes symbol = "SOCX"; // Set the symbol for display purposes decimals = 8; // Amount of decimals for display purposes crowdSaleAddress = _crowdSaleAddress; balances[crowdSaleAddress] = totalSupply; migrationMaster = _migrationMaster; } function unlock() public onlyAuthorized { locked = false; } function lock() public onlyAuthorized { locked = true; } event Migrate(address indexed _from, address indexed _to, uint256 _value); // Token migration support: /// @notice Migrate tokens to the new token contract. /// @dev Required state: Operational Migration /// @param _value The amount of token to be migrated function migrate(uint256 _value) external onlyUnlocked() { // Abort if not in Operational Migration state. if (migrationAgent == 0) revert(); // Validate input value. if (_value == 0) revert(); if (_value > balances[msg.sender]) revert(); balances[msg.sender] -= _value; totalSupply -= _value; totalMigrated += _value; MigrationAgent(migrationAgent).migrateFrom(msg.sender, _value); Migrate(msg.sender, migrationAgent, _value); } /// @notice Set address of migration target contract and enable migration /// process. /// @dev Required state: Operational Normal /// @dev State transition: -> Operational Migration /// @param _agent The address of the MigrationAgent contract function setMigrationAgent(address _agent) external onlyUnlocked() { // Abort if not in Operational Normal state. require(migrationAgent == 0); require(msg.sender == migrationMaster); migrationAgent = _agent; } function resetCrowdSaleAddress(address _newCrowdSaleAddress) external onlyAuthorized() { crowdSaleAddress = _newCrowdSaleAddress; } function setMigrationMaster(address _master) external { require(msg.sender == migrationMaster); require(_master != 0); migrationMaster = _master; } // @notice burn tokens in case campaign failed // @param _member {address} of member // @param _value {uint} amount of tokens to burn // @return {bool} true if successful function burn( address _member, uint256 _value) public onlyAuthorized returns(bool) { balances[_member] = balances[_member].sub(_value); totalSupply = totalSupply.sub(_value); Transfer(_member, 0x0, _value); return true; } // @notice transfer tokens to given address // @param _to {address} address or recipient // @param _value {uint} amount to transfer // @return {bool} true if successful function transfer(address _to, uint _value) public onlyUnlocked returns(bool) { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } // @notice transfer tokens from given address to another address // @param _from {address} from whom tokens are transferred // @param _to {address} to whom tokens are transferred // @parm _value {uint} amount of tokens to transfer // @return {bool} true if successful function transferFrom(address _from, address _to, uint256 _value) public onlyUnlocked returns(bool success) { require(balances[_from] >= _value); // Check if the sender has enough require(_value <= allowed[_from][msg.sender]); // Check if allowed is greater or equal balances[_from] = balances[_from].sub(_value); // Subtract from the sender balances[_to] = balances[_to].add(_value); // Add the same to the recipient allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } // @notice to query balance of account // @return _owner {address} address of user to query balance function balanceOf(address _owner) public view returns(uint balance) { return balances[_owner]; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint _value) public returns(bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } // @notice to query of allowance of one user to the other // @param _owner {address} of the owner of the account // @param _spender {address} of the spender of the account // @return remaining {uint} amount of remaining allowance function allowance(address _owner, address _spender) public view returns(uint remaining) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */ function increaseApproval (address _spender, uint _addedValue) public returns (bool success) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval (address _spender, uint _subtractedValue) public returns (bool success) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
48,068
14
// Returns the number of decimals used to represent fees /
function feeDecimals() external override view returns (uint8) { return _feeDecimals; }
function feeDecimals() external override view returns (uint8) { return _feeDecimals; }
56,924
2
// ERC20Basic.sol // ERC20.sol // ERC20 interface /
contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval( address indexed owner, address indexed spender, uint256 value ); }
contract ERC20 is ERC20Basic { function allowance(address owner, address spender) public view returns (uint256); function transferFrom(address from, address to, uint256 value) public returns (bool); function approve(address spender, uint256 value) public returns (bool); event Approval( address indexed owner, address indexed spender, uint256 value ); }
49,854
8
// marks a token as staked, can only be performed by delegated staking controller contract. By calling this function you disable the ability to transfer the token. /
function stakeFromController(uint256 tokenId, address originator) public { require( msg.sender == stakingController, "Function can only be called from staking controller contract" ); require( ownerOf(tokenId) == originator, "Originator is not the owner of this token" ); _stake(tokenId); }
function stakeFromController(uint256 tokenId, address originator) public { require( msg.sender == stakingController, "Function can only be called from staking controller contract" ); require( ownerOf(tokenId) == originator, "Originator is not the owner of this token" ); _stake(tokenId); }
37,908
72
// Mint as bridge/owner /
function mint( address account, uint256 id, uint256 value ) external;
function mint( address account, uint256 id, uint256 value ) external;
21,235
35
// Assign the return values.
totalMintedForTokenId = tokenSupply.totalMinted; maxSupply = tokenSupply.maxSupply; minterNumMinted = _totalMintedByUser[minter]; minterNumMintedForTokenId = _totalMintedByUserPerToken[minter][tokenId];
totalMintedForTokenId = tokenSupply.totalMinted; maxSupply = tokenSupply.maxSupply; minterNumMinted = _totalMintedByUser[minter]; minterNumMintedForTokenId = _totalMintedByUserPerToken[minter][tokenId];
12,590
123
// Modifier to ensure only depositor calls /
modifier onlyDepositor(uint256 depositNumber) { require(deposits[depositNumber].user == msg.sender, Errors.ONLY_DEPOSITOR); _; }
modifier onlyDepositor(uint256 depositNumber) { require(deposits[depositNumber].user == msg.sender, Errors.ONLY_DEPOSITOR); _; }
13,348
64
// Repay variable amount of USD, given exact amount of token input
function repayExactIn(address token, uint inExact, uint outMin) external { IERC20(token).safeTransferFrom(msg.sender, address(this), inExact); IERC20(this).safeApprove(address(UNI), 0); IERC20(this).safeApprove(address(UNI), inExact); address[] memory _path = new address[](2); _path[0] = token; _path[1] = address(this); uint[] memory _amounts = UNI.swapExactTokensForTokens(inExact, outMin, _path, msg.sender, now.add(1800)); emit Repay(msg.sender, token, _amounts[1], _amounts[0]); }
function repayExactIn(address token, uint inExact, uint outMin) external { IERC20(token).safeTransferFrom(msg.sender, address(this), inExact); IERC20(this).safeApprove(address(UNI), 0); IERC20(this).safeApprove(address(UNI), inExact); address[] memory _path = new address[](2); _path[0] = token; _path[1] = address(this); uint[] memory _amounts = UNI.swapExactTokensForTokens(inExact, outMin, _path, msg.sender, now.add(1800)); emit Repay(msg.sender, token, _amounts[1], _amounts[0]); }
21,171
141
// Emits event for multicall start - used in analytics to track actions within multicalls
emit MultiCallStarted(borrower); // F:[FA-26]
emit MultiCallStarted(borrower); // F:[FA-26]
20,679
28
// TODO: validate IPFS CID format for descriptionCid
require(proposalType < ProposalType.Last, "PollenDAO: invalid proposal type"); require(assetTokenType < TokenType.Last, "PollenDAO: invalid asset type"); require(_assets.contains(assetTokenAddress), "PollenDAO: unsupported asset"); require( assetTokenAddress != _getPollenAddress(), "PollenDAO: PLN can't be an asset" ); require( assetTokenAmount != 0 || pollenAmount != 0, "PollenDAO: both amounts are zero"
require(proposalType < ProposalType.Last, "PollenDAO: invalid proposal type"); require(assetTokenType < TokenType.Last, "PollenDAO: invalid asset type"); require(_assets.contains(assetTokenAddress), "PollenDAO: unsupported asset"); require( assetTokenAddress != _getPollenAddress(), "PollenDAO: PLN can't be an asset" ); require( assetTokenAmount != 0 || pollenAmount != 0, "PollenDAO: both amounts are zero"
30,309
52
// funder列表去重
if(!steps[currentStep].funder[msg.sender].isFunder){ steps[currentStep].funders.push(msg.sender); }
if(!steps[currentStep].funder[msg.sender].isFunder){ steps[currentStep].funders.push(msg.sender); }
53,046
31
// Compute the protocol fee that should be paid for a single fill. In this case this should be made the protocol fee for both the left and right orders.
uint256 protocolFee = gasPrice.safeMul(protocolFeeMultiplier); matchedFillResults.left.protocolFeePaid = protocolFee; matchedFillResults.right.protocolFeePaid = protocolFee;
uint256 protocolFee = gasPrice.safeMul(protocolFeeMultiplier); matchedFillResults.left.protocolFeePaid = protocolFee; matchedFillResults.right.protocolFeePaid = protocolFee;
47,935
296
// Skip the transfer and return true as long as the balance check worked.
success = balanceCheckWorked;
success = balanceCheckWorked;
82,688
337
// Validate taker is allowed to fill this order
if (order.takerAddress != address(0)) { if (order.takerAddress != takerAddress) { LibRichErrors.rrevert(LibExchangeRichErrors.ExchangeInvalidContextError( LibExchangeRichErrors.ExchangeContextErrorCodes.INVALID_TAKER, orderInfo.orderHash, takerAddress )); } }
if (order.takerAddress != address(0)) { if (order.takerAddress != takerAddress) { LibRichErrors.rrevert(LibExchangeRichErrors.ExchangeInvalidContextError( LibExchangeRichErrors.ExchangeContextErrorCodes.INVALID_TAKER, orderInfo.orderHash, takerAddress )); } }
12,315
16
// beneficiary.transfer(msg.value);refund money to contributor Refunded(beneficiary, msg.value);
} else { // contributor has not gone through the KYC process yet
} else { // contributor has not gone through the KYC process yet
8,811
4
// Compute square root of x return sqrt(x)/
function sqrt(uint256 x) internal pure returns (uint256) { uint256 n = x / 2; uint256 lstX = 0; while (n != lstX){ lstX = n; n = (n + x/n) / 2; } return uint256(n); }
function sqrt(uint256 x) internal pure returns (uint256) { uint256 n = x / 2; uint256 lstX = 0; while (n != lstX){ lstX = n; n = (n + x/n) / 2; } return uint256(n); }
36,057
203
// 查询用户已收益
function earned(address token, address userAddress) external view returns (uint256) { (uint256 reward,) = pending(getPoolId(token), userAddress); return reward; }
function earned(address token, address userAddress) external view returns (uint256) { (uint256 reward,) = pending(getPoolId(token), userAddress); return reward; }
43,993
53
// get deposit cap amountsreturn callTokenCapAmount call pool deposit capreturn putTokenCapAmount put pool deposit cap /
function getCapAmounts()
function getCapAmounts()
67,859
140
// if user does not want to stake
IERC20(ASG).transfer(_recipient, _amount); // send payout
IERC20(ASG).transfer(_recipient, _amount); // send payout
72,570
31
// SETTERS FOR MAXMINTAMOUNT
function setMaxMintAmountWhitelistFF(uint16 _newMaxMintAmountWhitelistFF) public onlyOwner { maxMintAmountWhitelistFF = _newMaxMintAmountWhitelistFF; }
function setMaxMintAmountWhitelistFF(uint16 _newMaxMintAmountWhitelistFF) public onlyOwner { maxMintAmountWhitelistFF = _newMaxMintAmountWhitelistFF; }
16,856
4
// Returns the total number of vaults managed by the Controller. /
function numVaults() external view returns (uint256);
function numVaults() external view returns (uint256);
23,103