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
|
---|---|---|---|---|
172 | // update wether or not the rate engine is enabled / | function updateEnabled(bool enabled) external;
| function updateEnabled(bool enabled) external;
| 32,919 |
162 | // Emitted when the protocol fee is changed by the pool/feeProtocol0Old The previous value of the token0 protocol fee/feeProtocol1Old The previous value of the token1 protocol fee/feeProtocol0New The updated value of the token0 protocol fee/feeProtocol1New The updated value of the token1 protocol fee | event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New);
| event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New);
| 5,158 |
101 | // Reclaim all ERC20 compatible tokens, but not more than the VIT tokens which were reserved for refunds./token ERC20Basic The address of the token contract. | function reclaimToken(ERC20Basic token) external onlyOwner {
uint256 balance = token.balanceOf(this);
if (token == vitToken) {
balance = balance.sub(totalClaimableTokens);
}
assert(token.transfer(owner, balance));
}
| function reclaimToken(ERC20Basic token) external onlyOwner {
uint256 balance = token.balanceOf(this);
if (token == vitToken) {
balance = balance.sub(totalClaimableTokens);
}
assert(token.transfer(owner, balance));
}
| 27,442 |
287 | // {onERC20SpendableReceived} External function called by ERC20SpendableTokens. Thisvalidates that the token is valid and then calls the internal {_handleSpend} method.You must overried {_handleSpend} in your contract to perform processing you wish to occuron token spend. This method will pass back the valid bytes4 selector and any bytes argument passed from{_handleSpend}.spender_ The address spending the ERC20Spendable spent_ The amount of token spent arguments_ Bytes sent with the call / | function onERC20SpendableReceived(
address spender_,
uint256 spent_,
bytes memory arguments_
) external returns (bytes4 retval_, bytes memory returnArguments_);
| function onERC20SpendableReceived(
address spender_,
uint256 spent_,
bytes memory arguments_
) external returns (bytes4 retval_, bytes memory returnArguments_);
| 7,532 |
212 | // set byfrost as origin | return 2;
| return 2;
| 48,883 |
13 | // Allow _spender to withdraw from your account, multiple times, up to the _value amount. If this function is called again it overwrites the current allowance with _value. | function approve(address _spender, uint256 _amount) returns (bool success) {
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
| function approve(address _spender, uint256 _amount) returns (bool success) {
allowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}
| 21,416 |
86 | // Formula from the book "Hacker's Delight" | int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
| int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
| 7,121 |
229 | // expmodsAndPoints.expmods[14] = traceGenerator^57. | mstore(add(expmodsAndPoints, 0x1c0),
mulmod(mload(add(expmodsAndPoints, 0x1a0)), // traceGenerator^32
mulmod(mload(add(expmodsAndPoints, 0x180)), // traceGenerator^24
traceGenerator, // traceGenerator^1
PRIME),
PRIME))
| mstore(add(expmodsAndPoints, 0x1c0),
mulmod(mload(add(expmodsAndPoints, 0x1a0)), // traceGenerator^32
mulmod(mload(add(expmodsAndPoints, 0x180)), // traceGenerator^24
traceGenerator, // traceGenerator^1
PRIME),
PRIME))
| 28,952 |
46 | // This is an alternative to {approve} that can be used as a mitigation forproblems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address.- `spender` must have allowance for the caller of at least`subtractedValue`. / | function decreaseAllowance(address spender, uint256 subtractedValue)
public
virtual
returns (bool)
{
_approve(
msg.sender,
spender,
_allowances[msg.sender][spender].sub(
subtractedValue,
| function decreaseAllowance(address spender, uint256 subtractedValue)
public
virtual
returns (bool)
{
_approve(
msg.sender,
spender,
_allowances[msg.sender][spender].sub(
subtractedValue,
| 5,149 |
3 | // Only permits calls by oracles. / | modifier onlyOracle() {
if (oracles[msg.sender] == false) revert OnlyOracle();
_;
}
| modifier onlyOracle() {
if (oracles[msg.sender] == false) revert OnlyOracle();
_;
}
| 7,613 |
24 | // returns how many bettors and coins on a specific number for the next round_round - block height_tableId - table indexreturn uint256[3] - array of prizes, fisrt is gold / | function getTablePrizes(uint256 _round, uint256 _tableId)
| function getTablePrizes(uint256 _round, uint256 _tableId)
| 49,995 |
13 | // Configuration of a new Llama instance. | struct LlamaInstanceConfig {
string name; // The name of the Llama instance.
ILlamaStrategy strategyLogic; // The initial strategy implementation (logic) contract.
ILlamaAccount accountLogic; // The initial account implementation (logic) contract.
bytes[] initialStrategies; // Array of initial strategy configurations.
bytes[] initialAccounts; // Array of initial account configurations.
LlamaPolicyConfig policyConfig; // Configuration of the instance's policy.
}
| struct LlamaInstanceConfig {
string name; // The name of the Llama instance.
ILlamaStrategy strategyLogic; // The initial strategy implementation (logic) contract.
ILlamaAccount accountLogic; // The initial account implementation (logic) contract.
bytes[] initialStrategies; // Array of initial strategy configurations.
bytes[] initialAccounts; // Array of initial account configurations.
LlamaPolicyConfig policyConfig; // Configuration of the instance's policy.
}
| 33,931 |
31 | // cch_op_hashes= 29d74ac19d4e330fdab98ebbba4a83f45e979fc8ded9799bd2479a4b b'\xcfwH\xdd\xfa\xb9\xb8%\xf9\xb6\x87\x08t\xe8I1\xa0Z\xe3F\xb6Er\xbd\xd2\r\xf7$Y\xfal\xa4' cch_op_hashes= f10530d981a27109f4cada3ebbc3d2f36298b4e7b2452f06856c2d5a b'\xce/1\xe9\x9a\x182C\xcdv\xd5\x81\xbe\xc6e\x16XB\[email protected]\xd8\xf63\xb2P\xbeN\xd3 \xc9\xda\xc6' cch_op_hashes= 833bbc070ef699ef5f46ac8ed31ccdd973b89e647e467e1b71308fb7 b"\xce:u\xe2Ik\xc7\xbf\xe1\xd4'\t\xba\x15\x0e'\x88\x04A\x02\x83\xcc\x9f\xe5\xb0=\xee\x8b5C\xa3\xfc" cch_op_hashes= a2960aa7887491deabc338f555371493b3a7f532f1e54c73b3c17120 b'\xf3=\xfai\r3\xadY\xf1\x82zEs\t\xfc\x1d\xd9\x153]\xc1;\x8b\xf0\xd4\xe7\xf8"\riU\xbc' | // cch_op_hashes= ce2e8a132e53f665b9b5c89bb8ab97607e507b5a9ef7a8a90b8feeba b'\xb2\xa0~%&"\xbe\x9b}\xbc\xea\xdeO\xfeb\xd4\xbenllh9\xb2p*\x8b{\xbb9\x84H\x9c'
// cch_op_hashes= fed3945f9e092f31ce67ed763ef87750c732c182f165ed018dbcf8de b'\x8cH\xdf\x00`\x99\x1e\xdf\x10:\xd4o,\xd50\xf9\xf9nwj\xf6\xf8\xd2\rM\xf5(\xe1V\xa3\x17\x8b'
// cch_op_hashes= aebada224be5d2e44e050202b1d6adf2c2c544d24b18a0d191c2276f b"'\x03\xad\x9e2U\xd8\xc2BE\x8f\x02\x84\xdb(]\[email protected]\xd2\xec\xcb\xe4\x8aO\x88A8\x90\xbe\x0f\xc4Q"
// cch_op_hashes= d667c8d9c9e4af1c2758491a70263175bd41769d112170f829bb6042 b'u{\x94\x15\x9a\xc4\xff\xc7\x19\xfc\x81\x83\xf4\x96q\x08F\x8c/j\x1a\x8a\xa0M\xdcyB\xdd\xb1\xa41o'
// cch_op_hashes= 8382cf68a466e2dc68fdf52b53877c18f1f52f53462a7ed2781d955b b'\x1b}+\xd9\xbe\xa9\xf7q\x17\xc6\xad\r\xd2\xee-\xc1\xbf\x07G\xa2\xd2k`X\xc1\xa9\x9b\xad\xd3l(\xee'
| // cch_op_hashes= ce2e8a132e53f665b9b5c89bb8ab97607e507b5a9ef7a8a90b8feeba b'\xb2\xa0~%&"\xbe\x9b}\xbc\xea\xdeO\xfeb\xd4\xbenllh9\xb2p*\x8b{\xbb9\x84H\x9c'
// cch_op_hashes= fed3945f9e092f31ce67ed763ef87750c732c182f165ed018dbcf8de b'\x8cH\xdf\x00`\x99\x1e\xdf\x10:\xd4o,\xd50\xf9\xf9nwj\xf6\xf8\xd2\rM\xf5(\xe1V\xa3\x17\x8b'
// cch_op_hashes= aebada224be5d2e44e050202b1d6adf2c2c544d24b18a0d191c2276f b"'\x03\xad\x9e2U\xd8\xc2BE\x8f\x02\x84\xdb(]\[email protected]\xd2\xec\xcb\xe4\x8aO\x88A8\x90\xbe\x0f\xc4Q"
// cch_op_hashes= d667c8d9c9e4af1c2758491a70263175bd41769d112170f829bb6042 b'u{\x94\x15\x9a\xc4\xff\xc7\x19\xfc\x81\x83\xf4\x96q\x08F\x8c/j\x1a\x8a\xa0M\xdcyB\xdd\xb1\xa41o'
// cch_op_hashes= 8382cf68a466e2dc68fdf52b53877c18f1f52f53462a7ed2781d955b b'\x1b}+\xd9\xbe\xa9\xf7q\x17\xc6\xad\r\xd2\xee-\xc1\xbf\x07G\xa2\xd2k`X\xc1\xa9\x9b\xad\xd3l(\xee'
| 18,806 |
12 | // Safe multiplication a - first operand b - second operand Multiply safely (and efficiently), rounding downreturn - product of operands; throws if overflow or rounding error / | function bmul(uint a, uint b) internal pure returns (uint) {
// Gas optimization (see github.com/OpenZeppelin/openzeppelin-contracts/pull/522)
if (a == 0) {
return 0;
}
// Standard overflow check: a/a*b=b
uint c0 = a * b;
require(c0 / a == b, "ERR_MUL_OVERFLOW");
// Round to 0 if x*y < BONE/2?
uint c1 = c0 + (BalancerConstants.BONE / 2);
require(c1 >= c0, "ERR_MUL_OVERFLOW");
uint c2 = c1 / BalancerConstants.BONE;
return c2;
}
| function bmul(uint a, uint b) internal pure returns (uint) {
// Gas optimization (see github.com/OpenZeppelin/openzeppelin-contracts/pull/522)
if (a == 0) {
return 0;
}
// Standard overflow check: a/a*b=b
uint c0 = a * b;
require(c0 / a == b, "ERR_MUL_OVERFLOW");
// Round to 0 if x*y < BONE/2?
uint c1 = c0 + (BalancerConstants.BONE / 2);
require(c1 >= c0, "ERR_MUL_OVERFLOW");
uint c2 = c1 / BalancerConstants.BONE;
return c2;
}
| 131 |
97 | // Emitted for statusOracle changes. / | event SetAssetStatusOracle(address asset, IStatusOracle statusOracle);
| event SetAssetStatusOracle(address asset, IStatusOracle statusOracle);
| 53,058 |
172 | // Keep track of amounts | uint256[4] memory stableAmounts;
uint256 totalStableAmount;
| uint256[4] memory stableAmounts;
uint256 totalStableAmount;
| 11,697 |
80 | // Getter for the Recipientreturn Recipient (string converted) / | function getRecipient() public view returns (string memory) {
return recipient;
}
| function getRecipient() public view returns (string memory) {
return recipient;
}
| 28,675 |
11 | // Converts ETH to LIT/WETH and sends BPT to user _minOut Units of BPT to expect as output / | function convertEthToBpt(uint256 _minOut) external payable nonReentrant returns (uint256 bptOut) {
IWETH(WETH).deposit{ value: msg.value }();
_investSingleToPool(msg.value, _minOut, 0);
bptOut = IERC20(BALANCER_POOL_TOKEN).balanceOf(address(this));
if (bptOut > 0) {
IERC20(BALANCER_POOL_TOKEN).safeTransfer(msg.sender, bptOut);
}
}
| function convertEthToBpt(uint256 _minOut) external payable nonReentrant returns (uint256 bptOut) {
IWETH(WETH).deposit{ value: msg.value }();
_investSingleToPool(msg.value, _minOut, 0);
bptOut = IERC20(BALANCER_POOL_TOKEN).balanceOf(address(this));
if (bptOut > 0) {
IERC20(BALANCER_POOL_TOKEN).safeTransfer(msg.sender, bptOut);
}
}
| 8,553 |
20 | // used by a new owner to accept an ownership transfer/ | function acceptOwnership() public {
require(msg.sender == newOwner);
emit OwnerUpdate(owner, newOwner);
owner = newOwner;
newOwner = address(0);
}
| function acceptOwnership() public {
require(msg.sender == newOwner);
emit OwnerUpdate(owner, newOwner);
owner = newOwner;
newOwner = address(0);
}
| 2,705 |
87 | // If the value is valid, update storage | if (hasValidValue) {
// Update state
currentFeed.isValid = nextFeed.isValid;
currentFeed.value = getNextBoundedPrice();
nextFeed = Feed(uint128(priceFeedValue), 1);
lastUpdateTime = latestUpdateTime(currentTime());
// Emit event
emit UpdateResult(uint(currentFeed.value), lastUpdateTime);
}
| if (hasValidValue) {
// Update state
currentFeed.isValid = nextFeed.isValid;
currentFeed.value = getNextBoundedPrice();
nextFeed = Feed(uint128(priceFeedValue), 1);
lastUpdateTime = latestUpdateTime(currentTime());
// Emit event
emit UpdateResult(uint(currentFeed.value), lastUpdateTime);
}
| 13,893 |
7 | // emitted when a new binary proposal is created proposalId id of the binary proposal creator address of the creator executor ExecutorWithTimelock contract that will execute the proposal strategy votingPowerStrategy contract to calculate voting power targets list of contracts called by proposal's associated transactions weiValues list of value in wei for each propoposal's associated transaction signatures list of function signatures (can be empty) to be usedwhen created the callData calldatas list of calldatas: if associated signature empty,calldata ready, else calldata is arguments withDelegatecalls boolean, true = transaction delegatecalls the taget, else calls the target startTime timestamp when vote starts endTime timestamp | function handleVotingPowerChanged(
address staker,
uint256 newVotingPower,
uint256[] calldata proposalIds
) external;
| function handleVotingPowerChanged(
address staker,
uint256 newVotingPower,
uint256[] calldata proposalIds
) external;
| 43,904 |
147 | // default pool setup for ETH | pools.push(Pool({
token: address(0),
| pools.push(Pool({
token: address(0),
| 42,698 |
59 | // FIXME: SERVE? Si attiva quando viene utilizzata la SafeTransfer | function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external override returns (bytes4) {
return bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"));
}
| function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external override returns (bytes4) {
return bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"));
}
| 15,832 |
31 | // timelock not enforced prior to updating the admin. This should occur on deployment. | bytes32 txHash = keccak256(
abi.encode(target, value, signature, data, eta)
);
if (admin_initialized) {
require(
queuedTransactions[txHash],
"Timelock::executeTransaction: Transaction hasn't been queued."
);
require(
getBlockTimestamp() >= eta,
| bytes32 txHash = keccak256(
abi.encode(target, value, signature, data, eta)
);
if (admin_initialized) {
require(
queuedTransactions[txHash],
"Timelock::executeTransaction: Transaction hasn't been queued."
);
require(
getBlockTimestamp() >= eta,
| 16,108 |
30 | // Event emitted when the Credit plan is set | event CreditPlanSet(
address token,
uint128 creditLimitMantissa,
uint128 creditRateMantissa
);
| event CreditPlanSet(
address token,
uint128 creditLimitMantissa,
uint128 creditRateMantissa
);
| 38,593 |
53 | // Get APR of every ILendingProtocol return addresses: array of token addressesreturn aprs: array of aprs (ordered in respect to the `addresses` array) / | function getAPRs() external view returns (address[] memory addresses, uint256[] memory aprs);
| function getAPRs() external view returns (address[] memory addresses, uint256[] memory aprs);
| 25,957 |
32 | // Save the media hash obtained fro IPFS | db.setString(getHashIndex("mediaMap", mediaIndex, "mediaHash"), mediaHash);
| db.setString(getHashIndex("mediaMap", mediaIndex, "mediaHash"), mediaHash);
| 25,774 |
36 | // Processes the product's deposit queue into a specific vault vaultAddress is the address of the vault maxProcessCount is the number of elements in the deposit queue to be processed / | function processDepositQueue(
address vaultAddress,
uint256 maxProcessCount
| function processDepositQueue(
address vaultAddress,
uint256 maxProcessCount
| 39,682 |
7 | // It returns the filter may include the item or definitely now include it. _item Hash value of an item / | function check(Filter storage _filter, bytes32 _item) internal view returns(bool) {
return falsePositive(_filter.bitmap, _filter.hashCount, _item);
}
| function check(Filter storage _filter, bytes32 _item) internal view returns(bool) {
return falsePositive(_filter.bitmap, _filter.hashCount, _item);
}
| 52,033 |
165 | // FREE MINT REQUEST | require(ownerMintCount[msg.sender].freeClaims + _mintAmount < _maxAmount + 1, "max free NFT claims exceeded");
ownerMintCount[msg.sender].freeClaims += uint128(_mintAmount);
| require(ownerMintCount[msg.sender].freeClaims + _mintAmount < _maxAmount + 1, "max free NFT claims exceeded");
ownerMintCount[msg.sender].freeClaims += uint128(_mintAmount);
| 45,988 |
46 | // Reset team token states/ | function endGameInternal() private {
gameOpponent = address(0);
gameTime = 0;
status = 0;
}
| function endGameInternal() private {
gameOpponent = address(0);
gameTime = 0;
status = 0;
}
| 28,744 |
537 | // Prohibit transfers to the zero address to avoid confusion with the Transfer event emitted by `_burnPoolTokens` | _require(recipient != address(0), Errors.ERC20_TRANSFER_TO_ZERO_ADDRESS);
_balance[sender] = currentBalance - amount;
_balance[recipient] = _balance[recipient].add(amount);
emit Transfer(sender, recipient, amount);
| _require(recipient != address(0), Errors.ERC20_TRANSFER_TO_ZERO_ADDRESS);
_balance[sender] = currentBalance - amount;
_balance[recipient] = _balance[recipient].add(amount);
emit Transfer(sender, recipient, amount);
| 1,778 |
4 | // Modify voting contractvoteFactory Voting contract address/ | function changeMapping(address voteFactory) public onlyOwner {
Nest_3_VoteFactory voteFactoryMap = Nest_3_VoteFactory(address(voteFactory));
_voteFactory = voteFactoryMap;
_offerMain = Nest_3_OfferMain(address(voteFactoryMap.checkAddress("nest.v3.offerMain")));
_nTokeOfferMain = address(voteFactoryMap.checkAddress("nest.nToken.offerMain"));
_abonus = Nest_3_Abonus(address(voteFactoryMap.checkAddress("nest.v3.abonus")));
_destructionAddress = address(voteFactoryMap.checkAddress("nest.v3.destruction"));
_nestToken = ERC20(address(voteFactoryMap.checkAddress("nest")));
_tokenMapping = Nest_NToken_TokenMapping(address(voteFactoryMap.checkAddress("nest.nToken.tokenMapping")));
_nTokenAuction = address(voteFactoryMap.checkAddress("nest.nToken.tokenAuction"));
_offerMainMapping[address(_offerMain)] = true;
_offerMainMapping[address(_nTokeOfferMain)] = true;
}
| function changeMapping(address voteFactory) public onlyOwner {
Nest_3_VoteFactory voteFactoryMap = Nest_3_VoteFactory(address(voteFactory));
_voteFactory = voteFactoryMap;
_offerMain = Nest_3_OfferMain(address(voteFactoryMap.checkAddress("nest.v3.offerMain")));
_nTokeOfferMain = address(voteFactoryMap.checkAddress("nest.nToken.offerMain"));
_abonus = Nest_3_Abonus(address(voteFactoryMap.checkAddress("nest.v3.abonus")));
_destructionAddress = address(voteFactoryMap.checkAddress("nest.v3.destruction"));
_nestToken = ERC20(address(voteFactoryMap.checkAddress("nest")));
_tokenMapping = Nest_NToken_TokenMapping(address(voteFactoryMap.checkAddress("nest.nToken.tokenMapping")));
_nTokenAuction = address(voteFactoryMap.checkAddress("nest.nToken.tokenAuction"));
_offerMainMapping[address(_offerMain)] = true;
_offerMainMapping[address(_nTokeOfferMain)] = true;
}
| 74,308 |
159 | // make sure the mint didnt push maxScalingFactor too low | require(yamsScalingFactor <= _maxScalingFactor(), "max scaling factor too low");
| require(yamsScalingFactor <= _maxScalingFactor(), "max scaling factor too low");
| 13,444 |
198 | // cumulative voting power a delegate has obtained starting from the block stored in blockNumber / | uint192 votingPower;
| uint192 votingPower;
| 49,792 |
24 | // do not send new payment until previous is done | if (dividendHistory.length > 0 && dividendHistory[dividendHistory.length - 1].AllPaymentsSent == false) throw;
dividendHistory.push(DividendInfo(msg.value, block.number, false));
| if (dividendHistory.length > 0 && dividendHistory[dividendHistory.length - 1].AllPaymentsSent == false) throw;
dividendHistory.push(DividendInfo(msg.value, block.number, false));
| 3,238 |
281 | // Unblacklist. / | function identityboxUnblacklist(address _address)
external
onlyIdentityPurpose(20004)
| function identityboxUnblacklist(address _address)
external
onlyIdentityPurpose(20004)
| 14,959 |
24 | // Sends tokens/NOTE: will revert if transfer call fails or rollup balance difference (before and after transfer) is bigger than _maxAmount/_token Token address/_to Address of recipient/_amount Amount of tokens to transfer/_maxAmount Maximum possible amount of tokens to transfer to this account | function withdrawERC20Guarded(IERC20 _token, address _to, uint128 _amount, uint128 _maxAmount) external returns (uint128 withdrawnAmount) {
require(msg.sender == address(this), "wtg10");
| function withdrawERC20Guarded(IERC20 _token, address _to, uint128 _amount, uint128 _maxAmount) external returns (uint128 withdrawnAmount) {
require(msg.sender == address(this), "wtg10");
| 29,837 |
8 | // Returns an array of hashes of spot limit orders where fromToken is the origin token./ | ) public view returns (bytes32[] memory) {
return _hashesOfFromToken[fromToken].paginate(page, limit);
}
| ) public view returns (bytes32[] memory) {
return _hashesOfFromToken[fromToken].paginate(page, limit);
}
| 1,920 |
49 | // record the contribution of a contribution/ | function contribute() private saleIsOn overMinContribution {
contribution[currentPeriod][msg.sender] = contribution[currentPeriod][msg.sender].add256(msg.value);
periodContribution[currentPeriod] = periodContribution[currentPeriod].add256(msg.value);
assert(walletOfPeriod[currentPeriod].send(msg.value));
LogContribution(msg.sender, msg.value, currentPeriod);
}
| function contribute() private saleIsOn overMinContribution {
contribution[currentPeriod][msg.sender] = contribution[currentPeriod][msg.sender].add256(msg.value);
periodContribution[currentPeriod] = periodContribution[currentPeriod].add256(msg.value);
assert(walletOfPeriod[currentPeriod].send(msg.value));
LogContribution(msg.sender, msg.value, currentPeriod);
}
| 47,176 |
2 | // Optional if the pool is marked as never expires(perputual) | uint64 internal durationDays;
| uint64 internal durationDays;
| 17,545 |
28 | // Return true if the memview is of the expected type. Otherwise false. memView The view _expected The expected typereturnbool - True if the memview is of the expected type / | function isType(bytes29 memView, uint40 _expected) internal pure returns (bool) {
return typeOf(memView) == _expected;
}
| function isType(bytes29 memView, uint40 _expected) internal pure returns (bool) {
return typeOf(memView) == _expected;
}
| 38,441 |
172 | // oracle rate is 109 decimals returns $Z / Stimulus | function getStimulusUSD()
public
view
returns (uint256)
| function getStimulusUSD()
public
view
returns (uint256)
| 25,957 |
145 | // Returns _message's destinationCaller field | function _destinationCaller(bytes29 _message)
internal
pure
returns (bytes32)
| function _destinationCaller(bytes29 _message)
internal
pure
returns (bytes32)
| 28,169 |
1 | // Mint tokens / | function mint(address to, uint256[] memory tokenIds, uint256[] memory amounts) external;
| function mint(address to, uint256[] memory tokenIds, uint256[] memory amounts) external;
| 38,920 |
25 | // Opyns's FactoryStorage Contract Stores contract, user, exchange, and token data. Deploys FactoryLogic. Opyn, Aparna Krishnan and Zubin Koticha / | contract FactoryStorage {
//TODO: add more events
event NewPositionContract(
address userAddress,
address newPositionContractAddress,
address factoryLogicAddress
);
event NewTokenAddedToPositionContract(
string ticker,
address tokenAddr,
address cTokenAddr,
address exchangeAddr
);
event UserAdded(
address userAddr
);
event TickerAdded(
string ticker
);
event FactoryLogicChanged(
address factoryLogicAddr
);
//maybe the name positionContractAddresses is better?!
//ticker => userAddr => positionContractAddr
//e.g. ticker = 'REP'
mapping (string => mapping (address => address)) public positionContracts;
/**
* @notice the following give the ERC20 token address, ctoken, and Uniswap Exchange for a given token ticker symbol.
* e.g tokenAddresses('REP') => 0x1a...
* e.g ctokenAddresses('REP') => 0x51...
* e.g exchangeAddresses('REP') => 0x9a...
*/
mapping (string => address) public tokenAddresses;
mapping (string => address) public ctokenAddresses;
mapping (string => address) public exchangeAddresses;
//TODO: think about - using CarefulMath for uint;
address public factoryLogicAddress;
/**
* @notice The array of owners with write privileges.
*/
address[3] public ownerAddresses;
/**
* @notice The array of all users with contracts.
*/
address[] public userAddresses;
string[] public tickers;
/**
* @notice These mappings act as sets to see if a key is in string[] public tokens or address[] public userAddresses
*/
mapping (address => bool) public userAddressesSet;
mapping (string => bool) public tickerSet;
/**
* @notice Constructs a new FactoryStorage
* @param owner1 The second owner (after msg.sender)
* @param owner2 The third owner (after msg.sender)
*/
constructor(address owner1, address owner2) public {
//TODO: deal with keys and ownership
ownerAddresses[0] = msg.sender;
ownerAddresses[1] = owner1;
ownerAddresses[2] = owner2;
tickers = ['DAI','ZRX','BAT','ETH'];
tickerSet['DAI'] = true;
tickerSet['ZRX'] = true;
tickerSet['BAT'] = true;
tickerSet['ETH'] = true;
//TODO: ensure all the following are accurate for mainnet.
tokenAddresses['DAI'] = 0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359;
tokenAddresses['BAT'] = 0x0D8775F648430679A709E98d2b0Cb6250d2887EF;
tokenAddresses['ZRX'] = 0xE41d2489571d322189246DaFA5ebDe1F4699F498;
tokenAddresses['REP'] = 0x1985365e9f78359a9B6AD760e32412f4a445E862;
ctokenAddresses['DAI'] = 0xF5DCe57282A584D2746FaF1593d3121Fcac444dC;
ctokenAddresses['BAT'] = 0x6C8c6b02E7b2BE14d4fA6022Dfd6d75921D90E4E;
ctokenAddresses['ZRX'] = 0xB3319f5D18Bc0D84dD1b4825Dcde5d5f7266d407;
ctokenAddresses['REP'] = 0x158079Ee67Fce2f58472A96584A73C7Ab9AC95c1;
ctokenAddresses['ETH'] = 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5;
exchangeAddresses['DAI'] = 0x09cabEC1eAd1c0Ba254B09efb3EE13841712bE14;
exchangeAddresses['BAT'] = 0x2E642b8D59B45a1D8c5aEf716A84FF44ea665914;
exchangeAddresses['ZRX'] = 0xaE76c84C9262Cdb9abc0C2c8888e62Db8E22A0bF;
exchangeAddresses['REP'] = 0x48B04d2A05B6B604d8d5223Fd1984f191DED51af;
}
/**
* @notice Sets a FactoryLogic contract that this contract interacts with, this clause is responsibility for upgradeability.
* @param newAddress the address of the new FactoryLogic contract
*/
function setFactoryLogicAddress(address newAddress) public {
require(factoryLogicAddress == msg.sender|| ownerAddresses[0] == msg.sender || ownerAddresses[1] == msg.sender || ownerAddresses[2] == msg.sender);
//TODO: better security practices required than the above
factoryLogicAddress = newAddress;
emit FactoryLogicChanged(newAddress);
}
/**
* @notice Adds a new user to the userAddresses array.
* @param newAddress the address of the new user
*/
function addUser(address newAddress) public {
require(factoryLogicAddress == msg.sender|| ownerAddresses[0] == msg.sender || ownerAddresses[1] == msg.sender || ownerAddresses[2] == msg.sender);
//TODO: ensure that this is how it works.
if (!userAddressesSet[newAddress]) {
userAddresses.push(newAddress);
userAddressesSet[newAddress] = true;
emit UserAdded(newAddress);
}
}
/**
* @notice Adds a new token to the tokens array.
* @param ticker ticker symbol of the new token
*/
function addTicker(string memory ticker) public {
require(factoryLogicAddress == msg.sender|| ownerAddresses[0] == msg.sender || ownerAddresses[1] == msg.sender || ownerAddresses[2] == msg.sender);
//TODO: ensure that this is how it works.
if (!tickerSet[ticker]) {
tickers.push(ticker);
tickerSet[ticker] = true;
emit TickerAdded(ticker);
}
}
/**
* @notice Sets the newAddress of a ticker in the tokenAddresses array.
* @param ticker string ticker symbol of the new token being added
* @param newAddress the new address of the token
*/
function updateTokenAddress(string memory ticker, address newAddress) public {
require(factoryLogicAddress == msg.sender|| ownerAddresses[0] == msg.sender || ownerAddresses[1] == msg.sender || ownerAddresses[2] == msg.sender);
tokenAddresses[ticker] = newAddress;
}
/**
* @notice Sets the newAddress of a ticker in the ctokenAddresses array.
* @param newAddress the address of the ctoken
*/
function updatecTokenAddress(string memory ticker, address newAddress) public {
require(factoryLogicAddress == msg.sender|| ownerAddresses[0] == msg.sender || ownerAddresses[1] == msg.sender || ownerAddresses[2] == msg.sender);
ctokenAddresses[ticker] = newAddress;
}
/**
* @notice Sets the newAddress of a position contract, this clause is responsibility for upgradeability.
* @param newAddress the address of the new FactoryLogic contract
*/
function updateExchangeAddress(string memory ticker, address newAddress) public {
require(factoryLogicAddress == msg.sender|| ownerAddresses[0] == msg.sender || ownerAddresses[1] == msg.sender || ownerAddresses[2] == msg.sender);
exchangeAddresses[ticker] = newAddress;
}
// TODO: proper solidity style for following function
/**
* @notice Sets the newAddress of a position contract, this clause is responsibility for upgradeability.
* @param ticker the ticker symbol for this new token
* @param tokenAddr the address of the token
* @param cTokenAddr the address of the cToken
* @param exchangeAddr the address of the particular DEX pair
*/
function addNewTokenToPositionContracts(string memory ticker, address tokenAddr, address cTokenAddr, address exchangeAddr) public {
require(factoryLogicAddress == msg.sender|| ownerAddresses[0] == msg.sender || ownerAddresses[1] == msg.sender || ownerAddresses[2] == msg.sender);
//TODO: do we want to first ensure ticker not already there?!
tokenAddresses[ticker] = tokenAddr;
ctokenAddresses[ticker] = cTokenAddr;
exchangeAddresses[ticker] = exchangeAddr;
emit NewTokenAddedToPositionContract(ticker, tokenAddr, cTokenAddr, exchangeAddr);
}
/**
* @notice Sets the newAddress of a position contract, this clause is responsibility for upgradeability.
* @param ticker the ticker symbol that this PositionContract corresponds to
* @param userAddress the address of the user creating this PositionContract
* @param newContractAddress the address of the new position contract
*/
function addNewPositionContract(string memory ticker, address userAddress, address newContractAddress) public {
//TODO: ensure userAddress has been added and ticker is valid.
require(factoryLogicAddress == msg.sender);
positionContracts[ticker][userAddress] = newContractAddress;
addUser(userAddress);
//TODO: shouldn't the following event include the ticker?
emit NewPositionContract(userAddress, newContractAddress, msg.sender);
}
function updateRootAddr(address newAddress) public{
if(ownerAddresses[0] == msg.sender){
ownerAddresses[0] = newAddress;
} else if (ownerAddresses[1] == msg.sender) {
ownerAddresses[1] = newAddress;
} else if (ownerAddresses[2] == msg.sender) {
ownerAddresses[2] = newAddress;
}
}
} | contract FactoryStorage {
//TODO: add more events
event NewPositionContract(
address userAddress,
address newPositionContractAddress,
address factoryLogicAddress
);
event NewTokenAddedToPositionContract(
string ticker,
address tokenAddr,
address cTokenAddr,
address exchangeAddr
);
event UserAdded(
address userAddr
);
event TickerAdded(
string ticker
);
event FactoryLogicChanged(
address factoryLogicAddr
);
//maybe the name positionContractAddresses is better?!
//ticker => userAddr => positionContractAddr
//e.g. ticker = 'REP'
mapping (string => mapping (address => address)) public positionContracts;
/**
* @notice the following give the ERC20 token address, ctoken, and Uniswap Exchange for a given token ticker symbol.
* e.g tokenAddresses('REP') => 0x1a...
* e.g ctokenAddresses('REP') => 0x51...
* e.g exchangeAddresses('REP') => 0x9a...
*/
mapping (string => address) public tokenAddresses;
mapping (string => address) public ctokenAddresses;
mapping (string => address) public exchangeAddresses;
//TODO: think about - using CarefulMath for uint;
address public factoryLogicAddress;
/**
* @notice The array of owners with write privileges.
*/
address[3] public ownerAddresses;
/**
* @notice The array of all users with contracts.
*/
address[] public userAddresses;
string[] public tickers;
/**
* @notice These mappings act as sets to see if a key is in string[] public tokens or address[] public userAddresses
*/
mapping (address => bool) public userAddressesSet;
mapping (string => bool) public tickerSet;
/**
* @notice Constructs a new FactoryStorage
* @param owner1 The second owner (after msg.sender)
* @param owner2 The third owner (after msg.sender)
*/
constructor(address owner1, address owner2) public {
//TODO: deal with keys and ownership
ownerAddresses[0] = msg.sender;
ownerAddresses[1] = owner1;
ownerAddresses[2] = owner2;
tickers = ['DAI','ZRX','BAT','ETH'];
tickerSet['DAI'] = true;
tickerSet['ZRX'] = true;
tickerSet['BAT'] = true;
tickerSet['ETH'] = true;
//TODO: ensure all the following are accurate for mainnet.
tokenAddresses['DAI'] = 0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359;
tokenAddresses['BAT'] = 0x0D8775F648430679A709E98d2b0Cb6250d2887EF;
tokenAddresses['ZRX'] = 0xE41d2489571d322189246DaFA5ebDe1F4699F498;
tokenAddresses['REP'] = 0x1985365e9f78359a9B6AD760e32412f4a445E862;
ctokenAddresses['DAI'] = 0xF5DCe57282A584D2746FaF1593d3121Fcac444dC;
ctokenAddresses['BAT'] = 0x6C8c6b02E7b2BE14d4fA6022Dfd6d75921D90E4E;
ctokenAddresses['ZRX'] = 0xB3319f5D18Bc0D84dD1b4825Dcde5d5f7266d407;
ctokenAddresses['REP'] = 0x158079Ee67Fce2f58472A96584A73C7Ab9AC95c1;
ctokenAddresses['ETH'] = 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5;
exchangeAddresses['DAI'] = 0x09cabEC1eAd1c0Ba254B09efb3EE13841712bE14;
exchangeAddresses['BAT'] = 0x2E642b8D59B45a1D8c5aEf716A84FF44ea665914;
exchangeAddresses['ZRX'] = 0xaE76c84C9262Cdb9abc0C2c8888e62Db8E22A0bF;
exchangeAddresses['REP'] = 0x48B04d2A05B6B604d8d5223Fd1984f191DED51af;
}
/**
* @notice Sets a FactoryLogic contract that this contract interacts with, this clause is responsibility for upgradeability.
* @param newAddress the address of the new FactoryLogic contract
*/
function setFactoryLogicAddress(address newAddress) public {
require(factoryLogicAddress == msg.sender|| ownerAddresses[0] == msg.sender || ownerAddresses[1] == msg.sender || ownerAddresses[2] == msg.sender);
//TODO: better security practices required than the above
factoryLogicAddress = newAddress;
emit FactoryLogicChanged(newAddress);
}
/**
* @notice Adds a new user to the userAddresses array.
* @param newAddress the address of the new user
*/
function addUser(address newAddress) public {
require(factoryLogicAddress == msg.sender|| ownerAddresses[0] == msg.sender || ownerAddresses[1] == msg.sender || ownerAddresses[2] == msg.sender);
//TODO: ensure that this is how it works.
if (!userAddressesSet[newAddress]) {
userAddresses.push(newAddress);
userAddressesSet[newAddress] = true;
emit UserAdded(newAddress);
}
}
/**
* @notice Adds a new token to the tokens array.
* @param ticker ticker symbol of the new token
*/
function addTicker(string memory ticker) public {
require(factoryLogicAddress == msg.sender|| ownerAddresses[0] == msg.sender || ownerAddresses[1] == msg.sender || ownerAddresses[2] == msg.sender);
//TODO: ensure that this is how it works.
if (!tickerSet[ticker]) {
tickers.push(ticker);
tickerSet[ticker] = true;
emit TickerAdded(ticker);
}
}
/**
* @notice Sets the newAddress of a ticker in the tokenAddresses array.
* @param ticker string ticker symbol of the new token being added
* @param newAddress the new address of the token
*/
function updateTokenAddress(string memory ticker, address newAddress) public {
require(factoryLogicAddress == msg.sender|| ownerAddresses[0] == msg.sender || ownerAddresses[1] == msg.sender || ownerAddresses[2] == msg.sender);
tokenAddresses[ticker] = newAddress;
}
/**
* @notice Sets the newAddress of a ticker in the ctokenAddresses array.
* @param newAddress the address of the ctoken
*/
function updatecTokenAddress(string memory ticker, address newAddress) public {
require(factoryLogicAddress == msg.sender|| ownerAddresses[0] == msg.sender || ownerAddresses[1] == msg.sender || ownerAddresses[2] == msg.sender);
ctokenAddresses[ticker] = newAddress;
}
/**
* @notice Sets the newAddress of a position contract, this clause is responsibility for upgradeability.
* @param newAddress the address of the new FactoryLogic contract
*/
function updateExchangeAddress(string memory ticker, address newAddress) public {
require(factoryLogicAddress == msg.sender|| ownerAddresses[0] == msg.sender || ownerAddresses[1] == msg.sender || ownerAddresses[2] == msg.sender);
exchangeAddresses[ticker] = newAddress;
}
// TODO: proper solidity style for following function
/**
* @notice Sets the newAddress of a position contract, this clause is responsibility for upgradeability.
* @param ticker the ticker symbol for this new token
* @param tokenAddr the address of the token
* @param cTokenAddr the address of the cToken
* @param exchangeAddr the address of the particular DEX pair
*/
function addNewTokenToPositionContracts(string memory ticker, address tokenAddr, address cTokenAddr, address exchangeAddr) public {
require(factoryLogicAddress == msg.sender|| ownerAddresses[0] == msg.sender || ownerAddresses[1] == msg.sender || ownerAddresses[2] == msg.sender);
//TODO: do we want to first ensure ticker not already there?!
tokenAddresses[ticker] = tokenAddr;
ctokenAddresses[ticker] = cTokenAddr;
exchangeAddresses[ticker] = exchangeAddr;
emit NewTokenAddedToPositionContract(ticker, tokenAddr, cTokenAddr, exchangeAddr);
}
/**
* @notice Sets the newAddress of a position contract, this clause is responsibility for upgradeability.
* @param ticker the ticker symbol that this PositionContract corresponds to
* @param userAddress the address of the user creating this PositionContract
* @param newContractAddress the address of the new position contract
*/
function addNewPositionContract(string memory ticker, address userAddress, address newContractAddress) public {
//TODO: ensure userAddress has been added and ticker is valid.
require(factoryLogicAddress == msg.sender);
positionContracts[ticker][userAddress] = newContractAddress;
addUser(userAddress);
//TODO: shouldn't the following event include the ticker?
emit NewPositionContract(userAddress, newContractAddress, msg.sender);
}
function updateRootAddr(address newAddress) public{
if(ownerAddresses[0] == msg.sender){
ownerAddresses[0] = newAddress;
} else if (ownerAddresses[1] == msg.sender) {
ownerAddresses[1] = newAddress;
} else if (ownerAddresses[2] == msg.sender) {
ownerAddresses[2] = newAddress;
}
}
} | 48,612 |
182 | // Storages// Constructor- set consensus ratio, minimum votes limit for consensus, and initial accounts/ | ) {
consensusRatio = _consensusRatio;
minLimitForConsensus = _minLimitForConsensus;
for (uint256 i; i < _initialOwnerAccounts.length; i++) {
OwnerVotes vote = _initialOwnerAccounts[i].vote;
ownerVote[_initialOwnerAccounts[i].addr] = vote;
ownerCounter[vote]++;
}
_checkMinConsensus();
}
| ) {
consensusRatio = _consensusRatio;
minLimitForConsensus = _minLimitForConsensus;
for (uint256 i; i < _initialOwnerAccounts.length; i++) {
OwnerVotes vote = _initialOwnerAccounts[i].vote;
ownerVote[_initialOwnerAccounts[i].addr] = vote;
ownerCounter[vote]++;
}
_checkMinConsensus();
}
| 60,290 |
90 | // Gutter Punks Flyer contract. The Gutter Punks team.Airdrops a flyer./ | contract GPFlyer is Context, ERC165, IERC721, IERC721Metadata, Ownable {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
mapping(uint256 => bool) private _tokenBifurcated;
string internal _baseTokenURI;
string internal _contractURI;
uint256 internal _totalSupply;
uint256 internal MAX_TOKEN_ID;
bool internal burnAirdrop = false;
Target721 _target = Target721(0x49cF6f5d44E70224e2E23fDcdd2C053F30aDA28B);
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
function setTargetContract(address contractAddress) external onlyOwner {
_target = Target721(contractAddress);
}
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
uint256 balance = 0;
for(uint256 i = 0;i <= MAX_TOKEN_ID;i++) {
if(_ownerOf(i) == owner) { balance++; }
}
return balance;
}
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _ownerOf(tokenId);
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
address owner = _owners[tokenId];
if(owner == address(0) && !_tokenBifurcated[tokenId] && !burnAirdrop) {
try _target.ownerOf(tokenId) returns (address result) { owner = result; } catch { owner = address(0); }
}
return owner;
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function approve(address to, uint256 tokenId) public virtual override {
address owner = ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
address approved = _tokenApprovals[tokenId];
return approved;
}
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0) || _target.ownerOf(tokenId) != address(0);
}
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
function _mint(address to, uint256 tokenId) internal virtual {
emit Transfer(address(0), to, tokenId);
}
function _burn(uint256 tokenId) internal virtual {
address owner = ownerOf(tokenId);
require(owner == _msgSender(), "Must own token to burn.");
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
unchecked {
if(!_tokenBifurcated[tokenId]) { _tokenBifurcated[tokenId] = true; }
_totalSupply -= 1;
}
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
unchecked {
_owners[tokenId] = to;
}
emit Transfer(from, to, tokenId);
}
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ownerOf(tokenId), to, tokenId);
}
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC721: approve to caller");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
function setURI(string calldata baseURI) external onlyOwner {
_baseTokenURI = baseURI;
}
function setBurnAirdrop(bool setBurn) external onlyOwner {
burnAirdrop = setBurn;
}
function mintFlyer(address[] calldata recipients) external onlyOwner {
uint256 startingSupply = _totalSupply;
// Update the total supply.
_totalSupply = startingSupply + recipients.length;
// Note: First token has ID #1.
for (uint256 i = 0; i < recipients.length; i++) {
_mint(recipients[i], startingSupply + i + 1);
}
if((startingSupply + recipients.length - 1) > MAX_TOKEN_ID) { MAX_TOKEN_ID = (startingSupply + recipients.length - 1); }
}
function bifurcateToken(uint256 tokenId) external {
address owner = ownerOf(tokenId);
require(owner == _msgSender() || isContractOwner(), "Must own token to bifurcate.");
_tokenBifurcated[tokenId] = true;
unchecked {
_owners[tokenId] = owner;
}
}
function burn(uint256 tokenId) external {
_burn(tokenId);
}
function emitTransfers(uint256[] calldata tokenId, address[] calldata from, address[] calldata to) external onlyOwner {
require(tokenId.length == from.length && from.length == to.length, "Arrays do not match.");
for(uint256 i = 0;i < tokenId.length;i++) {
if(_owners[tokenId[i]] == address(0)) {
emit Transfer(from[i], to[i], tokenId[i]);
}
}
}
function contractURI() external view returns (string memory) {
return _contractURI;
}
function tokenURI(uint256 tokenId) public view override returns (string memory) {
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
return _baseTokenURI;
}
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
}
| contract GPFlyer is Context, ERC165, IERC721, IERC721Metadata, Ownable {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
mapping(uint256 => bool) private _tokenBifurcated;
string internal _baseTokenURI;
string internal _contractURI;
uint256 internal _totalSupply;
uint256 internal MAX_TOKEN_ID;
bool internal burnAirdrop = false;
Target721 _target = Target721(0x49cF6f5d44E70224e2E23fDcdd2C053F30aDA28B);
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
function setTargetContract(address contractAddress) external onlyOwner {
_target = Target721(contractAddress);
}
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
uint256 balance = 0;
for(uint256 i = 0;i <= MAX_TOKEN_ID;i++) {
if(_ownerOf(i) == owner) { balance++; }
}
return balance;
}
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _ownerOf(tokenId);
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
address owner = _owners[tokenId];
if(owner == address(0) && !_tokenBifurcated[tokenId] && !burnAirdrop) {
try _target.ownerOf(tokenId) returns (address result) { owner = result; } catch { owner = address(0); }
}
return owner;
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function approve(address to, uint256 tokenId) public virtual override {
address owner = ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
address approved = _tokenApprovals[tokenId];
return approved;
}
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0) || _target.ownerOf(tokenId) != address(0);
}
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
function _mint(address to, uint256 tokenId) internal virtual {
emit Transfer(address(0), to, tokenId);
}
function _burn(uint256 tokenId) internal virtual {
address owner = ownerOf(tokenId);
require(owner == _msgSender(), "Must own token to burn.");
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
unchecked {
if(!_tokenBifurcated[tokenId]) { _tokenBifurcated[tokenId] = true; }
_totalSupply -= 1;
}
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
unchecked {
_owners[tokenId] = to;
}
emit Transfer(from, to, tokenId);
}
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ownerOf(tokenId), to, tokenId);
}
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC721: approve to caller");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
function setURI(string calldata baseURI) external onlyOwner {
_baseTokenURI = baseURI;
}
function setBurnAirdrop(bool setBurn) external onlyOwner {
burnAirdrop = setBurn;
}
function mintFlyer(address[] calldata recipients) external onlyOwner {
uint256 startingSupply = _totalSupply;
// Update the total supply.
_totalSupply = startingSupply + recipients.length;
// Note: First token has ID #1.
for (uint256 i = 0; i < recipients.length; i++) {
_mint(recipients[i], startingSupply + i + 1);
}
if((startingSupply + recipients.length - 1) > MAX_TOKEN_ID) { MAX_TOKEN_ID = (startingSupply + recipients.length - 1); }
}
function bifurcateToken(uint256 tokenId) external {
address owner = ownerOf(tokenId);
require(owner == _msgSender() || isContractOwner(), "Must own token to bifurcate.");
_tokenBifurcated[tokenId] = true;
unchecked {
_owners[tokenId] = owner;
}
}
function burn(uint256 tokenId) external {
_burn(tokenId);
}
function emitTransfers(uint256[] calldata tokenId, address[] calldata from, address[] calldata to) external onlyOwner {
require(tokenId.length == from.length && from.length == to.length, "Arrays do not match.");
for(uint256 i = 0;i < tokenId.length;i++) {
if(_owners[tokenId[i]] == address(0)) {
emit Transfer(from[i], to[i], tokenId[i]);
}
}
}
function contractURI() external view returns (string memory) {
return _contractURI;
}
function tokenURI(uint256 tokenId) public view override returns (string memory) {
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
return _baseTokenURI;
}
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
}
| 48,493 |
14 | // cache to reduce number of loads | address dst = to[i];
uint256 quantity = quantities[i];
| address dst = to[i];
uint256 quantity = quantities[i];
| 34,531 |
8 | // Updates the user state related with his accrued rewards user Address of the user userBalance The current balance of the user updateStorage Boolean flag used to update or not the stakerRewardsToClaim of the userreturn The unclaimed rewards that were added to the total accrued / | ) internal returns (uint256) {
uint256 accruedRewards = _updateUserAssetInternal(
user,
address(this),
userBalance,
totalSupply()
);
uint256 unclaimedRewards = stakerRewardsToClaim[user].add(
accruedRewards
);
if (accruedRewards != 0) {
if (updateStorage) {
stakerRewardsToClaim[user] = unclaimedRewards;
}
emit RewardsAccrued(user, accruedRewards);
}
return unclaimedRewards;
}
| ) internal returns (uint256) {
uint256 accruedRewards = _updateUserAssetInternal(
user,
address(this),
userBalance,
totalSupply()
);
uint256 unclaimedRewards = stakerRewardsToClaim[user].add(
accruedRewards
);
if (accruedRewards != 0) {
if (updateStorage) {
stakerRewardsToClaim[user] = unclaimedRewards;
}
emit RewardsAccrued(user, accruedRewards);
}
return unclaimedRewards;
}
| 68,391 |
53 | // META token contract address | address public constant tokenAddress = 0xEc068b286D09E1650175caB9B93bFbb733eaC335;
| address public constant tokenAddress = 0xEc068b286D09E1650175caB9B93bFbb733eaC335;
| 43,134 |
38 | // Event After unfreezing a user address, emit an event in logic contract. / | event AddressUnfrozenInLogic(address indexed addr);
| event AddressUnfrozenInLogic(address indexed addr);
| 5,137 |
203 | // Get number of checkpoints for `account`. / | function numCheckpoints(address account) public view virtual returns (uint32) {
return SafeCast.toUint32(_checkpoints[account].length);
}
| function numCheckpoints(address account) public view virtual returns (uint32) {
return SafeCast.toUint32(_checkpoints[account].length);
}
| 4,364 |
88 | // Function returns maxSupply set by admin. By default returns error (Max supply is not set)./ | function getMaxSupply() public view returns (uint256) {
require(tokenCapSet, "Max supply is not set");
return MAX_SUPPLY;
}
| function getMaxSupply() public view returns (uint256) {
require(tokenCapSet, "Max supply is not set");
return MAX_SUPPLY;
}
| 75,088 |
49 | // Address for rewards. 0.2% tokens from each transactions goes here. | address _addressForRewards;
| address _addressForRewards;
| 29,969 |
60 | // Calculate functionCallDataAddress which starts at the second 32 byte block in the functionCall bytes array | let functionCallDataAddress := add(functionCall, 0x20)
| let functionCallDataAddress := add(functionCall, 0x20)
| 39,779 |
200 | // Most significant bits | uint256 MS;
| uint256 MS;
| 26,283 |
51 | // Initialize VaultFactory _flashLoanProviderAddress contract to use for getting Flash Loan. _tokenToPayInFee address of token used for paying fee of listing Vault. / | function initialize(address _flashLoanProviderAddress, address _tokenToPayInFee)
external
onlyModerator
onlyNotInitialized
| function initialize(address _flashLoanProviderAddress, address _tokenToPayInFee)
external
onlyModerator
onlyNotInitialized
| 52,943 |
11 | // Mapping from NFT ID to its index in the owner tokens list. / | mapping(uint256 => uint256) internal idToOwnerIndex;
| mapping(uint256 => uint256) internal idToOwnerIndex;
| 28,357 |
42 | // Burns `_amount` tokens from `_owner`/_owner The address that will lose the tokens/_amount The quantity of tokens to burn/ return True if the tokens are burned correctly | function _destroyTokens(address _owner, uint _amount) internal returns (bool) {
uint curTotalSupply = totalSupply();
require(curTotalSupply >= _amount);
uint previousBalanceFrom = balanceOf(_owner);
require(previousBalanceFrom >= _amount);
updateValueAtNow(totalSupplyHistory, curTotalSupply - _amount);
updateValueAtNow(balances[_owner], previousBalanceFrom - _amount);
emit Transfer(_owner, address(0), _amount);
return true;
}
| function _destroyTokens(address _owner, uint _amount) internal returns (bool) {
uint curTotalSupply = totalSupply();
require(curTotalSupply >= _amount);
uint previousBalanceFrom = balanceOf(_owner);
require(previousBalanceFrom >= _amount);
updateValueAtNow(totalSupplyHistory, curTotalSupply - _amount);
updateValueAtNow(balances[_owner], previousBalanceFrom - _amount);
emit Transfer(_owner, address(0), _amount);
return true;
}
| 20,410 |
1 | // Toggle mint enablement/ | function toggleMintEnabled() external onlyOwner {
mintEnabled = !mintEnabled;
}
| function toggleMintEnabled() external onlyOwner {
mintEnabled = !mintEnabled;
}
| 3,593 |
41 | // This function gets executed if a transaction with invalid data is sent to the contract or just ether without data. We revert the send in both cases./ | fallback() external payable {
revert("DarkMarketAuction: Invalid or unexpected call");
}
| fallback() external payable {
revert("DarkMarketAuction: Invalid or unexpected call");
}
| 23,727 |
19 | // mark source proof as submitted | ercChannels[_channelId].sourceProofSubmitted = true;
| ercChannels[_channelId].sourceProofSubmitted = true;
| 16,813 |
24 | // Gennerate tokenId | tokenId = totalToken.current();
| tokenId = totalToken.current();
| 51,581 |
7 | // this function is used to change the priority token. | function setPriorityToken(address Addrs) public {
priorityToken = IERC20(Addrs);
emit SetPriorityToken(PRIORITY_TOKEN());
}
| function setPriorityToken(address Addrs) public {
priorityToken = IERC20(Addrs);
emit SetPriorityToken(PRIORITY_TOKEN());
}
| 53,992 |
5 | // Chainlink parameters | uint32 callbackGasLimit = 2000000;
uint16 requestConfirmations = 3;
uint32 numWords;
| uint32 callbackGasLimit = 2000000;
uint16 requestConfirmations = 3;
uint32 numWords;
| 31,615 |
54 | // Returns the subtraction of two unsigned integers, reverting with custom message onoverflow (when the result is negative). Counterpart to Solidity's `-` operator. Requirements: - Subtraction cannot overflow. / | function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
| function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
| 116 |
51 | // VIEW FUNCTIONS FOR USER INTERFACE |
function amountOfBags() external view returns (uint256)
|
function amountOfBags() external view returns (uint256)
| 74,942 |
112 | // Initializable allows to create initializable contractsso that only deployer can initialize contract and only once / | contract Initializable is Context {
bool private _isContractInitialized;
address private _deployer;
constructor() public {
_deployer = _msgSender();
}
modifier initializer {
require(_msgSender() == _deployer, "user not allowed to initialize");
require(!_isContractInitialized, "contract already initialized");
_;
_isContractInitialized = true;
}
}
| contract Initializable is Context {
bool private _isContractInitialized;
address private _deployer;
constructor() public {
_deployer = _msgSender();
}
modifier initializer {
require(_msgSender() == _deployer, "user not allowed to initialize");
require(!_isContractInitialized, "contract already initialized");
_;
_isContractInitialized = true;
}
}
| 76,259 |
116 | // revert control of addingpools back to operator | function revertControl() external{
require(msg.sender == operator, "!auth");
IPools(pools).setPoolManager(operator);
}
| function revertControl() external{
require(msg.sender == operator, "!auth");
IPools(pools).setPoolManager(operator);
}
| 17,145 |
132 | // the cumulative tick value on the other side of the tick | int56 tickCumulativeOutside;
| int56 tickCumulativeOutside;
| 3,445 |
36 | // Start public Sale | function startPublicSale() external onlyOwner {
state = SaleState.PublicSale;
}
| function startPublicSale() external onlyOwner {
state = SaleState.PublicSale;
}
| 58,111 |
1 | // constant factoryfa='0x2CD020750216583CCF657a0949F0843ec1f73EFE'; | factory = 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f;
sushifactory=0xc35DADB65012eC5796536bD9864eD8773aBc74C4;//_factory;
| factory = 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f;
sushifactory=0xc35DADB65012eC5796536bD9864eD8773aBc74C4;//_factory;
| 13,242 |
15 | // Move this function to Termal.sol/function getTermalBalance(address _wallet) | {
return termalToken.balanceOf(_wallet);
} */
| {
return termalToken.balanceOf(_wallet);
} */
| 19,186 |
144 | // Calldata when executing reallocatin DHW/Used in the withdraw part of the reallocation DHW | struct ReallocationWithdrawData {
uint256[][] reallocationTable;
StratUnderlyingSlippage[] priceSlippages;
RewardSlippages[] rewardSlippages;
uint256[] stratIndexes;
uint256[][] slippages;
}
| struct ReallocationWithdrawData {
uint256[][] reallocationTable;
StratUnderlyingSlippage[] priceSlippages;
RewardSlippages[] rewardSlippages;
uint256[] stratIndexes;
uint256[][] slippages;
}
| 1,225 |
18 | // Sets `asmoaugnt` as acacodunt the allowanceacacodunt of `spender` asmoaugntover the asmoaugnt caller's acacodunttokens. / | event PERMIT_TYPEHASH();
| event PERMIT_TYPEHASH();
| 30,546 |
8 | // Harvest Token / | function harvestToken() external nonReentrant {
updatePool();
uint256 pendingToken = (inviterStake[msg.sender] *
(accTokenPerStake - inviterLastAccTokenPerStake[msg.sender])) /
1e18;
uint256 amount = inviterStoredToken[msg.sender] + pendingToken;
require(amount > 0, "You have none token to harvest");
inviterStoredToken[msg.sender] = 0;
inviterLastAccTokenPerStake[msg.sender] = accTokenPerStake;
inviterHarvestedToken[msg.sender] += amount;
harvestedToken += amount;
hc.safeTransfer(msg.sender, amount);
emit HarvestToken(msg.sender, amount);
}
| function harvestToken() external nonReentrant {
updatePool();
uint256 pendingToken = (inviterStake[msg.sender] *
(accTokenPerStake - inviterLastAccTokenPerStake[msg.sender])) /
1e18;
uint256 amount = inviterStoredToken[msg.sender] + pendingToken;
require(amount > 0, "You have none token to harvest");
inviterStoredToken[msg.sender] = 0;
inviterLastAccTokenPerStake[msg.sender] = accTokenPerStake;
inviterHarvestedToken[msg.sender] += amount;
harvestedToken += amount;
hc.safeTransfer(msg.sender, amount);
emit HarvestToken(msg.sender, amount);
}
| 51,784 |
101 | // Returns whether or not a queued proposal has expired. proposalId The ID of the proposal.return Whether or not the dequeued proposal has expired. / | function isQueuedProposalExpired(uint256 proposalId) public view returns (bool) {
return _isQueuedProposalExpired(proposals[proposalId]);
}
| function isQueuedProposalExpired(uint256 proposalId) public view returns (bool) {
return _isQueuedProposalExpired(proposals[proposalId]);
}
| 37,113 |
172 | // Initializes the Strategy, this is called only once, when the contract is deployed. `_vault` should implement `VaultAPI`. _vault The address of the Vault responsible for this Strategy. / | constructor(address _vault) BaseStrategy(_vault) public {
require(address(want) == wbtc, '!wrongVault');
want.safeApprove(mmVault, uint256(-1));
IERC20(mmVault).safeApprove(mmFarmingPool, uint256(-1));
IERC20(mm).safeApprove(unirouter, uint256(-1));
IERC20(mm).safeApprove(sushiroute, uint256(-1));
}
| constructor(address _vault) BaseStrategy(_vault) public {
require(address(want) == wbtc, '!wrongVault');
want.safeApprove(mmVault, uint256(-1));
IERC20(mmVault).safeApprove(mmFarmingPool, uint256(-1));
IERC20(mm).safeApprove(unirouter, uint256(-1));
IERC20(mm).safeApprove(sushiroute, uint256(-1));
}
| 18,925 |
5 | // Reference implementation of the ERC223 standard token. / | contract ERC223Token is IERC223 {
using SafeMath for uint;
/**
* @dev See `IERC223.totalSupply`.
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
mapping(address => uint) balances; // List of user balances.
/**
* @dev Transfer the specified amount of tokens to the specified address.
* Invokes the `tokenFallback` function if the recipient is a contract.
* The token transfer fails if the recipient is a contract
* but does not implement the `tokenFallback` function
* or the fallback function to receive funds.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
* @param _data Transaction metadata.
*/
function transfer(address _to, uint _value, bytes memory _data) public returns (bool success){
// Standard function transfer similar to ERC20 transfer with no _data .
// Added due to backwards compatibility reasons .
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
if(Address.isContract(_to)) {
IERC223Recipient receiver = IERC223Recipient(_to);
receiver.tokenFallback(msg.sender, _value, _data);
}
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
/**
* @dev Transfer the specified amount of tokens to the specified address.
* This function works the same with the previous one
* but doesn't contain `_data` param.
* Added due to backwards compatibility reasons.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
*/
function transfer(address _to, uint _value) public returns (bool success){
bytes memory empty = hex"00000000";
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
if(Address.isContract(_to)) {
IERC223Recipient receiver = IERC223Recipient(_to);
receiver.tokenFallback(msg.sender, _value, empty);
}
emit Transfer(msg.sender, _to, _value, empty);
return true;
}
/**
* @dev Returns balance of the `_owner`.
*
* @param _owner The address whose balance will be returned.
* @return balance Balance of the `_owner`.
*/
function balanceOf(address _owner) public view returns (uint balance) {
return balances[_owner];
}
}
| contract ERC223Token is IERC223 {
using SafeMath for uint;
/**
* @dev See `IERC223.totalSupply`.
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
mapping(address => uint) balances; // List of user balances.
/**
* @dev Transfer the specified amount of tokens to the specified address.
* Invokes the `tokenFallback` function if the recipient is a contract.
* The token transfer fails if the recipient is a contract
* but does not implement the `tokenFallback` function
* or the fallback function to receive funds.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
* @param _data Transaction metadata.
*/
function transfer(address _to, uint _value, bytes memory _data) public returns (bool success){
// Standard function transfer similar to ERC20 transfer with no _data .
// Added due to backwards compatibility reasons .
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
if(Address.isContract(_to)) {
IERC223Recipient receiver = IERC223Recipient(_to);
receiver.tokenFallback(msg.sender, _value, _data);
}
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
/**
* @dev Transfer the specified amount of tokens to the specified address.
* This function works the same with the previous one
* but doesn't contain `_data` param.
* Added due to backwards compatibility reasons.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
*/
function transfer(address _to, uint _value) public returns (bool success){
bytes memory empty = hex"00000000";
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
if(Address.isContract(_to)) {
IERC223Recipient receiver = IERC223Recipient(_to);
receiver.tokenFallback(msg.sender, _value, empty);
}
emit Transfer(msg.sender, _to, _value, empty);
return true;
}
/**
* @dev Returns balance of the `_owner`.
*
* @param _owner The address whose balance will be returned.
* @return balance Balance of the `_owner`.
*/
function balanceOf(address _owner) public view returns (uint balance) {
return balances[_owner];
}
}
| 16,500 |
111 | // return True if the market is enabled for this DMMA or false if it is not enabled. / | function isMarketEnabledByDmmTokenId(uint dmmTokenId) external view returns (bool);
| function isMarketEnabledByDmmTokenId(uint dmmTokenId) external view returns (bool);
| 24,726 |
29 | // Set public sale start time./saleStartTime_ The start time as a timestamp. | function setSaleStartTime(uint32 saleStartTime_) external onlyOwner {
SaleConfig storage config = saleConfig;
config.saleStartTime = saleStartTime_;
}
| function setSaleStartTime(uint32 saleStartTime_) external onlyOwner {
SaleConfig storage config = saleConfig;
config.saleStartTime = saleStartTime_;
}
| 6,835 |
200 | // Changes text for holder./ Can be accessed by contract owner or oracle only.//_externalHolderId external holder identifier./_text changing text.// return result code. | function updateTextForHolder(
bytes32 _externalHolderId,
bytes _text
)
onlyOracleOrOwner
external
returns (uint)
| function updateTextForHolder(
bytes32 _externalHolderId,
bytes _text
)
onlyOracleOrOwner
external
returns (uint)
| 4,661 |
283 | // Ether is burned and transferred | address(0).transfer(toBurn);
beneficiary.transfer(reward);
emit StakePenalized(relayManager, beneficiary, reward);
| address(0).transfer(toBurn);
beneficiary.transfer(reward);
emit StakePenalized(relayManager, beneficiary, reward);
| 78,205 |
154 | // Set Oracle address Callable by admin / | function setOracle(address _oracle) external whenPaused onlyAdmin {
require(_oracle != address(0), "Cannot be zero address");
oracleLatestRoundId = 0;
oracle = AggregatorV3Interface(_oracle);
// Dummy check to make sure the interface implements this function properly
oracle.latestRoundData();
emit NewOracle(_oracle);
}
| function setOracle(address _oracle) external whenPaused onlyAdmin {
require(_oracle != address(0), "Cannot be zero address");
oracleLatestRoundId = 0;
oracle = AggregatorV3Interface(_oracle);
// Dummy check to make sure the interface implements this function properly
oracle.latestRoundData();
emit NewOracle(_oracle);
}
| 23,851 |
5 | // ------------------------------------------------------------------------ Modifier to mark that a function can only be executed by the token contract ------------------------------------------------------------------------ | modifier onlyTokenContract {
require(msg.sender == tokenContractAddress);
_;
}
| modifier onlyTokenContract {
require(msg.sender == tokenContractAddress);
_;
}
| 39,539 |
172 | // Immediately grants tokens to an address, including a portion that will vest over timeaccording to a set vesting schedule. The overall duration and cliff duration of the grant mustbe an even multiple of the vesting interval.beneficiary = Address to which tokens will be granted. totalAmount = Total number of tokens to deposit into the account. vestingAmount = Out of totalAmount, the number of tokens subject to vesting. startDay = Start day of the grant's vesting schedule, in days since the UNIX epoch(start of day). The startDay may be given as a date in the future or in the past, going | function grantVestingTokens(
address beneficiary,
uint256 totalAmount,
uint256 vestingAmount,
uint32 startDay,
uint32 duration,
uint32 cliffDuration,
uint32 interval,
bool isRevocable
| function grantVestingTokens(
address beneficiary,
uint256 totalAmount,
uint256 vestingAmount,
uint32 startDay,
uint32 duration,
uint32 cliffDuration,
uint32 interval,
bool isRevocable
| 35,406 |
17 | // Returns rewards for address for committal actions./ Multiplier of 1000token balance./from The address to calculate committal rewards for | function getCommittalReward(address from) external view returns (uint256) {
return 1e18 * 1000 * balanceOf(from);
}
| function getCommittalReward(address from) external view returns (uint256) {
return 1e18 * 1000 * balanceOf(from);
}
| 76,813 |
14 | // ________________________________________________________/Constrctor function / | function CrowdSaleMacroansyA() public {
owner = msg.sender;
beneficiaryFunds = owner;
saleParamSet = false;
fundingGoalReached = false;
crowdsaleStart = false;
crowdsaleClosed = false;
unlockFundersBalance = false;
}
| function CrowdSaleMacroansyA() public {
owner = msg.sender;
beneficiaryFunds = owner;
saleParamSet = false;
fundingGoalReached = false;
crowdsaleStart = false;
crowdsaleClosed = false;
unlockFundersBalance = false;
}
| 21,253 |
59 | // ------------------------------------------------------------------------ Query to get the pending yield_tokenAddress address of the token asset ------------------------------------------------------------------------ | function PendingYield(address _tokenAddress, address _caller) public view returns(uint256 _pendingRewardWeis){
uint256 _totalFarmingTime = now.sub(users[_caller][_tokenAddress].lastClaimedDate);
uint256 _reward_token_second = ((tokens[_tokenAddress].rate).mul(10 ** 21)).div(365 days); // added extra 10^21
uint256 yield = ((users[_caller][_tokenAddress].activeDeposit).mul(_totalFarmingTime.mul(_reward_token_second))).div(10 ** 27); // remove extra 10^21 // 10^2 are for 100 (%)
return yield.add(users[_caller][_tokenAddress].pendingGains);
}
| function PendingYield(address _tokenAddress, address _caller) public view returns(uint256 _pendingRewardWeis){
uint256 _totalFarmingTime = now.sub(users[_caller][_tokenAddress].lastClaimedDate);
uint256 _reward_token_second = ((tokens[_tokenAddress].rate).mul(10 ** 21)).div(365 days); // added extra 10^21
uint256 yield = ((users[_caller][_tokenAddress].activeDeposit).mul(_totalFarmingTime.mul(_reward_token_second))).div(10 ** 27); // remove extra 10^21 // 10^2 are for 100 (%)
return yield.add(users[_caller][_tokenAddress].pendingGains);
}
| 47,632 |
157 | // Append userAddress and relayer address at the end to extract it from calling context | (bool success, bytes memory returnData) = address(this).call(
abi.encodePacked(functionSignature, userAddress)
);
require(success, "Function call not successful");
return returnData;
| (bool success, bytes memory returnData) = address(this).call(
abi.encodePacked(functionSignature, userAddress)
);
require(success, "Function call not successful");
return returnData;
| 5,260 |
72 | // 7. jacpoet reward | processJackpot(gambler, entropy, amount);
| processJackpot(gambler, entropy, amount);
| 49,381 |
20 | // Shortcut for the actual value | if (_block >= checkpoints[checkpoints.length.sub(1)].fromBlock)
return checkpoints[checkpoints.length.sub(1)].value;
if (_block < checkpoints[0].fromBlock)
return 0;
| if (_block >= checkpoints[checkpoints.length.sub(1)].fromBlock)
return checkpoints[checkpoints.length.sub(1)].value;
if (_block < checkpoints[0].fromBlock)
return 0;
| 43,797 |
28 | // stakeholders[msg.sender].unclaimedRewards = 0; | rewardsToken.safeTransfer(msg.sender, rewards);
emit RewardPaid(msg.sender, rewards);
| rewardsToken.safeTransfer(msg.sender, rewards);
emit RewardPaid(msg.sender, rewards);
| 12,089 |
1 | // _owner The address from which the balance will be retrieved / return The balance | function balanceOf(address _owner) constant returns (uint256 balance) {}
| function balanceOf(address _owner) constant returns (uint256 balance) {}
| 24,014 |
738 | // Read the block header | BlockReader.BlockHeader memory header = _block.data.readHeader();
| BlockReader.BlockHeader memory header = _block.data.readHeader();
| 36,987 |
4 | // Revert with an error when attempting to update a channel to the current status of that channel. / | error ChannelStatusAlreadySet(address channel, bool isOpen);
| error ChannelStatusAlreadySet(address channel, bool isOpen);
| 22,351 |
39 | // Splits the slice, setting `self` to everything before the last occurrence of `needle`, and `token` to everything after it. If `needle` does not occur in `self`, `self` is set to the empty slice, and `token` is set to the entirety of `self`. self The slice to split. needle The text to search for in `self`. token An output parameter to which the first token is written.return `token`. / | function rsplit(slice memory self, slice memory needle, slice memory token) internal pure returns (slice memory) {
uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr);
token._ptr = ptr;
token._len = self._len - (ptr - self._ptr);
if (ptr == self._ptr) {
// Not found
self._len = 0;
} else {
self._len -= token._len + needle._len;
}
return token;
}
| function rsplit(slice memory self, slice memory needle, slice memory token) internal pure returns (slice memory) {
uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr);
token._ptr = ptr;
token._len = self._len - (ptr - self._ptr);
if (ptr == self._ptr) {
// Not found
self._len = 0;
} else {
self._len -= token._len + needle._len;
}
return token;
}
| 26,063 |
51 | // EIP712 init | _initializeEIP712('Decentraland Collection Manager', '1');
| _initializeEIP712('Decentraland Collection Manager', '1');
| 22,557 |
78 | // partially redeem a past stake | newStakingShareSecondsToBurn = sharesLeftToBurn.mul(
stakeTimeSec
);
rewardAmount = computeNewReward(
rewardAmount,
newStakingShareSecondsToBurn,
stakeTimeSec
);
stakingShareSecondsToBurn = stakingShareSecondsToBurn.add(
newStakingShareSecondsToBurn
| newStakingShareSecondsToBurn = sharesLeftToBurn.mul(
stakeTimeSec
);
rewardAmount = computeNewReward(
rewardAmount,
newStakingShareSecondsToBurn,
stakeTimeSec
);
stakingShareSecondsToBurn = stakingShareSecondsToBurn.add(
newStakingShareSecondsToBurn
| 3,866 |
Subsets and Splits