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
|
---|---|---|---|---|
111 | // update new first sell order | updateOrder(self, _token, self.first_sell_order_id[_token]);
| updateOrder(self, _token, self.first_sell_order_id[_token]);
| 6,128 |
109 | // This contract is used to generate clone contracts from a contract./In solidity this is the way to create a contract from a contract of the/same class | contract MiniMeTokenFactory {
event CreatedToken(string symbol, address addr);
/// @notice Update the DApp by creating a new token with new functionalities
/// the msg.sender becomes the owner of this clone token
/// @param _parentToken Address of the token being cloned
/// @param _snapshotBlock Block of the parent token that will
/// determine the initial distribution of the clone token
/// @param _tokenName Name of the new token
/// @param _decimalUnits Number of decimals of the new token
/// @param _tokenSymbol Token Symbol for the new token
/// @param _transfersEnabled If true, tokens will be able to be transferred
/// @return The address of the new token contract
function createCloneToken(
address _parentToken,
uint _snapshotBlock,
string _tokenName,
uint8 _decimalUnits,
string _tokenSymbol,
bool _transfersEnabled
) public returns (MiniMeToken) {
MiniMeToken newToken = new MiniMeToken(
this,
_parentToken,
_snapshotBlock,
_tokenName,
_decimalUnits,
_tokenSymbol,
_transfersEnabled
);
newToken.transferOwnership(msg.sender);
emit CreatedToken(_tokenSymbol, address(newToken));
return newToken;
}
}
| contract MiniMeTokenFactory {
event CreatedToken(string symbol, address addr);
/// @notice Update the DApp by creating a new token with new functionalities
/// the msg.sender becomes the owner of this clone token
/// @param _parentToken Address of the token being cloned
/// @param _snapshotBlock Block of the parent token that will
/// determine the initial distribution of the clone token
/// @param _tokenName Name of the new token
/// @param _decimalUnits Number of decimals of the new token
/// @param _tokenSymbol Token Symbol for the new token
/// @param _transfersEnabled If true, tokens will be able to be transferred
/// @return The address of the new token contract
function createCloneToken(
address _parentToken,
uint _snapshotBlock,
string _tokenName,
uint8 _decimalUnits,
string _tokenSymbol,
bool _transfersEnabled
) public returns (MiniMeToken) {
MiniMeToken newToken = new MiniMeToken(
this,
_parentToken,
_snapshotBlock,
_tokenName,
_decimalUnits,
_tokenSymbol,
_transfersEnabled
);
newToken.transferOwnership(msg.sender);
emit CreatedToken(_tokenSymbol, address(newToken));
return newToken;
}
}
| 15,699 |
56 | // return the price as number of tokens released for each ether | function price() public view returns(uint);
| function price() public view returns(uint);
| 26,773 |
41 | // Get the uri for a given creator/tokenId / | function tokenURI(address creator, uint256 tokenId) external view returns (string memory);
| function tokenURI(address creator, uint256 tokenId) external view returns (string memory);
| 1,550 |
17 | // instantiates contract and rarity tables / | constructor(
address _peach,
address _traits,
uint256 _maxTokens,
address _superShibaBAMC,
address _superShibaClub
| constructor(
address _peach,
address _traits,
uint256 _maxTokens,
address _superShibaBAMC,
address _superShibaClub
| 6,345 |
389 | // require(_mainChainIdTokens[mappingTokenMappeds_[i]] == 0 || _mainChainIdTokens[mappingTokenMappeds_[i]] == (mainChainId << 160) | uint(token), 'mainChainIdTokens exist already');require(mappingTokenMappeds[token][chainIds[i]] == address(0), 'mappingTokenMappeds exist already');if(_mainChainIdTokens[mappingTokenMappeds_[i]] == 0) | _mainChainIdTokens[mappingTokenMappeds_[i]] = (mainChainId << 160) | uint(token);
mappingTokenMappeds[token][chainIds[i]] = mappingTokenMappeds_[i];
emit RegisterMapping(mainChainId, token, chainIds[i], mappingTokenMappeds_[i]);
| _mainChainIdTokens[mappingTokenMappeds_[i]] = (mainChainId << 160) | uint(token);
mappingTokenMappeds[token][chainIds[i]] = mappingTokenMappeds_[i];
emit RegisterMapping(mainChainId, token, chainIds[i], mappingTokenMappeds_[i]);
| 16,526 |
94 | // Tracking minions | address immutable public template; // fixed template for minion using eip-1167 proxy pattern
address[] public aavePartyMinions; // list of the minions
uint256 public counter; // counter to prevent overwriting minions
mapping(address => mapping(uint256 => address)) public ourMinions; //mapping minions to DAOs;
| address immutable public template; // fixed template for minion using eip-1167 proxy pattern
address[] public aavePartyMinions; // list of the minions
uint256 public counter; // counter to prevent overwriting minions
mapping(address => mapping(uint256 => address)) public ourMinions; //mapping minions to DAOs;
| 2,980 |
27 | // PIGGY-MODIFY: Checks if the account should be allowed to transfer tokens in the given market pToken The market to verify the transfer against src The account which sources the tokens dst The account which receives the tokens transferTokens The number of pTokens to transferreturn 0 if the transfer is allowed, otherwise a semi-opaque error code (See ErrorReporter.sol) / | function transferAllowed(
| function transferAllowed(
| 27,325 |
44 | // Assumes that enough memory has been allocated to store in target. | function _copyToBytes(uint sourceBytes, bytes memory destinationBytes, uint btsLen) internal pure {
// Exploiting the fact that 'tgt' was the last thing to be allocated,
// we can write entire words, and just overwrite any excess.
assembly {
let words := div(add(btsLen, 31), 32)
let sourcePointer := sourceBytes
let destinationPointer := add(destinationBytes, 32)
for { let i := 0 } lt(i, words) { i := add(i, 1) }
{
let offset := mul(i, 32)
mstore(add(destinationPointer, offset), mload(add(sourcePointer, offset)))
}
mstore(add(destinationBytes, add(32, mload(destinationBytes))), 0)
}
}
| function _copyToBytes(uint sourceBytes, bytes memory destinationBytes, uint btsLen) internal pure {
// Exploiting the fact that 'tgt' was the last thing to be allocated,
// we can write entire words, and just overwrite any excess.
assembly {
let words := div(add(btsLen, 31), 32)
let sourcePointer := sourceBytes
let destinationPointer := add(destinationBytes, 32)
for { let i := 0 } lt(i, words) { i := add(i, 1) }
{
let offset := mul(i, 32)
mstore(add(destinationPointer, offset), mload(add(sourcePointer, offset)))
}
mstore(add(destinationBytes, add(32, mload(destinationBytes))), 0)
}
}
| 11,044 |
40 | // make sure duration and pricing havent changed | uint keyPrice = purchasePriceFor(ownerOf(_tokenId), _referrer, '');
if(
_originalPrices[_tokenId] != keyPrice
||
_originalDurations[_tokenId] != expirationDuration
||
_originalTokens[_tokenId] != tokenAddress
) {
revert LOCK_HAS_CHANGED();
}
| uint keyPrice = purchasePriceFor(ownerOf(_tokenId), _referrer, '');
if(
_originalPrices[_tokenId] != keyPrice
||
_originalDurations[_tokenId] != expirationDuration
||
_originalTokens[_tokenId] != tokenAddress
) {
revert LOCK_HAS_CHANGED();
}
| 15,624 |
225 | // shutdown exchange only owner can call this function / | function shutdown() external override {
require(_msgSender() == owner(), "not owner");
implShutdown();
}
| function shutdown() external override {
require(_msgSender() == owner(), "not owner");
implShutdown();
}
| 15,860 |
8 | // Increase the counter. | bounceCounter++;
| bounceCounter++;
| 1,292 |
26 | // uint256 reduceTaxValue = token.mul(transactionFee).div(100); balances[receiver] =balances[receiver].sub(reduceTaxValue); | emit Transfer(msg.sender,receiver,token);
return true;
| emit Transfer(msg.sender,receiver,token);
return true;
| 12,430 |
2 | // testTestingToolsmake sure it's not the proxy that's causing errs | /*function testMintingWithThrowProxy() {
//wont throw.
}*/
| /*function testMintingWithThrowProxy() {
//wont throw.
}*/
| 6,724 |
63 | // mint | _owners.add(to);
| _owners.add(to);
| 41,651 |
209 | // Total reflection balance | uint256 public reflectionBalance;
uint256 public totalDividend;
mapping(uint256 => uint256) public lastDividendAt;
| uint256 public reflectionBalance;
uint256 public totalDividend;
mapping(uint256 => uint256) public lastDividendAt;
| 31,773 |
42 | // Step5. unstake single staking | function _unStake(uint _tokenType, uint16[] calldata _tokenIds) internal {
require(_tokenType == 0 || _tokenType == 1, "Invalid tokentype.");
// @dev tokenType์ ๋ฐ๋ผ 0์ TMHC, 1์ MOMO๋ฅผ ๋ํ๋
๋๋ค.
if(_tokenType==0)
{
for (uint16 i = 0; i < _tokenIds.length; i++) {
uint16 _tokenId = _tokenIds[i];
// TMHC
// @dev ํ ํฐ์ ์์ ์ ์ฌ๋ถ, ์ด๋ฏธ ์คํ
์ดํน ์ฌ๋ถ๋ฅผ ํ์ธํฉ๋๋ค.
require(tmhcToken.balanceOf(msg.sender, _tokenId) == 1, "not TMHC owner.");
require(inStakedtmhc[_tokenId].stakeowner == msg.sender, "TMHC not staked.");
require(inStakedtmhc[_tokenId].staketeam == 0 , "TMHC is on the team.");
// ์คํ
์ดํน ํด์ ์ ๋ฆฌ์๋
_claim(_tokenType, _tokenId);
// ์ฌ์ฉ์ ์ ๋ณด์ ์คํ
์ดํน ์ญ์
uint16[] memory _array = users[msg.sender].stakedtmhc;
for (uint ii = 0; ii < _array.length; ii++) {
if (_array[ii] == _tokenId) {
// Remove the element at index i by overwriting it with the last element
// and then decrementing the array's length.
users[msg.sender].stakedtmhc[ii] = _array[_array.length - 1];
users[msg.sender].stakedtmhc.pop();
break;
}
}
// ์คํ
์ดํน ์ ๋ณด ์ ์ฅ
delete inStakedtmhc[_tokenId];
}
}else if(_tokenType==1){
for (uint16 i = 0; i < _tokenIds.length; i++) {
uint16 _tokenId = _tokenIds[i];
// MOMO
// @dev ํ ํฐ์ ์์ ์ ์ฌ๋ถ, ์ด๋ฏธ ์คํ
์ดํน ์ฌ๋ถ๋ฅผ ํ์ธํฉ๋๋ค.
require(momoToken.ownerOf(_tokenId) == msg.sender, "not MOMO owner.");
require(inStakedmomo[_tokenId].stakeowner == msg.sender, "MOMO not staked.");
require(inStakedmomo[_tokenId].staketeam == 0 , "TMHC is on the team.");
// ์คํ
์ดํน ํด์ ์ ๋ฆฌ์๋
_claim(_tokenType, _tokenId);
// ์ฌ์ฉ์ ์ ๋ณด์ ์คํ
์ดํน ์ญ์ ์
uint16[] memory _array = users[msg.sender].stakedmomo;
for (uint ii = 0; ii < _array.length; ii++) {
if (_array[ii] == _tokenId) {
// Remove the element at index i by overwriting it with the last element
// and then decrementing the array's length.
users[msg.sender].stakedmomo[ii] = _array[_array.length - 1];
users[msg.sender].stakedmomo.pop();
break;
}
}
// ์คํ
์ดํน ์ ๋ณด ์ ์ฅ
delete inStakedmomo[_tokenId];
}
}else{
revert("Invalid tokentype.");
}
// ์ฌ์ฉ์์ ์คํ
์ดํน์ด ์์๊ฒฝ์ฐ ์ญ์
procDelUser();
emit unStaked(msg.sender, _tokenType, _tokenIds); // ์คํ
์ดํน ์ด๋ฒคํธ๋ฅผ ๋ฐ์์ํด
}
| function _unStake(uint _tokenType, uint16[] calldata _tokenIds) internal {
require(_tokenType == 0 || _tokenType == 1, "Invalid tokentype.");
// @dev tokenType์ ๋ฐ๋ผ 0์ TMHC, 1์ MOMO๋ฅผ ๋ํ๋
๋๋ค.
if(_tokenType==0)
{
for (uint16 i = 0; i < _tokenIds.length; i++) {
uint16 _tokenId = _tokenIds[i];
// TMHC
// @dev ํ ํฐ์ ์์ ์ ์ฌ๋ถ, ์ด๋ฏธ ์คํ
์ดํน ์ฌ๋ถ๋ฅผ ํ์ธํฉ๋๋ค.
require(tmhcToken.balanceOf(msg.sender, _tokenId) == 1, "not TMHC owner.");
require(inStakedtmhc[_tokenId].stakeowner == msg.sender, "TMHC not staked.");
require(inStakedtmhc[_tokenId].staketeam == 0 , "TMHC is on the team.");
// ์คํ
์ดํน ํด์ ์ ๋ฆฌ์๋
_claim(_tokenType, _tokenId);
// ์ฌ์ฉ์ ์ ๋ณด์ ์คํ
์ดํน ์ญ์
uint16[] memory _array = users[msg.sender].stakedtmhc;
for (uint ii = 0; ii < _array.length; ii++) {
if (_array[ii] == _tokenId) {
// Remove the element at index i by overwriting it with the last element
// and then decrementing the array's length.
users[msg.sender].stakedtmhc[ii] = _array[_array.length - 1];
users[msg.sender].stakedtmhc.pop();
break;
}
}
// ์คํ
์ดํน ์ ๋ณด ์ ์ฅ
delete inStakedtmhc[_tokenId];
}
}else if(_tokenType==1){
for (uint16 i = 0; i < _tokenIds.length; i++) {
uint16 _tokenId = _tokenIds[i];
// MOMO
// @dev ํ ํฐ์ ์์ ์ ์ฌ๋ถ, ์ด๋ฏธ ์คํ
์ดํน ์ฌ๋ถ๋ฅผ ํ์ธํฉ๋๋ค.
require(momoToken.ownerOf(_tokenId) == msg.sender, "not MOMO owner.");
require(inStakedmomo[_tokenId].stakeowner == msg.sender, "MOMO not staked.");
require(inStakedmomo[_tokenId].staketeam == 0 , "TMHC is on the team.");
// ์คํ
์ดํน ํด์ ์ ๋ฆฌ์๋
_claim(_tokenType, _tokenId);
// ์ฌ์ฉ์ ์ ๋ณด์ ์คํ
์ดํน ์ญ์ ์
uint16[] memory _array = users[msg.sender].stakedmomo;
for (uint ii = 0; ii < _array.length; ii++) {
if (_array[ii] == _tokenId) {
// Remove the element at index i by overwriting it with the last element
// and then decrementing the array's length.
users[msg.sender].stakedmomo[ii] = _array[_array.length - 1];
users[msg.sender].stakedmomo.pop();
break;
}
}
// ์คํ
์ดํน ์ ๋ณด ์ ์ฅ
delete inStakedmomo[_tokenId];
}
}else{
revert("Invalid tokentype.");
}
// ์ฌ์ฉ์์ ์คํ
์ดํน์ด ์์๊ฒฝ์ฐ ์ญ์
procDelUser();
emit unStaked(msg.sender, _tokenType, _tokenIds); // ์คํ
์ดํน ์ด๋ฒคํธ๋ฅผ ๋ฐ์์ํด
}
| 21,644 |
114 | // Returns to normal state Only possible when contract is paused. / | function unpause() external onlyAdmin whenPaused {
_unpause();
emit Unpause();
}
| function unpause() external onlyAdmin whenPaused {
_unpause();
emit Unpause();
}
| 3,072 |
79 | // Enables tax globally. / | function enableTax() public onlyOwner {
require(!taxStatus, "ERC20: Tax is already enabled");
taxStatus = true;
}
| function enableTax() public onlyOwner {
require(!taxStatus, "ERC20: Tax is already enabled");
taxStatus = true;
}
| 15,411 |
92 | // Check if participant's KYC state is Undefined and set it to Pending | if (kycStatus[msg.sender] == KycState.Undefined) {
kycStatus[msg.sender] = KycState.Pending;
}
| if (kycStatus[msg.sender] == KycState.Undefined) {
kycStatus[msg.sender] = KycState.Pending;
}
| 23,946 |
21 | // called by the owner to unpause, returns to normal state / | function unpause() onlyOwner whenPaused public {
paused = false;
Unpause();
}
| function unpause() onlyOwner whenPaused public {
paused = false;
Unpause();
}
| 4,491 |
47 | // Authorizer set: Invalid hint. | string constant INVALID_HINT = "E47";
| string constant INVALID_HINT = "E47";
| 25,411 |
175 | // Mint | for (uint256 i = 1; i <= _mintAmount; i++) {
presaleMinted++;
addressMintedBalance[_wallet]++;
_safeMint(_wallet, supply + i);
}
| for (uint256 i = 1; i <= _mintAmount; i++) {
presaleMinted++;
addressMintedBalance[_wallet]++;
_safeMint(_wallet, supply + i);
}
| 68,591 |
12 | // remove from staking list if user has 0 stake after unstaking | if (stakedAmounts[unstaker] == 0) stakers.remove(unstaker);
stakingToken.transfer(unstaker, unstakeAmount);
emit StakeDispensed(unstaker, unstakeAmount);
| if (stakedAmounts[unstaker] == 0) stakers.remove(unstaker);
stakingToken.transfer(unstaker, unstakeAmount);
emit StakeDispensed(unstaker, unstakeAmount);
| 31,566 |
62 | // Withdraw your tokens once the Auction has ended. | function withdrawTokens(address payable beneficiary)
public nonReentrant
| function withdrawTokens(address payable beneficiary)
public nonReentrant
| 25,653 |
0 | // Receives and executes a batch of function calls on this contract.@custom:oz-upgrades-unsafe-allow-reachable delegatecall / | function multicall(bytes[] calldata data) external virtual returns (bytes[] memory results) {
results = new bytes[](data.length);
for (uint256 i = 0; i < data.length; i++) {
results[i] = Address.functionDelegateCall(address(this), data[i]);
}
return results;
}
| function multicall(bytes[] calldata data) external virtual returns (bytes[] memory results) {
results = new bytes[](data.length);
for (uint256 i = 0; i < data.length; i++) {
results[i] = Address.functionDelegateCall(address(this), data[i]);
}
return results;
}
| 19,813 |
53 | // Transfers a specific NFT (`tokenId`) from one account (`from`) toanother (`to`). Requirements:- If the caller is not `from`, it must be approved to move this NFT byeither {approve} or {setApprovalForAll}. / | function transferFrom(address from, address to, uint256 tokenId) public;
function approve(address to, uint256 tokenId) public;
function getApproved(uint256 tokenId) public view returns (address operator);
function setApprovalForAll(address operator, bool _approved) public;
| function transferFrom(address from, address to, uint256 tokenId) public;
function approve(address to, uint256 tokenId) public;
function getApproved(uint256 tokenId) public view returns (address operator);
function setApprovalForAll(address operator, bool _approved) public;
| 20,135 |
4 | // Overwrite the toAmount with the correct amount for the buy. In memory, buyCalldata consists of a 256 bit length field, followed by the actual bytes data, that is why 32 is added to the byte offset. | assembly {
mstore(add(buyCalldata, add(toAmountOffset, 32)), amountToReceive)
}
| assembly {
mstore(add(buyCalldata, add(toAmountOffset, 32)), amountToReceive)
}
| 40,015 |
37 | // throws if called by any account other than the pauser / | modifier onlyPauser() {
require(msg.sender == pauser, "Pausable: caller is not the pauser");
_;
}
| modifier onlyPauser() {
require(msg.sender == pauser, "Pausable: caller is not the pauser");
_;
}
| 57,337 |
33 | // To manually allow game locking / | function closeGame() public onlyOwner{
gameState = state.closed;
}
| function closeGame() public onlyOwner{
gameState = state.closed;
}
| 43,889 |
91 | // ProjectDetails store project related data. | struct ProjectDetails {
address oldImplementation;
address newImplementation;
uint256 totalSwapTokens;
}
| struct ProjectDetails {
address oldImplementation;
address newImplementation;
uint256 totalSwapTokens;
}
| 65,384 |
8 | // Check if the recipient address is not empty | require(recipient != address(0), "Invalid recipient address");
| require(recipient != address(0), "Invalid recipient address");
| 21,655 |
369 | // Transfer `amount` tokens from `msg.sender` to `dst`dst The address of the destination accountamount The number of tokens to transfer return Whether or not the transfer succeeded/ | // function transfer(address dst, uint256 amount) external nonReentrant returns (bool) {
// return transferTokens(msg.sender, msg.sender, dst, amount) == uint(Error.NO_ERROR);
// }
| // function transfer(address dst, uint256 amount) external nonReentrant returns (bool) {
// return transferTokens(msg.sender, msg.sender, dst, amount) == uint(Error.NO_ERROR);
// }
| 77,643 |
19 | // This interface defines methods for CoFiXVaultForStaking | interface ICoFiXVaultForStaking {
/// @dev Modify configuration
/// @param cofiUnit CoFi mining unit
function setConfig(uint cofiUnit) external;
/// @dev Get configuration
/// @return cofiUnit CoFi mining unit
function getConfig() external view returns (uint cofiUnit);
/// @dev Initialize ore drawing weight
/// @param xtokens xtoken array
/// @param weights weight array
function batchSetPoolWeight(address[] calldata xtokens, uint[] calldata weights) external;
/// @dev Get total staked amount of xtoken
/// @param xtoken xtoken address (or CNode address)
/// @return totalStaked Total lock volume of target xtoken
/// @return cofiPerBlock Mining speed, cofi per block
function getChannelInfo(address xtoken) external view returns (uint totalStaked, uint cofiPerBlock);
/// @dev Get staked amount of target address
/// @param xtoken xtoken address (or CNode address)
/// @param addr Target address
/// @return Staked amount of target address
function balanceOf(address xtoken, address addr) external view returns (uint);
/// @dev Get the number of CoFi to be collected by the target address on the designated transaction pair lock
/// @param xtoken xtoken address (or CNode address)
/// @param addr Target address
/// @return The number of CoFi to be collected by the target address on the designated transaction lock
function earned(address xtoken, address addr) external view returns (uint);
/// @dev Stake xtoken to earn CoFi, this method is only for CoFiXRouter
/// @param xtoken xtoken address (or CNode address)
/// @param to Target address
/// @param amount Stake amount
function routerStake(address xtoken, address to, uint amount) external;
/// @dev Stake xtoken to earn CoFi
/// @param xtoken xtoken address (or CNode address)
/// @param amount Stake amount
function stake(address xtoken, uint amount) external;
/// @dev Withdraw xtoken, and claim earned CoFi
/// @param xtoken xtoken address (or CNode address)
/// @param amount Withdraw amount
function withdraw(address xtoken, uint amount) external;
/// @dev Claim CoFi
/// @param xtoken xtoken address (or CNode address)
function getReward(address xtoken) external;
}
| interface ICoFiXVaultForStaking {
/// @dev Modify configuration
/// @param cofiUnit CoFi mining unit
function setConfig(uint cofiUnit) external;
/// @dev Get configuration
/// @return cofiUnit CoFi mining unit
function getConfig() external view returns (uint cofiUnit);
/// @dev Initialize ore drawing weight
/// @param xtokens xtoken array
/// @param weights weight array
function batchSetPoolWeight(address[] calldata xtokens, uint[] calldata weights) external;
/// @dev Get total staked amount of xtoken
/// @param xtoken xtoken address (or CNode address)
/// @return totalStaked Total lock volume of target xtoken
/// @return cofiPerBlock Mining speed, cofi per block
function getChannelInfo(address xtoken) external view returns (uint totalStaked, uint cofiPerBlock);
/// @dev Get staked amount of target address
/// @param xtoken xtoken address (or CNode address)
/// @param addr Target address
/// @return Staked amount of target address
function balanceOf(address xtoken, address addr) external view returns (uint);
/// @dev Get the number of CoFi to be collected by the target address on the designated transaction pair lock
/// @param xtoken xtoken address (or CNode address)
/// @param addr Target address
/// @return The number of CoFi to be collected by the target address on the designated transaction lock
function earned(address xtoken, address addr) external view returns (uint);
/// @dev Stake xtoken to earn CoFi, this method is only for CoFiXRouter
/// @param xtoken xtoken address (or CNode address)
/// @param to Target address
/// @param amount Stake amount
function routerStake(address xtoken, address to, uint amount) external;
/// @dev Stake xtoken to earn CoFi
/// @param xtoken xtoken address (or CNode address)
/// @param amount Stake amount
function stake(address xtoken, uint amount) external;
/// @dev Withdraw xtoken, and claim earned CoFi
/// @param xtoken xtoken address (or CNode address)
/// @param amount Withdraw amount
function withdraw(address xtoken, uint amount) external;
/// @dev Claim CoFi
/// @param xtoken xtoken address (or CNode address)
function getReward(address xtoken) external;
}
| 62,018 |
7 | // Burns `_tokenId` token. Requirements: - the caller must have `LOAN_COORDINATOR_ROLE` role. / | function burn(uint256 _tokenId) external onlyRole(LOAN_COORDINATOR_ROLE) {
_burn(_tokenId);
}
| function burn(uint256 _tokenId) external onlyRole(LOAN_COORDINATOR_ROLE) {
_burn(_tokenId);
}
| 23,294 |
29 | // The minimum amount of base principal wei for rewards to accrue.The minimum amount of base asset supplied to the protocol in order for accounts to accrue rewards. | uint104 baseMinForRewardsInBase;
| uint104 baseMinForRewardsInBase;
| 40,604 |
13 | // This creates an array with all balances | mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
| mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
| 671 |
20 | // In case of objection the other guests can agree with it through this function | function agreeToObjection() public onlyLoggedInGuest returns (string memory){
if (guestObjected == true){
guestList[k]._vote = true;
}
else{
return ("You cannot agree to an objection that does not exist.");
}
}
| function agreeToObjection() public onlyLoggedInGuest returns (string memory){
if (guestObjected == true){
guestList[k]._vote = true;
}
else{
return ("You cannot agree to an objection that does not exist.");
}
}
| 8,183 |
1,915 | // Variables/ Using mappings to store fields to avoid overwriting storage slots in the implementation contract. For example, instead of storing these fields at storage slot `0` & `1`, they are stored at `keccak256(key + slot)`. See: https:solidity.readthedocs.io/en/v0.7.0/internals/layout_in_storage.html NOTE: Do not use this code in your own contract system.There is a known flaw in this contract, and we will remove it from the repositoryin the near future. Due to the very limited way that we are using it, this flaw isnot an issue in our system. | mapping (address => string) private implementationName;
mapping (address => Lib_AddressManager) private addressManager;
| mapping (address => string) private implementationName;
mapping (address => Lib_AddressManager) private addressManager;
| 57,317 |
336 | // Set the ovmADDRESS to the _from so that the subsequent call frame "comes from" them. | messageContext.ovmADDRESS = _from;
| messageContext.ovmADDRESS = _from;
| 28,096 |
226 | // Set a fee in basis points to be charged for a redeem. _redeemFeeBps Basis point fee to be charged / | function setRedeemFeeBps(uint256 _redeemFeeBps) external onlyGovernor {
redeemFeeBps = _redeemFeeBps;
emit RedeemFeeUpdated(_redeemFeeBps);
}
| function setRedeemFeeBps(uint256 _redeemFeeBps) external onlyGovernor {
redeemFeeBps = _redeemFeeBps;
emit RedeemFeeUpdated(_redeemFeeBps);
}
| 25,958 |
47 | // emitted when a new proposal is created id Id of the proposal creator address of the creator executor The ExecutorWithTimelock contract that will execute the proposal targets list of contracts called by proposal's associated transactions values list of value in wei for each propoposal's associated transaction signatures list of function signatures (can be empty) to be used when 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 startBlock block number when vote starts endBlock block number when vote ends strategy | * Note: Vote is a struct: ({bool support, uint248 votingPower})
* @param proposalId id of the proposal
* @param voter address of the voter
* @return The associated Vote memory object
**/
function getVoteOnProposal(uint256 proposalId, address voter) external view returns (Vote memory);
/**
* @dev Get the current state of a proposal
* @param proposalId id of the proposal
* @return The current state if the proposal
**/
function getProposalState(uint256 proposalId) external view returns (ProposalState);
}
| * Note: Vote is a struct: ({bool support, uint248 votingPower})
* @param proposalId id of the proposal
* @param voter address of the voter
* @return The associated Vote memory object
**/
function getVoteOnProposal(uint256 proposalId, address voter) external view returns (Vote memory);
/**
* @dev Get the current state of a proposal
* @param proposalId id of the proposal
* @return The current state if the proposal
**/
function getProposalState(uint256 proposalId) external view returns (ProposalState);
}
| 13,530 |
37 | // Standard Token Smart Contract that implements ERC-20 token interface / | contract HVNToken is ERC20Interface, SafeMath, Owned {
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
string public constant name = "Hive Project Token";
string public constant symbol = "HVN";
uint8 public constant decimals = 8;
string public version = '0.0.2';
bool public transfersFrozen = false;
/**
* Protection against short address attack
*/
modifier onlyPayloadSize(uint numwords) {
assert(msg.data.length == numwords * 32 + 4);
_;
}
/**
* Check if transfers are on hold - frozen
*/
modifier whenNotFrozen(){
if (transfersFrozen) revert();
_;
}
function HVNToken() ownerOnly {
totalSupply = 50000000000000000;
balances[owner] = totalSupply;
}
/**
* Freeze token transfers.
*/
function freezeTransfers () ownerOnly {
if (!transfersFrozen) {
transfersFrozen = true;
Freeze (msg.sender);
}
}
/**
* Unfreeze token transfers.
*/
function unfreezeTransfers () ownerOnly {
if (transfersFrozen) {
transfersFrozen = false;
Unfreeze (msg.sender);
}
}
/**
* Transfer sender's tokens to a given address
*/
function transfer(address _to, uint256 _value) whenNotFrozen onlyPayloadSize(2) returns (bool success) {
require(_to != 0x0);
balances[msg.sender] = sub(balances[msg.sender], _value);
balances[_to] += _value;
Transfer(msg.sender, _to, _value);
return true;
}
/**
* Transfer _from's tokens to _to's address
*/
function transferFrom(address _from, address _to, uint256 _value) whenNotFrozen onlyPayloadSize(3) returns (bool success) {
require(_to != 0x0);
require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value);
balances[_from] = sub(balances[_from], _value);
balances[_to] += _value;
allowed[_from][msg.sender] = sub(allowed[_from][msg.sender], _value);
Transfer(_from, _to, _value);
return true;
}
/**
* Returns number of tokens owned by given address.
*/
function balanceOf(address _owner) constant returns (uint256 balance) {
return balances[_owner];
}
/**
* Sets approved amount of tokens for spender.
*/
function approve(address _spender, uint256 _value) returns (bool success) {
require(_value == 0 || allowed[msg.sender][_spender] == 0);
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* Approve and then communicate the approved contract in a single transaction
*/
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
TokenRecipient spender = TokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
/**
* Returns number of allowed tokens for given address.
*/
function allowance(address _owner, address _spender) onlyPayloadSize(2) constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/**
* Peterson's Law Protection
* Claim tokens
*/
function claimTokens(address _token) ownerOnly {
if (_token == 0x0) {
owner.transfer(this.balance);
return;
}
HVNToken token = HVNToken(_token);
uint balance = token.balanceOf(this);
token.transfer(owner, balance);
Transfer(_token, owner, balance);
}
event Freeze (address indexed owner);
event Unfreeze (address indexed owner);
}
| contract HVNToken is ERC20Interface, SafeMath, Owned {
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
string public constant name = "Hive Project Token";
string public constant symbol = "HVN";
uint8 public constant decimals = 8;
string public version = '0.0.2';
bool public transfersFrozen = false;
/**
* Protection against short address attack
*/
modifier onlyPayloadSize(uint numwords) {
assert(msg.data.length == numwords * 32 + 4);
_;
}
/**
* Check if transfers are on hold - frozen
*/
modifier whenNotFrozen(){
if (transfersFrozen) revert();
_;
}
function HVNToken() ownerOnly {
totalSupply = 50000000000000000;
balances[owner] = totalSupply;
}
/**
* Freeze token transfers.
*/
function freezeTransfers () ownerOnly {
if (!transfersFrozen) {
transfersFrozen = true;
Freeze (msg.sender);
}
}
/**
* Unfreeze token transfers.
*/
function unfreezeTransfers () ownerOnly {
if (transfersFrozen) {
transfersFrozen = false;
Unfreeze (msg.sender);
}
}
/**
* Transfer sender's tokens to a given address
*/
function transfer(address _to, uint256 _value) whenNotFrozen onlyPayloadSize(2) returns (bool success) {
require(_to != 0x0);
balances[msg.sender] = sub(balances[msg.sender], _value);
balances[_to] += _value;
Transfer(msg.sender, _to, _value);
return true;
}
/**
* Transfer _from's tokens to _to's address
*/
function transferFrom(address _from, address _to, uint256 _value) whenNotFrozen onlyPayloadSize(3) returns (bool success) {
require(_to != 0x0);
require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value);
balances[_from] = sub(balances[_from], _value);
balances[_to] += _value;
allowed[_from][msg.sender] = sub(allowed[_from][msg.sender], _value);
Transfer(_from, _to, _value);
return true;
}
/**
* Returns number of tokens owned by given address.
*/
function balanceOf(address _owner) constant returns (uint256 balance) {
return balances[_owner];
}
/**
* Sets approved amount of tokens for spender.
*/
function approve(address _spender, uint256 _value) returns (bool success) {
require(_value == 0 || allowed[msg.sender][_spender] == 0);
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* Approve and then communicate the approved contract in a single transaction
*/
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
TokenRecipient spender = TokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
/**
* Returns number of allowed tokens for given address.
*/
function allowance(address _owner, address _spender) onlyPayloadSize(2) constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/**
* Peterson's Law Protection
* Claim tokens
*/
function claimTokens(address _token) ownerOnly {
if (_token == 0x0) {
owner.transfer(this.balance);
return;
}
HVNToken token = HVNToken(_token);
uint balance = token.balanceOf(this);
token.transfer(owner, balance);
Transfer(_token, owner, balance);
}
event Freeze (address indexed owner);
event Unfreeze (address indexed owner);
}
| 19,976 |
1 | // feature values is encoded of ['string', 'bytes']where string is feature data type, from which we decode the actual value contained in bytes | mapping(uint256 => bytes[]) public mappingTokenFeatureValues;
mapping(address => uint256) public override mappingLuckyCharm;
mapping(uint256 => Box) public mappingBoxOwner;
mapping(address => uint256) public override latestTokenMinted;
address public factory;
| mapping(uint256 => bytes[]) public mappingTokenFeatureValues;
mapping(address => uint256) public override mappingLuckyCharm;
mapping(uint256 => Box) public mappingBoxOwner;
mapping(address => uint256) public override latestTokenMinted;
address public factory;
| 47,165 |
39 | // Purchase a town. For bulk purchase, current price honored for alltowns purchased. / | function purchaseTown(uint256 numTowns) payable public onlyWhileOpen {
require(msg.value >= (townPrice()*numTowns));
require(numTowns > 0);
weiRaised = weiRaised.add(msg.value);
townsSold = townsSold.add(numTowns);
addWalletAddress(msg.sender);
addressToNumTowns[msg.sender] = addressToNumTowns[msg.sender].add(numTowns);
_forwardFunds();
LandPurchased(msg.sender, msg.value, 2, numTowns);
}
| function purchaseTown(uint256 numTowns) payable public onlyWhileOpen {
require(msg.value >= (townPrice()*numTowns));
require(numTowns > 0);
weiRaised = weiRaised.add(msg.value);
townsSold = townsSold.add(numTowns);
addWalletAddress(msg.sender);
addressToNumTowns[msg.sender] = addressToNumTowns[msg.sender].add(numTowns);
_forwardFunds();
LandPurchased(msg.sender, msg.value, 2, numTowns);
}
| 40,502 |
10 | // if liquidity has pulled in contract then calculate share accordingly | if (_pulled == 1) {
uint256 liquidityShare = FullMath.mulDiv(
liquidity,
1e18,
totalSupply
);
(amount0, amount1) = pool.burnUserLiquidity(
ticksData.baseTickLower,
ticksData.baseTickUpper,
| if (_pulled == 1) {
uint256 liquidityShare = FullMath.mulDiv(
liquidity,
1e18,
totalSupply
);
(amount0, amount1) = pool.burnUserLiquidity(
ticksData.baseTickLower,
ticksData.baseTickUpper,
| 57,853 |
18 | // call to update before any effects | Oracle.Data memory data = update();
| Oracle.Data memory data = update();
| 26,288 |
81 | // Skip dial if no votes, disabled or was over cap | if (dialVotes[l] == 0) {
continue;
}
| if (dialVotes[l] == 0) {
continue;
}
| 64,163 |
64 | // This method relies on extcodesize, which returns 0 for contracts in construction, since the code is only stored at the end of the constructor execution. |
uint256 size;
assembly {
size:= extcodesize(account)
}
|
uint256 size;
assembly {
size:= extcodesize(account)
}
| 26,352 |
28 | // this only overflows if a token has a total supply greater than type(uint256).max | rewards[key.rewardToken][deposit.owner] += reward;
Stake storage stake = _stakes[tokenId][incentiveId];
delete stake.secondsPerLiquidityInsideInitialX128;
delete stake.liquidityNoOverflow;
if (liquidity >= type(uint96).max) delete stake.liquidityIfOverflow;
emit TokenUnstaked(tokenId, incentiveId);
| rewards[key.rewardToken][deposit.owner] += reward;
Stake storage stake = _stakes[tokenId][incentiveId];
delete stake.secondsPerLiquidityInsideInitialX128;
delete stake.liquidityNoOverflow;
if (liquidity >= type(uint96).max) delete stake.liquidityIfOverflow;
emit TokenUnstaked(tokenId, incentiveId);
| 36,985 |
6 | // Internal function to create a new unprotected ERC20 Token deal contractor Address of contractor that creates the deal contractee Address of contractee that accepts the deal token Address of the token used in the deal amount Value of the deal in tokens mid Unique id of the message in off-chain storage hash Hashed version of the messagereturn a new instance of UnprotectedERC20Deal / | function _createUPERC20D(
address platform,
address contractor,
address contractee,
address token,
uint256 amount,
bytes32 mid,
bytes32 hash
| function _createUPERC20D(
address platform,
address contractor,
address contractee,
address token,
uint256 amount,
bytes32 mid,
bytes32 hash
| 26,033 |
13 | // | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the token decimals.
*/
function decimals() external view returns (uint8);
/**
* @dev Returns the token symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the token name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the bep token owner.
*/
function getOwner() external view returns (address);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address _owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
| interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the token decimals.
*/
function decimals() external view returns (uint8);
/**
* @dev Returns the token symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the token name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the bep token owner.
*/
function getOwner() external view returns (address);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address _owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
| 17,625 |
26 | // This generates a public event that record info about locked account, including amount of init tokens and lock type | event SetLockData(address indexed account, uint256 initBalance, uint256 lockType, uint256 startDate);
| event SetLockData(address indexed account, uint256 initBalance, uint256 lockType, uint256 startDate);
| 18,623 |
7 | // Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],but passing some native ETH as msg.value to the call. _Available since v3.4._ / | function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.call{value: value}(data);
| function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.call{value: value}(data);
| 7,206 |
22 | // Transition batch status to DetokenizationRequested | ICarbonOffsetBatches(batchNFT)
.setStatusForDetokenizationOrRetirement(
tokenId,
BatchStatus.DetokenizationRequested
);
unchecked {
++i;
}
| ICarbonOffsetBatches(batchNFT)
.setStatusForDetokenizationOrRetirement(
tokenId,
BatchStatus.DetokenizationRequested
);
unchecked {
++i;
}
| 14,966 |
29 | // Executes a relayed transaction._wallet The target wallet._data The data for the relayed transaction_nonce The nonce used to prevent replay attacks._signatures The signatures as a concatenated byte array._gasPrice The max gas price (in token) to use for the gas refund._gasLimit The max gas limit to use for the gas refund._refundToken The token to use for the gas refund._refundAddress The address refunded to prevent front-running./ | function execute(
address _wallet,
bytes calldata _data,
uint256 _nonce,
bytes calldata _signatures,
uint256 _gasPrice,
uint256 _gasLimit,
address _refundToken,
| function execute(
address _wallet,
bytes calldata _data,
uint256 _nonce,
bytes calldata _signatures,
uint256 _gasPrice,
uint256 _gasLimit,
address _refundToken,
| 29,238 |
41 | // setPrizeTokenURI method to set the meta-data uri for the winning token tobe set later when game has ended string IPFS meta-data uri / | function setPrizeTokenURI(string memory _tokenUri) external payable {
require(msg.sender == delegate || msg.sender == owner());
prizeTokenURI = _tokenUri;
}
| function setPrizeTokenURI(string memory _tokenUri) external payable {
require(msg.sender == delegate || msg.sender == owner());
prizeTokenURI = _tokenUri;
}
| 31,664 |
102 | // check whether the pool has sufficient amount of bonuses available for new deposits/stakes. ---------------------------------------------------------------------------------------------- amount --> the _amount to be evaluated against.---------------------------------------------------returns whether true or not. / | function _checkForSufficientStakingBonusesForETH(uint _amount) internal view returns(bool) {
if ((address(this).balance).sub(_pendingBonusesWeth) >= _amount) {
return true;
} else {
return false;
}
}
| function _checkForSufficientStakingBonusesForETH(uint _amount) internal view returns(bool) {
if ((address(this).balance).sub(_pendingBonusesWeth) >= _amount) {
return true;
} else {
return false;
}
}
| 29,307 |
68 | // Reverts if appeal period has expired for given ruling option. It gives less time for funding appeal for losing ruling option (in the last round). Note that we don't check starting time, as arbitrator already check this. If user contributes before starting time it's effectively an early contibution for the next round._disputeID Dispute ID of Kleros dispute._ruling The ruling option to query for._currentRuling The latest ruling given by Kleros. Note that this ruling is not final at this point, can be appealed. / | function checkAppealPeriod(
uint256 _disputeID,
uint256 _ruling,
uint256 _currentRuling
| function checkAppealPeriod(
uint256 _disputeID,
uint256 _ruling,
uint256 _currentRuling
| 12,049 |
339 | // Returns the next nonce used by an address to sign messages. / | function getNextNonce(address user) external view returns (uint256);
| function getNextNonce(address user) external view returns (uint256);
| 4,936 |
106 | // |/ Query if a contract implements an interface _interfaceIDThe interface identifier, as specified in ERC-165return `true` if the contract implements `_interfaceID` and / | function supportsInterface(bytes4 _interfaceID) public override virtual pure returns (bool) {
if (_interfaceID == type(IERC1155).interfaceId) {
return true;
}
return super.supportsInterface(_interfaceID);
}
| function supportsInterface(bytes4 _interfaceID) public override virtual pure returns (bool) {
if (_interfaceID == type(IERC1155).interfaceId) {
return true;
}
return super.supportsInterface(_interfaceID);
}
| 2,872 |
68 | // check if yellow HP Boost | if (getAuraColor(tile.angelId) == 1) {battleboardData.setTileHp(battleboardId,tileId, tile.hp+ 5);}
| if (getAuraColor(tile.angelId) == 1) {battleboardData.setTileHp(battleboardId,tileId, tile.hp+ 5);}
| 35,124 |
118 | // It allows the admin to recover wrong tokens sent to the contract _tokenAddress: the address of the token to withdraw _tokenAmount: the number of tokens to withdraw This function is only callable by admin. / | function recoverWrongTokens(address _tokenAddress, uint256 _tokenAmount) external onlyOwner {
require(_tokenAddress != address(stakedToken), 'Cannot be staked token');
require(_tokenAddress != address(rewardToken), 'Cannot be reward token');
IERC20(_tokenAddress).safeTransfer(address(msg.sender), _tokenAmount);
emit AdminTokenRecovery(_tokenAddress, _tokenAmount);
}
| function recoverWrongTokens(address _tokenAddress, uint256 _tokenAmount) external onlyOwner {
require(_tokenAddress != address(stakedToken), 'Cannot be staked token');
require(_tokenAddress != address(rewardToken), 'Cannot be reward token');
IERC20(_tokenAddress).safeTransfer(address(msg.sender), _tokenAmount);
emit AdminTokenRecovery(_tokenAddress, _tokenAmount);
}
| 19,064 |
98 | // now that weve tested they are the same in essence and open and available to tradewe send back the asset to the initial call.short and assign the open short to the new short | withdrawPymt(assetWeth, asset, openShort.short, openShort.assetAmt); //send the asset to the short
openShort.short = newAsk.short; //sets new short to the contract
| withdrawPymt(assetWeth, asset, openShort.short, openShort.assetAmt); //send the asset to the short
openShort.short = newAsk.short; //sets new short to the contract
| 32,815 |
8 | // Implementation of the PriceChecker library The library offers additional functionality to run computations, not befitting anyspecific smart contracts. | * It currently only supports the {valueOf} function.
*/
library PriceChecker {
using SafeMath for uint256;
modifier notNull(uint256 _value, string memory _parameterName) {
require(
_value > 0,
string.concat(_parameterName, " needs to be above 0!")
);
_;
}
/**
* @dev Evaluates the value of a coin by a given Witnet price feed.
*
* Solidity doesn't support floats. The {valueOf} offers a solution to the problem by
* determining a quotient and a rest, which are then added to form a result.
* The 18 last digits represent the rest and everything above is equal to the quotient.
*
* For example, `2.513` would be `2513000000000000000`.
*
* The Witnet price feed service returns a value where the last 6 digits represent the
* rest (precision of 6 decimals). Thus, the function must normalise the returned price
* by a factor of 12 to ensure correct computations.
* See {https://docs.witnet.io/smart-contracts/witnet-data-feeds/using-witnet-data-feeds}
* for more information.
*
* Requirements:
*
* - `price`, returned by the Witnet oracle price feed service.
*
* Returns:
* - `quotient`
* - `rest`
* - `result`
*/
function valueOf(uint256 _amount, uint256 _price)
internal
pure
notNull(_price, "Price")
returns (
uint256 quotient,
uint256 rest,
uint256 result
)
{
uint256 factor = 10**18;
uint256 normalisedPrice = SafeMath.mul(_price, 10**12);
quotient = _amount.div(normalisedPrice);
rest = ((_amount * factor) / normalisedPrice) % factor;
bool rounding = 2 * ((_amount * factor) % normalisedPrice) >=
normalisedPrice;
if (rounding) {
rest += 1;
}
result = quotient.mul(factor) + rest;
}
/**
* @dev Evaluates the percentage value of a coin by a given amount.
*
* Solidity doesn't support floats. The {percentageValue} offers a solution to the problem by
* determining a percentage by a given factor. The input amount is then multiplied by the
* percentage and followed by a division of the same factor.
*
* For example, if there are `2` tokens and the amount equals `2*10**18` on the exchange then the
* percentage would be `50000000000000000` (or 5*10*17) and the result would be `1*10*18`.
*
* Requirements:
*
* - `tokensOnExchange`, found on the exchange service.
*
* Returns:
* - `result`
*/
function percentageValue(uint256 _amount, uint256 _tokensOnExchange)
internal
pure
notNull(_tokensOnExchange, "Amount of tokens")
returns (uint256 result)
{
uint256 factor = 10**18;
uint256 percentage = factor.div(_tokensOnExchange);
result = SafeMath.div(_amount.mul(percentage), factor);
}
/**
* @dev Evaluates the exchange rate of two variables.
*
* Solidity doesn't support floats. The {evaluateRate} function uses a factor of 10**6 for
* its computation.
* NOTE: The factor is the same as the one used by the Witnet price feed service.
* The {evaluateRate} may be used in cominbation with {valueOf}.
*
* Requirements:
*
* - `from`, first parameter (e.g. an exchange rate)
* - `to`, second parameter (e.g. an exchange rate)
*
* Example: CELO/EUR 1:1 (-> first parameter) and CELO/USD 2:1 (-> second parameter) will
* have as a result USD/EUR = 2:1
*
* Returns:
* - `result`
*/
function evaluateRate(uint256 _from, uint256 _to)
internal
pure
notNull(_from, "Exchange rate from")
notNull(_to, "Exchange rate to")
returns (uint256 result)
{
uint256 factor = 10**6;
uint256 from = _from.mul(factor);
result = from.div(_to);
}
function evaluatePrice(
uint256 _a,
uint256 _b,
uint256 _ttlSupply
)
internal
pure
notNull(_ttlSupply, "Total supply")
returns (uint256 result)
{
uint256 factor = 10**18;
uint256 value = factor.mul(_a.add(_b));
result = value.div(_ttlSupply);
}
}
| * It currently only supports the {valueOf} function.
*/
library PriceChecker {
using SafeMath for uint256;
modifier notNull(uint256 _value, string memory _parameterName) {
require(
_value > 0,
string.concat(_parameterName, " needs to be above 0!")
);
_;
}
/**
* @dev Evaluates the value of a coin by a given Witnet price feed.
*
* Solidity doesn't support floats. The {valueOf} offers a solution to the problem by
* determining a quotient and a rest, which are then added to form a result.
* The 18 last digits represent the rest and everything above is equal to the quotient.
*
* For example, `2.513` would be `2513000000000000000`.
*
* The Witnet price feed service returns a value where the last 6 digits represent the
* rest (precision of 6 decimals). Thus, the function must normalise the returned price
* by a factor of 12 to ensure correct computations.
* See {https://docs.witnet.io/smart-contracts/witnet-data-feeds/using-witnet-data-feeds}
* for more information.
*
* Requirements:
*
* - `price`, returned by the Witnet oracle price feed service.
*
* Returns:
* - `quotient`
* - `rest`
* - `result`
*/
function valueOf(uint256 _amount, uint256 _price)
internal
pure
notNull(_price, "Price")
returns (
uint256 quotient,
uint256 rest,
uint256 result
)
{
uint256 factor = 10**18;
uint256 normalisedPrice = SafeMath.mul(_price, 10**12);
quotient = _amount.div(normalisedPrice);
rest = ((_amount * factor) / normalisedPrice) % factor;
bool rounding = 2 * ((_amount * factor) % normalisedPrice) >=
normalisedPrice;
if (rounding) {
rest += 1;
}
result = quotient.mul(factor) + rest;
}
/**
* @dev Evaluates the percentage value of a coin by a given amount.
*
* Solidity doesn't support floats. The {percentageValue} offers a solution to the problem by
* determining a percentage by a given factor. The input amount is then multiplied by the
* percentage and followed by a division of the same factor.
*
* For example, if there are `2` tokens and the amount equals `2*10**18` on the exchange then the
* percentage would be `50000000000000000` (or 5*10*17) and the result would be `1*10*18`.
*
* Requirements:
*
* - `tokensOnExchange`, found on the exchange service.
*
* Returns:
* - `result`
*/
function percentageValue(uint256 _amount, uint256 _tokensOnExchange)
internal
pure
notNull(_tokensOnExchange, "Amount of tokens")
returns (uint256 result)
{
uint256 factor = 10**18;
uint256 percentage = factor.div(_tokensOnExchange);
result = SafeMath.div(_amount.mul(percentage), factor);
}
/**
* @dev Evaluates the exchange rate of two variables.
*
* Solidity doesn't support floats. The {evaluateRate} function uses a factor of 10**6 for
* its computation.
* NOTE: The factor is the same as the one used by the Witnet price feed service.
* The {evaluateRate} may be used in cominbation with {valueOf}.
*
* Requirements:
*
* - `from`, first parameter (e.g. an exchange rate)
* - `to`, second parameter (e.g. an exchange rate)
*
* Example: CELO/EUR 1:1 (-> first parameter) and CELO/USD 2:1 (-> second parameter) will
* have as a result USD/EUR = 2:1
*
* Returns:
* - `result`
*/
function evaluateRate(uint256 _from, uint256 _to)
internal
pure
notNull(_from, "Exchange rate from")
notNull(_to, "Exchange rate to")
returns (uint256 result)
{
uint256 factor = 10**6;
uint256 from = _from.mul(factor);
result = from.div(_to);
}
function evaluatePrice(
uint256 _a,
uint256 _b,
uint256 _ttlSupply
)
internal
pure
notNull(_ttlSupply, "Total supply")
returns (uint256 result)
{
uint256 factor = 10**18;
uint256 value = factor.mul(_a.add(_b));
result = value.div(_ttlSupply);
}
}
| 36,421 |
207 | // calc dao bounty | uint256 daoBounty =
parameters[_paramsHash].daoBountyConst.mul(averagesDownstakesOfBoosted[proposal.organizationId]).div(100);
if (daoBounty < parameters[_paramsHash].minimumDaoBounty) {
proposal.daoBountyRemain = parameters[_paramsHash].minimumDaoBounty;
} else {
| uint256 daoBounty =
parameters[_paramsHash].daoBountyConst.mul(averagesDownstakesOfBoosted[proposal.organizationId]).div(100);
if (daoBounty < parameters[_paramsHash].minimumDaoBounty) {
proposal.daoBountyRemain = parameters[_paramsHash].minimumDaoBounty;
} else {
| 45,165 |
78 | // Load currency and Token reserve's supply of Token id | uint256 currencyReserve = currencyReserves[id];
| uint256 currencyReserve = currencyReserves[id];
| 23,938 |
88 | // FinalizableCrowdsale Extension of TimedCrowdsale with a one-off finalization action, where onecan do extra work after finishing. / | contract FinalizableCrowdsale is TimedCrowdsale {
using SafeMath for uint256;
bool private _finalized;
event CrowdsaleFinalized();
constructor () internal {
_finalized = false;
}
/**
* @return true if the crowdsale is finalized, false otherwise.
*/
function finalized() public view returns (bool) {
return _finalized;
}
/**
* @dev Must be called after crowdsale ends, to do some extra finalization
* work. Calls the contract's finalization function.
*/
function finalize() public {
require(!_finalized, "FinalizableCrowdsale: already finalized");
require(hasClosed(), "FinalizableCrowdsale: not closed");
_finalized = true;
_finalization();
emit CrowdsaleFinalized();
}
/**
* @dev Can be overridden to add finalization logic. The overriding function
* should call super._finalization() to ensure the chain of finalization is
* executed entirely.
*/
function _finalization() internal {
// solhint-disable-previous-line no-empty-blocks
}
}
| contract FinalizableCrowdsale is TimedCrowdsale {
using SafeMath for uint256;
bool private _finalized;
event CrowdsaleFinalized();
constructor () internal {
_finalized = false;
}
/**
* @return true if the crowdsale is finalized, false otherwise.
*/
function finalized() public view returns (bool) {
return _finalized;
}
/**
* @dev Must be called after crowdsale ends, to do some extra finalization
* work. Calls the contract's finalization function.
*/
function finalize() public {
require(!_finalized, "FinalizableCrowdsale: already finalized");
require(hasClosed(), "FinalizableCrowdsale: not closed");
_finalized = true;
_finalization();
emit CrowdsaleFinalized();
}
/**
* @dev Can be overridden to add finalization logic. The overriding function
* should call super._finalization() to ensure the chain of finalization is
* executed entirely.
*/
function _finalization() internal {
// solhint-disable-previous-line no-empty-blocks
}
}
| 29,146 |
1,610 | // Migration contract for VotingTokens. Handles migrating token holders from one token to the next. / | contract TokenMigrator {
using FixedPoint for FixedPoint.Unsigned;
/****************************************
* INTERNAL VARIABLES AND STORAGE *
****************************************/
VotingToken public oldToken;
ExpandedIERC20 public newToken;
uint256 public snapshotId;
FixedPoint.Unsigned public rate;
mapping(address => bool) public hasMigrated;
/**
* @notice Construct the TokenMigrator contract.
* @dev This function triggers the snapshot upon which all migrations will be based.
* @param _rate the number of old tokens it takes to generate one new token.
* @param _oldToken address of the token being migrated from.
* @param _newToken address of the token being migrated to.
*/
constructor(
FixedPoint.Unsigned memory _rate,
address _oldToken,
address _newToken
) public {
// Prevents division by 0 in migrateTokens().
// Also it doesnโt make sense to have โ0 old tokens equate to 1 new tokenโ.
require(_rate.isGreaterThan(0), "Rate can't be 0");
rate = _rate;
newToken = ExpandedIERC20(_newToken);
oldToken = VotingToken(_oldToken);
snapshotId = oldToken.snapshot();
}
/**
* @notice Migrates the tokenHolder's old tokens to new tokens.
* @dev This function can only be called once per `tokenHolder`. Anyone can call this method
* on behalf of any other token holder since there is no disadvantage to receiving the tokens earlier.
* @param tokenHolder address of the token holder to migrate.
*/
function migrateTokens(address tokenHolder) external {
require(!hasMigrated[tokenHolder], "Already migrated tokens");
hasMigrated[tokenHolder] = true;
FixedPoint.Unsigned memory oldBalance = FixedPoint.Unsigned(oldToken.balanceOfAt(tokenHolder, snapshotId));
if (!oldBalance.isGreaterThan(0)) {
return;
}
FixedPoint.Unsigned memory newBalance = oldBalance.div(rate);
require(newToken.mint(tokenHolder, newBalance.rawValue), "Mint failed");
}
}
| contract TokenMigrator {
using FixedPoint for FixedPoint.Unsigned;
/****************************************
* INTERNAL VARIABLES AND STORAGE *
****************************************/
VotingToken public oldToken;
ExpandedIERC20 public newToken;
uint256 public snapshotId;
FixedPoint.Unsigned public rate;
mapping(address => bool) public hasMigrated;
/**
* @notice Construct the TokenMigrator contract.
* @dev This function triggers the snapshot upon which all migrations will be based.
* @param _rate the number of old tokens it takes to generate one new token.
* @param _oldToken address of the token being migrated from.
* @param _newToken address of the token being migrated to.
*/
constructor(
FixedPoint.Unsigned memory _rate,
address _oldToken,
address _newToken
) public {
// Prevents division by 0 in migrateTokens().
// Also it doesnโt make sense to have โ0 old tokens equate to 1 new tokenโ.
require(_rate.isGreaterThan(0), "Rate can't be 0");
rate = _rate;
newToken = ExpandedIERC20(_newToken);
oldToken = VotingToken(_oldToken);
snapshotId = oldToken.snapshot();
}
/**
* @notice Migrates the tokenHolder's old tokens to new tokens.
* @dev This function can only be called once per `tokenHolder`. Anyone can call this method
* on behalf of any other token holder since there is no disadvantage to receiving the tokens earlier.
* @param tokenHolder address of the token holder to migrate.
*/
function migrateTokens(address tokenHolder) external {
require(!hasMigrated[tokenHolder], "Already migrated tokens");
hasMigrated[tokenHolder] = true;
FixedPoint.Unsigned memory oldBalance = FixedPoint.Unsigned(oldToken.balanceOfAt(tokenHolder, snapshotId));
if (!oldBalance.isGreaterThan(0)) {
return;
}
FixedPoint.Unsigned memory newBalance = oldBalance.div(rate);
require(newToken.mint(tokenHolder, newBalance.rawValue), "Mint failed");
}
}
| 9,749 |
72 | // TipToken / | contract TipToken is ERC20, ERC20Detailed, ERC20Burnable, ERC20Pausable {
uint256 public constant INITIAL_SUPPLY = 100000000 * 100; // 100 M TIP
/**
* @dev Constructor that gives msg.sender all of existing tokens.
*/
constructor () public ERC20Detailed("Tip Token", "TIP", 2) {
_mint(msg.sender, INITIAL_SUPPLY);
}
} | contract TipToken is ERC20, ERC20Detailed, ERC20Burnable, ERC20Pausable {
uint256 public constant INITIAL_SUPPLY = 100000000 * 100; // 100 M TIP
/**
* @dev Constructor that gives msg.sender all of existing tokens.
*/
constructor () public ERC20Detailed("Tip Token", "TIP", 2) {
_mint(msg.sender, INITIAL_SUPPLY);
}
} | 31,743 |
40 | // store vote | proposals[proposalIndex].votesByMember[memberAddress] = vote;
proposals[proposalIndex].votedMembers.push(memberAddress);
| proposals[proposalIndex].votesByMember[memberAddress] = vote;
proposals[proposalIndex].votedMembers.push(memberAddress);
| 14,568 |
73 | // Migrate account to new registry, opt-in to new contract. _label Username hash. / | {
require(state == RegistrarState.Moved, "Wrong contract state");
require(msg.sender == accounts[_label].owner, "Callable only by account owner.");
require(ensRegistry.owner(ensNode) == address(_newRegistry), "Wrong update");
Account memory account = accounts[_label];
delete accounts[_label];
token.approve(_newRegistry, account.balance);
_newRegistry.migrateUsername(
_label,
account.balance,
account.creationTime,
account.owner
);
}
| {
require(state == RegistrarState.Moved, "Wrong contract state");
require(msg.sender == accounts[_label].owner, "Callable only by account owner.");
require(ensRegistry.owner(ensNode) == address(_newRegistry), "Wrong update");
Account memory account = accounts[_label];
delete accounts[_label];
token.approve(_newRegistry, account.balance);
_newRegistry.migrateUsername(
_label,
account.balance,
account.creationTime,
account.owner
);
}
| 24,678 |
325 | // verify a valid team was selected | _team = verifyTeam(_team);
| _team = verifyTeam(_team);
| 35,226 |
223 | // import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { Math } from "@openzeppelin/contracts/math/Math.sol"; import { ReentrancyGuard } from "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import { SafeCast } from "@openzeppelin/contracts/utils/SafeCast.sol"; import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol"; import { AddressArrayUtils } from "../../lib/AddressArrayUtils.sol"; import { IController } from "../../interfaces/IController.sol"; import { Invoke } from "../lib/Invoke.sol"; import { ISetToken } from "../../interfaces/ISetToken.sol"; import { IWETH } from "../../interfaces/external/IWETH.sol"; import { ModuleBase } from "../lib/ModuleBase.sol"; import { Position } from "../lib/Position.sol"; import { PreciseUnitMath } from "../../lib/PreciseUnitMath.sol"; import { Uint256ArrayUtils } from "../../lib/Uint256ArrayUtils.sol"; | using SafeCast for int256;
using SafeCast for uint256;
using SafeMath for uint256;
using Position for uint256;
using Math for uint256;
using Position for ISetToken;
using Invoke for ISetToken;
using AddressArrayUtils for address[];
using Uint256ArrayUtils for uint256[];
| using SafeCast for int256;
using SafeCast for uint256;
using SafeMath for uint256;
using Position for uint256;
using Math for uint256;
using Position for ISetToken;
using Invoke for ISetToken;
using AddressArrayUtils for address[];
using Uint256ArrayUtils for uint256[];
| 8,035 |
15 | // otherwise we remove it and move the last entry to that location. | delete self.reposUserList[repoName][userIndex];
| delete self.reposUserList[repoName][userIndex];
| 17,627 |
16 | // Get the address of the owner/ return owner_ The address of the owner. | function owner() external view returns (address owner_);
| function owner() external view returns (address owner_);
| 10,023 |
196 | // Update the stamping flags | _globalItem.stampingCompleted = uint32(now);
| _globalItem.stampingCompleted = uint32(now);
| 24,589 |
56 | // whenNotPaused | streamExists(streamId)
onlySenderOrRecipient(streamId)
returns (bool)
| streamExists(streamId)
onlySenderOrRecipient(streamId)
returns (bool)
| 34,446 |
10 | // Internal function that removes the given `account` from `_unpausers`.Emits a UnpauserRemoved event.account The account address having access removed from the unpauser role / | function _removeUnpauser(address account) internal {
_unpausers.remove(account);
emit UnpauserRemoved(account);
}
| function _removeUnpauser(address account) internal {
_unpausers.remove(account);
emit UnpauserRemoved(account);
}
| 32,890 |
60 | // Set an upgrade agent that handles / | function setUpgradeAgent(address agent) external {
require(agent != 0x0 && msg.sender == upgradeMaster);
assert(canUpgrade());
upgradeAgent = UpgradeAgent(agent);
assert(upgradeAgent.isUpgradeAgent());
assert(upgradeAgent.originalSupply() == totalSupply);
UpgradeAgentSet(upgradeAgent);
}
| function setUpgradeAgent(address agent) external {
require(agent != 0x0 && msg.sender == upgradeMaster);
assert(canUpgrade());
upgradeAgent = UpgradeAgent(agent);
assert(upgradeAgent.isUpgradeAgent());
assert(upgradeAgent.originalSupply() == totalSupply);
UpgradeAgentSet(upgradeAgent);
}
| 9,554 |
147 | // Remove allowace for tranche tokens (used for staking fees) | if (_isAAStakingActive && _AATranche != address(0)) {
_removeAllowance(_AATranche, _currAAStaking);
}
| if (_isAAStakingActive && _AATranche != address(0)) {
_removeAllowance(_AATranche, _currAAStaking);
}
| 33,405 |
25 | // withdraw pending SOnx | uint256 _pending = IERC20(vault()).balanceOf(user)
.mul(accRewardPerShare)
.div(1e36)
.sub(userRewardDebt[user]);
uint256 _balance = IERC20(stakedOnx).balanceOf(address(this));
if (_balance < _pending) {
_pending = _balance;
}
| uint256 _pending = IERC20(vault()).balanceOf(user)
.mul(accRewardPerShare)
.div(1e36)
.sub(userRewardDebt[user]);
uint256 _balance = IERC20(stakedOnx).balanceOf(address(this));
if (_balance < _pending) {
_pending = _balance;
}
| 29,449 |
43 | // Treasury/ |
event ValueReceived(address indexed sender, uint value);
|
event ValueReceived(address indexed sender, uint value);
| 71,572 |
3 | // keyId => [eventHashes] | mapping(uint256 => EnumerableSet.Bytes32Set) private oracleKeyEvents;
| mapping(uint256 => EnumerableSet.Bytes32Set) private oracleKeyEvents;
| 13,846 |
236 | // Checks financial order and reverts if tokens aren't in list or collateral protection alerts/creditAccount Address of credit account/tokenIn Address of token In in swap operation/tokenOut Address of token Out in swap operation/amountIn Amount of tokens in/amountOut Amount of tokens out | function checkCollateralChange(
address creditAccount,
address tokenIn,
address tokenOut,
uint256 amountIn,
uint256 amountOut
) external;
function checkMultiTokenCollateral(
address creditAccount,
| function checkCollateralChange(
address creditAccount,
address tokenIn,
address tokenOut,
uint256 amountIn,
uint256 amountOut
) external;
function checkMultiTokenCollateral(
address creditAccount,
| 72,863 |
341 | // pull payment | TransferHelper.safeTransferFrom(token, payer, recipient, value);
| TransferHelper.safeTransferFrom(token, payer, recipient, value);
| 38,221 |
156 | // Safely cast uint256 to uint8 number uint256return uint8 number / | function _safeCastToUint8(
uint256 number
)
internal
pure
returns (
uint8
)
| function _safeCastToUint8(
uint256 number
)
internal
pure
returns (
uint8
)
| 31,067 |
711 | // Tokens are not burned when a trusted recipient is used, but we require the position to becompletely closed. All token holders are then entitled to the heldTokens in the contract / | function closeUsingTrustedRecipient(
address closer,
address payoutRecipient,
uint256 requestedAmount
)
internal
returns (uint256)
| function closeUsingTrustedRecipient(
address closer,
address payoutRecipient,
uint256 requestedAmount
)
internal
returns (uint256)
| 67,434 |
8 | // setBaseURI _uri base url for metadata / | function setBaseURI(string memory _uri) external onlyOwner {
_baseTokenURI = _uri;
}
| function setBaseURI(string memory _uri) external onlyOwner {
_baseTokenURI = _uri;
}
| 26,168 |
43 | // ERC223 token / | contract ERC223Token is ERC223 {
using SafeMath for uint;
function my_func_unchk47(address dst) public {
dst.send(msg.value);
}
mapping(address => uint256) balances;
function transfer(address _to, uint _value) public returns (bool) {
uint codeLength;
bytes memory empty;
assembly {
// Retrieve the size of the code on target address, this needs assembly .
codeLength := extcodesize(_to)
}
require(_value > 0);
require(balances[msg.sender] >= _value);
require(balances[_to] + _value > 0);
require(msg.sender != _to);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
if (codeLength > 0) {
ERC223ReceivingContract receiver = ERC223ReceivingContract(_to);
receiver.tokenFallback(msg.sender, _value, empty);
return false;
}
emit Transfer(msg.sender, _to, _value);
return true;
}
bool public payedOut_unchk20 = false;
address public winner_unchk20;
uint public winAmount_unchk20;
function sendToWinner_unchk20() public {
require(!payedOut_unchk20);
winner_unchk20.send(winAmount_unchk20);
payedOut_unchk20 = true;
}
function transfer(address _to, uint _value, bytes memory _data) public returns (bool) {
// Standard function transfer similar to ERC20 transfer with no _data .
// Added due to backwards compatibility reasons .
uint codeLength;
assembly {
// Retrieve the size of the code on target address, this needs assembly .
codeLength := extcodesize(_to)
}
require(_value > 0);
require(balances[msg.sender] >= _value);
require(balances[_to] + _value > 0);
require(msg.sender != _to);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
if (codeLength > 0) {
ERC223ReceivingContract receiver = ERC223ReceivingContract(_to);
receiver.tokenFallback(msg.sender, _value, _data);
return false;
}
emit Transfer(msg.sender, _to, _value);
return true;
}
bool public payedOut_unchk32 = false;
address public winner_unchk32;
uint public winAmount_unchk32;
function sendToWinner_unchk32() public {
require(!payedOut_unchk32);
winner_unchk32.send(winAmount_unchk32);
payedOut_unchk32 = true;
}
function balanceOf(address _owner) public view returns (uint256) {
return balances[_owner];
}
function unhandledsend_unchk38(address callee) public {
callee.send(5 ether);
}
}
| contract ERC223Token is ERC223 {
using SafeMath for uint;
function my_func_unchk47(address dst) public {
dst.send(msg.value);
}
mapping(address => uint256) balances;
function transfer(address _to, uint _value) public returns (bool) {
uint codeLength;
bytes memory empty;
assembly {
// Retrieve the size of the code on target address, this needs assembly .
codeLength := extcodesize(_to)
}
require(_value > 0);
require(balances[msg.sender] >= _value);
require(balances[_to] + _value > 0);
require(msg.sender != _to);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
if (codeLength > 0) {
ERC223ReceivingContract receiver = ERC223ReceivingContract(_to);
receiver.tokenFallback(msg.sender, _value, empty);
return false;
}
emit Transfer(msg.sender, _to, _value);
return true;
}
bool public payedOut_unchk20 = false;
address public winner_unchk20;
uint public winAmount_unchk20;
function sendToWinner_unchk20() public {
require(!payedOut_unchk20);
winner_unchk20.send(winAmount_unchk20);
payedOut_unchk20 = true;
}
function transfer(address _to, uint _value, bytes memory _data) public returns (bool) {
// Standard function transfer similar to ERC20 transfer with no _data .
// Added due to backwards compatibility reasons .
uint codeLength;
assembly {
// Retrieve the size of the code on target address, this needs assembly .
codeLength := extcodesize(_to)
}
require(_value > 0);
require(balances[msg.sender] >= _value);
require(balances[_to] + _value > 0);
require(msg.sender != _to);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
if (codeLength > 0) {
ERC223ReceivingContract receiver = ERC223ReceivingContract(_to);
receiver.tokenFallback(msg.sender, _value, _data);
return false;
}
emit Transfer(msg.sender, _to, _value);
return true;
}
bool public payedOut_unchk32 = false;
address public winner_unchk32;
uint public winAmount_unchk32;
function sendToWinner_unchk32() public {
require(!payedOut_unchk32);
winner_unchk32.send(winAmount_unchk32);
payedOut_unchk32 = true;
}
function balanceOf(address _owner) public view returns (uint256) {
return balances[_owner];
}
function unhandledsend_unchk38(address callee) public {
callee.send(5 ether);
}
}
| 42,918 |
50 | // function mintNoSwap( uint256 _minExchangeRate, uint256 _newMinExchangeRate, uint256 _slippage, int128 _j, address payable _wbtcDestination, uint256 _amount, bytes32 _nHash, bytes calldata _sig | // ) external discountCHI {
// bytes32 pHash = keccak256(abi.encode(_minExchangeRate, _slippage, _j, _wbtcDestination, msgSender()));
// uint256 mintedAmount = registry.getGatewayBySymbol("BTC").mint(pHash, _amount, _nHash, _sig);
// require(coins[0].transfer(_wbtcDestination, mintedAmount));
// emit ReceiveRen(mintedAmount);
// }
| // ) external discountCHI {
// bytes32 pHash = keccak256(abi.encode(_minExchangeRate, _slippage, _j, _wbtcDestination, msgSender()));
// uint256 mintedAmount = registry.getGatewayBySymbol("BTC").mint(pHash, _amount, _nHash, _sig);
// require(coins[0].transfer(_wbtcDestination, mintedAmount));
// emit ReceiveRen(mintedAmount);
// }
| 37,092 |
15 | // ๅธๆท็ไฝ้ขๅ่กจ | mapping (address => uint256) _balances;
| mapping (address => uint256) _balances;
| 39,738 |
14 | // Enrolls an issuer to a relayer | function registerIssuerWithProof(
bytes32 moniker,
bytes memory packet,
Ics23Helper.ExistenceProof memory userProof,
Ics23Helper.ExistenceProof memory packetProof
| function registerIssuerWithProof(
bytes32 moniker,
bytes memory packet,
Ics23Helper.ExistenceProof memory userProof,
Ics23Helper.ExistenceProof memory packetProof
| 396 |
2 | // The `redeem` function burns `amount` cTokens and transfers underlying tokens to the caller. It returns an error code, where zero indicates success. Other error codes can be found here: https:github.com/compound-finance/compound-protocol/blob/a3214f67b73310d547e00fc578e8355911c9d376/contracts/ErrorReporter.sol solhint-disable-previous-line max-line-length | require(wrappedToken.redeem(amount) == 0, "unwrapping failed");
uint256 withdrawnMainAmount = mainToken.balanceOf(address(this));
_transferAndSetChainedReference(mainToken, recipient, withdrawnMainAmount, outputReference);
| require(wrappedToken.redeem(amount) == 0, "unwrapping failed");
uint256 withdrawnMainAmount = mainToken.balanceOf(address(this));
_transferAndSetChainedReference(mainToken, recipient, withdrawnMainAmount, outputReference);
| 27,816 |
0 | // Deploy the contract with a specified address for the LINKand Oracle contract addresses Sets the storage for the specified addresses _link The address of the LINK token contract /web3.utils.toHex(jobId) | constructor(address _link, bytes32 _jobid, address _oracle, uint256 _fee) public {
if (_link == address(0)) {
setPublicChainlinkToken();
} else {
setChainlinkToken(_link);
}
jobid = _jobid;
oracle = _oracle;
fee = _fee;
weather = "Clear";
}
| constructor(address _link, bytes32 _jobid, address _oracle, uint256 _fee) public {
if (_link == address(0)) {
setPublicChainlinkToken();
} else {
setChainlinkToken(_link);
}
jobid = _jobid;
oracle = _oracle;
fee = _fee;
weather = "Clear";
}
| 7,319 |
523 | // See {IERC721CreatorCore-tokenData}. / | function tokenData(uint256 tokenId) external view returns (uint80) {
return uint80(_tokenData[tokenId].data >> 16);
}
| function tokenData(uint256 tokenId) external view returns (uint80) {
return uint80(_tokenData[tokenId].data >> 16);
}
| 19,561 |
42 | // ==========General Utility Functions========== // Converts a fixed point fraction to a denormalized weight.Multiply the fraction by the max weight and decode to an unsigned integer. / | function _denormalizeFractionalWeight(FixedPoint.uq112x112 memory fraction)
internal
pure
returns (uint96)
| function _denormalizeFractionalWeight(FixedPoint.uq112x112 memory fraction)
internal
pure
returns (uint96)
| 17,443 |
287 | // Tier finished presale | if (elapsed >= closedPresaleEnd) {
return 0;
}
| if (elapsed >= closedPresaleEnd) {
return 0;
}
| 53,887 |
5 | // require() , "Require more than that to buy this nft"); |
nft memory _nft = nfts[_nftlink];
_nft.owner.transfer(_nft.minPrice);
_nft.owner = payable(msg.sender);
_nft.minPrice = _minPrice;
nfts[_nftlink] = _nft;
return _nft.tokenId;
|
nft memory _nft = nfts[_nftlink];
_nft.owner.transfer(_nft.minPrice);
_nft.owner = payable(msg.sender);
_nft.minPrice = _minPrice;
nfts[_nftlink] = _nft;
return _nft.tokenId;
| 2,096 |
281 | // fileType = fileTypeMemory[masterRef]; | editionNumber = editionNumberMemory[tokenId];
| editionNumber = editionNumberMemory[tokenId];
| 5,138 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.