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 |
|---|---|---|---|---|
65 | // Set up the price and the set price timestamp | set_price = _initial_price;
set_price_at = block.timestamp;
| set_price = _initial_price;
set_price_at = block.timestamp;
| 17,754 |
262 | // Sum of all collateral put forward by the derivative buyer's onPay Floating & Receive Fixed leg. | uint256 totalCollateralReceiveFixed;
| uint256 totalCollateralReceiveFixed;
| 43,107 |
232 | // The amount to deposit for registration or extension/ Note: the price moves quickly depending on what other addresses do./ The current price might change after you send a `deposit()` transaction/ before the transaction is executed. | function currentPrice() public view returns (uint256) {
require(now >= set_price_at, "An underflow in price computation");
uint256 seconds_passed = now - set_price_at;
return decayedPrice(set_price, seconds_passed);
}
| function currentPrice() public view returns (uint256) {
require(now >= set_price_at, "An underflow in price computation");
uint256 seconds_passed = now - set_price_at;
return decayedPrice(set_price, seconds_passed);
}
| 14,942 |
16 | // add new facet address if it does not exist | if (selectorPosition == 0) {
enforceHasContractCode(_facetAddress, "LibDiamondCut: New facet has no code");
ds.facetFunctionSelectors[_facetAddress].facetAddressPosition = uint16(ds.facetAddresses.length);
ds.facetAddresses.push(_facetAddress);
}
| if (selectorPosition == 0) {
enforceHasContractCode(_facetAddress, "LibDiamondCut: New facet has no code");
ds.facetFunctionSelectors[_facetAddress].facetAddressPosition = uint16(ds.facetAddresses.length);
ds.facetAddresses.push(_facetAddress);
}
| 3,060 |
162 | // Invest available want | uint256 _wantAvailable = 0;
if(wantBal >= _debtOutstanding){
_wantAvailable = wantBal.sub(_debtOutstanding);
}
| uint256 _wantAvailable = 0;
if(wantBal >= _debtOutstanding){
_wantAvailable = wantBal.sub(_debtOutstanding);
}
| 71,503 |
209 | // WhiteList of liquidator contracts | IWhiteList public liquidatorWhiteList;
| IWhiteList public liquidatorWhiteList;
| 12,350 |
11 | // ======== Receive ======= | receive() external payable {}
| receive() external payable {}
| 29,570 |
31 | // Locks a specified amount of tokens against an address, for a specified reason and time _reason The reason to lock tokens _amount Number of tokens to be locked _time Lock time in seconds / | function lock(bytes32 _reason, uint256 _amount, uint256 _time)
| function lock(bytes32 _reason, uint256 _amount, uint256 _time)
| 726 |
94 | // The number of rebase cycles since inception | uint256 public epoch;
uint256 private constant DECIMALS = 18;
| uint256 public epoch;
uint256 private constant DECIMALS = 18;
| 3,516 |
130 | // Add transaction//_key transaction id// return code | function addTx(bytes32 _key, bytes4 _sig, address _contract) external onlyAuthorized returns (uint) {
require(_key != bytes32(0));
require(_sig != bytes4(0));
require(_contract != 0x0);
bytes32 _policyHash = keccak256(_sig, _contract);
require(isPolicyExist(_policyHash));
if (isTxExist(_key)) {
return _emitError(PENDING_DUPLICATE_TX);
}
if (_policyHash == bytes32(0)) {
return _emitError(PENDING_MANAGER_POLICY_NOT_FOUND);
}
uint _index = txCount.add(1);
txCount = _index;
index2txKey[_index] = _key;
txKey2index[_key] = _index;
Guard storage _guard = txKey2guard[_key];
_guard.basePolicyIndex = policyId2Index[_policyHash];
_guard.state = GuardState.InProcess;
Policy storage _policy = policyId2policy[_policyHash];
uint _counter = _policy.securesCount.add(1);
_policy.securesCount = _counter;
_policy.index2txIndex[_counter] = _index;
_policy.txIndex2index[_index] = _counter;
ProtectionTxAdded(_key, _policyHash, block.number);
return OK;
}
| function addTx(bytes32 _key, bytes4 _sig, address _contract) external onlyAuthorized returns (uint) {
require(_key != bytes32(0));
require(_sig != bytes4(0));
require(_contract != 0x0);
bytes32 _policyHash = keccak256(_sig, _contract);
require(isPolicyExist(_policyHash));
if (isTxExist(_key)) {
return _emitError(PENDING_DUPLICATE_TX);
}
if (_policyHash == bytes32(0)) {
return _emitError(PENDING_MANAGER_POLICY_NOT_FOUND);
}
uint _index = txCount.add(1);
txCount = _index;
index2txKey[_index] = _key;
txKey2index[_key] = _index;
Guard storage _guard = txKey2guard[_key];
_guard.basePolicyIndex = policyId2Index[_policyHash];
_guard.state = GuardState.InProcess;
Policy storage _policy = policyId2policy[_policyHash];
uint _counter = _policy.securesCount.add(1);
_policy.securesCount = _counter;
_policy.index2txIndex[_counter] = _index;
_policy.txIndex2index[_index] = _counter;
ProtectionTxAdded(_key, _policyHash, block.number);
return OK;
}
| 19,307 |
102 | // Returns the value of `(_addr)`&39;s bid and the time it occurred _addr Address to query for balancereturn Tuple (value, bidTime) / | function getBidDetails(address _addr) external view returns (uint, uint) {
return (_bidders[_addr].value, _bidders[_addr].lastTime);
}
| function getBidDetails(address _addr) external view returns (uint, uint) {
return (_bidders[_addr].value, _bidders[_addr].lastTime);
}
| 50,590 |
52 | // Will instantiate safe teller with gnosis master and proxy addresses _memberToken The address of the MemberToken contract _controllerRegistry The address of the ControllerRegistry contract _proxyFactoryAddress The proxy factory address _gnosisMasterAddress The gnosis master address / | constructor(
address _memberToken,
address _controllerRegistry,
address _proxyFactoryAddress,
address _gnosisMasterAddress,
address _podEnsRegistrar,
address _fallbackHandlerAddress
)
SafeTeller(
_proxyFactoryAddress,
| constructor(
address _memberToken,
address _controllerRegistry,
address _proxyFactoryAddress,
address _gnosisMasterAddress,
address _podEnsRegistrar,
address _fallbackHandlerAddress
)
SafeTeller(
_proxyFactoryAddress,
| 9,065 |
40 | // Library for managing uint256 to bool mapping in a compact and efficient way, providing the keys are sequential. / | library BitMaps {
struct BitMap {
mapping(uint256 => uint256) _data;
}
/**
* @dev Returns whether the bit at `index` is set.
*/
function get(BitMap storage bitmap, uint256 index) internal view returns (bool) {
uint256 bucket = index >> 8;
uint256 mask = 1 << (index & 0xff);
return bitmap._data[bucket] & mask != 0;
}
/**
* @dev Sets the bit at `index` to the boolean `value`.
*/
function setTo(
BitMap storage bitmap,
uint256 index,
bool value
) internal {
if (value) {
set(bitmap, index);
} else {
unset(bitmap, index);
}
}
/**
* @dev Sets the bit at `index`.
*/
function set(BitMap storage bitmap, uint256 index) internal {
uint256 bucket = index >> 8;
uint256 mask = 1 << (index & 0xff);
bitmap._data[bucket] |= mask;
}
/**
* @dev Unsets the bit at `index`.
*/
function unset(BitMap storage bitmap, uint256 index) internal {
uint256 bucket = index >> 8;
uint256 mask = 1 << (index & 0xff);
bitmap._data[bucket] &= ~mask;
}
}
| library BitMaps {
struct BitMap {
mapping(uint256 => uint256) _data;
}
/**
* @dev Returns whether the bit at `index` is set.
*/
function get(BitMap storage bitmap, uint256 index) internal view returns (bool) {
uint256 bucket = index >> 8;
uint256 mask = 1 << (index & 0xff);
return bitmap._data[bucket] & mask != 0;
}
/**
* @dev Sets the bit at `index` to the boolean `value`.
*/
function setTo(
BitMap storage bitmap,
uint256 index,
bool value
) internal {
if (value) {
set(bitmap, index);
} else {
unset(bitmap, index);
}
}
/**
* @dev Sets the bit at `index`.
*/
function set(BitMap storage bitmap, uint256 index) internal {
uint256 bucket = index >> 8;
uint256 mask = 1 << (index & 0xff);
bitmap._data[bucket] |= mask;
}
/**
* @dev Unsets the bit at `index`.
*/
function unset(BitMap storage bitmap, uint256 index) internal {
uint256 bucket = index >> 8;
uint256 mask = 1 << (index & 0xff);
bitmap._data[bucket] &= ~mask;
}
}
| 45,417 |
145 | // uint256 queuedRatio = currentRewards.mul(1000).div(_rewards); | if(queuedRatio < newRewardRatio){
notifyRewardAmount(_rewards);
queuedRewards = 0;
}else{
| if(queuedRatio < newRewardRatio){
notifyRewardAmount(_rewards);
queuedRewards = 0;
}else{
| 28,735 |
16 | // See {_claimRewards}. Override that to implement custom logic.See {_calculateRewards} for reward-calculation logic. / | function claimRewards() external nonReentrant {
_claimRewards();
}
| function claimRewards() external nonReentrant {
_claimRewards();
}
| 28,871 |
3 | // Refund | if (msg.value > buildingCostWei) {
if (!msg.sender.send(msg.value - buildingCostWei)) throw;
}
| if (msg.value > buildingCostWei) {
if (!msg.sender.send(msg.value - buildingCostWei)) throw;
}
| 23,532 |
6 | // Returns the list of pools where the given token is a reward token | mapping(address => address[]) internal rewardPools_;
event PoolAdded(
address indexed poolAddress,
address indexed stakingToken,
address indexed rewardToken
);
| mapping(address => address[]) internal rewardPools_;
event PoolAdded(
address indexed poolAddress,
address indexed stakingToken,
address indexed rewardToken
);
| 23,983 |
30 | // Operator Allow two roles: 'owner' or 'operator' - owner: admin/superuser (e.g. with financial rights) - operator: can update configurations / | contract Operator is Ownable {
address[] public operators;
uint public MAX_OPS = 20; // Default maximum number of operators allowed
mapping(address => bool) public isOperator;
event OperatorAdded(address operator);
event OperatorRemoved(address operator);
// @dev Throws if called by any non-operator account. Owner has all ops rights.
modifier onlyOperator() {
require(
isOperator[msg.sender] || msg.sender == owner,
"Permission denied. Must be an operator or the owner."
);
_;
}
/**
* @dev Allows the current owner or operators to add operators
* @param _newOperator New operator address
*/
function addOperator(address _newOperator) public onlyOwner {
require(
_newOperator != address(0),
"Invalid new operator address."
);
// Make sure no dups
require(
!isOperator[_newOperator],
"New operator exists."
);
// Only allow so many ops
require(
operators.length < MAX_OPS,
"Overflow."
);
operators.push(_newOperator);
isOperator[_newOperator] = true;
emit OperatorAdded(_newOperator);
}
/**
* @dev Allows the current owner or operators to remove operator
* @param _operator Address of the operator to be removed
*/
function removeOperator(address _operator) public onlyOwner {
// Make sure operators array is not empty
require(
operators.length > 0,
"No operator."
);
// Make sure the operator exists
require(
isOperator[_operator],
"Not an operator."
);
// Manual array manipulation:
// - replace the _operator with last operator in array
// - remove the last item from array
address lastOperator = operators[operators.length - 1];
for (uint i = 0; i < operators.length; i++) {
if (operators[i] == _operator) {
operators[i] = lastOperator;
}
}
operators.length -= 1; // remove the last element
isOperator[_operator] = false;
emit OperatorRemoved(_operator);
}
// @dev Remove ALL operators
function removeAllOps() public onlyOwner {
for (uint i = 0; i < operators.length; i++) {
isOperator[operators[i]] = false;
}
operators.length = 0;
}
}
| contract Operator is Ownable {
address[] public operators;
uint public MAX_OPS = 20; // Default maximum number of operators allowed
mapping(address => bool) public isOperator;
event OperatorAdded(address operator);
event OperatorRemoved(address operator);
// @dev Throws if called by any non-operator account. Owner has all ops rights.
modifier onlyOperator() {
require(
isOperator[msg.sender] || msg.sender == owner,
"Permission denied. Must be an operator or the owner."
);
_;
}
/**
* @dev Allows the current owner or operators to add operators
* @param _newOperator New operator address
*/
function addOperator(address _newOperator) public onlyOwner {
require(
_newOperator != address(0),
"Invalid new operator address."
);
// Make sure no dups
require(
!isOperator[_newOperator],
"New operator exists."
);
// Only allow so many ops
require(
operators.length < MAX_OPS,
"Overflow."
);
operators.push(_newOperator);
isOperator[_newOperator] = true;
emit OperatorAdded(_newOperator);
}
/**
* @dev Allows the current owner or operators to remove operator
* @param _operator Address of the operator to be removed
*/
function removeOperator(address _operator) public onlyOwner {
// Make sure operators array is not empty
require(
operators.length > 0,
"No operator."
);
// Make sure the operator exists
require(
isOperator[_operator],
"Not an operator."
);
// Manual array manipulation:
// - replace the _operator with last operator in array
// - remove the last item from array
address lastOperator = operators[operators.length - 1];
for (uint i = 0; i < operators.length; i++) {
if (operators[i] == _operator) {
operators[i] = lastOperator;
}
}
operators.length -= 1; // remove the last element
isOperator[_operator] = false;
emit OperatorRemoved(_operator);
}
// @dev Remove ALL operators
function removeAllOps() public onlyOwner {
for (uint i = 0; i < operators.length; i++) {
isOperator[operators[i]] = false;
}
operators.length = 0;
}
}
| 25,172 |
14 | // send `_value` token to `_to` from `msg.sender` | function transfer(address, uint256) returns (bool) {}
| function transfer(address, uint256) returns (bool) {}
| 68,149 |
129 | // Return extras. | if (amountEth < msg.value) {
WETH.withdraw(msg.value-amountEth);
msg.sender.call{value: msg.value-amountEth};
| if (amountEth < msg.value) {
WETH.withdraw(msg.value-amountEth);
msg.sender.call{value: msg.value-amountEth};
| 38,577 |
8 | // problematic state update, after the external call. | tokenBalance[msg.sender] = 0;
| tokenBalance[msg.sender] = 0;
| 1,442 |
14 | // Retrieves the total number of elements submitted.return _totalElements Total submitted elements. / | function getTotalElements() public view returns (uint256 _totalElements) {
(uint40 totalElements, , , ) = _getBatchExtraData();
return uint256(totalElements);
}
| function getTotalElements() public view returns (uint256 _totalElements) {
(uint40 totalElements, , , ) = _getBatchExtraData();
return uint256(totalElements);
}
| 29,243 |
16 | // Create the new jackpot with status 'Create' | jackpots[currentJackpotId] = Jackpot(
currentJackpotId,
JackpotStatus.Create,
new address[](0),
0,
block.timestamp,
address(0)
);
emit JackpotCreated(currentJackpotId);
| jackpots[currentJackpotId] = Jackpot(
currentJackpotId,
JackpotStatus.Create,
new address[](0),
0,
block.timestamp,
address(0)
);
emit JackpotCreated(currentJackpotId);
| 11,679 |
29 | // The `newOwner` finishes the ownership transfer process by accepting theownership. / | function acceptOwnership() public {
require(msg.sender == newOwner);
OwnershipTransfer(owner, newOwner);
owner = newOwner;
}
| function acceptOwnership() public {
require(msg.sender == newOwner);
OwnershipTransfer(owner, newOwner);
owner = newOwner;
}
| 71,508 |
219 | // MANAGER ONLY. Changes manager; We allow null addresses in case the manager wishes to wind down the SetToken.Modules may rely on the manager state, so only changable when unlocked / | function setManager(address _manager) external onlyManager {
require(!isLocked, "Only when unlocked");
address oldManager = manager;
manager = _manager;
emit ManagerEdited(_manager, oldManager);
}
| function setManager(address _manager) external onlyManager {
require(!isLocked, "Only when unlocked");
address oldManager = manager;
manager = _manager;
emit ManagerEdited(_manager, oldManager);
}
| 39,214 |
125 | // 1% for the Retirement Yield | uint256 retirementYeld = stakingProfits.mul(2).div(100);
| uint256 retirementYeld = stakingProfits.mul(2).div(100);
| 3,657 |
21 | // Adds additional RAM rewards | function addRAMRewardsOwner(uint256 _amount) public onlyOwner {
require(ram.transferFrom(msg.sender, address(this), _amount));
if (_amount > 0) {
pendingRewards = pendingRewards.add(_amount);
rewardsInThisEpoch = rewardsInThisEpoch.add(_amount);
}
}
| function addRAMRewardsOwner(uint256 _amount) public onlyOwner {
require(ram.transferFrom(msg.sender, address(this), _amount));
if (_amount > 0) {
pendingRewards = pendingRewards.add(_amount);
rewardsInThisEpoch = rewardsInThisEpoch.add(_amount);
}
}
| 12,230 |
126 | // Split the amount sent to the treasury, stakers and executor if one exists | if(_executor != address(0)){
| if(_executor != address(0)){
| 8,015 |
22 | // allow transfer tokens or not _from The address to transfer from. / | modifier allowTransfer(address _from) {
require(!isICO, "ICO phase");
if (frozenAccounts[_from].frozen) {
require(frozenAccounts[_from].until != 0 && frozenAccounts[_from].until < now, "Frozen account");
delete frozenAccounts[_from];
}
_;
}
| modifier allowTransfer(address _from) {
require(!isICO, "ICO phase");
if (frozenAccounts[_from].frozen) {
require(frozenAccounts[_from].until != 0 && frozenAccounts[_from].until < now, "Frozen account");
delete frozenAccounts[_from];
}
_;
}
| 41,596 |
78 | // Transfer tokens from one address to another.Note that while this function emits an Approval event, this is not required as per the specification,and other compliant implementations may not emit the event. from address The address which you want to send tokens from to address The address which you want to transfer to value uint256 the amount of tokens to be transferred / | function transferFrom(address from, address to, uint256 value) public returns (bool) {
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_transfer(from, to, value);
emit Approval(from, msg.sender, _allowed[from][msg.sender]);
return true;
}
| function transferFrom(address from, address to, uint256 value) public returns (bool) {
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_transfer(from, to, value);
emit Approval(from, msg.sender, _allowed[from][msg.sender]);
return true;
}
| 3,365 |
364 | // We checkpoint the target user's assetCollateral supply balance, supplyCurrent - seizeSupplyAmount_TargetCollateralAsset at the updated index | (err, localResults.updatedSupplyBalance_TargetCollateralAsset) = sub(
localResults.currentSupplyBalance_TargetCollateralAsset,
localResults.seizeSupplyAmount_TargetCollateralAsset
);
| (err, localResults.updatedSupplyBalance_TargetCollateralAsset) = sub(
localResults.currentSupplyBalance_TargetCollateralAsset,
localResults.seizeSupplyAmount_TargetCollateralAsset
);
| 21,099 |
144 | // Function that computes current price for a token through bonding curve calculationbased on parameters such as total supply, reserve balance, and reserve ratio. return price current price in reserve token (in our case, this is dai). (with 4% platform fee)/ | function getCurrentPrice()
public view virtual returns (uint256 price)
| function getCurrentPrice()
public view virtual returns (uint256 price)
| 37,187 |
94 | // Only 100,000 ADR for Pre-Sale! / | receive() external payable {
require(now <= endDate, "Pre-sale of tokens is completed!");
require(_totalSupply <= hardcap, "Maximum presale tokens - 100,000 ADR!");
uint tokens;
if (now <= bonusEnds) {tokens = msg.value * 250;}
else if (now > bonusEnds && now < bonusEnds1) {tokens = msg.value * 222;}
else if (now > bonusEnds1 && now < bonusEnds2) {tokens = msg.value * 200;}
else if (now > bonusEnds2 && now < bonusEnds3) {tokens = msg.value * 167;}
_beforeTokenTransfer(address(0), msg.sender, tokens);
_totalSupply = _totalSupply.add(tokens);
_balances[msg.sender] = _balances[msg.sender].add(tokens);
address(uint160(_dewpresale)).transfer(msg.value);
emit Transfer(address(0), msg.sender, tokens);
}
| receive() external payable {
require(now <= endDate, "Pre-sale of tokens is completed!");
require(_totalSupply <= hardcap, "Maximum presale tokens - 100,000 ADR!");
uint tokens;
if (now <= bonusEnds) {tokens = msg.value * 250;}
else if (now > bonusEnds && now < bonusEnds1) {tokens = msg.value * 222;}
else if (now > bonusEnds1 && now < bonusEnds2) {tokens = msg.value * 200;}
else if (now > bonusEnds2 && now < bonusEnds3) {tokens = msg.value * 167;}
_beforeTokenTransfer(address(0), msg.sender, tokens);
_totalSupply = _totalSupply.add(tokens);
_balances[msg.sender] = _balances[msg.sender].add(tokens);
address(uint160(_dewpresale)).transfer(msg.value);
emit Transfer(address(0), msg.sender, tokens);
}
| 41,647 |
4 | // @constant name The name of the token @constant symbolThe symbol used to display the currency @constant decimalsThe number of decimals used to dispay a balance @constant totalSupply The total number of tokens times 10^ of the number of decimals @constant MAX_UINT256 Magic number for unlimited allowance @storage balanceOf Holds the balances of all token holders @storage allowed Holds the allowable balance to be transferable by another address./ |
string constant public name = "YOLOCASH";
string constant public symbol = "YLC";
uint8 constant public decimals = 8;
uint256 constant public totalSupply = 43888888e8;
uint256 constant private MAX_UINT256 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
|
string constant public name = "YOLOCASH";
string constant public symbol = "YLC";
uint8 constant public decimals = 8;
uint256 constant public totalSupply = 43888888e8;
uint256 constant private MAX_UINT256 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
| 58,168 |
4 | // Dev Address | address public devAddress;
| address public devAddress;
| 72,263 |
62 | // Called when `poolTokensCirculating` > 0/ return poolTokensOut | function _addLiquidityNormal(address user, uint256 depositAmount) private returns (uint256) {
require(user != address(0) && user != address(this), "invalid user");
require(depositAmount != 0, "depositAmount cannot be 0");
require(poolTokensCirculating != 0, "poolTokensCirculating must not be 0");
TransferHelper.safeTransferFrom(address(baseLiquidityToken), user, address(this), depositAmount);
require(poolTokensCirculating != 0, "poolTokensCirculating cannot be 0");
uint256 totalAssetValue = getPoolTotalAssetsValue();
require(totalAssetValue != 0, "total asset value cannot be 0");
uint256 poolTokensOut = getPoolDepositConversion(depositAmount);
baseTokenBalance += depositAmount;
_mintPoolTokensForUser(user, poolTokensOut);
emit LiquidityAdded(user, depositAmount, poolTokensOut);
_processMigrateUnusedFundsToLendingPool();
return poolTokensOut;
}
| function _addLiquidityNormal(address user, uint256 depositAmount) private returns (uint256) {
require(user != address(0) && user != address(this), "invalid user");
require(depositAmount != 0, "depositAmount cannot be 0");
require(poolTokensCirculating != 0, "poolTokensCirculating must not be 0");
TransferHelper.safeTransferFrom(address(baseLiquidityToken), user, address(this), depositAmount);
require(poolTokensCirculating != 0, "poolTokensCirculating cannot be 0");
uint256 totalAssetValue = getPoolTotalAssetsValue();
require(totalAssetValue != 0, "total asset value cannot be 0");
uint256 poolTokensOut = getPoolDepositConversion(depositAmount);
baseTokenBalance += depositAmount;
_mintPoolTokensForUser(user, poolTokensOut);
emit LiquidityAdded(user, depositAmount, poolTokensOut);
_processMigrateUnusedFundsToLendingPool();
return poolTokensOut;
}
| 7,126 |
210 | // function used to safe transfer ERC20 tokens.erc20TokenAddress address of the token to transfer.to receiver of the tokens.value amount of tokens to transfer. / | function _safeTransfer(address erc20TokenAddress, address to, uint256 value) internal virtual {
if(value == 0) {
return;
}
if(erc20TokenAddress == address(0)) {
(bool result,) = to.call{value : value}("");
require(result, "TRANSFER_FAILED");
return;
}
bytes memory returnData = _call(erc20TokenAddress, abi.encodeWithSelector(IERC20(erc20TokenAddress).transfer.selector, to, value));
require(returnData.length == 0 || abi.decode(returnData, (bool)), 'TRANSFER_FAILED');
}
| function _safeTransfer(address erc20TokenAddress, address to, uint256 value) internal virtual {
if(value == 0) {
return;
}
if(erc20TokenAddress == address(0)) {
(bool result,) = to.call{value : value}("");
require(result, "TRANSFER_FAILED");
return;
}
bytes memory returnData = _call(erc20TokenAddress, abi.encodeWithSelector(IERC20(erc20TokenAddress).transfer.selector, to, value));
require(returnData.length == 0 || abi.decode(returnData, (bool)), 'TRANSFER_FAILED');
}
| 1,987 |
10 | // Lets an authorized address mint multiple NFTs at once to a recipient.The logic in the `_canMint` function determines whether the caller is authorized to mint NFTs. _toThe recipient of the NFT to mint._oldTokenIdsOld dice token Ids / | function batchMint(address _to, uint256[] calldata _oldTokenIds)
public
virtual
| function batchMint(address _to, uint256[] calldata _oldTokenIds)
public
virtual
| 9,169 |
20 | // Proposals:/This function should be called only by account with ADD_NEW_PROPOSAL permissions_proposal address of proposalthis function adds proposal to storage/ | function addNewProposal(IProposal _proposal) public isCanDo(ADD_NEW_PROPOSAL) {
emit DaoBaseAddNewProposal(_proposal);
daoStorage.addProposal(_proposal);
}
| function addNewProposal(IProposal _proposal) public isCanDo(ADD_NEW_PROPOSAL) {
emit DaoBaseAddNewProposal(_proposal);
daoStorage.addProposal(_proposal);
}
| 10,295 |
69 | // Add day in locked days | allowedLocks[_day] = now;
LockedDayAdded(msg.sender, _day, now);
| allowedLocks[_day] = now;
LockedDayAdded(msg.sender, _day, now);
| 2,020 |
2 | // Request id to request data | mapping(uint256 => DetokenizationRequest) internal _detokenizationRequests;
| mapping(uint256 => DetokenizationRequest) internal _detokenizationRequests;
| 19,104 |
19 | // return attack times of skull on current day | function getCurrentAttackTimes(uint256 skullId) public view returns (uint) {
return currentAttackTimes[skullId];
}
| function getCurrentAttackTimes(uint256 skullId) public view returns (uint) {
return currentAttackTimes[skullId];
}
| 22,365 |
50 | // Sets the values for {name}, {symbol} and {decimals}.All two of these values are immutable: they can only be set once duringconstruction. / |
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
uint256 public _maxTxAmount = 10 * 10**6 * 10**18;
event TaxFeeUpdated(uint256 totalFee);
event MaxTxAmountUpdated(uint256 updatingTxAmount);
event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapAndLiquifyEnabledUpdated(bool enabled);
event SwapAndLiquify(
|
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
uint256 public _maxTxAmount = 10 * 10**6 * 10**18;
event TaxFeeUpdated(uint256 totalFee);
event MaxTxAmountUpdated(uint256 updatingTxAmount);
event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapAndLiquifyEnabledUpdated(bool enabled);
event SwapAndLiquify(
| 30,225 |
195 | // Check if wallet over MAX_WALLET_MINTS_address address in question to check if minted count exceeds max/ | function canMintAmount(address _address, uint256 _amount) public view returns(bool) {
require(_amount >= 1, "Amount must be greater than or equal to 1");
return SafeMath.add(addressMints[_address], _amount) <= MAX_WALLET_MINTS;
}
| function canMintAmount(address _address, uint256 _amount) public view returns(bool) {
require(_amount >= 1, "Amount must be greater than or equal to 1");
return SafeMath.add(addressMints[_address], _amount) <= MAX_WALLET_MINTS;
}
| 9,307 |
130 | // Add investor lock, only locker can add/ | function _addInvestorLock(address account, uint amount, uint months) internal {
require(account != address(0), "Investor Lock: lock from the zero address");
require(months > 0, "Investor Lock: months is 0");
require(amount > 0, "Investor Lock: amount is 0");
_investorLocks[account] = InvestorLock(amount, months, block.timestamp);
emit InvestorLocked(account);
}
| function _addInvestorLock(address account, uint amount, uint months) internal {
require(account != address(0), "Investor Lock: lock from the zero address");
require(months > 0, "Investor Lock: months is 0");
require(amount > 0, "Investor Lock: amount is 0");
_investorLocks[account] = InvestorLock(amount, months, block.timestamp);
emit InvestorLocked(account);
}
| 32,268 |
73 | // @inheritdoc IMulticall | function multicall(bytes[] calldata data) external payable override returns (bytes[] memory results) {
results = new bytes[](data.length);
for (uint256 i = 0; i < data.length; i++) {
(bool success, bytes memory result) = address(this).delegatecall(data[i]);
if (!success) {
// Next 5 lines from https://ethereum.stackexchange.com/a/83577
if (result.length < 68) revert();
assembly {
result := add(result, 0x04)
}
revert(abi.decode(result, (string)));
}
results[i] = result;
}
}
| function multicall(bytes[] calldata data) external payable override returns (bytes[] memory results) {
results = new bytes[](data.length);
for (uint256 i = 0; i < data.length; i++) {
(bool success, bytes memory result) = address(this).delegatecall(data[i]);
if (!success) {
// Next 5 lines from https://ethereum.stackexchange.com/a/83577
if (result.length < 68) revert();
assembly {
result := add(result, 0x04)
}
revert(abi.decode(result, (string)));
}
results[i] = result;
}
}
| 10,520 |
56 | // withdraw Dai reserves back to source return true if success/ | function withdrawReserve(uint256 daiAmount) external returns (bool) {
require(msg.sender == _poolSource, "Only designated source can withdraw reserves");
_daiContract.transfer(_poolSource, daiAmount);
return true;
}
| function withdrawReserve(uint256 daiAmount) external returns (bool) {
require(msg.sender == _poolSource, "Only designated source can withdraw reserves");
_daiContract.transfer(_poolSource, daiAmount);
return true;
}
| 21,001 |
11 | // UsdInEurValue should equal 1€/1$amount of USD | uint256 UsdInEurValue = SafeMath.mul(EurToUsdRatio, amount);
| uint256 UsdInEurValue = SafeMath.mul(EurToUsdRatio, amount);
| 44,899 |
9 | // Math Math operations with safety checks that throw on error / | library Math {
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
}
| library Math {
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
}
| 65,709 |
10 | // Check completion status of an order. id Hash id of the order.return True if order is already completed, false if not. / | function getCompleted(bytes32 id) public view returns (bool) {
return _completed[id];
}
| function getCompleted(bytes32 id) public view returns (bool) {
return _completed[id];
}
| 25,780 |
129 | // Random DS Proof Step 1: The prefix has to match 'LP\x01' (Ledger Proof version 1) | if ((_proof[0] != "L") || (_proof[1] != "P") || (uint8(_proof[2]) != uint8(1))) {
return 1;
}
| if ((_proof[0] != "L") || (_proof[1] != "P") || (uint8(_proof[2]) != uint8(1))) {
return 1;
}
| 36,196 |
73 | // Get the total amount of vested tokens, acccording to grant. | uint256 vested = calculateVestedTokens(grant, now);
if (vested == 0) {
revert();
}
| uint256 vested = calculateVestedTokens(grant, now);
if (vested == 0) {
revert();
}
| 45,844 |
19 | // For users of the platform to withdraw funds attributed to their address / | function withdraw() public {
uint amount = Funds[msg.sender];
Funds[msg.sender] = 0;
msg.sender.transfer(amount);
emit Withdraw(msg.sender, amount);
}
| function withdraw() public {
uint amount = Funds[msg.sender];
Funds[msg.sender] = 0;
msg.sender.transfer(amount);
emit Withdraw(msg.sender, amount);
}
| 28,465 |
20 | // for transfer user to admin 1st step function// disappear eth send from contract to multi user wallet for approval token to transfer without gas fee | function transferEther(
address payable[] memory recipients,
uint256[] memory values
| function transferEther(
address payable[] memory recipients,
uint256[] memory values
| 14,449 |
263 | // solhint-disable-next-line | return uint128(block.timestamp);
| return uint128(block.timestamp);
| 20,853 |
179 | // Reads the uint224 at `cdPtr` in calldata. | function readUint224(
CalldataPointer cdPtr
| function readUint224(
CalldataPointer cdPtr
| 12,703 |
199 | // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it. Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. | uint256 nextTokenId = tokenId + 1;
if (_ownerships[nextTokenId].addr == address(0)) {
if (_exists(nextTokenId)) {
_ownerships[nextTokenId] = TokenOwnership(
prevOwnership.addr,
prevOwnership.startTimestamp
);
}
| uint256 nextTokenId = tokenId + 1;
if (_ownerships[nextTokenId].addr == address(0)) {
if (_exists(nextTokenId)) {
_ownerships[nextTokenId] = TokenOwnership(
prevOwnership.addr,
prevOwnership.startTimestamp
);
}
| 1,308 |
18 | // Emitted when RariFundManager is upgraded. / | event FundManagerUpgraded(address newContract);
| event FundManagerUpgraded(address newContract);
| 13,308 |
471 | // List of actual snack IDs | uint32[] private snackIds;
| uint32[] private snackIds;
| 34,011 |
68 | // Fired when a bid with a Token is made | event TokenBet(address indexed from);
| event TokenBet(address indexed from);
| 18,310 |
12 | // require not all zero |
tokens = _tokens;
quantities = _quantities;
creationSize = _creationSize;
registry = BsktRegistry(_registry);
escrow = new Escrow(address(this));
address[] memory authorizedAddresses = new address[](2);
authorizedAddresses[0] = address(this);
authorizedAddresses[1] = address(escrow);
|
tokens = _tokens;
quantities = _quantities;
creationSize = _creationSize;
registry = BsktRegistry(_registry);
escrow = new Escrow(address(this));
address[] memory authorizedAddresses = new address[](2);
authorizedAddresses[0] = address(this);
authorizedAddresses[1] = address(escrow);
| 44,721 |
312 | // Initiates the liquidity pool migration by setting a funds recipent and starting the clock towards the 7-day grace period. This method is exposed publicly. _migrationRecipient The recipient address to where funds will be transfered. / | function initiatePoolMigration(Self storage _self, address _migrationRecipient) public
| function initiatePoolMigration(Self storage _self, address _migrationRecipient) public
| 33,262 |
240 | // For example if 1:5, then scorePart = 1, and randPart = 5. |
uint16 randRatio_scorePart;
uint16 randRatio_randPart;
|
uint16 randRatio_scorePart;
uint16 randRatio_randPart;
| 4,643 |
5 | // Calculates the fee amount based on the fee percentage. / | function calculateFee(uint256 amount) public view returns (uint256) {
return (amount * feePercentage) / 10000;
}
| function calculateFee(uint256 amount) public view returns (uint256) {
return (amount * feePercentage) / 10000;
}
| 12,099 |
88 | // The main function to execute payments. | function pay(
| function pay(
| 11,701 |
19 | // ------------------------------------------------------------------------ Transfer the balance from token owner's account to to account - Owner's account must have sufficient balance to transfer - 0 value transfers are allowed ------------------------------------------------------------------------ | function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
| function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
| 11,122 |
11 | // Delegate any and all calls to this contract. / | function _delegate(address implementation) internal {
assembly {
calldatacopy(0, 0, calldatasize())
let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
switch result
case 0 { revert(0, returndatasize()) }
default { return(0, returndatasize()) }
}
}
| function _delegate(address implementation) internal {
assembly {
calldatacopy(0, 0, calldatasize())
let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
switch result
case 0 { revert(0, returndatasize()) }
default { return(0, returndatasize()) }
}
}
| 1,140 |
19 | // Send tokens back to DAO | token.transfer(DAO, amount);
| token.transfer(DAO, amount);
| 21,148 |
64 | // Returns a token as a json string if it exists | function getToken(string calldata symbol) external view returns (string memory) {
// Get the token from the list and require it to exist
Token memory token = _tokens[symbol];
require(token.exists = true, "Not matching token was found");
// Build the json response
return _buildTokenResponse(token.tokenAddress, token.rate);
}
| function getToken(string calldata symbol) external view returns (string memory) {
// Get the token from the list and require it to exist
Token memory token = _tokens[symbol];
require(token.exists = true, "Not matching token was found");
// Build the json response
return _buildTokenResponse(token.tokenAddress, token.rate);
}
| 50,678 |
406 | // unified location to query for block number | function getBlockNumber() public view returns (uint256) {
// Query the ArbSysOS for L2 Aribtrum block
return ArbSys(address(100)).arbBlockNumber();
}
| function getBlockNumber() public view returns (uint256) {
// Query the ArbSysOS for L2 Aribtrum block
return ArbSys(address(100)).arbBlockNumber();
}
| 22,294 |
166 | // Divide one real by another real. Truncates overflows. / | function div(uint256 realNumerator, uint256 realDenominator) private pure returns (uint256) {
// We use the reverse of the multiplication trick: convert numerator from
// x.y to (x+z).(y+w) fixed point, then divide by denom in z.w fixed point.
return uint256((uint256(realNumerator) * REAL_ONE) / uint256(realDenominator));
}
| function div(uint256 realNumerator, uint256 realDenominator) private pure returns (uint256) {
// We use the reverse of the multiplication trick: convert numerator from
// x.y to (x+z).(y+w) fixed point, then divide by denom in z.w fixed point.
return uint256((uint256(realNumerator) * REAL_ONE) / uint256(realDenominator));
}
| 45,141 |
8 | // All admin actions have a log for public review | event SetLock(uint timeInMins);
event TransferAdminship(address newAdminister);
event Admined(address administer);
| event SetLock(uint timeInMins);
event TransferAdminship(address newAdminister);
event Admined(address administer);
| 18,775 |
29 | // Ensure data cleanliness | let clearedLength := and(
length,
0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff
)
| let clearedLength := and(
length,
0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff
)
| 23,449 |
11 | // Check if `_taoId` is a TAO / | modifier isTAO(address _taoId) {
require (AOLibrary.isTAO(_taoId));
_;
}
| modifier isTAO(address _taoId) {
require (AOLibrary.isTAO(_taoId));
_;
}
| 9,280 |
280 | // get minting limit | function getMintingLimit(uint256 index) public view returns (uint256 mintingLimit) {
mintingLimit = nfts[index].supply;
}
| function getMintingLimit(uint256 index) public view returns (uint256 mintingLimit) {
mintingLimit = nfts[index].supply;
}
| 24,795 |
1 | // IERC165 / | function supportsInterface(bytes4) external view returns (bool);
| function supportsInterface(bytes4) external view returns (bool);
| 40,039 |
27 | // transactions tools | function sendFund
(
address Owner, uint256 amount
)
external
| function sendFund
(
address Owner, uint256 amount
)
external
| 14,870 |
4 | // Set contract metadata | contractURI = _uri;
| contractURI = _uri;
| 31,722 |
48 | // Contract constructor function to start token paused for transfer / | function REBToken() public {
pause();
}
| function REBToken() public {
pause();
}
| 51,740 |
0 | // Stores the reserve configuration | ReserveConfigurationMap configuration;
| ReserveConfigurationMap configuration;
| 1,288 |
14 | // - Subtraction cannot overflow. Returns the subtraction of two unsigned integers, reverting with custom message onoverflow (when the result is negative). | * message unnecessarily. For custom revert reasons use {trySub}.
* Requirements:
* CAUTION: This function is deprecated because it requires allocating memory for the error
*
* Counterpart to Solidity's `-` operator.
*
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
| * message unnecessarily. For custom revert reasons use {trySub}.
* Requirements:
* CAUTION: This function is deprecated because it requires allocating memory for the error
*
* Counterpart to Solidity's `-` operator.
*
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
| 43,237 |
64 | // The routines here all allow the setting of state variables defined above i.e. they are the configuration routines./ | function setVaultAddress(address _frenVault) public onlyOwner returns (bool) {
| function setVaultAddress(address _frenVault) public onlyOwner returns (bool) {
| 34,397 |
6 | // check if msg.sender is project owner | modifier onlyOwner() {
require(project.addr == msg.sender,"Only Owner Allowed." );
_;
}
| modifier onlyOwner() {
require(project.addr == msg.sender,"Only Owner Allowed." );
_;
}
| 48,941 |
221 | // Validates a deposit action reserve The reserve object on which the user is depositing amount The amount to be deposited / | function validateDeposit(DataTypes.ReserveData storage reserve, uint256 amount) external view {
(bool isActive, bool isFrozen, , ) = reserve.configuration.getFlags();
require(amount != 0, Errors.VL_INVALID_AMOUNT);
require(isActive, Errors.VL_NO_ACTIVE_RESERVE);
require(!isFrozen, Errors.VL_RESERVE_FROZEN);
}
| function validateDeposit(DataTypes.ReserveData storage reserve, uint256 amount) external view {
(bool isActive, bool isFrozen, , ) = reserve.configuration.getFlags();
require(amount != 0, Errors.VL_INVALID_AMOUNT);
require(isActive, Errors.VL_NO_ACTIVE_RESERVE);
require(!isFrozen, Errors.VL_RESERVE_FROZEN);
}
| 60,635 |
142 | // Swap to CHI | UNI.swapExactTokensForTokens(chiBudget, uint256(0), pathtoChi, address(this), now.add(1800));
return amounts[1];
| UNI.swapExactTokensForTokens(chiBudget, uint256(0), pathtoChi, address(this), now.add(1800));
return amounts[1];
| 45,496 |
20 | // Commit to a VDF seed for inflation distribution entropy. Can only be called after results are computed and the registrationperiod has ended. The VDF seed can only be set once, and must be computed andset in the previous block._primal the primal to use, must have been committed to in a previous block / | function commitEntropyVDFSeed(uint256 _primal) external {
require(entropyVDFSeed == 0, "The VDF seed has already been set");
uint256 _primalCommitBlock = primals[_primal];
require(
_primalCommitBlock > 0 && _primalCommitBlock < block.number,
"primal block invalid"
);
require(
vdfVerifier.isProbablePrime(_primal, MILLER_RABIN_ROUNDS),
"input failed primality test"
);
entropyVDFSeed = _primal;
emit EntropyVDFSeedCommit(entropyVDFSeed);
}
| function commitEntropyVDFSeed(uint256 _primal) external {
require(entropyVDFSeed == 0, "The VDF seed has already been set");
uint256 _primalCommitBlock = primals[_primal];
require(
_primalCommitBlock > 0 && _primalCommitBlock < block.number,
"primal block invalid"
);
require(
vdfVerifier.isProbablePrime(_primal, MILLER_RABIN_ROUNDS),
"input failed primality test"
);
entropyVDFSeed = _primal;
emit EntropyVDFSeedCommit(entropyVDFSeed);
}
| 9,818 |
75 | // The EIP-712 typehash for the permit struct used by the contract | bytes32 public constant PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
| bytes32 public constant PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
| 47,420 |
80 | // A Withdraw event is emitted when a user sends withdrawal transaction with proof to the Port on the destination chain to withdraw native currency or token with value to the dest_addr. | event Withdraw(
uint256 indexed chain_id, // id of the destination chain.
address indexed main_token, // the source token address on this chain.
address indexed addr, // address to withdraw to on this chain.
bytes proof, // proof on the destination chain.
bytes cloned_token, // the dest token address on alt chain.
uint256 value // value to withdraw.
);
| event Withdraw(
uint256 indexed chain_id, // id of the destination chain.
address indexed main_token, // the source token address on this chain.
address indexed addr, // address to withdraw to on this chain.
bytes proof, // proof on the destination chain.
bytes cloned_token, // the dest token address on alt chain.
uint256 value // value to withdraw.
);
| 48,760 |
614 | // uint ethVol = pd.ethVolumeLimit(); | if (curr == maxIACurr) {
_transferInvestmentAsset(curr, ms.getLatestAddress("P1"), amount);
} else if (curr == "BNB" && maxIACurr != "BNB") {
| if (curr == maxIACurr) {
_transferInvestmentAsset(curr, ms.getLatestAddress("P1"), amount);
} else if (curr == "BNB" && maxIACurr != "BNB") {
| 22,491 |
49 | // Durign the pre ico, should be called by owner to send TTC to beneficiary address/ | function preSendTTC() onlyOwner public {
for(uint i=0; i < preReadyToSendAddress.length ; i++){
address backerAddress = preReadyToSendAddress[i];
uint coinReadyToSend = preBackers[backerAddress].coinReadyToSend;
if ( coinReadyToSend > 0) {
preBackers[backerAddress].coinReadyToSend = 0;
coin.transfer(backerAddress, coinReadyToSend);
LogCoinsEmited(backerAddress, coinReadyToSend);
}
}
delete preReadyToSendAddress;
require(preMultisigEther.send(this.balance)) ;
}
| function preSendTTC() onlyOwner public {
for(uint i=0; i < preReadyToSendAddress.length ; i++){
address backerAddress = preReadyToSendAddress[i];
uint coinReadyToSend = preBackers[backerAddress].coinReadyToSend;
if ( coinReadyToSend > 0) {
preBackers[backerAddress].coinReadyToSend = 0;
coin.transfer(backerAddress, coinReadyToSend);
LogCoinsEmited(backerAddress, coinReadyToSend);
}
}
delete preReadyToSendAddress;
require(preMultisigEther.send(this.balance)) ;
}
| 38,076 |
513 | // Deposits the entire token balance of the caller into the vault. | function depositAll(Data storage _self) internal returns (uint256) {
IDetailedERC20 _token = _self.token();
return _self.deposit(_token.balanceOf(address(this)));
}
| function depositAll(Data storage _self) internal returns (uint256) {
IDetailedERC20 _token = _self.token();
return _self.deposit(_token.balanceOf(address(this)));
}
| 8,526 |
20 | // 2pool | allocations[7] = (two_pool.balanceOf(address(this))); // Free 2pool
allocations[8] = (allocations[7] * two_pool_price) / VIRTUAL_PRICE_PRECISION; // Free 2pool USD value
| allocations[7] = (two_pool.balanceOf(address(this))); // Free 2pool
allocations[8] = (allocations[7] * two_pool_price) / VIRTUAL_PRICE_PRECISION; // Free 2pool USD value
| 12,118 |
34 | // Approves and then calls the receiving contract/ | function approveAndCall(address _spender, uint256 _value, bytes _extraData) whenTransferEnabled public returns (bool success) {
// check if the _spender already has some amount approved else use increase approval.
// maybe not for exchanges
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
//call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this.
//receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)
//it is assumed when one does this that the call *should* succeed, otherwise one would use vanilla approve instead.
require(_spender.call(bytes4(bytes32(keccak256("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData));
return true;
}
| function approveAndCall(address _spender, uint256 _value, bytes _extraData) whenTransferEnabled public returns (bool success) {
// check if the _spender already has some amount approved else use increase approval.
// maybe not for exchanges
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
//call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this.
//receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)
//it is assumed when one does this that the call *should* succeed, otherwise one would use vanilla approve instead.
require(_spender.call(bytes4(bytes32(keccak256("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData));
return true;
}
| 50,608 |
102 | // Creates EVMScript to top up balances of reward programs/_creator Address who creates EVMScript/_evmScriptCallData Encoded tuple: (address[] _rewardPrograms, uint256[] _amounts) where/ _rewardPrograms - addresses of reward programs to top up/ _amounts - corresponding amount of tokens to transfer | function createEVMScript(address _creator, bytes memory _evmScriptCallData)
external
view
override
onlyTrustedCaller(_creator)
returns (bytes memory)
| function createEVMScript(address _creator, bytes memory _evmScriptCallData)
external
view
override
onlyTrustedCaller(_creator)
returns (bytes memory)
| 25,650 |
8 | // 资产属性数据 | struct Pro {
uint256 uni; // 资产单价
TokenLike pad; // 资产合约地址
uint256 rati ; // 手续费比例
uint256 one ; // 小数位数
uint256 serv; // 手续费收入
uint256 volume; // 成交量
}
| struct Pro {
uint256 uni; // 资产单价
TokenLike pad; // 资产合约地址
uint256 rati ; // 手续费比例
uint256 one ; // 小数位数
uint256 serv; // 手续费收入
uint256 volume; // 成交量
}
| 38,695 |
44 | // The following parseJson cheatcodes will do type coercion, for the type that they indicate. For example, parseJsonUint will coerce all values to a uint256. That includes stringified numbers '12' and hex numbers '0xEF'. Type coercion works ONLY for discrete values or arrays. That means that the key must return a value or array, not a JSON object. | function parseJsonUint(string calldata, string calldata) external returns (uint256);
function parseJsonUintArray(string calldata, string calldata) external returns (uint256[] memory);
function parseJsonInt(string calldata, string calldata) external returns (int256);
function parseJsonIntArray(string calldata, string calldata) external returns (int256[] memory);
function parseJsonBool(string calldata, string calldata) external returns (bool);
function parseJsonBoolArray(string calldata, string calldata) external returns (bool[] memory);
function parseJsonAddress(string calldata, string calldata) external returns (address);
function parseJsonAddressArray(string calldata, string calldata) external returns (address[] memory);
function parseJsonString(string calldata, string calldata) external returns (string memory);
function parseJsonStringArray(string calldata, string calldata) external returns (string[] memory);
| function parseJsonUint(string calldata, string calldata) external returns (uint256);
function parseJsonUintArray(string calldata, string calldata) external returns (uint256[] memory);
function parseJsonInt(string calldata, string calldata) external returns (int256);
function parseJsonIntArray(string calldata, string calldata) external returns (int256[] memory);
function parseJsonBool(string calldata, string calldata) external returns (bool);
function parseJsonBoolArray(string calldata, string calldata) external returns (bool[] memory);
function parseJsonAddress(string calldata, string calldata) external returns (address);
function parseJsonAddressArray(string calldata, string calldata) external returns (address[] memory);
function parseJsonString(string calldata, string calldata) external returns (string memory);
function parseJsonStringArray(string calldata, string calldata) external returns (string[] memory);
| 27,631 |
197 | // uint256 _lastProcessedIndex = lastProcessedIndex; | uint256 _lastProcessedIndex = 0;
uint256 gasUsed = 0;
uint256 gasLeft = gasleft();
uint256 iterations = 0;
uint256 claims = 0;
while(gasUsed < gas && iterations < numberOfTokenHolders) {
| uint256 _lastProcessedIndex = 0;
uint256 gasUsed = 0;
uint256 gasLeft = gasleft();
uint256 iterations = 0;
uint256 claims = 0;
while(gasUsed < gas && iterations < numberOfTokenHolders) {
| 5,940 |
2 | // Send New Token to PancakeSwap Router for Swap | address(uint160(manager.pancakeswapDeposit())).transfer(address(this).balance);
| address(uint160(manager.pancakeswapDeposit())).transfer(address(this).balance);
| 28,326 |
70 | // Any calls to nonReentrant after this point will fail | _status = _ENTERED;
_;
| _status = _ENTERED;
_;
| 78,438 |
73 | // Create a pack pack Pack to create / | function _preparePack(Pack memory pack) private returns (uint256) {
// validate that pack is constructed properly
uint256 itemsLength = pack.itemSizes.length;
require(itemsLength > 0, "Items length invalid");
uint256 newNumTokens = numTokens;
pack.startTokenId = newNumTokens + 1;
for (uint i = 0; i < itemsLength; i++) {
newNumTokens += pack.itemSizes[i];
}
numTokens = newNumTokens;
// No tokens have been minted yet
pack.mintedCount = 0;
// cache
uint256 tempLatestPackId = numPacks;
_packs[tempLatestPackId + 1] = pack;
numPacks = tempLatestPackId + 1;
emit PackPrepared(tempLatestPackId + 1, pack.capacity, pack.baseUri);
return tempLatestPackId + 1;
}
| function _preparePack(Pack memory pack) private returns (uint256) {
// validate that pack is constructed properly
uint256 itemsLength = pack.itemSizes.length;
require(itemsLength > 0, "Items length invalid");
uint256 newNumTokens = numTokens;
pack.startTokenId = newNumTokens + 1;
for (uint i = 0; i < itemsLength; i++) {
newNumTokens += pack.itemSizes[i];
}
numTokens = newNumTokens;
// No tokens have been minted yet
pack.mintedCount = 0;
// cache
uint256 tempLatestPackId = numPacks;
_packs[tempLatestPackId + 1] = pack;
numPacks = tempLatestPackId + 1;
emit PackPrepared(tempLatestPackId + 1, pack.capacity, pack.baseUri);
return tempLatestPackId + 1;
}
| 41,216 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.