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 | // return new game id | uint256 gameId = _addGameData(
msg.sender,
hiddenMove,
currency,
amount,
playerB
);
| uint256 gameId = _addGameData(
msg.sender,
hiddenMove,
currency,
amount,
playerB
);
| 6,285 |
1,093 | // https:etherscan.io/address/0x005d19CA7ff9D79a5Bdf0805Fc01D9D7c53B6827; | Synth existingSynth = Synth(0x005d19CA7ff9D79a5Bdf0805Fc01D9D7c53B6827);
| Synth existingSynth = Synth(0x005d19CA7ff9D79a5Bdf0805Fc01D9D7c53B6827);
| 49,047 |
39 | // Checks if the auction has ended.return bool True if current time is greater than auction end time. / | function auctionEnded() public view returns (bool) {
return block.timestamp > marketInfo.endTime;
}
| function auctionEnded() public view returns (bool) {
return block.timestamp > marketInfo.endTime;
}
| 73,406 |
271 | // Set token IDs for each rarity class. Bulk version of `setTokenIdForClass` _tokenIds List of token IDs to set for each class, specified above in order / | function setTokenIdsForClasses(
uint256[NUM_CLASSES] memory _tokenIds
| function setTokenIdsForClasses(
uint256[NUM_CLASSES] memory _tokenIds
| 17,028 |
65 | // console.log (bytes32ToString(_symbol), "safeIncrease = Amnt/Fee ", _amount, _feeCharged ); console.log (bytes32ToString(_symbol), "safeIncrease Before Total/Avail= ", assets[_trader][_symbol].total, assets[_trader][_symbol].available ); | assets[_trader][_symbol].total += _amount - _feeCharged;
assets[_trader][_symbol].available += _amount - _feeCharged;
| assets[_trader][_symbol].total += _amount - _feeCharged;
assets[_trader][_symbol].available += _amount - _feeCharged;
| 43,297 |
10 | // Allows user to mint tokens at a quantity | modifier canMintTokens(uint256 quantity) {
if (quantity + _totalMinted() > config.editionSize) {
revert Mint_SoldOut();
}
_;
}
| modifier canMintTokens(uint256 quantity) {
if (quantity + _totalMinted() > config.editionSize) {
revert Mint_SoldOut();
}
_;
}
| 17,290 |
10 | // Square root./Reference: https:stackoverflow.com/questions/3766020/binary-search-to-compute-square-root-java | function fSqrt(uint n) internal pure returns (uint) {
if (n == 0) {
return 0;
}
uint z = n * n;
require(z / n == n);
uint high = fAdd(n, DECMULT);
uint low = 0;
while (fSub(high, low) > 1) {
uint mid = fAdd(low, high) / 2;
if (fSqr(mid) <= n) {
low = mid;
} else {
high = mid;
}
}
return low;
}
| function fSqrt(uint n) internal pure returns (uint) {
if (n == 0) {
return 0;
}
uint z = n * n;
require(z / n == n);
uint high = fAdd(n, DECMULT);
uint low = 0;
while (fSub(high, low) > 1) {
uint mid = fAdd(low, high) / 2;
if (fSqr(mid) <= n) {
low = mid;
} else {
high = mid;
}
}
return low;
}
| 36,820 |
0 | // Fraction of the Reserve that is committed to the gold bucket when updating buckets. | FixidityLib.Fraction public reserveFraction;
address public stable;
| FixidityLib.Fraction public reserveFraction;
address public stable;
| 36,442 |
115 | // Only withdraw funds from underlying pool if contract doesn't have enough balance to fulfill the early withdraw. there is no redeem function in v2 it is replaced by withdraw in v2 | if (contractBalance < withdrawAmount) {
adaiToken.redeem(adaiToken.balanceOf(address(this)));
}
| if (contractBalance < withdrawAmount) {
adaiToken.redeem(adaiToken.balanceOf(address(this)));
}
| 36,910 |
360 | // Lock native token as original token to trigger cross-chain mint of pegged tokens at a remote chain'sPeggedTokenBridge. _amount The amount to deposit. _mintChainId The destination chain ID to mint tokens. _mintAccount The destination account to receive the minted pegged tokens. _nonce A number input to guarantee unique depositId. Can be timestamp in practice. / | function depositNative(
uint256 _amount,
uint64 _mintChainId,
address _mintAccount,
uint64 _nonce
| function depositNative(
uint256 _amount,
uint64 _mintChainId,
address _mintAccount,
uint64 _nonce
| 5,299 |
102 | // Maximum Token Sale (Crowdsale + Early Sale + Supporters) Approximate 250 millions ITS + 125 millions for early investors + 75 Millions to Supports | uint256 public tokenSaleMax;
| uint256 public tokenSaleMax;
| 45,652 |
50 | // Create a new role identifier for the controller role | bytes32 public constant CONTROLLER_ROLE = keccak256("CONTROLLER_ROLE");
| bytes32 public constant CONTROLLER_ROLE = keccak256("CONTROLLER_ROLE");
| 21,159 |
3 | // These are only callable by the admin | function setInbox(address inbox, bool enabled) external;
function setOutbox(address inbox, bool enabled) external;
| function setInbox(address inbox, bool enabled) external;
function setOutbox(address inbox, bool enabled) external;
| 32,811 |
366 | // Struct storing variables used in calculations in the | // {add,remove}Liquidity functions to avoid stack too deep errors
struct ManageLiquidityInfo {
uint256 d0;
uint256 d1;
uint256 d2;
uint256 preciseA;
LPToken lpToken;
uint256 totalSupply;
uint256[] balances;
uint256[] multipliers;
}
| // {add,remove}Liquidity functions to avoid stack too deep errors
struct ManageLiquidityInfo {
uint256 d0;
uint256 d1;
uint256 d2;
uint256 preciseA;
LPToken lpToken;
uint256 totalSupply;
uint256[] balances;
uint256[] multipliers;
}
| 33,655 |
27 | // Returns the total amount of tokens stored by the contract.Burned tokens are calculated here, use `_totalMinted()` if you want to count just minted tokens. / |
function totalSupply() external view returns (uint256);
|
function totalSupply() external view returns (uint256);
| 26,336 |
9 | // Changes the SoundEdition implementation contract address. Calling conditions:- The caller must be the owner of the contract.newImplementation The new implementation address to be set. / | function setEditionImplementation(address newImplementation) external;
| function setEditionImplementation(address newImplementation) external;
| 34,925 |
313 | // Internal function to convert id to full uri string id uint256 ID to convertreturn string URI convert from given ID / | function _fullUriFromId(uint256 id) private view returns(string memory) {
return string(abi.encodePacked(abi.encodePacked(_uriPrefix, Bytes.uint2str(id))));
}
| function _fullUriFromId(uint256 id) private view returns(string memory) {
return string(abi.encodePacked(abi.encodePacked(_uriPrefix, Bytes.uint2str(id))));
}
| 40,552 |
8 | // Whether the collection is revealed or not.return revealed True if the final content has been revealed. / | function isRevealed() external view returns (bool revealed) {
revealed = $isRevealed;
}
| function isRevealed() external view returns (bool revealed) {
revealed = $isRevealed;
}
| 33,553 |
24 | // Error for only developer | error OnlyDeveloper();
| error OnlyDeveloper();
| 37,963 |
4 | // create functions for smartcontract specifing the parameters that Create function going to take Public - used in the front end , Private stored on in the backendreturns (uint256) because we want it to return the ID of this object | function createEvidence(address _owner, string memory _title, string memory _description, uint256 _target, uint256 _deadline, string memory _image) public returns (uint256) {
Evidence storage evidence = evidences[numberOfEvidence];
// require --> test to see if everything is okay (it is a condition to move forword)
// timestamp will show us the time block was submitted
require(evidence.deadline < block.timestamp, "The deadlin should be in the future.");
evidence.owner = _owner;
evidence.title = _title;
evidence.description = _description;
evidence.target = _target;
evidence.deadline = _deadline;
evidence.amountCollected = 0;
evidence.image = _image;
numberOfEvidence++; // incrementing the number of evidences it is alternative to numberOfEvidence = numberOfEvidence + 1
return numberOfEvidence - 1; // index of the most recently created evidence
}
| function createEvidence(address _owner, string memory _title, string memory _description, uint256 _target, uint256 _deadline, string memory _image) public returns (uint256) {
Evidence storage evidence = evidences[numberOfEvidence];
// require --> test to see if everything is okay (it is a condition to move forword)
// timestamp will show us the time block was submitted
require(evidence.deadline < block.timestamp, "The deadlin should be in the future.");
evidence.owner = _owner;
evidence.title = _title;
evidence.description = _description;
evidence.target = _target;
evidence.deadline = _deadline;
evidence.amountCollected = 0;
evidence.image = _image;
numberOfEvidence++; // incrementing the number of evidences it is alternative to numberOfEvidence = numberOfEvidence + 1
return numberOfEvidence - 1; // index of the most recently created evidence
}
| 10,434 |
230 | // Allows users to access the number of decimals/ | function decimals() external pure returns (uint8) {
return 18;
}
| function decimals() external pure returns (uint8) {
return 18;
}
| 26,870 |
18 | // This generates a public event for frozen (blacklisting) accounts | event FrozenAccounts(address target, bool frozen);
| event FrozenAccounts(address target, bool frozen);
| 19,847 |
20 | // remove deposit from list | delete _pendingDeposits[userAddr];
| delete _pendingDeposits[userAddr];
| 30,404 |
11 | // checks if an item is listed in an active auction | function isActive(address token, uint256 tokenId) external view returns (bool);
| function isActive(address token, uint256 tokenId) external view returns (bool);
| 52,762 |
235 | // FEE PAYER DATA STRUCTURES/ The collateral currency used to back the positions in this contract. | IERC20 public collateralCurrency;
| IERC20 public collateralCurrency;
| 8,031 |
26 | // store contract instances | treasury = _treasury;
| treasury = _treasury;
| 32,357 |
2 | // executes the ERC20 token's `approve` function and reverts upon failurethe main purpose of this function is to prevent a non standard ERC20 tokenfrom failing silently_token ERC20 token address _spender approved address _value allowance amount / | function safeApprove(
IERC20Token _token,
address _spender,
uint256 _value
| function safeApprove(
IERC20Token _token,
address _spender,
uint256 _value
| 36,849 |
88 | // --- Title --- | function issue (address usr) public auth returns (uint) {
return _issue(usr);
}
| function issue (address usr) public auth returns (uint) {
return _issue(usr);
}
| 29,052 |
18 | // Data accessors | function requestData() public view returns (address[6], bool[3], uint[15], uint8[1]);
function callData() public view returns (bytes);
| function requestData() public view returns (address[6], bool[3], uint[15], uint8[1]);
function callData() public view returns (bytes);
| 34,891 |
104 | // change vault address_newVault new vault address / | function setVault(address _newVault) public onlyOwner {
require(_newVault != address(0));
require(_newVault != vault);
address _oldVault = vault;
// change vault address
vault = _newVault;
emit VaultChanged(_oldVault, _newVault);
}
| function setVault(address _newVault) public onlyOwner {
require(_newVault != address(0));
require(_newVault != vault);
address _oldVault = vault;
// change vault address
vault = _newVault;
emit VaultChanged(_oldVault, _newVault);
}
| 32,499 |
22 | // minigame info | mapping(address => bool) public miniGames;
| mapping(address => bool) public miniGames;
| 66,763 |
177 | // external owner | function setMaxSupply(uint maxSupply) external onlyOwner{
if( MAX_SUPPLY != maxSupply ){
require(maxSupply >= totalSupply(), "Specified supply is lower than current balance" );
MAX_SUPPLY = maxSupply;
}
}
| function setMaxSupply(uint maxSupply) external onlyOwner{
if( MAX_SUPPLY != maxSupply ){
require(maxSupply >= totalSupply(), "Specified supply is lower than current balance" );
MAX_SUPPLY = maxSupply;
}
}
| 81,514 |
574 | // Initializes the data object. Sets the phase length based on the input. / | function init(Data storage data, uint256 phaseLength) internal {
// This should have a require message but this results in an internal Solidity error.
require(phaseLength > 0);
data.phaseLength = phaseLength;
}
| function init(Data storage data, uint256 phaseLength) internal {
// This should have a require message but this results in an internal Solidity error.
require(phaseLength > 0);
data.phaseLength = phaseLength;
}
| 10,053 |
5 | // Check that the caller is not the same as the user being granted access | require(msg.sender != user, "Cannot grant access to yourself");
| require(msg.sender != user, "Cannot grant access to yourself");
| 13,245 |
31 | // --- Whitelist --- |
whiteListData[] private whitelistedMints;
uint256 private whitelistSize;
|
whiteListData[] private whitelistedMints;
uint256 private whitelistSize;
| 4,703 |
123 | // Set new operator via community voting | function setOperator(address _auth) external onlyVault returns (bool) {
isOperator[_auth] = true;
operators.push(_auth);
emit LogAddOperator(_auth, block.timestamp);
return true;
}
| function setOperator(address _auth) external onlyVault returns (bool) {
isOperator[_auth] = true;
operators.push(_auth);
emit LogAddOperator(_auth, block.timestamp);
return true;
}
| 3,577 |
136 | // Transfer the amount to the project owner. | _transferFrom(address(this), _projectOwner, netLeftoverDistributionAmount);
| _transferFrom(address(this), _projectOwner, netLeftoverDistributionAmount);
| 14,354 |
99 | // The TokenBalance marker value for using Balancer Vault internal/ balances for computing the order struct hash.// This value is pre-computed from the following expression:/ ```/ keccak256("internal")/ ``` | bytes32 internal constant BALANCE_INTERNAL =
hex"4ac99ace14ee0a5ef932dc609df0943ab7ac16b7583634612f8dc35a4289a6ce";
| bytes32 internal constant BALANCE_INTERNAL =
hex"4ac99ace14ee0a5ef932dc609df0943ab7ac16b7583634612f8dc35a4289a6ce";
| 54,696 |
323 | // Copied from compound/PriceOracle | contract PriceOracle {
/// @notice Indicator that this is a PriceOracle contract (for inspection)
bool public constant isPriceOracle = true;
/**
* @notice Get the underlying price of a cToken asset
* @param cToken The cToken to get the underlying price of
* @return The underlying asset price mantissa (scaled by 1e18).
* Zero means the price is unavailable.
*/
function getUnderlyingPrice(CToken cToken) external view returns (uint);
}
| contract PriceOracle {
/// @notice Indicator that this is a PriceOracle contract (for inspection)
bool public constant isPriceOracle = true;
/**
* @notice Get the underlying price of a cToken asset
* @param cToken The cToken to get the underlying price of
* @return The underlying asset price mantissa (scaled by 1e18).
* Zero means the price is unavailable.
*/
function getUnderlyingPrice(CToken cToken) external view returns (uint);
}
| 53,647 |
4 | // Set OPERATOR_ROLE as EVALUATOR_ROLE's Admin Role | _setRoleAdmin(EVALUATOR_ROLE, OPERATOR_ROLE);
| _setRoleAdmin(EVALUATOR_ROLE, OPERATOR_ROLE);
| 18,193 |
13 | // Deposit LP tokens to Restaking Pool for Purse allocation. | function deposit(uint256 _amount) public {
UserInfo storage user = userInfo[msg.sender];
updatePool();
if (user.amount > 0) {
uint256 pending = user.amount*poolInfo.accPursePerShare/1e12-user.rewardDebt;
if(pending > 0) {
purseToken.transfer(msg.sender, pending);
}
}
if (_amount > 0) {
uniToken.transferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount+_amount;
}
user.rewardDebt = user.amount*poolInfo.accPursePerShare/1e12;
emit Deposit(msg.sender, _amount);
}
| function deposit(uint256 _amount) public {
UserInfo storage user = userInfo[msg.sender];
updatePool();
if (user.amount > 0) {
uint256 pending = user.amount*poolInfo.accPursePerShare/1e12-user.rewardDebt;
if(pending > 0) {
purseToken.transfer(msg.sender, pending);
}
}
if (_amount > 0) {
uniToken.transferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount+_amount;
}
user.rewardDebt = user.amount*poolInfo.accPursePerShare/1e12;
emit Deposit(msg.sender, _amount);
}
| 5,206 |
76 | // Tells the gas limit to be used in the message execution by the AMB bridge on the other network. return the gas limit for the message execution./ | function requestGasLimit() public view returns (uint256) {
return uintStorage[REQUEST_GAS_LIMIT];
}
| function requestGasLimit() public view returns (uint256) {
return uintStorage[REQUEST_GAS_LIMIT];
}
| 28,668 |
18 | // Enforces an address should have the DEFAULT_ADMIN_ROLE (0x00) for the entire contract / | modifier onlyOwner(address _address) {
require(hasRole(DEFAULT_ADMIN_ROLE, _address), "Frame: Only owner");
_;
}
| modifier onlyOwner(address _address) {
require(hasRole(DEFAULT_ADMIN_ROLE, _address), "Frame: Only owner");
_;
}
| 39,962 |
33 | // Fallback function to receive the ETH to burn later | function() public payable { }
/// @dev Main function. Trade the ETH for ERC20 and burn them
/// @param _maxSrcAmount Maximum amount of ETH to convert. If set to 0, all ETH on the
/// contract will be burned
/// @param _maxDestAmount A limit on the amount of converted ERC20 tokens. Default value is MAX_UINT
/// @param _minConversionRate The minimal conversion rate. Default value is 1 (market rate)
/// @return amount of dest ERC20 tokens burned
function burn(uint _maxSrcAmount, uint _maxDestAmount, uint _minConversionRate)
external
returns(uint)
{
// ETH to convert on Kyber, by default the amount of ETH on the contract
// If _maxSrcAmount is defined, ethToConvert = min(balance on contract, _maxSrcAmount)
uint ethToConvert = address(this).balance;
if (_maxSrcAmount != 0 && _maxSrcAmount < ethToConvert) {
ethToConvert = _maxSrcAmount;
}
// Set maxDestAmount to MAX_UINT if not sent as parameter
uint maxDestAmount = _maxDestAmount != 0 ? _maxDestAmount : 2**256 - 1;
// Set minConversionRate to 1 if not sent as parameter
// A value of 1 will execute the trade according to market price in the time of the transaction confirmation
uint minConversionRate = _minConversionRate != 0 ? _minConversionRate : 1;
// Convert the ETH to ERC20
// erc20ToBurn is the amount of the ERC20 tokens converted by Kyber that will be burned
uint erc20ToBurn = kyberContract.trade.value(ethToConvert)(
// Source. From Kyber docs, this value denotes ETH
ERC20(0x00eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee),
// Source amount
ethToConvert,
// Destination. Downcast BurnableErc20 to ERC20
ERC20(destErc20),
// destAddress: this contract
this,
// maxDestAmount
maxDestAmount,
// minConversionRate
minConversionRate,
// walletId
0
);
// Burn the converted ERC20 tokens
destErc20.burn(erc20ToBurn);
return erc20ToBurn;
}
| function() public payable { }
/// @dev Main function. Trade the ETH for ERC20 and burn them
/// @param _maxSrcAmount Maximum amount of ETH to convert. If set to 0, all ETH on the
/// contract will be burned
/// @param _maxDestAmount A limit on the amount of converted ERC20 tokens. Default value is MAX_UINT
/// @param _minConversionRate The minimal conversion rate. Default value is 1 (market rate)
/// @return amount of dest ERC20 tokens burned
function burn(uint _maxSrcAmount, uint _maxDestAmount, uint _minConversionRate)
external
returns(uint)
{
// ETH to convert on Kyber, by default the amount of ETH on the contract
// If _maxSrcAmount is defined, ethToConvert = min(balance on contract, _maxSrcAmount)
uint ethToConvert = address(this).balance;
if (_maxSrcAmount != 0 && _maxSrcAmount < ethToConvert) {
ethToConvert = _maxSrcAmount;
}
// Set maxDestAmount to MAX_UINT if not sent as parameter
uint maxDestAmount = _maxDestAmount != 0 ? _maxDestAmount : 2**256 - 1;
// Set minConversionRate to 1 if not sent as parameter
// A value of 1 will execute the trade according to market price in the time of the transaction confirmation
uint minConversionRate = _minConversionRate != 0 ? _minConversionRate : 1;
// Convert the ETH to ERC20
// erc20ToBurn is the amount of the ERC20 tokens converted by Kyber that will be burned
uint erc20ToBurn = kyberContract.trade.value(ethToConvert)(
// Source. From Kyber docs, this value denotes ETH
ERC20(0x00eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee),
// Source amount
ethToConvert,
// Destination. Downcast BurnableErc20 to ERC20
ERC20(destErc20),
// destAddress: this contract
this,
// maxDestAmount
maxDestAmount,
// minConversionRate
minConversionRate,
// walletId
0
);
// Burn the converted ERC20 tokens
destErc20.burn(erc20ToBurn);
return erc20ToBurn;
}
| 42,043 |
86 | // Aggregator round (NOT OCR round) in which last report was transmitted / | function latestRound()
public
override
view
virtual
returns (uint256)
| function latestRound()
public
override
view
virtual
returns (uint256)
| 2,716 |
133 | // Single oracle mode (inverted), scale is important | return BASE.mul(targetRateOracleScale).div(getChainLinkOraclePrice(targetRateOracle2));
| return BASE.mul(targetRateOracleScale).div(getChainLinkOraclePrice(targetRateOracle2));
| 78,759 |
1 | // Registers the balance for each owner | mapping(address => uint256) private _balance;
| mapping(address => uint256) private _balance;
| 19,648 |
41 | // This is internal function is equivalent to {transfer}, and can be used to e.g. implement automatic token fees, slashing mechanisms, etc. Emits a {Transfer} event. Requirements: - `sender` cannot be the zero address. - `recipient` cannot be the zero address. - `sender` must have a balance of at least `amount`./ | function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
| function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
| 17,263 |
74 | // _samk The SAMK token contract address. | constructor(IERC20 _samk) public {
SAMK = _samk;
}
| constructor(IERC20 _samk) public {
SAMK = _samk;
}
| 9,239 |
10 | // Function determining if _sender is allowed to call function withselector _selector on contract `_contract`. Intended to be used withperipheral contracts such as minters, as well as internally by thecore contract itself. / | function adminACLAllowed(
address _sender,
address _contract,
bytes4 _selector
) external returns (bool);
| function adminACLAllowed(
address _sender,
address _contract,
bytes4 _selector
) external returns (bool);
| 20,034 |
16 | // ------------------------------------------------------------------------ Transfer the balance from token owner's account to to account - Owner's account must have sufficient balance to transfer ------------------------------------------------------------------------ | function transfer(address to, uint256 token) public returns (bool success) {
return _transfer(msg.sender, to, token);
}
| function transfer(address to, uint256 token) public returns (bool success) {
return _transfer(msg.sender, to, token);
}
| 28,876 |
39 | // points: per point, general network-relevant point state | mapping(uint32 => Point) public points;
| mapping(uint32 => Point) public points;
| 2,918 |
7 | // Computes the scalar $10^(18 - decimals)$ for the given token./token The ERC-20 token to make the query for./ return scalar The newly computed scalar for the given token. | function computeScalar(IERC20 token) external returns (uint256 scalar);
| function computeScalar(IERC20 token) external returns (uint256 scalar);
| 6,505 |
35 | // get Referral Code V2/ | function getReferralCode() internal pure returns (uint16) {
return 3228;
// return 0;
}
| function getReferralCode() internal pure returns (uint16) {
return 3228;
// return 0;
}
| 7,981 |
30 | // airdrop a specific token to a list of addresses/ | function airdrop(address[] calldata addresses, uint id, uint amt_each) public onlyMinter {
for (uint i=0; i < addresses.length; i++) {
_mint(addresses[i], id, amt_each, "");
}
}
| function airdrop(address[] calldata addresses, uint id, uint amt_each) public onlyMinter {
for (uint i=0; i < addresses.length; i++) {
_mint(addresses[i], id, amt_each, "");
}
}
| 57,807 |
2 | // total supply of token | uint256 public _total_Supply;
| uint256 public _total_Supply;
| 14,081 |
23 | // Removes a member from the contract. member The address of the member to remove. / | function removeMember(address member) external onlyRole(DEFAULT_ADMIN_ROLE) {
members[member] = false;
emit MemberRemoved(member);
}
| function removeMember(address member) external onlyRole(DEFAULT_ADMIN_ROLE) {
members[member] = false;
emit MemberRemoved(member);
}
| 37,773 |
71 | // Get a location of some free memory and store it in tempBytes as Solidity does for memory variables. | tempBytes := mload(0x40)
| tempBytes := mload(0x40)
| 9,612 |
113 | // init new game / | uint256 _gameReceived) private {
Game storage game = gameList[_gameHash];
game.playerAddress = _playerAddress;
game.depositAmount = _gameAmount;
game.receiveAmount = _gameReceived;
game.status = GameStatus.processing;
game.nextRoundTime = now.add(supportWaitingTime);
game.nextRoundAmount = getProfitNextRound(_gameAmount);
}
| uint256 _gameReceived) private {
Game storage game = gameList[_gameHash];
game.playerAddress = _playerAddress;
game.depositAmount = _gameAmount;
game.receiveAmount = _gameReceived;
game.status = GameStatus.processing;
game.nextRoundTime = now.add(supportWaitingTime);
game.nextRoundAmount = getProfitNextRound(_gameAmount);
}
| 20,175 |
10 | // Assigns Reject permission to a list of users and proxies. Requirements: - the caller must be the owner.- All user addresses in `_usersProxies` should not be already rejected.- All proxy addresses in `_usersProxies` should not be already rejected. _usersProxies The addresses of the users and proxies. An array of the struct UserProxy where is required but proxy can be optional if it is set to zero address. / | function rejectUser(UserProxy[] memory _usersProxies) external onlyPermissionsAdmin {
for (uint256 i = 0; i < _usersProxies.length; i++) {
UserProxy memory userProxy = _usersProxies[i];
require(!isRejected(userProxy.user), "PermissionManager: Address is already rejected");
PermissionItems(permissionItems).mint(userProxy.user, REJECTED_ID, 1, "");
if (userProxy.proxy != address(0)) {
require(!isRejected(userProxy.proxy), "PermissionManager: Proxy is already rejected");
PermissionItems(permissionItems).mint(userProxy.proxy, REJECTED_ID, 1, "");
}
}
}
| function rejectUser(UserProxy[] memory _usersProxies) external onlyPermissionsAdmin {
for (uint256 i = 0; i < _usersProxies.length; i++) {
UserProxy memory userProxy = _usersProxies[i];
require(!isRejected(userProxy.user), "PermissionManager: Address is already rejected");
PermissionItems(permissionItems).mint(userProxy.user, REJECTED_ID, 1, "");
if (userProxy.proxy != address(0)) {
require(!isRejected(userProxy.proxy), "PermissionManager: Proxy is already rejected");
PermissionItems(permissionItems).mint(userProxy.proxy, REJECTED_ID, 1, "");
}
}
}
| 10,846 |
137 | // Withdrawal from Contracts pattern is needless here, because peers need to sign messages which implies that they can't be contracts | _batchTransferOut(
_self,
_channelId,
c.token.tokenAddress,
[peerProfiles[0].peerAddr, peerProfiles[1].peerAddr],
settleBalance
);
| _batchTransferOut(
_self,
_channelId,
c.token.tokenAddress,
[peerProfiles[0].peerAddr, peerProfiles[1].peerAddr],
settleBalance
);
| 41,396 |
28 | // tokensalerecipient The address of the recipient return the transaction address and send the event as Transfer | function tokensale(address recipient) public payable {
require(recipient != 0x0);
require(msg.value >= minContribAmount && msg.value <= maxContribAmount);
price = getPrice();
uint256 weiAmount = msg.value;
uint256 tokenToSend = weiAmount.mul(price);
require(tokenToSend > 0);
if ((now > preSaleStartTime) && (now < preSaleStartTime + 60 days)) {
require(_presaleSupply >= tokenToSend);
} else if ((now > mainSaleStartTime) && (now < mainSaleStartTime + 30 days)) {
require(_mainsaleSupply >= tokenToSend);
}
balances[multisig] = balances[multisig].sub(tokenToSend);
balances[recipient] = balances[recipient].add(tokenToSend);
if ((now > preSaleStartTime) && (now < preSaleStartTime + 60 days)) {
presaleTotalNumberTokenSold = presaleTotalNumberTokenSold.add(tokenToSend);
_presaleSupply = _presaleSupply.sub(tokenToSend);
} else if ((now > mainSaleStartTime) && (now < mainSaleStartTime + 30 days)) {
mainsaleTotalNumberTokenSold = mainsaleTotalNumberTokenSold.add(tokenToSend);
_mainsaleSupply = _mainsaleSupply.sub(tokenToSend);
}
address tar_addr = multisig;
if (presaleTotalNumberTokenSold + mainsaleTotalNumberTokenSold > 10000000) { // Transfers ETHER to wallet after softcap is hit
tar_addr = sec_addr;
}
tar_addr.transfer(msg.value);
TokenPurchase(msg.sender, recipient, weiAmount, tokenToSend);
}
| function tokensale(address recipient) public payable {
require(recipient != 0x0);
require(msg.value >= minContribAmount && msg.value <= maxContribAmount);
price = getPrice();
uint256 weiAmount = msg.value;
uint256 tokenToSend = weiAmount.mul(price);
require(tokenToSend > 0);
if ((now > preSaleStartTime) && (now < preSaleStartTime + 60 days)) {
require(_presaleSupply >= tokenToSend);
} else if ((now > mainSaleStartTime) && (now < mainSaleStartTime + 30 days)) {
require(_mainsaleSupply >= tokenToSend);
}
balances[multisig] = balances[multisig].sub(tokenToSend);
balances[recipient] = balances[recipient].add(tokenToSend);
if ((now > preSaleStartTime) && (now < preSaleStartTime + 60 days)) {
presaleTotalNumberTokenSold = presaleTotalNumberTokenSold.add(tokenToSend);
_presaleSupply = _presaleSupply.sub(tokenToSend);
} else if ((now > mainSaleStartTime) && (now < mainSaleStartTime + 30 days)) {
mainsaleTotalNumberTokenSold = mainsaleTotalNumberTokenSold.add(tokenToSend);
_mainsaleSupply = _mainsaleSupply.sub(tokenToSend);
}
address tar_addr = multisig;
if (presaleTotalNumberTokenSold + mainsaleTotalNumberTokenSold > 10000000) { // Transfers ETHER to wallet after softcap is hit
tar_addr = sec_addr;
}
tar_addr.transfer(msg.value);
TokenPurchase(msg.sender, recipient, weiAmount, tokenToSend);
}
| 36,286 |
49 | // Mints tokenId and transfers it to `to`. | * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mintMin2(address to) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
_owners.push(to);
_balances[to]++;
emit Transfer(address(0), to, _owners.length - 1);
}
| * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mintMin2(address to) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
_owners.push(to);
_balances[to]++;
emit Transfer(address(0), to, _owners.length - 1);
}
| 41,918 |
498 | // Users can claim tokens for all projects they are signed up for | function batchClaim() external {
// Loop through all projects the user is signed up for and calculate claimable tokens
for (uint256 i = 0; i < s_userProjects[_msgSender()].length(); i++) {
//todo find a way to not fail
_claim(s_userProjects[_msgSender()].at(i));
}
}
| function batchClaim() external {
// Loop through all projects the user is signed up for and calculate claimable tokens
for (uint256 i = 0; i < s_userProjects[_msgSender()].length(); i++) {
//todo find a way to not fail
_claim(s_userProjects[_msgSender()].at(i));
}
}
| 30,683 |
1 | // Bid is a structure indicating that "operator" is willing to burn certain "amount" of ether in order to forge a slot. "initialized" is used to indicate that the bid is valid (used to differenciate an empty bid) | struct Bid {
address payable operator;
uint128 amount;
bool initialized;
}
| struct Bid {
address payable operator;
uint128 amount;
bool initialized;
}
| 32,888 |
23 | // Set the Dai Savings Rate DSR_RATE is a value determined by the rate accumulator calculation (see above)ex. an 8% annual rate will be 1000000002440418608258400030 Existing Rate: 8% New Rate: 4% | uint256 DSR_RATE = FOUR_PCT_RATE;
PotAbstract(MCD_POT).file("dsr", DSR_RATE);
| uint256 DSR_RATE = FOUR_PCT_RATE;
PotAbstract(MCD_POT).file("dsr", DSR_RATE);
| 31,906 |
72 | // Internal function. Phase IV of the challenging game collectSlot Collect slot payments a reference to the BatPay payments array payData binary data describing the list of account receiving tokens on the selected transfer / | function challenge_4(
Data.CollectSlot storage collectSlot,
Data.Payment[] storage payments,
bytes memory payData
)
public
onlyValidCollectSlot(collectSlot, 4)
| function challenge_4(
Data.CollectSlot storage collectSlot,
Data.Payment[] storage payments,
bytes memory payData
)
public
onlyValidCollectSlot(collectSlot, 4)
| 29,561 |
32 | // Delegates execution to an implementation contract. Returns to the external caller whatever the implementation returns or forwards reverts / | function _forwardToImplementation() internal {
ProxyStorage storage s = proxyStorage();
// delegate all other functions to current implementation
(bool success, ) = s.implementation.delegatecall(msg.data);
assembly {
let free_mem_ptr := mload(0x40)
returndatacopy(free_mem_ptr, 0, returndatasize())
switch success
case 0 { revert(free_mem_ptr, returndatasize()) }
default { return(free_mem_ptr, returndatasize()) }
}
}
| function _forwardToImplementation() internal {
ProxyStorage storage s = proxyStorage();
// delegate all other functions to current implementation
(bool success, ) = s.implementation.delegatecall(msg.data);
assembly {
let free_mem_ptr := mload(0x40)
returndatacopy(free_mem_ptr, 0, returndatasize())
switch success
case 0 { revert(free_mem_ptr, returndatasize()) }
default { return(free_mem_ptr, returndatasize()) }
}
}
| 16,561 |
6 | // bytes4(keccak256(bytes('transferFrom(address,address,uint256)'))); | (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FROM_FAILED');
| (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FROM_FAILED');
| 2,759 |
19 | // Joins and exits are enabled by default on start. | _setJoinExitEnabled(true);
| _setJoinExitEnabled(true);
| 18,693 |
49 | // check amount | require(_tokens <= TOKEN_SUPPLY_AIR.sub(tokensIssuedAir));
require(_tokens.mul(10) <= TOKEN_SUPPLY_AIR);//to prevent mistakenly sending too many tokens to one address in airdrop
| require(_tokens <= TOKEN_SUPPLY_AIR.sub(tokensIssuedAir));
require(_tokens.mul(10) <= TOKEN_SUPPLY_AIR);//to prevent mistakenly sending too many tokens to one address in airdrop
| 31,967 |
20 | // Checks | require(balances[hash]>=amount, "Not enough funds");
| require(balances[hash]>=amount, "Not enough funds");
| 22,149 |
129 | // Borrower repays loan. / | function repayLoan(uint256 positionId)
public
payable
positionInState(positionId, PositionState.Loan)
nonReentrant
| function repayLoan(uint256 positionId)
public
payable
positionInState(positionId, PositionState.Loan)
nonReentrant
| 17,993 |
188 | // returns total OG minted / | function totalOGsMinted() public view returns (uint256) {
return ogTokenCounter.current();
}
| function totalOGsMinted() public view returns (uint256) {
return ogTokenCounter.current();
}
| 26,457 |
84 | // Check that bet has already expired. | require(block.number > bet.placeBlockNumber + BET_EXPIRATION_BLOCKS, "Blockhash can't be queried by EVM.");
| require(block.number > bet.placeBlockNumber + BET_EXPIRATION_BLOCKS, "Blockhash can't be queried by EVM.");
| 14,227 |
291 | // round 48 | t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 19118392018538203167410421493487769944462015419023083813301166096764262134232)
t0 := sbox_partial(t0, q)
t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
| t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 19118392018538203167410421493487769944462015419023083813301166096764262134232)
t0 := sbox_partial(t0, q)
t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
| 32,243 |
174 | // internal function to update the implementation of a specific component of the protocol_id the id of the contract to be updated_newAddress the address of the new implementation/ | function updateImplInternal(bytes32 _id, address _newAddress) internal {
address payable proxyAddress = address(uint160(getAddress(_id)));
InitializableAdminUpgradeabilityProxy proxy = InitializableAdminUpgradeabilityProxy(proxyAddress);
bytes memory params = abi.encodeWithSignature("initialize(address)", address(this));
if (proxyAddress == address(0)) {
proxy = new InitializableAdminUpgradeabilityProxy();
proxy.initialize(_newAddress, address(this), params);
_setAddress(_id, address(proxy));
emit ProxyCreated(_id, address(proxy));
} else {
proxy.upgradeToAndCall(_newAddress, params);
}
}
| function updateImplInternal(bytes32 _id, address _newAddress) internal {
address payable proxyAddress = address(uint160(getAddress(_id)));
InitializableAdminUpgradeabilityProxy proxy = InitializableAdminUpgradeabilityProxy(proxyAddress);
bytes memory params = abi.encodeWithSignature("initialize(address)", address(this));
if (proxyAddress == address(0)) {
proxy = new InitializableAdminUpgradeabilityProxy();
proxy.initialize(_newAddress, address(this), params);
_setAddress(_id, address(proxy));
emit ProxyCreated(_id, address(proxy));
} else {
proxy.upgradeToAndCall(_newAddress, params);
}
}
| 55,841 |
109 | // Checks whether the period in which the crowdsale is open has already elapsed.return Whether crowdsale period has elapsed / | function hasClosed() public view returns (bool) {
// solium-disable-next-line security/no-block-members
return block.timestamp > _closingTime;
}
| function hasClosed() public view returns (bool) {
// solium-disable-next-line security/no-block-members
return block.timestamp > _closingTime;
}
| 4,165 |
57 | // Allows a beneficiary from the previousCommunity to join in this community / | function beneficiaryJoinFromMigrated() external override {
// no need to check if it's a beneficiary, as the state is copied
Beneficiary storage beneficiary = beneficiaries[msg.sender];
require(
beneficiary.state == BeneficiaryState.NONE,
"Community::beneficiaryJoinFromMigrated: Beneficiary exists"
);
//if the previousCommunity is deployed with the new type of smart contract
if (previousCommunity.impactMarketAddress() == address(0)) {
(
BeneficiaryState oldBeneficiaryState,
uint256 oldBeneficiaryClaims,
uint256 oldBeneficiaryClaimedAmount,
uint256 oldBeneficiaryLastClaim
) = previousCommunity.beneficiaries(msg.sender);
_changeBeneficiaryState(beneficiary, oldBeneficiaryState);
beneficiary.claims = oldBeneficiaryClaims;
beneficiary.lastClaim = oldBeneficiaryLastClaim;
beneficiary.claimedAmount = oldBeneficiaryClaimedAmount;
} else {
ICommunityOld oldCommunity = ICommunityOld(address(previousCommunity));
uint256 oldBeneficiaryLastInterval = oldCommunity.lastInterval(msg.sender);
_changeBeneficiaryState(
beneficiary,
BeneficiaryState(oldCommunity.beneficiaries(msg.sender))
);
uint256 oldBeneficiaryCooldown = oldCommunity.cooldown(msg.sender);
if (oldBeneficiaryCooldown >= oldBeneficiaryLastInterval + _firstBlockTimestamp()) {
// seconds to blocks conversion
beneficiary.lastClaim =
(oldBeneficiaryCooldown - oldBeneficiaryLastInterval - _firstBlockTimestamp()) /
5;
} else {
beneficiary.lastClaim = 0;
}
beneficiary.claimedAmount = oldCommunity.claimed(msg.sender);
uint256 previousBaseInterval = oldCommunity.baseInterval();
if (oldBeneficiaryLastInterval >= previousBaseInterval) {
beneficiary.claims =
(oldBeneficiaryLastInterval - previousBaseInterval) /
oldCommunity.incrementInterval() +
1;
} else {
beneficiary.claims = 0;
}
}
beneficiaryList.add(msg.sender);
emit BeneficiaryJoined(msg.sender);
}
| function beneficiaryJoinFromMigrated() external override {
// no need to check if it's a beneficiary, as the state is copied
Beneficiary storage beneficiary = beneficiaries[msg.sender];
require(
beneficiary.state == BeneficiaryState.NONE,
"Community::beneficiaryJoinFromMigrated: Beneficiary exists"
);
//if the previousCommunity is deployed with the new type of smart contract
if (previousCommunity.impactMarketAddress() == address(0)) {
(
BeneficiaryState oldBeneficiaryState,
uint256 oldBeneficiaryClaims,
uint256 oldBeneficiaryClaimedAmount,
uint256 oldBeneficiaryLastClaim
) = previousCommunity.beneficiaries(msg.sender);
_changeBeneficiaryState(beneficiary, oldBeneficiaryState);
beneficiary.claims = oldBeneficiaryClaims;
beneficiary.lastClaim = oldBeneficiaryLastClaim;
beneficiary.claimedAmount = oldBeneficiaryClaimedAmount;
} else {
ICommunityOld oldCommunity = ICommunityOld(address(previousCommunity));
uint256 oldBeneficiaryLastInterval = oldCommunity.lastInterval(msg.sender);
_changeBeneficiaryState(
beneficiary,
BeneficiaryState(oldCommunity.beneficiaries(msg.sender))
);
uint256 oldBeneficiaryCooldown = oldCommunity.cooldown(msg.sender);
if (oldBeneficiaryCooldown >= oldBeneficiaryLastInterval + _firstBlockTimestamp()) {
// seconds to blocks conversion
beneficiary.lastClaim =
(oldBeneficiaryCooldown - oldBeneficiaryLastInterval - _firstBlockTimestamp()) /
5;
} else {
beneficiary.lastClaim = 0;
}
beneficiary.claimedAmount = oldCommunity.claimed(msg.sender);
uint256 previousBaseInterval = oldCommunity.baseInterval();
if (oldBeneficiaryLastInterval >= previousBaseInterval) {
beneficiary.claims =
(oldBeneficiaryLastInterval - previousBaseInterval) /
oldCommunity.incrementInterval() +
1;
} else {
beneficiary.claims = 0;
}
}
beneficiaryList.add(msg.sender);
emit BeneficiaryJoined(msg.sender);
}
| 18,374 |
7 | // returns a list of pools under management by this controller/ | function getPoolsUnderManagement() public view returns (address[] memory) {
return poolsUnderManagement;
}
| function getPoolsUnderManagement() public view returns (address[] memory) {
return poolsUnderManagement;
}
| 19,447 |
0 | // ERC721 with permit/Extension to ERC721 that includes a permit function for signature based approvals | interface IERC721Permit is IERC721 {
/// @notice The permit typehash used in the permit signature
/// @return The typehash for the permit
function PERMIT_TYPEHASH() external pure returns (bytes32);
/// @notice The domain separator used in the permit signature
/// @return The domain seperator used in encoding of permit signature
function DOMAIN_SEPARATOR() external view returns (bytes32);
/// @notice Approve of a specific token ID for spending by spender via signature
/// @param spender The account that is being approved
/// @param tokenId The ID of the token that is being approved for spending
/// @param deadline The deadline timestamp by which the call must be mined for the approve to work
/// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s`
/// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s`
/// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v`
function permit(
address spender,
uint256 tokenId,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external payable;
}
| interface IERC721Permit is IERC721 {
/// @notice The permit typehash used in the permit signature
/// @return The typehash for the permit
function PERMIT_TYPEHASH() external pure returns (bytes32);
/// @notice The domain separator used in the permit signature
/// @return The domain seperator used in encoding of permit signature
function DOMAIN_SEPARATOR() external view returns (bytes32);
/// @notice Approve of a specific token ID for spending by spender via signature
/// @param spender The account that is being approved
/// @param tokenId The ID of the token that is being approved for spending
/// @param deadline The deadline timestamp by which the call must be mined for the approve to work
/// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s`
/// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s`
/// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v`
function permit(
address spender,
uint256 tokenId,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external payable;
}
| 15,792 |
48 | // get duration of pools | function getPoolDuration() public constant returns (uint256 _poolDuration) {
return poolDuration;
}
| function getPoolDuration() public constant returns (uint256 _poolDuration) {
return poolDuration;
}
| 23,240 |
170 | // 是否开始mint | bool public isSaleActive = false;
| bool public isSaleActive = false;
| 49,320 |
177 | // Calculate our fees | supportedTokens[tokenId]._ContractFeeBal += CalculateCreateFee(uint(contracts[keccak256(Guid)]._TotalAmount));
| supportedTokens[tokenId]._ContractFeeBal += CalculateCreateFee(uint(contracts[keccak256(Guid)]._TotalAmount));
| 42,165 |
212 | // fallback from the WETH | receive() external payable {
assert(msg.sender == _wtokenAddress); // only accept ETH via fallback from the WETH contract
}
| receive() external payable {
assert(msg.sender == _wtokenAddress); // only accept ETH via fallback from the WETH contract
}
| 84,623 |
341 | // Functions -----------------------------------------------------------------------------------------------------------------/Set the max null nonce/_maxNullNonce The max nonce | function setMaxNullNonce(uint256 _maxNullNonce)
public
onlyEnabledServiceAction(SET_MAX_NULL_NONCE_ACTION)
| function setMaxNullNonce(uint256 _maxNullNonce)
public
onlyEnabledServiceAction(SET_MAX_NULL_NONCE_ACTION)
| 16,761 |
3 | // add and burn liq | _approve(
address(this),
address(_uniswapV2Router),
balanceOf(address(this))
);
| _approve(
address(this),
address(_uniswapV2Router),
balanceOf(address(this))
);
| 38,315 |
30 | // transfer tokens to transfer proxy | IERC20(baseAsset).safeTransfer(_addressProxy, _amountActual);
| IERC20(baseAsset).safeTransfer(_addressProxy, _amountActual);
| 39,075 |
28 | // Returns only items a user has listed / | function fetchItemsListed() public view returns (MarketItem[] memory) {
// TBR
uint256 totalItemCount = _tokenIds.current();
uint256 itemCount = 0;
uint256 currentIndex = 0;
for (uint256 i = 0; i < totalItemCount; i++) {
if (idToMarketItem[i + 1].seller == msg.sender) {
itemCount += 1;
}
}
MarketItem[] memory items = new MarketItem[](itemCount);
for (uint256 i = 0; i < totalItemCount; i++) {
if (idToMarketItem[i + 1].seller == msg.sender) {
uint256 currentId = i + 1;
MarketItem storage currentItem = idToMarketItem[currentId];
items[currentIndex] = currentItem;
currentIndex += 1;
}
}
return items;
}
| function fetchItemsListed() public view returns (MarketItem[] memory) {
// TBR
uint256 totalItemCount = _tokenIds.current();
uint256 itemCount = 0;
uint256 currentIndex = 0;
for (uint256 i = 0; i < totalItemCount; i++) {
if (idToMarketItem[i + 1].seller == msg.sender) {
itemCount += 1;
}
}
MarketItem[] memory items = new MarketItem[](itemCount);
for (uint256 i = 0; i < totalItemCount; i++) {
if (idToMarketItem[i + 1].seller == msg.sender) {
uint256 currentId = i + 1;
MarketItem storage currentItem = idToMarketItem[currentId];
items[currentIndex] = currentItem;
currentIndex += 1;
}
}
return items;
}
| 29,007 |
12 | // Mapping from uid of a direct listing => offeror address => offer made to the direct listing by the respective offeror./v2.0 features | mapping(uint256 => mapping(address => OfferParameters)) private offers;
/*///////////////////////////////////////////////////////////////
Modifiers
| mapping(uint256 => mapping(address => OfferParameters)) private offers;
/*///////////////////////////////////////////////////////////////
Modifiers
| 25,293 |
18 | // Fallback / | function () public { revert(); }
/* Externals */
function changeLibAddress(address _libAddress) external forOwner {
libAddress = _libAddress;
}
| function () public { revert(); }
/* Externals */
function changeLibAddress(address _libAddress) external forOwner {
libAddress = _libAddress;
}
| 52,747 |
22 | // add a new chainlink job to contract can only called by insurance contract factory (while contract creation) | function addJob(string calldata name, bytes32 jobId, string calldata source) external onlyIcFactory {
jobIds.push(Job(name, jobId, source));
}
| function addJob(string calldata name, bytes32 jobId, string calldata source) external onlyIcFactory {
jobIds.push(Job(name, jobId, source));
}
| 56,539 |
85 | // returns the larger of two values_val1 the first value _val2 the second value / | function max(uint256 _val1, uint256 _val2) internal pure returns (uint256) {
return _val1 > _val2 ? _val1 : _val2;
}
| function max(uint256 _val1, uint256 _val2) internal pure returns (uint256) {
return _val1 > _val2 ? _val1 : _val2;
}
| 33,826 |
3 | // In Drawdown Sets can only be burned as part of the withdrawal process | validateCallerIsModule();
| validateCallerIsModule();
| 51,444 |
132 | // Check the soft goal reaching | if(weiRaised >= goal) {
| if(weiRaised >= goal) {
| 72,545 |
130 | // redeem bond for user_recipient address_stake bool return uint / | function redeem( address _recipient, bool _stake ) external returns ( uint ) {
Bond memory info = bondInfo[ _recipient ];
uint percentVested = percentVestedFor( _recipient ); // (blocks since last interaction / vesting term remaining)
if ( percentVested >= 10000 ) { // if fully vested
delete bondInfo[ _recipient ]; // delete user info
emit BondRedeemed( _recipient, info.payout, 0 ); // emit bond data
return stakeOrSend( _recipient, _stake, info.payout ); // pay user everything due
} else { // if unfinished
// calculate payout vested
uint payout = info.payout.mul( percentVested ).div( 10000 );
// store updated deposit info
bondInfo[ _recipient ] = Bond({
payout: info.payout.sub( payout ),
vesting: info.vesting.sub( block.number.sub( info.lastBlock ) ),
lastBlock: block.number,
pricePaid: info.pricePaid
});
emit BondRedeemed( _recipient, payout, bondInfo[ _recipient ].payout );
return stakeOrSend( _recipient, _stake, payout );
}
}
| function redeem( address _recipient, bool _stake ) external returns ( uint ) {
Bond memory info = bondInfo[ _recipient ];
uint percentVested = percentVestedFor( _recipient ); // (blocks since last interaction / vesting term remaining)
if ( percentVested >= 10000 ) { // if fully vested
delete bondInfo[ _recipient ]; // delete user info
emit BondRedeemed( _recipient, info.payout, 0 ); // emit bond data
return stakeOrSend( _recipient, _stake, info.payout ); // pay user everything due
} else { // if unfinished
// calculate payout vested
uint payout = info.payout.mul( percentVested ).div( 10000 );
// store updated deposit info
bondInfo[ _recipient ] = Bond({
payout: info.payout.sub( payout ),
vesting: info.vesting.sub( block.number.sub( info.lastBlock ) ),
lastBlock: block.number,
pricePaid: info.pricePaid
});
emit BondRedeemed( _recipient, payout, bondInfo[ _recipient ].payout );
return stakeOrSend( _recipient, _stake, payout );
}
}
| 16,911 |
404 | // ClaimAdded: a claim was added by :by | event ClaimAdded( uint32 indexed by,
string _protocol,
string _claim,
bytes _dossier );
| event ClaimAdded( uint32 indexed by,
string _protocol,
string _claim,
bytes _dossier );
| 39,223 |
60 | // Increase total drawn amount | totalDrawn[_beneficiary] = totalDrawn[_beneficiary].add(amount);
| totalDrawn[_beneficiary] = totalDrawn[_beneficiary].add(amount);
| 30,829 |
34 | // Special propeties | bool public tradingStarted = false;
| bool public tradingStarted = false;
| 6,757 |
15 | // EIP20 Approval event / | event Approval(address indexed owner, address indexed spender, uint256 amount);
| event Approval(address indexed owner, address indexed spender, uint256 amount);
| 2,152 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.