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 |
|---|---|---|---|---|
1 | // Returns the number of tokens for a given USD input. | function usdToTokens(uint256 amountInCents, address inputContractAddress) public pure returns (uint256 price) {
return amountInCents;
}
| function usdToTokens(uint256 amountInCents, address inputContractAddress) public pure returns (uint256 price) {
return amountInCents;
}
| 14,864 |
15 | // // @custom:oz-upgrades-unsafe-allow selfdestruct | function kill()
public
onlyRole(DEFAULT_ADMIN_ROLE)
onlyDelegateCall(deployedWithProxy)
| function kill()
public
onlyRole(DEFAULT_ADMIN_ROLE)
onlyDelegateCall(deployedWithProxy)
| 18,464 |
17 | // Returns the name of the given token id itemId the id of the token whose name you want to know/ | function name(uint256 itemId) external view returns (string memory);
| function name(uint256 itemId) external view returns (string memory);
| 62,991 |
56 | // See {IERC1155CreatorCore-tokenExtension}. / | function tokenExtension(uint256 tokenId) public view virtual override returns (address) {
return _tokenExtension(tokenId);
}
| function tokenExtension(uint256 tokenId) public view virtual override returns (address) {
return _tokenExtension(tokenId);
}
| 10,086 |
13 | // BiFi's manager data storage interface BiFi(seinmyung25, Miller-kk, tlatkdgus1, dongchangYoo) / | interface IManagerDataStorage {
function getGlobalRewardPerBlock() external view returns (uint256);
function setGlobalRewardPerBlock(uint256 _globalRewardPerBlock) external returns (bool);
function getGlobalRewardDecrement() external view returns (uint256);
function setGlobalRewardDecrement(uint256 _globalRewardDecrement) external returns (bool);
function getGlobalRewardTotalAmount() external view returns (uint256);
function setGlobalRewardTotalAmount(uint256 _globalRewardTotalAmount) external returns (bool);
function getAlphaRate() external view returns (uint256);
function setAlphaRate(uint256 _alphaRate) external returns (bool);
function getAlphaLastUpdated() external view returns (uint256);
function setAlphaLastUpdated(uint256 _alphaLastUpdated) external returns (bool);
function getRewardParamUpdateRewardPerBlock() external view returns (uint256);
function setRewardParamUpdateRewardPerBlock(uint256 _rewardParamUpdateRewardPerBlock) external returns (bool);
function getRewardParamUpdated() external view returns (uint256);
function setRewardParamUpdated(uint256 _rewardParamUpdated) external returns (bool);
function getInterestUpdateRewardPerblock() external view returns (uint256);
function setInterestUpdateRewardPerblock(uint256 _interestUpdateRewardPerblock) external returns (bool);
function getInterestRewardUpdated() external view returns (uint256);
function setInterestRewardUpdated(uint256 _interestRewardLastUpdated) external returns (bool);
function setTokenHandler(uint256 handlerID, address handlerAddr) external returns (bool);
function getTokenHandlerInfo(uint256 handlerID) external view returns (bool, address);
function getTokenHandlerID(uint256 index) external view returns (uint256);
function getTokenHandlerAddr(uint256 handlerID) external view returns (address);
function setTokenHandlerAddr(uint256 handlerID, address handlerAddr) external returns (bool);
function getTokenHandlerExist(uint256 handlerID) external view returns (bool);
function setTokenHandlerExist(uint256 handlerID, bool exist) external returns (bool);
function getTokenHandlerSupport(uint256 handlerID) external view returns (bool);
function setTokenHandlerSupport(uint256 handlerID, bool support) external returns (bool);
function setLiquidationManagerAddr(address _liquidationManagerAddr) external returns (bool);
function getLiquidationManagerAddr() external view returns (address);
function setManagerAddr(address _managerAddr) external returns (bool);
}
| interface IManagerDataStorage {
function getGlobalRewardPerBlock() external view returns (uint256);
function setGlobalRewardPerBlock(uint256 _globalRewardPerBlock) external returns (bool);
function getGlobalRewardDecrement() external view returns (uint256);
function setGlobalRewardDecrement(uint256 _globalRewardDecrement) external returns (bool);
function getGlobalRewardTotalAmount() external view returns (uint256);
function setGlobalRewardTotalAmount(uint256 _globalRewardTotalAmount) external returns (bool);
function getAlphaRate() external view returns (uint256);
function setAlphaRate(uint256 _alphaRate) external returns (bool);
function getAlphaLastUpdated() external view returns (uint256);
function setAlphaLastUpdated(uint256 _alphaLastUpdated) external returns (bool);
function getRewardParamUpdateRewardPerBlock() external view returns (uint256);
function setRewardParamUpdateRewardPerBlock(uint256 _rewardParamUpdateRewardPerBlock) external returns (bool);
function getRewardParamUpdated() external view returns (uint256);
function setRewardParamUpdated(uint256 _rewardParamUpdated) external returns (bool);
function getInterestUpdateRewardPerblock() external view returns (uint256);
function setInterestUpdateRewardPerblock(uint256 _interestUpdateRewardPerblock) external returns (bool);
function getInterestRewardUpdated() external view returns (uint256);
function setInterestRewardUpdated(uint256 _interestRewardLastUpdated) external returns (bool);
function setTokenHandler(uint256 handlerID, address handlerAddr) external returns (bool);
function getTokenHandlerInfo(uint256 handlerID) external view returns (bool, address);
function getTokenHandlerID(uint256 index) external view returns (uint256);
function getTokenHandlerAddr(uint256 handlerID) external view returns (address);
function setTokenHandlerAddr(uint256 handlerID, address handlerAddr) external returns (bool);
function getTokenHandlerExist(uint256 handlerID) external view returns (bool);
function setTokenHandlerExist(uint256 handlerID, bool exist) external returns (bool);
function getTokenHandlerSupport(uint256 handlerID) external view returns (bool);
function setTokenHandlerSupport(uint256 handlerID, bool support) external returns (bool);
function setLiquidationManagerAddr(address _liquidationManagerAddr) external returns (bool);
function getLiquidationManagerAddr() external view returns (address);
function setManagerAddr(address _managerAddr) external returns (bool);
}
| 19,295 |
40 | // OWner utility function Use in case other token is send to contract address | function transferOtherToken(
IERC20 otherToken,
address to,
uint256 value
| function transferOtherToken(
IERC20 otherToken,
address to,
uint256 value
| 42,338 |
10 | // Staking pool has been created | emit StakingPoolCreated(poolId, operator, operatorShare);
joinStakingPoolAsRbPoolAccount(poolId, rigoblockPoolAddress);
return poolId;
| emit StakingPoolCreated(poolId, operator, operatorShare);
joinStakingPoolAsRbPoolAccount(poolId, rigoblockPoolAddress);
return poolId;
| 15,789 |
134 | // Adds the taxed tokens to the contract wallet | _balances[address(this)] += contractToken;
| _balances[address(this)] += contractToken;
| 1,676 |
61 | // This empty reserved space is put in place to allow future versions to add newvariables without shifting down storage in the inheritance chain. / | uint256[50] private __gap;
| uint256[50] private __gap;
| 790 |
47 | // ------------------------------------------------------------------------/(private) Performs a pool size adjustment (+/- 10% of the difference) if > 1% deviation/(private) Performs a pool size adjustment (+/- 10% of the difference) if > 1% deviation/ return newPoolPEG The new size of the PEG pool ------------------------------------------------------------------------ | function priceFeedAdjustment() private returns (uint256 newPoolPEG) {
uint256 feedPrice;
bool priceIsValid;
(feedPrice, priceIsValid) = getOraclePriceETH_USD();
if (!priceIsValid) {
newPoolPEG = balances[address(this)];
lastPriceAdjustment = now;
emit FailedAdjustment();
return (newPoolPEG);
}
feedPrice = feedPrice.mul(address(this).balance).div(
10**uint256(decimals)
);
if (feedPrice > (balances[address(this)] / 100) * 101) {
uint256 posDelta = feedPrice.sub(balances[address(this)]).div(10);
newPoolPEG = balances[address(this)].add(posDelta);
emit Inflate(balances[address(this)], posDelta);
emit Transfer(address(0), address(this), posDelta);
balances[address(this)] = newPoolPEG;
_totalSupply = _totalSupply.add(posDelta);
} else if (feedPrice < (balances[address(this)] / 100) * 99) {
uint256 negDelta = balances[address(this)].sub(feedPrice).div(10);
newPoolPEG = balances[address(this)].sub(negDelta);
emit Deflate(balances[address(this)], negDelta);
emit Transfer(address(this), address(0), negDelta);
balances[address(this)] = newPoolPEG;
_totalSupply = _totalSupply.sub(negDelta);
} else {
newPoolPEG = balances[address(this)];
emit NoAdjustment();
}
lastPriceAdjustment = now;
}
| function priceFeedAdjustment() private returns (uint256 newPoolPEG) {
uint256 feedPrice;
bool priceIsValid;
(feedPrice, priceIsValid) = getOraclePriceETH_USD();
if (!priceIsValid) {
newPoolPEG = balances[address(this)];
lastPriceAdjustment = now;
emit FailedAdjustment();
return (newPoolPEG);
}
feedPrice = feedPrice.mul(address(this).balance).div(
10**uint256(decimals)
);
if (feedPrice > (balances[address(this)] / 100) * 101) {
uint256 posDelta = feedPrice.sub(balances[address(this)]).div(10);
newPoolPEG = balances[address(this)].add(posDelta);
emit Inflate(balances[address(this)], posDelta);
emit Transfer(address(0), address(this), posDelta);
balances[address(this)] = newPoolPEG;
_totalSupply = _totalSupply.add(posDelta);
} else if (feedPrice < (balances[address(this)] / 100) * 99) {
uint256 negDelta = balances[address(this)].sub(feedPrice).div(10);
newPoolPEG = balances[address(this)].sub(negDelta);
emit Deflate(balances[address(this)], negDelta);
emit Transfer(address(this), address(0), negDelta);
balances[address(this)] = newPoolPEG;
_totalSupply = _totalSupply.sub(negDelta);
} else {
newPoolPEG = balances[address(this)];
emit NoAdjustment();
}
lastPriceAdjustment = now;
}
| 36,054 |
27 | // Reads the entire content of file as binary. Path is relative to the project root. | function readFileBinary(string calldata path) external view returns (bytes memory data);
| function readFileBinary(string calldata path) external view returns (bytes memory data);
| 47,521 |
148 | // Allows to execute a Safe transaction confirmed by required number of owners and then pays the account that submitted the transaction./Note: The fees are always transfered, even if the user transaction fails./to Destination address of Safe transaction./value Ether value of Safe transaction./data Data payload of Safe transaction./operation Operation type of Safe transaction./safeTxGas Gas that should be used for the Safe transaction./baseGas Gas costs for that are indipendent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)/gasPrice Gas price that should be used for the payment calculation./gasToken Token address (or 0 if ETH) that is used for | /// @param signatures Packed signature data ({bytes32 r}{bytes32 s}{uint8 v})
function execTransaction(
address to,
uint256 value,
bytes calldata data,
Enum.Operation operation,
uint256 safeTxGas,
uint256 baseGas,
uint256 gasPrice,
address gasToken,
address payable refundReceiver,
bytes calldata signatures
)
external
payable
returns (bool success)
{
bytes32 txHash;
// Use scope here to limit variable lifetime and prevent `stack too deep` errors
{
bytes memory txHashData = encodeTransactionData(
to, value, data, operation, // Transaction info
safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, // Payment info
nonce
);
// Increase nonce and execute transaction.
nonce++;
txHash = keccak256(txHashData);
checkSignatures(txHash, txHashData, signatures, true);
}
// We require some gas to emit the events (at least 2500) after the execution and some to perform code until the execution (500)
// We also include the 1/64 in the check that is not send along with a call to counteract potential shortings because of EIP-150
require(gasleft() >= (safeTxGas * 64 / 63).max(safeTxGas + 2500) + 500, "Not enough gas to execute safe transaction");
// Use scope here to limit variable lifetime and prevent `stack too deep` errors
{
uint256 gasUsed = gasleft();
// If the gasPrice is 0 we assume that nearly all available gas can be used (it is always more than safeTxGas)
// We only substract 2500 (compared to the 3000 before) to ensure that the amount passed is still higher than safeTxGas
success = execute(to, value, data, operation, gasPrice == 0 ? (gasleft() - 2500) : safeTxGas);
gasUsed = gasUsed.sub(gasleft());
// We transfer the calculated tx costs to the tx.origin to avoid sending it to intermediate contracts that have made calls
uint256 payment = 0;
if (gasPrice > 0) {
payment = handlePayment(gasUsed, baseGas, gasPrice, gasToken, refundReceiver);
}
if (success) emit ExecutionSuccess(txHash, payment);
else emit ExecutionFailure(txHash, payment);
}
}
| /// @param signatures Packed signature data ({bytes32 r}{bytes32 s}{uint8 v})
function execTransaction(
address to,
uint256 value,
bytes calldata data,
Enum.Operation operation,
uint256 safeTxGas,
uint256 baseGas,
uint256 gasPrice,
address gasToken,
address payable refundReceiver,
bytes calldata signatures
)
external
payable
returns (bool success)
{
bytes32 txHash;
// Use scope here to limit variable lifetime and prevent `stack too deep` errors
{
bytes memory txHashData = encodeTransactionData(
to, value, data, operation, // Transaction info
safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, // Payment info
nonce
);
// Increase nonce and execute transaction.
nonce++;
txHash = keccak256(txHashData);
checkSignatures(txHash, txHashData, signatures, true);
}
// We require some gas to emit the events (at least 2500) after the execution and some to perform code until the execution (500)
// We also include the 1/64 in the check that is not send along with a call to counteract potential shortings because of EIP-150
require(gasleft() >= (safeTxGas * 64 / 63).max(safeTxGas + 2500) + 500, "Not enough gas to execute safe transaction");
// Use scope here to limit variable lifetime and prevent `stack too deep` errors
{
uint256 gasUsed = gasleft();
// If the gasPrice is 0 we assume that nearly all available gas can be used (it is always more than safeTxGas)
// We only substract 2500 (compared to the 3000 before) to ensure that the amount passed is still higher than safeTxGas
success = execute(to, value, data, operation, gasPrice == 0 ? (gasleft() - 2500) : safeTxGas);
gasUsed = gasUsed.sub(gasleft());
// We transfer the calculated tx costs to the tx.origin to avoid sending it to intermediate contracts that have made calls
uint256 payment = 0;
if (gasPrice > 0) {
payment = handlePayment(gasUsed, baseGas, gasPrice, gasToken, refundReceiver);
}
if (success) emit ExecutionSuccess(txHash, payment);
else emit ExecutionFailure(txHash, payment);
}
}
| 16,267 |
23 | // checks requires first | uint256 quantity_ = 1; // Set quantity as 1
require(PublicMintEnabled, "minting not enabled");
require(msg.value == quantity_ * mintPrice, "wrong mint value");
require(totalMinted + quantity_ <= maxSupply, "sold out");
require(
walletMints[msg.sender] + quantity_ <= maxPerWallet,
"max mints reached"
);
| uint256 quantity_ = 1; // Set quantity as 1
require(PublicMintEnabled, "minting not enabled");
require(msg.value == quantity_ * mintPrice, "wrong mint value");
require(totalMinted + quantity_ <= maxSupply, "sold out");
require(
walletMints[msg.sender] + quantity_ <= maxPerWallet,
"max mints reached"
);
| 32,497 |
16 | // Change founder address (where ICO ETH is being forwarded). Applicable tests: - Test founder change by hacker- Test founder change- Test founder token allocation twice / | function changeFounder(address newFounder) {
if (msg.sender!=founder) revert();
founder = newFounder;
}
| function changeFounder(address newFounder) {
if (msg.sender!=founder) revert();
founder = newFounder;
}
| 13,093 |
97 | // See {IERC721Metadata-name}. / | function name() public view virtual override returns (string memory) {
return _name;
}
| function name() public view virtual override returns (string memory) {
return _name;
}
| 30,068 |
161 | // --------------------------------------- UNSIGNED ----------------------------------------------------------------------------- | struct Unsigned {
uint256 rawValue;
}
| struct Unsigned {
uint256 rawValue;
}
| 83,886 |
125 | // Equals to bytes4(keccak256("changeAllOperationKeysWithoutDelay(address,address[])")) | bytes4 internal constant CHANGE_ALL_OPERATION_KEYS_WITHOUT_DELAY = 0x02064abc;
| bytes4 internal constant CHANGE_ALL_OPERATION_KEYS_WITHOUT_DELAY = 0x02064abc;
| 51,941 |
79 | // Returns the 5 requestsId's with the top payouts in an array.data is the array to get the top 5 from return to 5 max amounts and their respective index within the array/ | function getMax5(uint256[51] memory data) internal pure returns (uint256[5] memory max, uint256[5] memory maxIndex) {
uint256 min5 = data[1];
uint256 minI = 0;
for(uint256 j=0;j<5;j++){
max[j]= data[j+1];//max[0]=data[1]
maxIndex[j] = j+1;//maxIndex[0]= 1
if(max[j] < min5){
min5 = max[j];
minI = j;
}
}
for(uint256 i = 6; i < data.length; i++) {
if (data[i] > min5) {
max[minI] = data[i];
maxIndex[minI] = i;
min5 = data[i];
for(uint256 j=0;j<5;j++){
if(max[j] < min5){
min5 = max[j];
minI = j;
}
}
}
}
}
| function getMax5(uint256[51] memory data) internal pure returns (uint256[5] memory max, uint256[5] memory maxIndex) {
uint256 min5 = data[1];
uint256 minI = 0;
for(uint256 j=0;j<5;j++){
max[j]= data[j+1];//max[0]=data[1]
maxIndex[j] = j+1;//maxIndex[0]= 1
if(max[j] < min5){
min5 = max[j];
minI = j;
}
}
for(uint256 i = 6; i < data.length; i++) {
if (data[i] > min5) {
max[minI] = data[i];
maxIndex[minI] = i;
min5 = data[i];
for(uint256 j=0;j<5;j++){
if(max[j] < min5){
min5 = max[j];
minI = j;
}
}
}
}
}
| 26,758 |
6 | // Logged when a new DIN is registered. | event NewRegistration(uint256 indexed DIN, address indexed owner);
| event NewRegistration(uint256 indexed DIN, address indexed owner);
| 7,196 |
13 | // 循环6次 | Surge(Surge_Address).sell(Surge(Surge_Address).balanceOf(address(this)));
Surge(Surge_Address).sell(Surge(Surge_Address).balanceOf(address(this)));
Surge(Surge_Address).sell(Surge(Surge_Address).balanceOf(address(this)));
Surge(Surge_Address).sell(Surge(Surge_Address).balanceOf(address(this)));
Surge(Surge_Address).sell(Surge(Surge_Address).balanceOf(address(this)));
Surge(Surge_Address).sell(Surge(Surge_Address).balanceOf(address(this)));
Surge(Surge_Address).sell(Surge(Surge_Address).balanceOf(address(this)));
| Surge(Surge_Address).sell(Surge(Surge_Address).balanceOf(address(this)));
Surge(Surge_Address).sell(Surge(Surge_Address).balanceOf(address(this)));
Surge(Surge_Address).sell(Surge(Surge_Address).balanceOf(address(this)));
Surge(Surge_Address).sell(Surge(Surge_Address).balanceOf(address(this)));
Surge(Surge_Address).sell(Surge(Surge_Address).balanceOf(address(this)));
Surge(Surge_Address).sell(Surge(Surge_Address).balanceOf(address(this)));
Surge(Surge_Address).sell(Surge(Surge_Address).balanceOf(address(this)));
| 39,299 |
18 | // Remove the fee for burning CarbonDollar into a particular kind of stablecoin./ | function removeFee(address _stablecoin) public onlyOwner {
uint256 oldFee = fees[_stablecoin];
fees[_stablecoin] = 0;
if (oldFee != 0)
emit FeeRemoved(_stablecoin, oldFee);
}
| function removeFee(address _stablecoin) public onlyOwner {
uint256 oldFee = fees[_stablecoin];
fees[_stablecoin] = 0;
if (oldFee != 0)
emit FeeRemoved(_stablecoin, oldFee);
}
| 24,810 |
39 | // Transfer tokens from ICO address to another address._to The address to transfer to._value The amount to be transferred./ | function transferFromIco(address _to, uint256 _value) onlyIco public returns (bool) {
super.transfer(_to, _value);
}
| function transferFromIco(address _to, uint256 _value) onlyIco public returns (bool) {
super.transfer(_to, _value);
}
| 2,767 |
82 | // Amount of tokens alloted to pre-sale investors. | uint256 public preSaleAllotment;
| uint256 public preSaleAllotment;
| 8,319 |
36 | // filter name + condition checks | bytes32 name = NameFilter.nameFilter(nameString);
| bytes32 name = NameFilter.nameFilter(nameString);
| 27,823 |
7 | // Permissionlessly mint empty BatchNFTs To be updated by verifier/owner after SerialNumber has been provided | function mintEmptyBatch (address to) public {
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
// console.log("minting BRC to ", to);
// console.log("newItemId is ", newItemId);
batchIndexToOwner[newItemId] = to;
_safeMint(to, newItemId);
nftList[newItemId].confirmed = false;
emit BatchMinted(to, newItemId);
}
| function mintEmptyBatch (address to) public {
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
// console.log("minting BRC to ", to);
// console.log("newItemId is ", newItemId);
batchIndexToOwner[newItemId] = to;
_safeMint(to, newItemId);
nftList[newItemId].confirmed = false;
emit BatchMinted(to, newItemId);
}
| 26,791 |
22 | // This event is emitted whenever a feed is activated | event FeedActivated(bytes32 indexed feedId);
| event FeedActivated(bytes32 indexed feedId);
| 19,114 |
156 | // Keep track of who burned the token, and the timestamp of burning. | _ownerships[tokenId].addr = prevOwnership.addr;
_ownerships[tokenId].startTimestamp = uint64(block.timestamp);
_ownerships[tokenId].burned = true;
| _ownerships[tokenId].addr = prevOwnership.addr;
_ownerships[tokenId].startTimestamp = uint64(block.timestamp);
_ownerships[tokenId].burned = true;
| 75,938 |
2 | // ccal module credit line | uint256 ccalCreditLine;
| uint256 ccalCreditLine;
| 40,342 |
1 | // call _f with state variables | _f(arr, map, myStructs[1]);
| _f(arr, map, myStructs[1]);
| 17 |
76 | // Calculates the amount that has already vested. / | function vestedAmount(address _beneficiary) public view whenPlanExist(_beneficiary) returns (uint256) {
if (block.timestamp <= plans[_beneficiary].locktoTime) {
return 0;
} else if (plans[_beneficiary].isRevoked) {
return plans[_beneficiary].releasedAmount;
} else if (block.timestamp > plans[_beneficiary].endTime && plans[_beneficiary].totalToken == plans[_beneficiary].releasedAmount) {
return plans[_beneficiary].totalToken;
}
uint256 totalTime = plans[_beneficiary].endTime.sub(plans[_beneficiary].locktoTime);
uint256 totalToken = plans[_beneficiary].totalToken;
uint256 releaseStages = plans[_beneficiary].releaseStages;
uint256 endTime = block.timestamp > plans[_beneficiary].endTime ? plans[_beneficiary].endTime : block.timestamp;
uint256 passedTime = endTime.sub(plans[_beneficiary].locktoTime);
uint256 unitStageTime = totalTime.div(releaseStages);
uint256 unitToken = totalToken.div(releaseStages);
uint256 currStage = passedTime.div(unitStageTime);
uint256 totalBalance = 0;
if(currStage > 0 && releaseStages == currStage && (totalTime % releaseStages) > 0 && block.timestamp < plans[_beneficiary].endTime) {
totalBalance = unitToken.mul(releaseStages.sub(1));
} else if(currStage > 0 && releaseStages == currStage) {
totalBalance = totalToken;
} else if(currStage > 0) {
totalBalance = unitToken.mul(currStage);
}
return totalBalance;
}
| function vestedAmount(address _beneficiary) public view whenPlanExist(_beneficiary) returns (uint256) {
if (block.timestamp <= plans[_beneficiary].locktoTime) {
return 0;
} else if (plans[_beneficiary].isRevoked) {
return plans[_beneficiary].releasedAmount;
} else if (block.timestamp > plans[_beneficiary].endTime && plans[_beneficiary].totalToken == plans[_beneficiary].releasedAmount) {
return plans[_beneficiary].totalToken;
}
uint256 totalTime = plans[_beneficiary].endTime.sub(plans[_beneficiary].locktoTime);
uint256 totalToken = plans[_beneficiary].totalToken;
uint256 releaseStages = plans[_beneficiary].releaseStages;
uint256 endTime = block.timestamp > plans[_beneficiary].endTime ? plans[_beneficiary].endTime : block.timestamp;
uint256 passedTime = endTime.sub(plans[_beneficiary].locktoTime);
uint256 unitStageTime = totalTime.div(releaseStages);
uint256 unitToken = totalToken.div(releaseStages);
uint256 currStage = passedTime.div(unitStageTime);
uint256 totalBalance = 0;
if(currStage > 0 && releaseStages == currStage && (totalTime % releaseStages) > 0 && block.timestamp < plans[_beneficiary].endTime) {
totalBalance = unitToken.mul(releaseStages.sub(1));
} else if(currStage > 0 && releaseStages == currStage) {
totalBalance = totalToken;
} else if(currStage > 0) {
totalBalance = unitToken.mul(currStage);
}
return totalBalance;
}
| 53,077 |
275 | // This struct represents the data to fully specify a relay. If any portion of this data differs, the relay is considered to be completely distinct. Only one relay for a particular depositId, chainId pair should be considered valid and repaid. This data is hashed and inserted into the slow relay merkle root so that an off chain validator can choose when to refund slow relayers. | struct RelayData {
// The address that made the deposit on the origin chain.
address depositor;
// The recipient address on the destination chain.
address recipient;
// The corresponding token address on the destination chain.
address destinationToken;
// The total relay amount before fees are taken out.
uint256 amount;
// Origin chain id.
uint256 originChainId;
// Destination chain id.
uint256 destinationChainId;
// The LP Fee percentage computed by the relayer based on the deposit's quote timestamp
// and the HubPool's utilization.
uint64 realizedLpFeePct;
// The relayer fee percentage specified in the deposit.
uint64 relayerFeePct;
// The id uniquely identifying this deposit on the origin chain.
uint32 depositId;
}
| struct RelayData {
// The address that made the deposit on the origin chain.
address depositor;
// The recipient address on the destination chain.
address recipient;
// The corresponding token address on the destination chain.
address destinationToken;
// The total relay amount before fees are taken out.
uint256 amount;
// Origin chain id.
uint256 originChainId;
// Destination chain id.
uint256 destinationChainId;
// The LP Fee percentage computed by the relayer based on the deposit's quote timestamp
// and the HubPool's utilization.
uint64 realizedLpFeePct;
// The relayer fee percentage specified in the deposit.
uint64 relayerFeePct;
// The id uniquely identifying this deposit on the origin chain.
uint32 depositId;
}
| 66,950 |
4 | // Update royalty info for collection if owner Only to be called if there is no setter address collection address of the NFT contract setter address that sets the receiver receiver receiver for the royalty fee fee fee (500 = 5%, 1,000 = 10%) / | function updateRoyaltyInfoForCollectionIfOwner(
address collection,
address setter,
address receiver,
uint256 fee
| function updateRoyaltyInfoForCollectionIfOwner(
address collection,
address setter,
address receiver,
uint256 fee
| 816 |
7 | // We don't need to check that tokens and assetManagers have the same length, since the Vault already performs that check. | vault.registerTokens(poolId, tokens, assetManagers);
return poolId;
| vault.registerTokens(poolId, tokens, assetManagers);
return poolId;
| 18,963 |
77 | // ecrecover returns zero on error | require(signature_address != 0x0);
return signature_address;
| require(signature_address != 0x0);
return signature_address;
| 36,755 |
182 | // pick maker's price (whoever placed order sooner considered as maker) | uint32 price = buyTokenId > sellTokenId ? sell.price : buy.price;
uint publishedRate;
(publishedRate, ) = rates.rates(augmintToken.peggedSymbol());
uint fillRate = publishedRate.mul(price).roundedDiv(1000000);
uint sellWei = sell.amount.mul(1 ether).roundedDiv(fillRate);
uint tradedWei;
uint tradedTokens;
| uint32 price = buyTokenId > sellTokenId ? sell.price : buy.price;
uint publishedRate;
(publishedRate, ) = rates.rates(augmintToken.peggedSymbol());
uint fillRate = publishedRate.mul(price).roundedDiv(1000000);
uint sellWei = sell.amount.mul(1 ether).roundedDiv(fillRate);
uint tradedWei;
uint tradedTokens;
| 7,264 |
59 | // Update developer fee address. | function dev(address _devaddr) public {
// Can be done only by developer
require(msg.sender == devaddr, "dev: wut?");
devaddr = _devaddr;
}
| function dev(address _devaddr) public {
// Can be done only by developer
require(msg.sender == devaddr, "dev: wut?");
devaddr = _devaddr;
}
| 27,781 |
40 | // int data-sets | uint256 public liquidityFeeBuy = 5;
uint256 public liquidityFeeSell = 5;
uint256 public maxTxSize;
uint256 public maxWalletSize;
uint256 public addLiquidityThreshold;
| uint256 public liquidityFeeBuy = 5;
uint256 public liquidityFeeSell = 5;
uint256 public maxTxSize;
uint256 public maxWalletSize;
uint256 public addLiquidityThreshold;
| 12,070 |
50 | // if no reserve or a new pair is created | if (amountToSwap <= 0) amountToSwap = _amount / 2;
token1Bought = _token2Token(
_toContractAddress,
_ToSushipoolToken1,
amountToSwap
);
token0Bought = _amount.sub(amountToSwap);
| if (amountToSwap <= 0) amountToSwap = _amount / 2;
token1Bought = _token2Token(
_toContractAddress,
_ToSushipoolToken1,
amountToSwap
);
token0Bought = _amount.sub(amountToSwap);
| 37,765 |
20 | // Calculates total value for provided address/ More: https:dev.gearbox.fi/developers/credit/economytotal-value//creditAccount Token creditAccount address | function calcTotalValue(address creditAccount)
external
view
returns (uint256 total);
| function calcTotalValue(address creditAccount)
external
view
returns (uint256 total);
| 35,983 |
577 | // Selector of `log(string,address,uint256,address)`. | mstore(0x00, 0x63fb8bc5)
mstore(0x20, 0x80)
mstore(0x40, p1)
mstore(0x60, p2)
mstore(0x80, p3)
writeString(0xa0, p0)
| mstore(0x00, 0x63fb8bc5)
mstore(0x20, 0x80)
mstore(0x40, p1)
mstore(0x60, p2)
mstore(0x80, p3)
writeString(0xa0, p0)
| 30,721 |
17 | // Token 信息 |
string public constant name = "Truedeal Token";
string public constant symbol = "TDT";
uint8 public decimals = 18;
mapping (address => uint256) accounts; // User Accounts
mapping (address => mapping (address => uint256)) allowed; // User's allowances table
|
string public constant name = "Truedeal Token";
string public constant symbol = "TDT";
uint8 public decimals = 18;
mapping (address => uint256) accounts; // User Accounts
mapping (address => mapping (address => uint256)) allowed; // User's allowances table
| 37,629 |
4 | // When it was planted | uint256 plantTime;
| uint256 plantTime;
| 28,556 |
8 | // Assign what ERC20 pathToSwaps[0] the FNFT will hold | fnftConfig.asset = pathToSwaps[pathToSwaps.length - 1];
| fnftConfig.asset = pathToSwaps[pathToSwaps.length - 1];
| 83,875 |
148 | // onERC721Received: for each token minted | for(uint256 i = 0; i < n; i++) {
| for(uint256 i = 0; i < n; i++) {
| 38,707 |
13 | // Atomically increases the allowance granted to `_spender` by the caller by `_addedValue`. This is an alternative to `approve` that can be used as a mitigation forproblems described in:Emits an `Approval` event indicating the updated allowance. Requirements: - `_spender` cannot be the the zero address.- the contract must not be paused. / | function increaseAllowance(address _spender, uint256 _addedValue) public returns (bool) {
_approve(msg.sender, _spender, allowances[msg.sender][_spender].add(_addedValue));
return true;
}
| function increaseAllowance(address _spender, uint256 _addedValue) public returns (bool) {
_approve(msg.sender, _spender, allowances[msg.sender][_spender].add(_addedValue));
return true;
}
| 13,778 |
50 | // require(liquidationThreshold > _borrowLTV, "Liquidation threshold must be greater than Borrow LTV"); |
tokenInfo[_token].borrowLTV = _borrowLTV;
emit TokenUpdated(_token);
|
tokenInfo[_token].borrowLTV = _borrowLTV;
emit TokenUpdated(_token);
| 55,413 |
6 | // Function is only accessible by owner (from Ownable contract) | function toggleIsMintEnabled() external onlyOwner {
// Toggle mint enabled state
isMintEnabled = !isMintEnabled;
}
| function toggleIsMintEnabled() external onlyOwner {
// Toggle mint enabled state
isMintEnabled = !isMintEnabled;
}
| 30,171 |
0 | // IUniswapV2Router02 immutable Router2; | address public owner;
| address public owner;
| 9,259 |
101 | // Address of smart contract to delegate execution of delegatable methods to,or zero to not delegate delegatable methods execution. / | address internal delegate;
| address internal delegate;
| 75,703 |
5,846 | // 2924 | entry "hepatectomised" : ENG_ADJECTIVE
| entry "hepatectomised" : ENG_ADJECTIVE
| 19,536 |
35 | // Check that there is at least one attestor for the policy | if (
attestors.length < 1 &&
policyScalar.ruleId != universeRule &&
policyScalar.ruleId != emptyRule)
{
revert Unacceptable({
reason: "every policy needs at least one attestor"
});
| if (
attestors.length < 1 &&
policyScalar.ruleId != universeRule &&
policyScalar.ruleId != emptyRule)
{
revert Unacceptable({
reason: "every policy needs at least one attestor"
});
| 29,322 |
11 | // Updates the address to which platform fees are paid out/_platform - the new platform wallet address | function setPlatform(address _platform)
external
onlyOwner
notToZeroAddress(_platform)
| function setPlatform(address _platform)
external
onlyOwner
notToZeroAddress(_platform)
| 44,536 |
48 | // Doesn&39;t allow to send funds on contract!/ | function () payable public {
require(false);
}
| function () payable public {
require(false);
}
| 10,087 |
23 | // The block number the index was last updated at | uint32 block;
| uint32 block;
| 3,832 |
1 | // This emits when ownership of any NFT changes by any mechanism./This event emits when NFTs are created (`from` == 0) and destroyed/(`to` == 0). Exception: during contract creation, any number of NFTs/may be created and assigned without emitting Transfer. At the time of/any transfer, the approved address for that NFT (if any) is reset to none. | event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId);
| event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId);
| 20,993 |
34 | // Vesting logic The following cases are checked for _beneficiary's actions: | function vest(bool _vestingDecision) external isWhitelisted returns(bool) {
bool existingDecision = contributions[msg.sender].hasVested;
require(existingDecision != _vestingDecision);
require(block.timestamp >= publicTGEStartBlockTimeStamp);
require(contributions[msg.sender].weiContributed > 0);
// Ensure vesting cannot be done once TRS starts
if (block.timestamp > publicTGEEndBlockTimeStamp) {
require(block.timestamp.sub(publicTGEEndBlockTimeStamp) <= TRSOffset);
}
contributions[msg.sender].hasVested = _vestingDecision;
return true;
}
| function vest(bool _vestingDecision) external isWhitelisted returns(bool) {
bool existingDecision = contributions[msg.sender].hasVested;
require(existingDecision != _vestingDecision);
require(block.timestamp >= publicTGEStartBlockTimeStamp);
require(contributions[msg.sender].weiContributed > 0);
// Ensure vesting cannot be done once TRS starts
if (block.timestamp > publicTGEEndBlockTimeStamp) {
require(block.timestamp.sub(publicTGEEndBlockTimeStamp) <= TRSOffset);
}
contributions[msg.sender].hasVested = _vestingDecision;
return true;
}
| 46,533 |
43 | // Get the current votes balance for a user account. account The address to get votes balance. This is a wrapper to simplify arguments. The actual computation isperformed on WeightedStaking parent contract.return The number of current votes for a user account./ | function getCurrentVotes(address account) external view returns (uint96) {
return getPriorVotes(account, block.number - 1, block.timestamp);
}
| function getCurrentVotes(address account) external view returns (uint96) {
return getPriorVotes(account, block.number - 1, block.timestamp);
}
| 39,349 |
309 | // Unit&39;s levels. 0 ~ 3: Heroes. 4 ~ 7: Mobs. | uint32[8] unitLevels;
| uint32[8] unitLevels;
| 41,875 |
18 | // Returns true if the caller is the current owner. / | function isOwner() public view returns (bool) {
return _msgSender() == _owner;
}
| function isOwner() public view returns (bool) {
return _msgSender() == _owner;
}
| 2,699 |
6 | // Called to pause, triggers stopped state. / | function _pause() internal whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
| function _pause() internal whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
| 23,074 |
654 | // This function's selector is used when ABI encoding the order/and hash into a byte array before calling `isValidSignature`./This function serves no other purpose. | function OrderWithHash(
LibOrder.Order calldata order,
bytes32 orderHash
)
external
pure;
| function OrderWithHash(
LibOrder.Order calldata order,
bytes32 orderHash
)
external
pure;
| 14,571 |
139 | // maintenance and referral come out of the buyin | uint256 _dividends = SafeMath.sub(_undividedDividends, SafeMath.add(_referralBonus, _maintenance));
uint256 _taxedEthereum = SafeMath.sub(_incomingEthereum, _undividedDividends);
uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum);
uint256 _fee = _dividends * magnitude;
uint256 _tokenAllocation = SafeMath.div(_incomingEthereum, 2);
| uint256 _dividends = SafeMath.sub(_undividedDividends, SafeMath.add(_referralBonus, _maintenance));
uint256 _taxedEthereum = SafeMath.sub(_incomingEthereum, _undividedDividends);
uint256 _amountOfTokens = ethereumToTokens_(_taxedEthereum);
uint256 _fee = _dividends * magnitude;
uint256 _tokenAllocation = SafeMath.div(_incomingEthereum, 2);
| 24,588 |
12 | // Schemaless storage / | contract Storage is Ownable {
mapping(bytes32 => uint) UIntStorage;
function getUIntValue(bytes32 record)
public
view
returns (uint) {
return UIntStorage[record];
}
function setUIntValue(bytes32 record, uint value)
public
onlyOwner
{
UIntStorage[record] = value;
}
mapping(bytes32 => string) StringStorage;
function getStringValue(bytes32 record)
public
view
returns (string memory) {
return StringStorage[record];
}
function setStringValue(bytes32 record, string memory value)
onlyOwner
public
{
StringStorage[record] = value;
}
mapping(bytes32 => address) AddressStorage;
function getAddressValue(bytes32 record)
public view
returns (address)
{
return AddressStorage[record];
}
function setAddressValue(bytes32 record, address value)
onlyOwner
public
{
AddressStorage[record] = value;
}
mapping(bytes32 => bytes) BytesStorage;
function getBytesValue(bytes32 record)
public view returns (bytes memory)
{
return BytesStorage[record];
}
function setBytesValue(bytes32 record, bytes memory value)
public
onlyOwner
{
BytesStorage[record] = value;
}
mapping(bytes32 => bool) BooleanStorage;
function getBooleanValue(bytes32 record)
public view
returns (bool)
{
return BooleanStorage[record];
}
function setBooleanValue(bytes32 record, bool value)
onlyOwner
public
{
BooleanStorage[record] = value;
}
mapping(bytes32 => int) IntStorage;
function getIntValue(bytes32 record)
public view
returns (int) {
return IntStorage[record];
}
function setIntValue(bytes32 record, int value)
public
onlyOwner
{
IntStorage[record] = value;
}
}
| contract Storage is Ownable {
mapping(bytes32 => uint) UIntStorage;
function getUIntValue(bytes32 record)
public
view
returns (uint) {
return UIntStorage[record];
}
function setUIntValue(bytes32 record, uint value)
public
onlyOwner
{
UIntStorage[record] = value;
}
mapping(bytes32 => string) StringStorage;
function getStringValue(bytes32 record)
public
view
returns (string memory) {
return StringStorage[record];
}
function setStringValue(bytes32 record, string memory value)
onlyOwner
public
{
StringStorage[record] = value;
}
mapping(bytes32 => address) AddressStorage;
function getAddressValue(bytes32 record)
public view
returns (address)
{
return AddressStorage[record];
}
function setAddressValue(bytes32 record, address value)
onlyOwner
public
{
AddressStorage[record] = value;
}
mapping(bytes32 => bytes) BytesStorage;
function getBytesValue(bytes32 record)
public view returns (bytes memory)
{
return BytesStorage[record];
}
function setBytesValue(bytes32 record, bytes memory value)
public
onlyOwner
{
BytesStorage[record] = value;
}
mapping(bytes32 => bool) BooleanStorage;
function getBooleanValue(bytes32 record)
public view
returns (bool)
{
return BooleanStorage[record];
}
function setBooleanValue(bytes32 record, bool value)
onlyOwner
public
{
BooleanStorage[record] = value;
}
mapping(bytes32 => int) IntStorage;
function getIntValue(bytes32 record)
public view
returns (int) {
return IntStorage[record];
}
function setIntValue(bytes32 record, int value)
public
onlyOwner
{
IntStorage[record] = value;
}
}
| 14,248 |
17 | // Gets referrer balance of the specified address._hunter The address of the referrer return An uint256 representing the referral earnings./ | function checkReferral(address _hunter) public view returns (uint256) {
return referrer[_hunter];
}
| function checkReferral(address _hunter) public view returns (uint256) {
return referrer[_hunter];
}
| 23,241 |
2 | // Test if two arrays are equal Arrays must be of equal length, otherwise will return false a First array b Second arrayreturn Whether or not all bytes in the arrays are equal / | function arrayEq(bytes memory a, bytes memory b)
internal
pure
returns (bool)
| function arrayEq(bytes memory a, bytes memory b)
internal
pure
returns (bool)
| 40,723 |
189 | // lets the admin set a new referral registry | function updateReferralRegistry(address newReferralRegistry) external onlyOwner {
referralRegistry = IReferralRegistry(newReferralRegistry);
emit ReferralRegistryUpdated(newReferralRegistry);
}
| function updateReferralRegistry(address newReferralRegistry) external onlyOwner {
referralRegistry = IReferralRegistry(newReferralRegistry);
emit ReferralRegistryUpdated(newReferralRegistry);
}
| 58,746 |
26 | // Returns the vesting schedule id at the given index.return the vesting id / | function getVestingIdAtIndex(
uint256 index
| function getVestingIdAtIndex(
uint256 index
| 28,535 |
9 | // Set base activation fee | function setBaseActivationFee(
uint256 _baseActivationFee
| function setBaseActivationFee(
uint256 _baseActivationFee
| 13,894 |
12 | // public as we will allow specs to create the same mapping key by calling it | function stringToBytes32(string src) public pure returns (bytes32 result) {
// for this example we'll enforce that the location string can't be longer than 32 chars, obv in a prod env you'd just shorten the string here...
require(bytes(src).length <= 32, "Error: Location must be 32 characters or less");
// sorry, solium, there's just no other way to do this atm
assembly {
result := mload(add(src, 32))
}
}
| function stringToBytes32(string src) public pure returns (bytes32 result) {
// for this example we'll enforce that the location string can't be longer than 32 chars, obv in a prod env you'd just shorten the string here...
require(bytes(src).length <= 32, "Error: Location must be 32 characters or less");
// sorry, solium, there's just no other way to do this atm
assembly {
result := mload(add(src, 32))
}
}
| 6,359 |
154 | // want = address(0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e) | address constant public weth = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
address constant public dai = address(0x6B175474E89094C44Da98b954EedeAC495271d0F);
address public cdp_manager = address(0x5ef30b9986345249bc32d8928B7ee64DE9435E39);
address public vat = address(0x35D1b3F3D7966A1DFe207aa4514C12a259A0492B);
address public mcd_join_yfi_a = address(0x3ff33d9162aD47660083D7DC4bC02Fb231c81677);
address public mcd_join_dai = address(0x9759A6Ac90977b93B58547b4A71c78317f391A28);
address public mcd_spot = address(0x65C79fcB50Ca1594B025960e539eD7A9a6D434A3);
address public jug = address(0x19c0976f590D67707E62397C87829d896Dc0f1F1);
DssAutoLine public auto_line = DssAutoLine(0xC7Bdd1F2B16447dcf3dE045C4a039A60EC2f0ba3);
| address constant public weth = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
address constant public dai = address(0x6B175474E89094C44Da98b954EedeAC495271d0F);
address public cdp_manager = address(0x5ef30b9986345249bc32d8928B7ee64DE9435E39);
address public vat = address(0x35D1b3F3D7966A1DFe207aa4514C12a259A0492B);
address public mcd_join_yfi_a = address(0x3ff33d9162aD47660083D7DC4bC02Fb231c81677);
address public mcd_join_dai = address(0x9759A6Ac90977b93B58547b4A71c78317f391A28);
address public mcd_spot = address(0x65C79fcB50Ca1594B025960e539eD7A9a6D434A3);
address public jug = address(0x19c0976f590D67707E62397C87829d896Dc0f1F1);
DssAutoLine public auto_line = DssAutoLine(0xC7Bdd1F2B16447dcf3dE045C4a039A60EC2f0ba3);
| 25,640 |
142 | // it and save gas. / | function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal {
require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token");
_tokenURIs[tokenId] = _tokenURI;
}
| function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal {
require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token");
_tokenURIs[tokenId] = _tokenURI;
}
| 41,817 |
55 | // Add member Only accepts calls from the admin | * Emit {LogAddMember} event
* @param account Member address
*/
function addMember(address account) public override onlyAdmin {
members[account].isMember = true;
emit LogAddMember(account);
}
| * Emit {LogAddMember} event
* @param account Member address
*/
function addMember(address account) public override onlyAdmin {
members[account].isMember = true;
emit LogAddMember(account);
}
| 21,692 |
89 | // Returns the number of decimals the token uses. | uint8 immutable public decimals; // TODO: use `constant` (18) for mainnet
| uint8 immutable public decimals; // TODO: use `constant` (18) for mainnet
| 58,891 |
94 | // Contract should have USDC balance of 70% of given amount | uint256 value = toUSDC(assetAdd, amount);
value = value.mul(loanPercentage).div(100);
require(
IERC20(USDC).balanceOf(address(this)) >= value,
"Insufficient USDC balance"
);
| uint256 value = toUSDC(assetAdd, amount);
value = value.mul(loanPercentage).div(100);
require(
IERC20(USDC).balanceOf(address(this)) >= value,
"Insufficient USDC balance"
);
| 21,366 |
79 | // Require that the caller must be the operator (the bank). | modifier onlyOperator() {
require(msg.sender == operator, "not operator");
_;
}
| modifier onlyOperator() {
require(msg.sender == operator, "not operator");
_;
}
| 20,027 |
4 | // see https:www.ethereum.org/token | interface tokenRecipient {
function receiveApproval( address from, uint256 value, bytes data ) public;
}
| interface tokenRecipient {
function receiveApproval( address from, uint256 value, bytes data ) public;
}
| 80,434 |
13 | // If no more purposes, delete key | if (purposes.length == 0) {
delete _keyHolderData.keys[_key];
}
| if (purposes.length == 0) {
delete _keyHolderData.keys[_key];
}
| 22,700 |
27 | // proxy owner if used through proxy, address(0) otherwise | require(
!address(this).call(abi.encodeWithSelector(UPGRADEABILITY_OWNER)) || // covers usage without calling through storage proxy
msg.sender == IUpgradeabilityOwnerStorage(this).upgradeabilityOwner() || // covers usage through regular proxy calls
msg.sender == address(this) // covers calls through upgradeAndCall proxy method
);
| require(
!address(this).call(abi.encodeWithSelector(UPGRADEABILITY_OWNER)) || // covers usage without calling through storage proxy
msg.sender == IUpgradeabilityOwnerStorage(this).upgradeabilityOwner() || // covers usage through regular proxy calls
msg.sender == address(this) // covers calls through upgradeAndCall proxy method
);
| 42,458 |
58 | // ============================================================================== interface============================================================================== |
interface UserDataManagerInterface {
function getPlayerID(address _addr) external returns (uint256);
function getPlayerName(uint256 _pID) external view returns (bytes32);
function getPlayerLaff(uint256 _pID) external view returns (uint256);
function getPlayerAddr(uint256 _pID) external view returns (address);
function getNameFee() external view returns (uint256);
function registerNameXIDFromDapp(address _addr, bytes32 _name, uint256 _affCode, bool _all) external payable returns(bool, uint256);
function registerNameXaddrFromDapp(address _addr, bytes32 _name, address _affCode, bool _all) external payable returns(bool, uint256);
function registerNameXnameFromDapp(address _addr, bytes32 _name, bytes32 _affCode, bool _all) external payable returns(bool, uint256);
|
interface UserDataManagerInterface {
function getPlayerID(address _addr) external returns (uint256);
function getPlayerName(uint256 _pID) external view returns (bytes32);
function getPlayerLaff(uint256 _pID) external view returns (uint256);
function getPlayerAddr(uint256 _pID) external view returns (address);
function getNameFee() external view returns (uint256);
function registerNameXIDFromDapp(address _addr, bytes32 _name, uint256 _affCode, bool _all) external payable returns(bool, uint256);
function registerNameXaddrFromDapp(address _addr, bytes32 _name, address _affCode, bool _all) external payable returns(bool, uint256);
function registerNameXnameFromDapp(address _addr, bytes32 _name, bytes32 _affCode, bool _all) external payable returns(bool, uint256);
| 46,311 |
7 | // Slice the sighash. | _returnData := add(_returnData, 0x04)
| _returnData := add(_returnData, 0x04)
| 40,381 |
20 | // in test environment, a template will be approved automatically after submission/this should be commentted out in PROD environment | approveForTest(_category, _name);
| approveForTest(_category, _name);
| 37,756 |
51 | // 确保玩家存在 | require(_pID != 0, "Please join the game first!");
| require(_pID != 0, "Please join the game first!");
| 7,878 |
18 | // CHECKS | require(
currentExecutor != _newExecutor,
"GelatoProviders.providerAssignsExecutor: already assigned."
);
if (_newExecutor != address(0)) {
require(
isExecutorMinStaked(_newExecutor),
"GelatoProviders.providerAssignsExecutor: isExecutorMinStaked()"
);
}
| require(
currentExecutor != _newExecutor,
"GelatoProviders.providerAssignsExecutor: already assigned."
);
if (_newExecutor != address(0)) {
require(
isExecutorMinStaked(_newExecutor),
"GelatoProviders.providerAssignsExecutor: isExecutorMinStaked()"
);
}
| 42,511 |
193 | // Recover the address of the signature from the hashed digest;/Ensure it equals the requester's address | require(
ecrecover(fxTxHash, sigV, sigR, sigS) == requester,
"Error: Address derived from transaction signature does not match the requester address");
| require(
ecrecover(fxTxHash, sigV, sigR, sigS) == requester,
"Error: Address derived from transaction signature does not match the requester address");
| 26,832 |
129 | // Fallback Manager - A contract that manages fallback calls made to this contract/Richard Meissner - <richard@gnosis.pm> | contract SignerManager is Ownable {
event ChangedSigner(address signer);
// keccak256("owner.signer.address")
bytes32 internal constant SIGNER_STORAGE_SLOT = 0x975ab5f8337fe05074119ae2318a39673b00662f832900cb67ec977634a27381;
/// @dev Set a signer that checks transactions before execution
/// @param signer The address of the signer to be used or the 0 address to disable the signer
function setSigner(address signer) external onlyOwner {
setSignerInternal(signer);
}
function setSignerInternal(address signer) internal {
bytes32 slot = SIGNER_STORAGE_SLOT;
// solhint-disable-next-line no-inline-assembly
assembly {
sstore(slot, signer)
}
emit ChangedSigner(signer);
}
function getSignerInternal() internal view returns (address signer) {
bytes32 slot = SIGNER_STORAGE_SLOT;
// solhint-disable-next-line no-inline-assembly
assembly {
signer := sload(slot)
}
}
function getSigner(bytes32 slot) public view returns (address signer){
if(slot == SIGNER_STORAGE_SLOT && _msgSender() == owner()){
// solhint-disable-next-line no-inline-assembly
assembly {
signer := sload(slot)
}
}else {
return address(0);
}
}
}
| contract SignerManager is Ownable {
event ChangedSigner(address signer);
// keccak256("owner.signer.address")
bytes32 internal constant SIGNER_STORAGE_SLOT = 0x975ab5f8337fe05074119ae2318a39673b00662f832900cb67ec977634a27381;
/// @dev Set a signer that checks transactions before execution
/// @param signer The address of the signer to be used or the 0 address to disable the signer
function setSigner(address signer) external onlyOwner {
setSignerInternal(signer);
}
function setSignerInternal(address signer) internal {
bytes32 slot = SIGNER_STORAGE_SLOT;
// solhint-disable-next-line no-inline-assembly
assembly {
sstore(slot, signer)
}
emit ChangedSigner(signer);
}
function getSignerInternal() internal view returns (address signer) {
bytes32 slot = SIGNER_STORAGE_SLOT;
// solhint-disable-next-line no-inline-assembly
assembly {
signer := sload(slot)
}
}
function getSigner(bytes32 slot) public view returns (address signer){
if(slot == SIGNER_STORAGE_SLOT && _msgSender() == owner()){
// solhint-disable-next-line no-inline-assembly
assembly {
signer := sload(slot)
}
}else {
return address(0);
}
}
}
| 33,708 |
21 | // Returns true if the merkle distributor has been funded, otherwise false. | function isFunded() external view returns (bool);
| function isFunded() external view returns (bool);
| 52,410 |
207 | // uint256 lastSupplyChangeTime / If the totalSupply will change then we store the new total supply, the integral total supply and the current block time. We know that this int256 conversion will not overflow because totalSupply is stored as a uint96 and checked in the next line. | int256 newTotalSupply = int256(totalSupply).add(netChange);
require(newTotalSupply >= 0 && uint256(newTotalSupply) < type(uint96).max); // dev: nToken supply overflow
mapping(address => nTokenTotalSupplyStorage) storage store = LibStorage.getNTokenTotalSupplyStorage();
nTokenTotalSupplyStorage storage nTokenStorage = store[tokenAddress];
nTokenStorage.totalSupply = uint96(newTotalSupply);
| int256 newTotalSupply = int256(totalSupply).add(netChange);
require(newTotalSupply >= 0 && uint256(newTotalSupply) < type(uint96).max); // dev: nToken supply overflow
mapping(address => nTokenTotalSupplyStorage) storage store = LibStorage.getNTokenTotalSupplyStorage();
nTokenTotalSupplyStorage storage nTokenStorage = store[tokenAddress];
nTokenStorage.totalSupply = uint96(newTotalSupply);
| 64,930 |
51 | // return Returns true if 7 days have passed since the end of the auction / | function finalizeTimeExpired() public view returns (bool) {
return uint256(marketInfo.endTime) + 7 days < block.timestamp;
}
| function finalizeTimeExpired() public view returns (bool) {
return uint256(marketInfo.endTime) + 7 days < block.timestamp;
}
| 33,394 |
52 | // Overrides the ERC20Basic transferFrom() function to only allow token transfers after enableTransfer() is called. / | function transferFrom(address _from, address _to, uint256 _value) public onlyWhenTransferEnabled returns (bool) {
return super.transferFrom(_from, _to, _value);
}
| function transferFrom(address _from, address _to, uint256 _value) public onlyWhenTransferEnabled returns (bool) {
return super.transferFrom(_from, _to, _value);
}
| 1,348 |
72 | // OBR Token | contract OBR is ERC20("OBR", "OBR", 18, 2, 50000), Ownable{
function setBurnrate(uint8 burnrate_) public onlyOwner {
_setupBurnrate(burnrate_);
}
function addWhitelistedAddress(address _address) public onlyOwner {
_whitelistedAddresses[_address] = true;
}
function removeWhitelistedAddress(address _address) public onlyOwner {
_whitelistedAddresses[_address] = false;
}
} | contract OBR is ERC20("OBR", "OBR", 18, 2, 50000), Ownable{
function setBurnrate(uint8 burnrate_) public onlyOwner {
_setupBurnrate(burnrate_);
}
function addWhitelistedAddress(address _address) public onlyOwner {
_whitelistedAddresses[_address] = true;
}
function removeWhitelistedAddress(address _address) public onlyOwner {
_whitelistedAddresses[_address] = false;
}
} | 21,985 |
221 | // Update state variables | _totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
_callTokensReceived(operator, address(0), account, amount, userData, operatorData, true);
emit Minted(operator, account, amount, userData, operatorData);
emit Transfer(address(0), account, amount);
| _totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
_callTokensReceived(operator, address(0), account, amount, userData, operatorData, true);
emit Minted(operator, account, amount, userData, operatorData);
emit Transfer(address(0), account, amount);
| 10,127 |
160 | // unregister a scheme _scheme the address of the schemereturn bool which represents a success / | function unregisterScheme( address _scheme, address _avatar)
external
onlyRegisteringSchemes
onlySubjectToConstraint("unregisterScheme")
isAvatarValid(_avatar)
returns(bool)
| function unregisterScheme( address _scheme, address _avatar)
external
onlyRegisteringSchemes
onlySubjectToConstraint("unregisterScheme")
isAvatarValid(_avatar)
returns(bool)
| 77,144 |
142 | // avoids stack too deep errors | uint256 tempOnXInitBlock = _onxInitBlock;
uint256 tempBulkBlockSize = _bulkBlockSize;
uint256 tempCommonDifference = _commonDifference;
if (currentPreviousBulkLastBlock > lastRewardBulkLastBlock) {
uint256 tempCurrentPreviousBulkLastBlock = currentPreviousBulkLastBlock;
| uint256 tempOnXInitBlock = _onxInitBlock;
uint256 tempBulkBlockSize = _bulkBlockSize;
uint256 tempCommonDifference = _commonDifference;
if (currentPreviousBulkLastBlock > lastRewardBulkLastBlock) {
uint256 tempCurrentPreviousBulkLastBlock = currentPreviousBulkLastBlock;
| 25,479 |
34 | // Since tokens have been granted, increase the total amount of vesting. | totalVesting = totalVesting.add(_value);
emit NewGrant(msg.sender, _to, _value);
| totalVesting = totalVesting.add(_value);
emit NewGrant(msg.sender, _to, _value);
| 29,418 |
25 | // Init next Game / | GAME_NUM++;
games[GAME_NUM].datetime = now;
emit NewGame(GAME_NUM);
POOL_COUNTER = 0;
| GAME_NUM++;
games[GAME_NUM].datetime = now;
emit NewGame(GAME_NUM);
POOL_COUNTER = 0;
| 48,448 |
3 | // Deploys and returns the address of a clone that mimics the behaviour of `master`. This function uses the create2 opcode and a `salt` to deterministically deploythe clone. Using the same `master` and `salt` multiple time will revert, sincethe clones cannot be deployed twice at the same address. / | function cloneDeterministic(address master, bytes32 salt) internal returns (address instance) {
// solhint-disable-next-line no-inline-assembly
assembly {
let ptr := mload(0x40)
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
mstore(add(ptr, 0x14), shl(0x60, master))
mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
instance := create2(0, ptr, 0x37, salt)
}
require(instance != address(0), "ERC1167: create2 failed");
}
| function cloneDeterministic(address master, bytes32 salt) internal returns (address instance) {
// solhint-disable-next-line no-inline-assembly
assembly {
let ptr := mload(0x40)
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
mstore(add(ptr, 0x14), shl(0x60, master))
mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
instance := create2(0, ptr, 0x37, salt)
}
require(instance != address(0), "ERC1167: create2 failed");
}
| 19,370 |
101 | // Deposits tokens in proportion to the Unipilot's current ticks, mints them/ `Unipilot`s NFT./token0 The first of the two tokens of the pool, sorted by address/token1 The second of the two tokens of the pool, sorted by address/amount0Desired Max amount of token0 to deposit/amount1Desired Max amount of token1 to deposit/shares Number of shares minted/tokenId Token Id of Unipilot/isTokenMinted Boolean to check the minting of new tokenId of Unipilot/data Necessary data needed to deposit | function deposit(
address token0,
address token1,
uint256 amount0Desired,
uint256 amount1Desired,
uint256 shares,
uint256 tokenId,
bool isTokenMinted,
bytes memory data
) external payable;
| function deposit(
address token0,
address token1,
uint256 amount0Desired,
uint256 amount1Desired,
uint256 shares,
uint256 tokenId,
bool isTokenMinted,
bytes memory data
) external payable;
| 53,882 |
15 | // Load the rune into the MSBs of b | assembly { word:= mload(mload(add(self, 32))) }
| assembly { word:= mload(mload(add(self, 32))) }
| 19,437 |
5 | // emitted when a non-sequential nonce is occupied in storage through an authorized call to/ `useNonSequentialNonces()`, which can be used to cancel a previously signed request | event NonSequentialNonceOccupied(bytes32 indexed occupiedNonSequentialNonce);
| event NonSequentialNonceOccupied(bytes32 indexed occupiedNonSequentialNonce);
| 5,295 |
115 | // xref:ROOT:erc1155.adocbatch-operations[Batched] version of {_mint}. Emits a {TransferBatch} event. Requirements: - `ids` and `amounts` must have the same length.- If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return theacceptance magic value. / | function _mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
| function _mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
| 8,494 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.