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
21
// to withdraw StableCoin that was not spent if this function is called in a reentrantway during arbitrageit/would skew the token allocation and must be protected against/ _amount amount to withdraw
function withdraw(uint256 _amount) public override nonReentrant { uint256 contributorDeposit = deposits[msg.sender]; require(_amount > 0, "f6c8a withdrawal amount must be bigger than 0"); require(contributorDeposit > 0, "f6c8a user has no deposit"); _redeemReward(); Snapshots memory snapshots = depositSnapshots[msg.sender]; uint256 compoundedDeposit = _getCompoundedDepositFromSnapshots(contributorDeposit, snapshots); uint256 calculatedAmount = compoundedDeposit.min(_amount); uint256 newValue = compoundedDeposit - calculatedAmount; totalDeposit = totalDeposit - calculatedAmount; _updateDepositAndSnapshots(msg.sender, newValue); stableCoin.transfer(msg.sender, calculatedAmount); emit Withdraw(msg.sender, calculatedAmount); emit TotalDepositUpdated(totalDeposit); }
function withdraw(uint256 _amount) public override nonReentrant { uint256 contributorDeposit = deposits[msg.sender]; require(_amount > 0, "f6c8a withdrawal amount must be bigger than 0"); require(contributorDeposit > 0, "f6c8a user has no deposit"); _redeemReward(); Snapshots memory snapshots = depositSnapshots[msg.sender]; uint256 compoundedDeposit = _getCompoundedDepositFromSnapshots(contributorDeposit, snapshots); uint256 calculatedAmount = compoundedDeposit.min(_amount); uint256 newValue = compoundedDeposit - calculatedAmount; totalDeposit = totalDeposit - calculatedAmount; _updateDepositAndSnapshots(msg.sender, newValue); stableCoin.transfer(msg.sender, calculatedAmount); emit Withdraw(msg.sender, calculatedAmount); emit TotalDepositUpdated(totalDeposit); }
14,261
31
// gets the interest rate strategy contract address for the reserve_reserve the reserve address return the address of the interest rate strategy contract/
function getReserveInterestRateStrategyAddress(address _reserve) public view returns (address) { CoreLibrary.ReserveData storage reserve = reserves[_reserve]; return reserve.interestRateStrategyAddress; }
function getReserveInterestRateStrategyAddress(address _reserve) public view returns (address) { CoreLibrary.ReserveData storage reserve = reserves[_reserve]; return reserve.interestRateStrategyAddress; }
5,302
9
// Anyone can harvest it at any given time. I understand the possibility of being frontrun But ETH is a dark forest, and I wanna see how this plays out i.e. will be be heavily frontrunned?if so, a new strategy will be deployed.
address[] memory _path = new address[](2);
address[] memory _path = new address[](2);
22,185
78
// bytes32 are "0x" followed by 32 bytes of data which take up 2 characters each
bytes memory result = new bytes(66);
bytes memory result = new bytes(66);
1,237
8
// Set the initial guess to the closest power of two that is higher than x.
uint256 xAux = uint256(x); result = 1;
uint256 xAux = uint256(x); result = 1;
8,173
82
// X1 - X5: OK
amountOut = _swap(token, joe, amountIn, bar);
amountOut = _swap(token, joe, amountIn, bar);
7,202
90
// Transfers tokens listed for sale in a direct or auction listing.
function transferListingTokens( address _from, address _to, uint256 _quantity, Listing memory _listing
function transferListingTokens( address _from, address _to, uint256 _quantity, Listing memory _listing
25,686
26
// When owner wants to elect new Keepers, she cancels the contract and starts a new one. This variable contains the address of the new continuation contract.
address public continuationContractAddress = address(0); uint public checkInInterval; uint public lastOwnerCheckInAt; States public state = States.CallForKeepers; bytes[] public encryptedKeyPartsChunks; EncryptedData public encryptedData;
address public continuationContractAddress = address(0); uint public checkInInterval; uint public lastOwnerCheckInAt; States public state = States.CallForKeepers; bytes[] public encryptedKeyPartsChunks; EncryptedData public encryptedData;
48,139
48
// Revert if maximum NFTs minted (address) after minting bulk
if (balanceOf[msg.sender][0] + numToMint > MAX_NFTS_PER_ADDRESS) revert MaxMinted();
if (balanceOf[msg.sender][0] + numToMint > MAX_NFTS_PER_ADDRESS) revert MaxMinted();
20,174
4
// owner => tokens
mapping(address => address[]) private _tokens;
mapping(address => address[]) private _tokens;
4,324
18
// require a valid active contract
require(contractState == 0); Player memory currentPlayer; Bet memory currentBet = Bet(_team1Score, _team2Score); if (activePlayer[msg.sender]) { currentPlayer = players[msg.sender]; if (_team1Score == currentPlayer.bet.team1Score && _team2Score == currentPlayer.bet.team2Score) { players[msg.sender].amountBet += msg.value; }
require(contractState == 0); Player memory currentPlayer; Bet memory currentBet = Bet(_team1Score, _team2Score); if (activePlayer[msg.sender]) { currentPlayer = players[msg.sender]; if (_team1Score == currentPlayer.bet.team1Score && _team2Score == currentPlayer.bet.team2Score) { players[msg.sender].amountBet += msg.value; }
33,448
2
// Agreements
uint256 public agreementIndex; mapping(uint256 => Agreement) public agreements;
uint256 public agreementIndex; mapping(uint256 => Agreement) public agreements;
39,774
7
// (PSNbs)/(PSNH+((PSNrs+PSNHrt)/rt));
return SafeMath.div(SafeMath.mul(PSN,bs),SafeMath.add(PSNH,SafeMath.div(SafeMath.add(SafeMath.mul(PSN,rs),SafeMath.mul(PSNH,rt)),rt)));
return SafeMath.div(SafeMath.mul(PSN,bs),SafeMath.add(PSNH,SafeMath.div(SafeMath.add(SafeMath.mul(PSN,rs),SafeMath.mul(PSNH,rt)),rt)));
11,917
66
// the timestamp of the current block
uint32 blockTimestamp;
uint32 blockTimestamp;
26,844
219
// Returns the base URI set via {_setBaseURI}. This will beautomatically added as a prefix in {tokenURI} to each token's URI, orto the token ID if no specific URI is set for that token ID. /
function baseURI() public view virtual returns (string memory) { return _baseURI; }
function baseURI() public view virtual returns (string memory) { return _baseURI; }
28,256
744
// Calculates the binary exponent of x using the binary fraction method.//See https:ethereum.stackexchange.com/q/79903/24693.// Requirements:/ - x must be 192 or less./ - The result must fit within MAX_UD60x18.//x The exponent as an unsigned 60.18-decimal fixed-point number./ return result The result as an unsigned 60.18-decimal fixed-point number.
function exp2(uint256 x) internal pure returns (uint256 result) { // 2^192 doesn't fit within the 192.64-bit format used internally in this function. if (x >= 192e18) { revert PRBMathUD60x18__Exp2InputTooBig(x); } unchecked { // Convert x to the 192.64-bit fixed-point format. uint256 x192x64 = (x << 64) / SCALE; // Pass x to the PRBMath.exp2 function, which uses the 192.64-bit fixed-point number representation. result = PRBMath.exp2(x192x64); } }
function exp2(uint256 x) internal pure returns (uint256 result) { // 2^192 doesn't fit within the 192.64-bit format used internally in this function. if (x >= 192e18) { revert PRBMathUD60x18__Exp2InputTooBig(x); } unchecked { // Convert x to the 192.64-bit fixed-point format. uint256 x192x64 = (x << 64) / SCALE; // Pass x to the PRBMath.exp2 function, which uses the 192.64-bit fixed-point number representation. result = PRBMath.exp2(x192x64); } }
26,318
22
// Allows the owner to withdraw the balance of the tokens. _commission The percentage of the commission 0-100 /
function changeCommission(uint256 _commission) public onlyOwner { emit CommissionChanged(commission, _commission); commission = _commission; }
function changeCommission(uint256 _commission) public onlyOwner { emit CommissionChanged(commission, _commission); commission = _commission; }
77,986
101
// Check for rounding error since we round down in previewDeposit.
require((shares = previewDeposit(amount)) != 0, "ZERO_SHARES");
require((shares = previewDeposit(amount)) != 0, "ZERO_SHARES");
40,932
100
// Make sure the first signature is from the closing participant
require(closing_participant_state.is_the_closer);
require(closing_participant_state.is_the_closer);
68,225
17
// SETTER // Set payee of a request _requestId Request id _payee new payee /
function setPayee(bytes32 _requestId, address _payee) external
function setPayee(bytes32 _requestId, address _payee) external
46,304
3
// Precomputing hash of strings
bytes32 ethHash = keccak256(abi.encodePacked("ETH")); bytes32 linkHash = keccak256(abi.encodePacked("LINK")); address payable contractAddr;
bytes32 ethHash = keccak256(abi.encodePacked("ETH")); bytes32 linkHash = keccak256(abi.encodePacked("LINK")); address payable contractAddr;
1,375
9
// Set the fee address/_address The address to receive fees
function setFeeAddress(address _address) public override onlyOwner { feeAddress = _address; }
function setFeeAddress(address _address) public override onlyOwner { feeAddress = _address; }
12,426
6
// Last block timestamp getter
function getTime() public view returns (uint) { return now; }
function getTime() public view returns (uint) { return now; }
336
11
// Mints new frame with customizations using ETH /
function mintCustomooseWithEth(string memory tokenConfig) public payable { require(block.timestamp >= MINT_START_ETH, "Minting for ETH has not started"); require(msg.value >= getMintPriceEth(), "Not enough ETH"); uint256 tokenId = mintInternal(); setTokenConfig(tokenId, tokenConfig); }
function mintCustomooseWithEth(string memory tokenConfig) public payable { require(block.timestamp >= MINT_START_ETH, "Minting for ETH has not started"); require(msg.value >= getMintPriceEth(), "Not enough ETH"); uint256 tokenId = mintInternal(); setTokenConfig(tokenId, tokenConfig); }
25,224
5
// Ownable The Ownable contract inherits the owner of a parent contract as its owner, and provides basic authorization control functions, this simplifies the implementation of "user permissions". /
contract DelegatedOwnable { address internal ownableParent; event ParentOwnerChanged(address indexed previousParent, address indexed newParent); /** * @dev The Ownable constructor sets the original `ownableParent` of the contract to the specied address * @param _firstOwnableParent Address of the first ownable parent contract */ constructor (address _firstOwnableParent) { try IOwnable(_firstOwnableParent).getOwner() { // Do nothing if parent has ownable function } catch { revert("DO#1"); // PARENT IS NOT OWNABLE } ownableParent = _firstOwnableParent; emit ParentOwnerChanged(address(0), _firstOwnableParent); } /** * @dev Throws if called by any account other than the master owner. */ modifier onlyOwner() { require(msg.sender == getOwner(), "DO#2"); // DelegatedOwnable#onlyOwner: SENDER_IS_NOT_OWNER _; } /** * @notice Will use the owner address of another parent contract * @param _newParent Address of the new owner */ function changeOwnableParent(address _newParent) public onlyOwner { require(_newParent != address(0), "D3"); // DelegatedOwnable#changeOwnableParent: INVALID_ADDRESS ownableParent = _newParent; emit ParentOwnerChanged(ownableParent, _newParent); } /** * @notice Returns the address of the owner. */ function getOwner() public view returns (address) { return IOwnable(ownableParent).getOwner(); } }
contract DelegatedOwnable { address internal ownableParent; event ParentOwnerChanged(address indexed previousParent, address indexed newParent); /** * @dev The Ownable constructor sets the original `ownableParent` of the contract to the specied address * @param _firstOwnableParent Address of the first ownable parent contract */ constructor (address _firstOwnableParent) { try IOwnable(_firstOwnableParent).getOwner() { // Do nothing if parent has ownable function } catch { revert("DO#1"); // PARENT IS NOT OWNABLE } ownableParent = _firstOwnableParent; emit ParentOwnerChanged(address(0), _firstOwnableParent); } /** * @dev Throws if called by any account other than the master owner. */ modifier onlyOwner() { require(msg.sender == getOwner(), "DO#2"); // DelegatedOwnable#onlyOwner: SENDER_IS_NOT_OWNER _; } /** * @notice Will use the owner address of another parent contract * @param _newParent Address of the new owner */ function changeOwnableParent(address _newParent) public onlyOwner { require(_newParent != address(0), "D3"); // DelegatedOwnable#changeOwnableParent: INVALID_ADDRESS ownableParent = _newParent; emit ParentOwnerChanged(ownableParent, _newParent); } /** * @notice Returns the address of the owner. */ function getOwner() public view returns (address) { return IOwnable(ownableParent).getOwner(); } }
17,076
8
// Moves `amount` tokens from `from` to `to` using theallowance mechanism. `amount` is then deducted from the caller'sallowance. Returns a boolean value indicating whether the operation succeeded. Emits a {Transfer} event. /
function transferFrom(address from, address to, uint256 amount) external returns (bool);
function transferFrom(address from, address to, uint256 amount) external returns (bool);
45,121
2
// Cut owner takes on each auction, measured in basis points (1/100 of a percent). Values 0-10,000 map to 0%-100%
uint256 public ownerCut; uint256 public farmCut; Farm farm;
uint256 public ownerCut; uint256 public farmCut; Farm farm;
34,345
35
// If ETH is being paid, set the amount to the message value, and decimals to 18.
_amount = msg.value; _decimals = 18;
_amount = msg.value; _decimals = 18;
37,081
126
// A node points to the node before it, and the node after it. If node.previous = NULL, then the node is the head of the list. If node.next = NULL, then the node is the tail of the list./
struct Node { bool inList; address previous; address next; }
struct Node { bool inList; address previous; address next; }
11,710
73
// Make a new offer. Takes funds from the caller into market escrow.
function offer(uint pay_amt, ERC20 pay_gem, uint buy_amt, ERC20 buy_gem) can_offer synchronized returns (uint id)
function offer(uint pay_amt, ERC20 pay_gem, uint buy_amt, ERC20 buy_gem) can_offer synchronized returns (uint id)
16,164
54
// The latest oracle data.
MD1Types.MerkleRoot internal _ORACLE_ROOT_;
MD1Types.MerkleRoot internal _ORACLE_ROOT_;
14,525
33
// Emergency function to rescue reward tokens in case of issue
function rescueRemainingRewards(address to) external onlyOwner { updatePool(); _safeRewardTransfer(to, remainingRewards); remainingRewards = 0; }
function rescueRemainingRewards(address to) external onlyOwner { updatePool(); _safeRewardTransfer(to, remainingRewards); remainingRewards = 0; }
12,187
5
// Locker Structure
struct StakedUser { uint256 tokensLocked; uint256 timeLocked; uint256 lastClaim; uint256 totalExcluded; }
struct StakedUser { uint256 tokensLocked; uint256 timeLocked; uint256 lastClaim; uint256 totalExcluded; }
14,533
66
// See {IERC1155-balanceOf}. Requirements: - `account` cannot be the zero address. /
function balanceOf(address account, uint256 id) public view virtual override returns (uint256) { require(account != address(0), "ERC1155: balance query for the zero address"); return _balances[id][account]; }
function balanceOf(address account, uint256 id) public view virtual override returns (uint256) { require(account != address(0), "ERC1155: balance query for the zero address"); return _balances[id][account]; }
2,305
206
// amount of path[path.length - 1]
uint256 amount = reserveB.mul(amounts[path.length - 2]).div(reserveA); tradeAmount = getValueConvertETH(amount, path[path.length - 1]);
uint256 amount = reserveB.mul(amounts[path.length - 2]).div(reserveA); tradeAmount = getValueConvertETH(amount, path[path.length - 1]);
36,001
7
// External contracts /Token meta data
string constant public name = "Alt Token Fund"; string constant public symbol = "ATF"; uint8 constant public decimals = 8;
string constant public name = "Alt Token Fund"; string constant public symbol = "ATF"; uint8 constant public decimals = 8;
25,437
72
// user gradual struct, similar to global gradual holds user gragual voting power values points at `userTranches` mapping@member maturedVotingPower users fully-matured voting power amount@member maturingAmount users maturing amount@member rawUnmaturedVotingPower users raw voting power still maturing every tranche@member oldestTranchePosition UserTranchePosition pointing at the oldest unmatured UserTranche@member latestTranchePosition UserTranchePosition pointing at the latest unmatured UserTranche@member lastUpdatedTrancheIndex last (finished) tranche index user gradual has updated /
struct UserGradual { uint48 maturedVotingPower; // matured voting amount, power accumulated and older than FULL_POWER_TIME, not accumulating anymore uint48 maturingAmount; // total maturing amount (also maximum matured) uint56 rawUnmaturedVotingPower; // current user raw unmatured voting power (increases every new tranche), actual unmatured voting power can be calculated as unmaturedVotingPower / FULL_POWER_TRANCHES_COUNT UserTranchePosition oldestTranchePosition; // if arrayIndex is 0, user has no tranches (even if `latestTranchePosition` is not empty) UserTranchePosition latestTranchePosition; // can only increment, in case of tranche removal, next time user gradually mints we point at tranche at next position uint16 lastUpdatedTrancheIndex; }
struct UserGradual { uint48 maturedVotingPower; // matured voting amount, power accumulated and older than FULL_POWER_TIME, not accumulating anymore uint48 maturingAmount; // total maturing amount (also maximum matured) uint56 rawUnmaturedVotingPower; // current user raw unmatured voting power (increases every new tranche), actual unmatured voting power can be calculated as unmaturedVotingPower / FULL_POWER_TRANCHES_COUNT UserTranchePosition oldestTranchePosition; // if arrayIndex is 0, user has no tranches (even if `latestTranchePosition` is not empty) UserTranchePosition latestTranchePosition; // can only increment, in case of tranche removal, next time user gradually mints we point at tranche at next position uint16 lastUpdatedTrancheIndex; }
6,335
7
// Checks if rounding error >= 0.1% when rounding up./numerator Numerator./denominator Denominator./target Value to multiply with numerator/denominator./ return isError Rounding error is present.
function isRoundingErrorCeil( uint256 numerator, uint256 denominator, uint256 target
function isRoundingErrorCeil( uint256 numerator, uint256 denominator, uint256 target
2,148
12
// Write an event
emit BoxesMinted(_msgSender(), totalPrice, totalLand, box.packID, box.numberOfPacks, box.numberOfItemsInPack, box.numberOfMercenaries);
emit BoxesMinted(_msgSender(), totalPrice, totalLand, box.packID, box.numberOfPacks, box.numberOfItemsInPack, box.numberOfMercenaries);
19,843
510
// --- Connected contract declarations ---
address public borrowerOperationsAddress; IStabilityPool public override stabilityPool; address gasPoolAddress; ICollSurplusPool collSurplusPool; ILUSDToken public override lusdToken;
address public borrowerOperationsAddress; IStabilityPool public override stabilityPool; address gasPoolAddress; ICollSurplusPool collSurplusPool; ILUSDToken public override lusdToken;
75,306
87
// Current number of votes in favor of this proposal
uint256 forVotes;
uint256 forVotes;
13,197
113
// @Artyom Required for ERC-721 compliance. @Artyom only gen1
function takeOwnership(uint256 _tokenId) public { address newOwner = msg.sender; address oldOwner = personIndexToOwnerGen1[_tokenId]; // Safety check to prevent against an unexpected 0x0 default. require(_addressNotNull(newOwner)); // Making sure transfer is approved require(_approvedGen1(newOwner, _tokenId)); _transfer(oldOwner, newOwner, _tokenId); }
function takeOwnership(uint256 _tokenId) public { address newOwner = msg.sender; address oldOwner = personIndexToOwnerGen1[_tokenId]; // Safety check to prevent against an unexpected 0x0 default. require(_addressNotNull(newOwner)); // Making sure transfer is approved require(_approvedGen1(newOwner, _tokenId)); _transfer(oldOwner, newOwner, _tokenId); }
46,403
83
// Emits {Approval} event./ Requirements:/ - `deadline` must be timestamp in future./ - `v`, `r` and `s` must be valid `secp256k1` signature from `owner` account over EIP712-formatted function arguments./ - the signature must use `owner` account's current nonce (see {nonces})./ - the signer cannot be zero address and must be `owner` account./ For more information on signature format, see https:eips.ethereum.org/EIPS/eip-2612specification[relevant EIP section]./ WETH10 token implementation adapted from https:github.com/albertocuestacanada/ERC20Permit/blob/master/contracts/ERC20Permit.sol.
function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external override { require(block.timestamp <= deadline, "WETH: Expired permit");
function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external override { require(block.timestamp <= deadline, "WETH: Expired permit");
50,362
18
// Lottery's divs
function myDividends() public view returns(uint256)
function myDividends() public view returns(uint256)
68,826
91
// Contract which oversees inter-pToken operations /
IComptroller public comptroller;
IComptroller public comptroller;
20,353
340
// returns the respective pool collection for the provided pool /
function collectionByPool(Token pool) external view returns (IPoolCollection);
function collectionByPool(Token pool) external view returns (IPoolCollection);
31,335
265
// This loop should hardly ever 1 or more unless something bad happened In which case it costs gas but there isn't overflow
for (uint256 i = 0; hoursDelta > i; i++) {
for (uint256 i = 0; hoursDelta > i; i++) {
47,550
31
// To avoid weirdness with the single and batch token maps, rather than sending to the 0 address, we send to 0x00000dead instead
_single_owner_map[tokenId] = DEAD_ADDR; emit Transfer(msg.sender, address(0), tokenId);
_single_owner_map[tokenId] = DEAD_ADDR; emit Transfer(msg.sender, address(0), tokenId);
18,797
29
// See {IERC721Enumerable-tokenByIndex}. /
function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require( index < _owners.length, "ERC721Enumerable: global index out of bounds"
function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require( index < _owners.length, "ERC721Enumerable: global index out of bounds"
1,439
135
// Preallocate tokens for the early investors. /
function preallocate(address receiver, uint tokens, uint weiPrice) internal { uint decimals = token.decimals(); uint tokenAmount = tokens * 10 ** decimals; uint weiAmount = weiPrice * tokens; presaleWeiRaised = presaleWeiRaised.add(weiAmount); tokensSent = tokensSent.add(tokenAmount); tokenBalanceOf[receiver] = tokenBalanceOf[receiver].add(tokenAmount); presaleBalanceOf[receiver] = presaleBalanceOf[receiver].add(weiAmount); produceTokens(receiver, weiAmount, tokenAmount); }
function preallocate(address receiver, uint tokens, uint weiPrice) internal { uint decimals = token.decimals(); uint tokenAmount = tokens * 10 ** decimals; uint weiAmount = weiPrice * tokens; presaleWeiRaised = presaleWeiRaised.add(weiAmount); tokensSent = tokensSent.add(tokenAmount); tokenBalanceOf[receiver] = tokenBalanceOf[receiver].add(tokenAmount); presaleBalanceOf[receiver] = presaleBalanceOf[receiver].add(weiAmount); produceTokens(receiver, weiAmount, tokenAmount); }
48,182
19
// Provability of overflow/underflow, but this is designed as storage is continuum.
let slot := add(offset_, sub(index_, 1)) sstore(slot, 0)
let slot := add(offset_, sub(index_, 1)) sstore(slot, 0)
29,960
6
// function removes a manufacturer account from the system.
function renounceManufacturer() public { _removeManufacturer(msg.sender); }
function renounceManufacturer() public { _removeManufacturer(msg.sender); }
4,034
41
// Transfers amount of deposit tokens from the caller on behalf of user. user User address who gains credit for this stake operation. amount Number of deposit tokens to stake. data Not used. /
function stakeFor(address user, uint256 amount, bytes calldata data) external onlyOwner { _stakeFor(msg.sender, user, amount); }
function stakeFor(address user, uint256 amount, bytes calldata data) external onlyOwner { _stakeFor(msg.sender, user, amount); }
17,839
106
// List of short/long orders of a manager in the current cycle.
mapping(address => address payable[]) public userCompoundOrders;
mapping(address => address payable[]) public userCompoundOrders;
2,540
7
// Couldn't use local variables because of stack too deep error(QtyVirtual Balance) / Total Capital
return(SafeMath.div(SafeMath.mul(qty, self.list[_fundNum].virtualBalances[msg.sender]), self.list[_fundNum].totalCapital));
return(SafeMath.div(SafeMath.mul(qty, self.list[_fundNum].virtualBalances[msg.sender]), self.list[_fundNum].totalCapital));
40,383
27
// Gets the number of tokens sold thus far/self Stored Crowdsale from crowdsale contract/ return Number of tokens sold
function getTokensSold(DirectCrowdsaleStorage storage self) public view returns (uint256) { return self.startingTokenBalance - self.withdrawTokensMap[self.owner]; }
function getTokensSold(DirectCrowdsaleStorage storage self) public view returns (uint256) { return self.startingTokenBalance - self.withdrawTokensMap[self.owner]; }
33,404
44
// Toggles the status of a gauge to either killed or unkilled/gaugeAddr Gauge to toggle the status of/It is impossible to kill a gauge in the `GaugeController` contract, for this reason killing of gauges/ takes place in the `SdtDistributor` contract/This means that people could vote for a gauge in the gauge controller contract but that rewards are not going/ to be distributed to it in the end: people would need to remove their weights on the gauge killed to end the diminution/ in rewards/In the case of a gauge being killed, this function resets the timestamps at which this gauge has
function toggleGauge(address gaugeAddr) external onlyRole(GOVERNOR_ROLE) { bool gaugeKilledMem = killedGauges[gaugeAddr]; if (!gaugeKilledMem) { rewardToken.safeApprove(gaugeAddr, 0); } killedGauges[gaugeAddr] = !gaugeKilledMem; emit GaugeToggled(gaugeAddr, !gaugeKilledMem); }
function toggleGauge(address gaugeAddr) external onlyRole(GOVERNOR_ROLE) { bool gaugeKilledMem = killedGauges[gaugeAddr]; if (!gaugeKilledMem) { rewardToken.safeApprove(gaugeAddr, 0); } killedGauges[gaugeAddr] = !gaugeKilledMem; emit GaugeToggled(gaugeAddr, !gaugeKilledMem); }
1,451
31
// Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirementon the return value: the return value is optional (but if data is returned, it must not be false). token The token targeted by the call. data The call data (encoded using abi.encode or one of its variants). /
function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. // A Solidity high level call has three parts: // 1. The target address is checked to verify it contains contract code // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. // solhint-disable-next-line max-line-length require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } }
function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. // A Solidity high level call has three parts: // 1. The target address is checked to verify it contains contract code // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. // solhint-disable-next-line max-line-length require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } }
67
33
// Query a contract to see if it supports a certain interface/Returns `true` the interface is supported and `false` otherwise,/returns `true` for INTERFACE_SIGNATURE_ERC165 and/INTERFACE_SIGNATURE_ERC721, see ERC-165 for other interface signatures.
function supportsInterface(bytes4 _interfaceID) external pure returns (bool);
function supportsInterface(bytes4 _interfaceID) external pure returns (bool);
3,916
18
// Reset Balance /
function _resetBalance() internal virtual { Settings storage s = getSettings(); if (isAggregated()) s.contractBalance = 0; else s.contractERCBalance = 0; }
function _resetBalance() internal virtual { Settings storage s = getSettings(); if (isAggregated()) s.contractBalance = 0; else s.contractERCBalance = 0; }
2,041
128
// 将BAC奖励转给当前用户
cash.safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, reward);
cash.safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, reward);
17,502
85
// return the minted of the crowdsale. /
function minted() public view returns (uint256) { return _minted; }
function minted() public view returns (uint256) { return _minted; }
38,090
40
// Transfer tokens from one address to another. _from address The address from which you want to send tokens. _to address The address to which you want to transfer tokens. _value uint256 the amount of tokens to be transferred. /
function transferFrom(address _from, address _to, uint _value) public unfreezed(_to) unfreezed(msg.sender) noEmergencyFreeze() returns (bool success)
function transferFrom(address _from, address _to, uint _value) public unfreezed(_to) unfreezed(msg.sender) noEmergencyFreeze() returns (bool success)
10,797
194
// support IERC2981
function supportsInterface(bytes4 _interfaceId) public view virtual override (ERC721, IERC165) returns (bool) { return _interfaceId == type(IERC2981).interfaceId || super.supportsInterface(_interfaceId); }
function supportsInterface(bytes4 _interfaceId) public view virtual override (ERC721, IERC165) returns (bool) { return _interfaceId == type(IERC2981).interfaceId || super.supportsInterface(_interfaceId); }
48,031
359
// Allows to retrieve current nonce for token/tokenId token id/ return current nonce
function nonce(uint256 tokenId) public view returns (uint256) { require(_exists(tokenId), '!UNKNOWN_TOKEN!'); return _nonces[tokenId]; }
function nonce(uint256 tokenId) public view returns (uint256) { require(_exists(tokenId), '!UNKNOWN_TOKEN!'); return _nonces[tokenId]; }
75,213
279
// DEPOSIT & WITHDRAWALS // Deposits ETH into the contract and mint vault shares. /
function depositETH() external payable nonReentrant { require(msg.value > 0, "!value"); _depositFor(msg.value, msg.sender, true); }
function depositETH() external payable nonReentrant { require(msg.value > 0, "!value"); _depositFor(msg.value, msg.sender, true); }
21,049
82
// enables owner to pause / unpause contract /
function setPaused(bool _paused) external requireContractsSet onlyOwner { if (_paused) _pause(); else _unpause(); }
function setPaused(bool _paused) external requireContractsSet onlyOwner { if (_paused) _pause(); else _unpause(); }
49,290
4
// Owner-specific contract interface
contract Owned { event NewOwner(address indexed old, address indexed current); modifier only_owner { require (msg.sender == owner); _; } address public owner = msg.sender; function setOwner(address _new) only_owner { NewOwner(owner, _new); owner = _new; } }
contract Owned { event NewOwner(address indexed old, address indexed current); modifier only_owner { require (msg.sender == owner); _; } address public owner = msg.sender; function setOwner(address _new) only_owner { NewOwner(owner, _new); owner = _new; } }
24,637
18
// Check: extension namespace must already exist. Check: provided extension implementation must be non-zero.
require(_canReplaceExtension(_extension), "ExtensionManager: cannot replace extension.");
require(_canReplaceExtension(_extension), "ExtensionManager: cannot replace extension.");
31,071
2
// Chain ID of the recipient
uint16 toChain;
uint16 toChain;
20,705
139
// bool public miningFinished = false;
mapping(address => bool) claimed; mapping(address => bool) claimstaked;
mapping(address => bool) claimed; mapping(address => bool) claimstaked;
7,034
79
// update remaining unstakeAmount
unstakeAmount = unstakeAmount.sub(currentAmount);
unstakeAmount = unstakeAmount.sub(currentAmount);
10,792
140
// _vrfCoordinator address of VRFCoordinator contract _link address of LINK token contract/
constructor(address _vrfCoordinator, address _link) { vrfCoordinator = _vrfCoordinator; LINK = LinkTokenInterface(_link); }
constructor(address _vrfCoordinator, address _link) { vrfCoordinator = _vrfCoordinator; LINK = LinkTokenInterface(_link); }
42,292
3
// name String with EIP712 name. version String with EIP712 version. /
constructor(string memory name, string memory version) EIP712(name, version) { // solhint-disable-previous-line no-empty-blocks }
constructor(string memory name, string memory version) EIP712(name, version) { // solhint-disable-previous-line no-empty-blocks }
11,406
118
// Functions with this modifier can only be called by pendingGovernance
modifier onlyPendingGovernance() { if (msg.sender != pendingGovernance) revert OnlyPendingGovernance(); _; }
modifier onlyPendingGovernance() { if (msg.sender != pendingGovernance) revert OnlyPendingGovernance(); _; }
68,877
90
// if restriction is to check whether the current transaction is performed within the 24 hours span after the last transaction performed by the user
if (BokkyPooBahsDateTimeLibrary.diffSeconds(_lastTradedTimestamp, now) < 86400) { (,, uint256 lastTxDay) = BokkyPooBahsDateTimeLibrary.timestampToDate(_lastTradedTimestamp); (,, uint256 currentTxDay) = BokkyPooBahsDateTimeLibrary.timestampToDate(now);
if (BokkyPooBahsDateTimeLibrary.diffSeconds(_lastTradedTimestamp, now) < 86400) { (,, uint256 lastTxDay) = BokkyPooBahsDateTimeLibrary.timestampToDate(_lastTradedTimestamp); (,, uint256 currentTxDay) = BokkyPooBahsDateTimeLibrary.timestampToDate(now);
33,294
7
// If any case another erc20 token is being sent here
function recoverTokens(address token) external onlyOwner { IERC20(token).transfer( msg.sender, IERC20(token).balanceOf(address(this)) ); }
function recoverTokens(address token) external onlyOwner { IERC20(token).transfer( msg.sender, IERC20(token).balanceOf(address(this)) ); }
10,959
67
// Calling onReceive method if recipient is contract
_callonERC1155Received(address(0x0), _to, _id, _amount, _data);
_callonERC1155Received(address(0x0), _to, _id, _amount, _data);
1,855
166
// A minimum deposit amount is designed to protect purchasers from over paying gas for fullfilling multiple small synth deposits
if (amount < minimumDepositAmount) {
if (amount < minimumDepositAmount) {
21,084
101
// Change token name from `name` to the `_newName`.
name = _newName;
name = _newName;
41,548
224
// Get the time when a pepe can cozy again_pepeId ID of the pepereturn Time when the pepe can cozy again /
function getCozyAgain(uint256 _pepeId) public view returns(uint64) { return pepes[_pepeId].canCozyAgain; }
function getCozyAgain(uint256 _pepeId) public view returns(uint64) { return pepes[_pepeId].canCozyAgain; }
11,332
79
// set the minQuorum to 20% again, in the case it has been reached
if (quorum > SponsorTotalSupply / 5) minQuorumDivisor = 5;
if (quorum > SponsorTotalSupply / 5) minQuorumDivisor = 5;
14,800
224
// Enter Compound's DAI market to take it into account when using flashminted DAI as collateral
address[] memory markets; if (address(cToken) != address(FlashMintLib.CDAI)) { markets = new address[](2); markets[0] = address(FlashMintLib.CDAI); markets[1] = address(cToken);
address[] memory markets; if (address(cToken) != address(FlashMintLib.CDAI)) { markets = new address[](2); markets[0] = address(FlashMintLib.CDAI); markets[1] = address(cToken);
31,473
88
// Mint 30,0000 BRAIN (18 Decimals)
_mint(msg.sender, 30000000000000000000000);
_mint(msg.sender, 30000000000000000000000);
66,840
377
// Hash name/name The name to be hashed/ return The hash value
function hashName(string memory name) public pure returns (bytes32)
function hashName(string memory name) public pure returns (bytes32)
11,514
166
// minimum amount of network tokens that the system can mint as compensation for base token losses
uint256 private _minNetworkCompensation = 1e16; // = 0.01 network tokens
uint256 private _minNetworkCompensation = 1e16; // = 0.01 network tokens
56,122
38
// Redeem tokens Send `_value` tokens from '_from' to `_to`Used to redeem AWMVouchers for AWMDollars_from The address of the source _to The address of the recipient _value the amount to send /
function redeem(address _from, address _to, uint256 _value) stoppable public onlyOwner { _transfer(_from, _to, _value); }
function redeem(address _from, address _to, uint256 _value) stoppable public onlyOwner { _transfer(_from, _to, _value); }
7,839
141
// NyanVoting(votingContract).nyanV2LPStaked(userStake[msg.sender].stakedNyanV2LP, msg.sender);
emit nyanV2LPStaked(msg.sender, _amount);
emit nyanV2LPStaked(msg.sender, _amount);
13,491
86
// once we have tokens we can enable the withdrawal setting this _useAsDefault to true will set this incoming address to the defaultToken.
function enableTokenWithdrawals (address _tokenAddr, bool _useAsDefault) public onlyAdmin noReentrancy { require (contractStage == CONTRACT_SUBMIT_FUNDS, "wrong contract stage"); if (_useAsDefault) { defaultToken = _tokenAddr; } else { require (defaultToken != 0x00, "defaultToken must be set"); } TokenAllocation storage ta = tokenAllocationMap[_tokenAddr]; if (ta.pct.length==0){ ta.token = ERC20(_tokenAddr); } uint256 amount = ta.token.balanceOf(this).sub(ta.balanceRemaining); require (amount > 0); if (feePct > 0) { uint256 feePctFromBips = _toPct(feePct, 10000); uint256 feeAmount = _applyPct(amount, feePctFromBips); require (ta.token.transfer(owner, feeAmount)); emit TokenWithdrawal(owner, _tokenAddr, feeAmount); } amount = ta.token.balanceOf(this).sub(ta.balanceRemaining); ta.balanceRemaining = ta.token.balanceOf(this); ta.pct.push(_toPct(amount,finalBalance)); }
function enableTokenWithdrawals (address _tokenAddr, bool _useAsDefault) public onlyAdmin noReentrancy { require (contractStage == CONTRACT_SUBMIT_FUNDS, "wrong contract stage"); if (_useAsDefault) { defaultToken = _tokenAddr; } else { require (defaultToken != 0x00, "defaultToken must be set"); } TokenAllocation storage ta = tokenAllocationMap[_tokenAddr]; if (ta.pct.length==0){ ta.token = ERC20(_tokenAddr); } uint256 amount = ta.token.balanceOf(this).sub(ta.balanceRemaining); require (amount > 0); if (feePct > 0) { uint256 feePctFromBips = _toPct(feePct, 10000); uint256 feeAmount = _applyPct(amount, feePctFromBips); require (ta.token.transfer(owner, feeAmount)); emit TokenWithdrawal(owner, _tokenAddr, feeAmount); } amount = ta.token.balanceOf(this).sub(ta.balanceRemaining); ta.balanceRemaining = ta.token.balanceOf(this); ta.pct.push(_toPct(amount,finalBalance)); }
3,003
565
// Return the address of the COMP tokenreturn The address of COMP /
function getCompAddress() public view returns (address) { return 0xbc16da9df0A22f01A16BC0620a27e7D6d6488550; }
function getCompAddress() public view returns (address) { return 0xbc16da9df0A22f01A16BC0620a27e7D6d6488550; }
32,290
15
// Notifies a weight change of a member/Called only by: Elections contract/addr is the committee member address/weight is the updated weight of the committee member
function memberWeightChange(address addr, uint256 weight) external /* onlyElectionsContract onlyWhenActive */;
function memberWeightChange(address addr, uint256 weight) external /* onlyElectionsContract onlyWhenActive */;
989
6
// Add a function lookUptokenIdToStarInfo, that looks up the stars using the Token ID, and then returns the name of the star.
function lookUptokenIdToStarInfo(uint256 _tokenId) public view returns (string memory starName){ Star memory lookupStar = tokenIdToStarInfo[_tokenId]; starName = lookupStar.name; return starName; }
function lookUptokenIdToStarInfo(uint256 _tokenId) public view returns (string memory starName){ Star memory lookupStar = tokenIdToStarInfo[_tokenId]; starName = lookupStar.name; return starName; }
17,094
0
// {ERC1155} token, including:This contract uses {AccessControl} to lock permissioned functions using the/ Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE`, and `PAUSER_ROLE` to the account thatdeploys the contract. _maker default roles overriden and all tokens initially assigned to the _maker address /
constructor(address _maker, string memory uri, uint256 _creatorTokens, uint256 _memberTokens, uint256 _communitySpiritTokens) public ERC1155(uri) {
constructor(address _maker, string memory uri, uint256 _creatorTokens, uint256 _memberTokens, uint256 _communitySpiritTokens) public ERC1155(uri) {
27,665
24
// Total amount of reserves of the underlying held in this market /
uint public totalReserves;
uint public totalReserves;
18,959
84
// Issue new outcome tokens to sender
for (uint8 i = 0; i < outcomeTokens.length; i++) outcomeTokens[i].issue(msg.sender, collateralTokenCount); OutcomeTokenSetIssuance(msg.sender, collateralTokenCount);
for (uint8 i = 0; i < outcomeTokens.length; i++) outcomeTokens[i].issue(msg.sender, collateralTokenCount); OutcomeTokenSetIssuance(msg.sender, collateralTokenCount);
37,843
137
// Submit an IOU to claim the owed amount./ If the deposit is smaller than the claim, the remaining deposit is/ claimed. If no tokens are claimed, `claim` may be retried, later./sender Address from which the amount is transferred/receiver Address to which the amount is transferred/amount Owed amount of tokens/expiration_block Tokens can only be claimed before this time/signature Sender's signature over keccak256(sender, receiver, amount, expiration_block)/ return Amount of transferred tokens
function claim( address sender, address receiver, uint256 amount, uint256 expiration_block, bytes memory signature ) public returns (uint)
function claim( address sender, address receiver, uint256 amount, uint256 expiration_block, bytes memory signature ) public returns (uint)
25,898
75
// Solidity already throws when dividing by 0.
return a / b;
return a / b;
3,952
16
// Required override for Solidity /
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal override(ERC721, ERC721Enumerable){
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal override(ERC721, ERC721Enumerable){
18,494
5
// event emitted when erc20 tokens are saved
event SavedTokens( address indexed admin, address indexed token, address indexed receiver, uint256 amount );
event SavedTokens( address indexed admin, address indexed token, address indexed receiver, uint256 amount );
9,541
90
// Manual send tokens to the specified address._beneficiary The address of a investor._tokensAmount Amount of tokens./
function manualSendTokens(address _beneficiary, uint256 _tokensAmount) public onlyOwner { require(_beneficiary != address(0)); require(_tokensAmount > 0); super._deliverTokens(_beneficiary, _tokensAmount); tokensSoldCount = tokensSoldCount.add(_tokensAmount); emit TokenAssignment(_beneficiary, _tokensAmount); }
function manualSendTokens(address _beneficiary, uint256 _tokensAmount) public onlyOwner { require(_beneficiary != address(0)); require(_tokensAmount > 0); super._deliverTokens(_beneficiary, _tokensAmount); tokensSoldCount = tokensSoldCount.add(_tokensAmount); emit TokenAssignment(_beneficiary, _tokensAmount); }
53,661