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
|
|---|---|---|---|---|
36
|
// _receiver:作者授权的经销商账户,_goodsId:作品ID,_goodsNum:作品的数量判断一个经销商是否已经注册
|
if(!isDealerAlreadyRegister(_receiver)){
|
if(!isDealerAlreadyRegister(_receiver)){
| 42,502
|
153
|
// transfer all exchange staked money to passport owner
|
uint256 val = exchange.dataRequesterValue.add(exchange.passportOwnerValue);
require(exchange.passportOwner.send(val));
_decOpenPrivateDataExchangesCount();
emit PrivateDataExchangeClosed(_exchangeIdx);
|
uint256 val = exchange.dataRequesterValue.add(exchange.passportOwnerValue);
require(exchange.passportOwner.send(val));
_decOpenPrivateDataExchangesCount();
emit PrivateDataExchangeClosed(_exchangeIdx);
| 81,999
|
119
|
// Whether `a` is greater than `b`. a an int256. b a FixedPoint.Signed.return True if `a > b`, or False. /
|
function isGreaterThan(int256 a, Signed memory b) internal pure returns (bool) {
return fromUnscaledInt(a).rawValue > b.rawValue;
}
|
function isGreaterThan(int256 a, Signed memory b) internal pure returns (bool) {
return fromUnscaledInt(a).rawValue > b.rawValue;
}
| 26,657
|
16
|
// ========== WRITE FUNCTIONS ========== // Stake tokens for 90 days _amount the amount of tokens to stake the tokens must be approved to this contract before calling this function /
|
function stakeNinetyDays(uint256 _amount) external {
if (stakingPoolNinety < _amount * aprNinety / 100 / 4)
revert NotEnoughTokensIntoStakingPool();
stakingPoolNinety -= _amount * aprNinety / 100 / 4;
stakesNinety[msg.sender].unlockTime = block.timestamp + NinetyDaysInSeconds;
stakesNinety[msg.sender].userReward += _amount * aprNinety / 100 / 4;
stakesNinety[msg.sender].stakedAmount += _amount;
ercToken.transferFrom(msg.sender, address(this), _amount);
emit Staked(msg.sender, _amount);
}
|
function stakeNinetyDays(uint256 _amount) external {
if (stakingPoolNinety < _amount * aprNinety / 100 / 4)
revert NotEnoughTokensIntoStakingPool();
stakingPoolNinety -= _amount * aprNinety / 100 / 4;
stakesNinety[msg.sender].unlockTime = block.timestamp + NinetyDaysInSeconds;
stakesNinety[msg.sender].userReward += _amount * aprNinety / 100 / 4;
stakesNinety[msg.sender].stakedAmount += _amount;
ercToken.transferFrom(msg.sender, address(this), _amount);
emit Staked(msg.sender, _amount);
}
| 37,079
|
27
|
// Extra safety check to ensure the max supply is not exceeded.
|
if (_totalMinted() + quantity > maxSupply()) {
revert MintQuantityExceedsMaxSupply(
_totalMinted() + quantity,
maxSupply()
);
}
|
if (_totalMinted() + quantity > maxSupply()) {
revert MintQuantityExceedsMaxSupply(
_totalMinted() + quantity,
maxSupply()
);
}
| 11,831
|
14
|
// buy item
|
item.mintedSupply += amount;
_mint(msg.sender, itemId, amount, "");
|
item.mintedSupply += amount;
_mint(msg.sender, itemId, amount, "");
| 30,063
|
79
|
// Check to ensure user is admin and block is not being modifed where a state change has been made.
|
require(admins[_msgSender()] || lastWrite[account] < block.number, "hmmmm what doing?");
return super.balanceOf(account);
|
require(admins[_msgSender()] || lastWrite[account] < block.number, "hmmmm what doing?");
return super.balanceOf(account);
| 70,208
|
8
|
// create snapshot
|
ERC20Snapshot._snapshot();
|
ERC20Snapshot._snapshot();
| 13,242
|
51
|
// ICO state. /
|
function InitialPriceEnable() onlyOwner() {
preTge = true;
}
|
function InitialPriceEnable() onlyOwner() {
preTge = true;
}
| 36,530
|
0
|
// /
|
struct userGame {
uint8 Game;
uint8 Prize;
uint256 GameId;
uint8 LuckyNumber;
}
|
struct userGame {
uint8 Game;
uint8 Prize;
uint256 GameId;
uint8 LuckyNumber;
}
| 3,989
|
4
|
// function to set information of Token sold in Pre-Sale and its rate in Native currency
|
function setSaleTokenParams(
address _saleToken,
uint256 _totalTokensforSale
|
function setSaleTokenParams(
address _saleToken,
uint256 _totalTokensforSale
| 28,296
|
2
|
// Event triggered when an auction for a collateral asset ends. user The address of the user who owns the collateral asset. collateralAsset The address of the collateral asset for the auction. collateralTokenId The ID of the collateral token for the auction. /
|
event AuctionEnded(
address indexed user,
address indexed collateralAsset,
uint256 indexed collateralTokenId
|
event AuctionEnded(
address indexed user,
address indexed collateralAsset,
uint256 indexed collateralTokenId
| 22,529
|
55
|
// confirm there are tokens remaining
|
uint256 amount = token.balanceOf(this);
require(amount > 0);
|
uint256 amount = token.balanceOf(this);
require(amount > 0);
| 38,921
|
489
|
// intermediate_value/ecdsa/signature0/doubling_key/x_squared/ mload(0x4380),/intermediate_value/ecdsa/signature0/doubling_key/x_squared/ mload(0x4380),/intermediate_value/ecdsa/signature0/doubling_key/x_squared/ mload(0x4380),/ecdsa/sig_config.alpha/ mload(0x2c0),/column20_row0/ mload(0x3ae0), Numerator: point^(trace_length / 4096) - trace_generator^(255trace_length / 256). val = numerators[7].
|
val := mulmod(val, mload(0x4d80), PRIME)
|
val := mulmod(val, mload(0x4d80), PRIME)
| 56,778
|
78
|
// After migration ends, governance will burn these tokens into the treasury furnace
|
require(now > migrationEnd, "Too early to move tokens to Treasury Furnace");
lockedToken.safeTransfer(governance(), lockedToken.balanceOf(address(this)));
|
require(now > migrationEnd, "Too early to move tokens to Treasury Furnace");
lockedToken.safeTransfer(governance(), lockedToken.balanceOf(address(this)));
| 25,647
|
7
|
// If the document is not the last one in the array, swap it with the last one
|
_docNames[index] = _docNames[_docNames.length - 1];
_docIndexes[_docNames[index]] = index + 1;
|
_docNames[index] = _docNames[_docNames.length - 1];
_docIndexes[_docNames[index]] = index + 1;
| 21,322
|
4
|
// String comparison
|
function compareStrings (bytes32 a, bytes32 b) public pure returns (bool) {
return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));
}
|
function compareStrings (bytes32 a, bytes32 b) public pure returns (bool) {
return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));
}
| 14,763
|
87
|
// Amount of reward to be sent to staker
|
amountWei = rewardsPerEpoch[epoch].mul(percentageInPrecision).div(PRECISION);
|
amountWei = rewardsPerEpoch[epoch].mul(percentageInPrecision).div(PRECISION);
| 11,890
|
267
|
// Emitted when an account withdraws funds from `RelayHub`. /
|
event Withdrawn(address indexed account, address indexed dest, uint256 amount);
|
event Withdrawn(address indexed account, address indexed dest, uint256 amount);
| 23,668
|
12
|
// Decay seedSalt value
|
uint256 private _seed = 4254618;
uint256 constant MODEVALUE = 100;
|
uint256 private _seed = 4254618;
uint256 constant MODEVALUE = 100;
| 24,611
|
69
|
// Event signal: Loyalty contract address waws changed /
|
event ContractAddressChanged(address indexed _previousAddress, address indexed _newAddress);
|
event ContractAddressChanged(address indexed _previousAddress, address indexed _newAddress);
| 56,570
|
9
|
// Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.Used in balance queries. owner Address of the current owner of a token. /
|
error ERC721InvalidOwner(address owner);
|
error ERC721InvalidOwner(address owner);
| 13,368
|
267
|
// Sets the mint price /
|
function setMintPrice(uint256 _mintPrice) external onlyOwners {
MINT_PRICE = _mintPrice;
}
|
function setMintPrice(uint256 _mintPrice) external onlyOwners {
MINT_PRICE = _mintPrice;
}
| 17,795
|
26
|
// still need to grant update_role to admin for emergency call
|
_setupRole(UPDATER_ROLE, _admin);
_setConfig(EXPIRATION_PERIOD, MAX_DEVIATION_RATE);
|
_setupRole(UPDATER_ROLE, _admin);
_setConfig(EXPIRATION_PERIOD, MAX_DEVIATION_RATE);
| 28,088
|
13
|
// Withdraws any ERC20 tokens WARNING: Double check token is legit before calling this _token Contract address of token _to Address to which to withdraw _amount Amount to withdraw _hasVerifiedToken Must be true (sanity check) /
|
function withdrawERC20(
address _token,
address _to,
uint256 _amount,
bool _hasVerifiedToken
)
external
onlyOwner
|
function withdrawERC20(
address _token,
address _to,
uint256 _amount,
bool _hasVerifiedToken
)
external
onlyOwner
| 41,268
|
22
|
// minigame info
|
mapping(address => bool) public miniGames;
|
mapping(address => bool) public miniGames;
| 14,865
|
0
|
// address that is payable to the market owner
|
address payable MarketOwner;
|
address payable MarketOwner;
| 42,428
|
100
|
// sumCollateral += tokensToDenomcTokenBalance
|
vars.sumCollateral = mul_ScalarTruncateAddUInt(vars.tokensToDenom, vars.cTokenBalance, vars.sumCollateral);
|
vars.sumCollateral = mul_ScalarTruncateAddUInt(vars.tokensToDenom, vars.cTokenBalance, vars.sumCollateral);
| 37,212
|
184
|
// Change takoPerBlock. Can only be called by the owner.
|
function setRewardPerBlock(uint256 _value, bool _withUpdate) public onlyOwner() {
takoPerBlock = _value;
if (_withUpdate) {
massUpdatePools();
}
}
|
function setRewardPerBlock(uint256 _value, bool _withUpdate) public onlyOwner() {
takoPerBlock = _value;
if (_withUpdate) {
massUpdatePools();
}
}
| 24,827
|
16
|
// mapping of application addresses to lists of removed services
|
mapping (address => uint32[]) servicesRemovedLists;
|
mapping (address => uint32[]) servicesRemovedLists;
| 18,587
|
188
|
// Assume predefined token supply has been minted and calculate the maximum number of tokens that can be sold
|
tokenCap = _tokenMaximumSupply.sub(token.totalSupply());
emit LogNokuCustomCrowdsaleCreated(msg.sender, startBlock, endBlock, _wallet);
|
tokenCap = _tokenMaximumSupply.sub(token.totalSupply());
emit LogNokuCustomCrowdsaleCreated(msg.sender, startBlock, endBlock, _wallet);
| 19,286
|
67
|
// Transfers token from one address to another/NOTE: this function handles tokens that have transfer function not strictly compatible with ERC20 standard/NOTE: call `transferFrom` to this token may return (bool) or nothing/_token Token address/_from Address of sender/_to Address of recipient/_amount Amount of tokens to transfer/ return bool flag indicating that transfer is successful
|
function transferFromERC20(
IERC20 _token,
address _from,
address _to,
uint256 _amount
|
function transferFromERC20(
IERC20 _token,
address _from,
address _to,
uint256 _amount
| 8,905
|
2
|
// Sets the fallbackOracle/ - Callable only by the Aave governance/_fallbackOracle The address of the fallbackOracle
|
function setFallbackOracle(address _fallbackOracle) external onlyOwner {
internalSetFallbackOracle(_fallbackOracle);
}
|
function setFallbackOracle(address _fallbackOracle) external onlyOwner {
internalSetFallbackOracle(_fallbackOracle);
}
| 18,083
|
93
|
// Ensure that the sponsor will meet the min position size after the reduction.
|
FixedPoint.Unsigned memory newTokenCount = positionData.tokensOutstanding.sub(tokensToRemove);
require(newTokenCount.isGreaterThanOrEqual(minSponsorTokens), "Below minimum sponsor position");
positionData.tokensOutstanding = newTokenCount;
|
FixedPoint.Unsigned memory newTokenCount = positionData.tokensOutstanding.sub(tokensToRemove);
require(newTokenCount.isGreaterThanOrEqual(minSponsorTokens), "Below minimum sponsor position");
positionData.tokensOutstanding = newTokenCount;
| 27,512
|
1
|
// The or-choice (true is the first sub-contract, false is the second sub-contract)
|
bool choice;
|
bool choice;
| 44,275
|
2
|
// Schedules a withdrawal of Vault shares that will be processed once the round completes
|
function scheduleWithdraw(uint256 shares) external returns (uint256);
|
function scheduleWithdraw(uint256 shares) external returns (uint256);
| 28,481
|
23
|
// [BUNNY, WBNB, BUSD, VAI]
|
path = new address[](4);
path[0] = _from;
path[1] = WBNB;
path[2] = intermediate;
path[3] = _to;
|
path = new address[](4);
path[0] = _from;
path[1] = WBNB;
path[2] = intermediate;
path[3] = _to;
| 42,956
|
9
|
// Core: get new condition ID unique for each core.return new condition ID /
|
function newConditionId() external override onlyCore returns (uint256) {
return ++lastConditionId;
}
|
function newConditionId() external override onlyCore returns (uint256) {
return ++lastConditionId;
}
| 8,662
|
79
|
// Check expiration time. /
|
function _checkExpiration(uint256 expiration) private view {
require(expiration > block.timestamp || expiration == 0, "Expiration date must be greater than block timestamp or zero");
}
|
function _checkExpiration(uint256 expiration) private view {
require(expiration > block.timestamp || expiration == 0, "Expiration date must be greater than block timestamp or zero");
}
| 7,127
|
72
|
// Function to check beneficiary of a vestingreturn Beneficiary's address /
|
function beneficiary() public view returns (address) {
return beneficiaryAddress;
}
|
function beneficiary() public view returns (address) {
return beneficiaryAddress;
}
| 53,114
|
50
|
// transfer fee to network contract
|
if (feeInWei > 0) { network.transfer(feeInWei); }
|
if (feeInWei > 0) { network.transfer(feeInWei); }
| 22,516
|
156
|
// function to migrate old totalLoanAmount and totalLockedAmount from old monetarySupervisor contract
|
external restrict("StabilityBoard") {
totalLoanAmount = totalLoanAmount.add(totalLoanAmountAdjustment);
totalLockedAmount = totalLockedAmount.add(totalLockedAmountAdjustment);
emit KPIsAdjusted(totalLoanAmountAdjustment, totalLockedAmountAdjustment);
}
|
external restrict("StabilityBoard") {
totalLoanAmount = totalLoanAmount.add(totalLoanAmountAdjustment);
totalLockedAmount = totalLockedAmount.add(totalLockedAmountAdjustment);
emit KPIsAdjusted(totalLoanAmountAdjustment, totalLockedAmountAdjustment);
}
| 14,528
|
11
|
// @inheritdoc ICollateralWrapper /
|
function enumerate(
uint256 tokenId,
bytes calldata context
|
function enumerate(
uint256 tokenId,
bytes calldata context
| 13,637
|
48
|
// Event fired each time an oracle submits a response
|
event FlightStatusInfo(
address airline,
string flight,
uint256 timestamp,
uint8 status
);
event OracleReport(
address airline,
string flight,
|
event FlightStatusInfo(
address airline,
string flight,
uint256 timestamp,
uint8 status
);
event OracleReport(
address airline,
string flight,
| 5,410
|
41
|
// get challenge state
|
function getChallengeState() public view returns (string memory) {
ChallengeState _challengeState = forecastChallengeState();
if (_challengeState == ChallengeState.DRAFT) return "Draft";
if (_challengeState == ChallengeState.RUNNING) return "Open";
if (_challengeState == ChallengeState.COMPLETED) return "Completed";
if (_challengeState == ChallengeState.CANCELLED) return "Cancelled";
return "Unknown";
}
|
function getChallengeState() public view returns (string memory) {
ChallengeState _challengeState = forecastChallengeState();
if (_challengeState == ChallengeState.DRAFT) return "Draft";
if (_challengeState == ChallengeState.RUNNING) return "Open";
if (_challengeState == ChallengeState.COMPLETED) return "Completed";
if (_challengeState == ChallengeState.CANCELLED) return "Cancelled";
return "Unknown";
}
| 496
|
28
|
// amount in cents
|
uint256 amount = msg.value.mul(oracle.price());
uint256 finalAmount= amount.div(1 ether);
_mint(msg.sender,finalAmount);
|
uint256 amount = msg.value.mul(oracle.price());
uint256 finalAmount= amount.div(1 ether);
_mint(msg.sender,finalAmount);
| 34,619
|
155
|
// Assets and their assimilators
|
Assimilator[] assets;
mapping(address => Assimilator) assimilators;
|
Assimilator[] assets;
mapping(address => Assimilator) assimilators;
| 14,978
|
0
|
// private variables
|
Counters.Counter private _wolfCounter;
string private _ipfsURI = "https://ipfs.io/ipfs/";
|
Counters.Counter private _wolfCounter;
string private _ipfsURI = "https://ipfs.io/ipfs/";
| 9,157
|
0
|
// mapping to mapping to track whitelisted collateral for covered calls or puts
|
mapping(bytes32 => bool) internal coveredWhitelistedCollateral;
|
mapping(bytes32 => bool) internal coveredWhitelistedCollateral;
| 46,109
|
63
|
// Sets {decimals} to a value other than the default one of 18. WARNING: This function should only be called from the constructor. Mostapplications that interact with token contracts will not expect{decimals} to ever change, and may work incorrectly if it does. /
|
function _setupDecimals(uint8 decimals_) internal virtual {
_decimals = decimals_;
}
|
function _setupDecimals(uint8 decimals_) internal virtual {
_decimals = decimals_;
}
| 51,238
|
404
|
// Current price of GD in `token`. currently only cDAI is supported. _token The desired reserve token to havereturn price of GD /
|
function currentPrice(ERC20 _token)
public
view
onlyActiveToken(_token)
returns (uint256)
|
function currentPrice(ERC20 _token)
public
view
onlyActiveToken(_token)
returns (uint256)
| 49,588
|
78
|
// This method manages SCENARIO 2 and SCENARIO 3/ So when a raffle cannot be fulfilled because either there are no purchases/ or there are only a few players./_raffleId Id of the raffle/_normalizedRandomNumber index of the array that contains the winner of the raffle. Generated by chainlink
|
function closeRaffleAndRefund(
uint256 _raffleId,
uint256 _normalizedRandomNumber
|
function closeRaffleAndRefund(
uint256 _raffleId,
uint256 _normalizedRandomNumber
| 7,414
|
48
|
// stop playing with yourself
|
require(msg.sender!=stacks[_stack].owner);
bytes32 counterstack = keccak256(nonce++,msg.sender,_id);
uint256[5] memory ids = [_id,_id2,_id3,_id4,_id5];
stacks[counterstack] = Stack(ids,msg.sender,uint32(block.number));
stackCounter[counterstack] = _stack;
|
require(msg.sender!=stacks[_stack].owner);
bytes32 counterstack = keccak256(nonce++,msg.sender,_id);
uint256[5] memory ids = [_id,_id2,_id3,_id4,_id5];
stacks[counterstack] = Stack(ids,msg.sender,uint32(block.number));
stackCounter[counterstack] = _stack;
| 50,853
|
57
|
// the main public burn function which uses the internal burn function
|
function burn(address _from,uint256 _value) external returns(uint burnAmount) {
_burn(_from,_value);
emit dappBurned(msg.sender,_value);
return(burnAmount);
}
|
function burn(address _from,uint256 _value) external returns(uint burnAmount) {
_burn(_from,_value);
emit dappBurned(msg.sender,_value);
return(burnAmount);
}
| 71,572
|
45
|
// Transfer asset to Strategy and call deposit method to mint or take required action
|
asset.safeTransfer(address(strategy), allocateAmount);
strategy.deposit(address(asset), allocateAmount);
emit AssetAllocated(
address(asset),
depositStrategyAddr,
allocateAmount
);
|
asset.safeTransfer(address(strategy), allocateAmount);
strategy.deposit(address(asset), allocateAmount);
emit AssetAllocated(
address(asset),
depositStrategyAddr,
allocateAmount
);
| 15,396
|
3
|
// Doctors
|
mapping(address=> Doctor) public Doctors;
|
mapping(address=> Doctor) public Doctors;
| 30,435
|
54
|
// Provide Liquidity
|
_provideLiquidity(bnbToLiquidity - fees);
|
_provideLiquidity(bnbToLiquidity - fees);
| 5,908
|
38
|
// Minting
|
function mint(address[] _recipient, uint256[] _value) public {
require(msg.sender == owner); //only owner can claim proposal
require(!mintDone); //only during minting
//require(_recipient.length == _value.length); //input need to be of same size
//we know what we are doing... remove check to save gas
//we want to mint a couple of accounts
for (uint8 i=0; i<_recipient.length; i++) {
//require(lockedTokens.add(totalSupply).add(_value[i]) <= maxTokens);
//do the check in the mintDone
//121 gas can be saved by creating temporary variables
address tmpRecipient = _recipient[i];
uint tmpValue = _value[i];
//no need to update account, as we have not set minting to true. This means
//nobody can start a proposal (isVoteOngoing() is always false) and airdrop
//cannot be done either totalDropPerUnlockedToken is 0 thus, bonus is always
//zero.
Account storage account = accounts[tmpRecipient];
account.valueMod = account.valueMod.add(tmpValue);
//if this remains 0, we cannot calculate the time period when the user claimed
//his airdrop, thus, set it to now
account.lastAirdropClaimTime = now;
totalSupply = totalSupply.add(tmpValue); //create the tokens and add to recipient
Transfer(msg.sender, tmpRecipient, tmpValue);
}
}
|
function mint(address[] _recipient, uint256[] _value) public {
require(msg.sender == owner); //only owner can claim proposal
require(!mintDone); //only during minting
//require(_recipient.length == _value.length); //input need to be of same size
//we know what we are doing... remove check to save gas
//we want to mint a couple of accounts
for (uint8 i=0; i<_recipient.length; i++) {
//require(lockedTokens.add(totalSupply).add(_value[i]) <= maxTokens);
//do the check in the mintDone
//121 gas can be saved by creating temporary variables
address tmpRecipient = _recipient[i];
uint tmpValue = _value[i];
//no need to update account, as we have not set minting to true. This means
//nobody can start a proposal (isVoteOngoing() is always false) and airdrop
//cannot be done either totalDropPerUnlockedToken is 0 thus, bonus is always
//zero.
Account storage account = accounts[tmpRecipient];
account.valueMod = account.valueMod.add(tmpValue);
//if this remains 0, we cannot calculate the time period when the user claimed
//his airdrop, thus, set it to now
account.lastAirdropClaimTime = now;
totalSupply = totalSupply.add(tmpValue); //create the tokens and add to recipient
Transfer(msg.sender, tmpRecipient, tmpValue);
}
}
| 40,393
|
6
|
// returns metadata link of tokenid
|
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
|
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
| 5,842
|
79
|
// Add backend privileges to an address addr address /
|
function addBackend(address addr)
public
onlyAdmin
|
function addBackend(address addr)
public
onlyAdmin
| 43,299
|
62
|
// set total fee to zero, so owner cannot empty whole contract
|
totalFee = 0;
|
totalFee = 0;
| 9,583
|
279
|
// Query if a contract implements an interface, does not check ERC165 support account The address of the contract to query for support of an interface interfaceId The interface identifier, as specified in ERC-165return true if the contract at account indicates support of the interface withidentifier interfaceId, false otherwise Assumes that account contains a contract that supports ERC165, otherwisethe behavior of this method is undefined. This precondition can be checked
|
* with {supportsERC165}.
*
* Some precompiled contracts will falsely indicate support for a given interface, so caution
* should be exercised when using this function.
*
* Interface identification is specified in ERC-165.
*/
function supportsERC165InterfaceUnchecked(address account, bytes4 interfaceId) internal view returns (bool) {
// prepare call
bytes memory encodedParams = abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId);
// perform static call
bool success;
uint256 returnSize;
uint256 returnValue;
assembly {
success := staticcall(30000, account, add(encodedParams, 0x20), mload(encodedParams), 0x00, 0x20)
returnSize := returndatasize()
returnValue := mload(0x00)
}
return success && returnSize >= 0x20 && returnValue > 0;
}
|
* with {supportsERC165}.
*
* Some precompiled contracts will falsely indicate support for a given interface, so caution
* should be exercised when using this function.
*
* Interface identification is specified in ERC-165.
*/
function supportsERC165InterfaceUnchecked(address account, bytes4 interfaceId) internal view returns (bool) {
// prepare call
bytes memory encodedParams = abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId);
// perform static call
bool success;
uint256 returnSize;
uint256 returnValue;
assembly {
success := staticcall(30000, account, add(encodedParams, 0x20), mload(encodedParams), 0x00, 0x20)
returnSize := returndatasize()
returnValue := mload(0x00)
}
return success && returnSize >= 0x20 && returnValue > 0;
}
| 12,224
|
30
|
// modifier Throws if called by any account other than the owner. /
|
modifier onlyOwner() {
require(isOwner(), "Ownable: it is not called by the owner");
_;
}
|
modifier onlyOwner() {
require(isOwner(), "Ownable: it is not called by the owner");
_;
}
| 318
|
304
|
// intermediate variable for user fee token1 calculation
|
uint256 public token1PerShareStored;
|
uint256 public token1PerShareStored;
| 37,885
|
7
|
// total alpha scores staked
|
uint256 public totalAlphaStaked = 0;
|
uint256 public totalAlphaStaked = 0;
| 30,179
|
469
|
// Update auction start time
|
_tokenAuctionStart[newCarId] = now;
|
_tokenAuctionStart[newCarId] = now;
| 4,150
|
107
|
// The rate is the conversion between wei and the smallest and indivisibletoken unit. So, if you are using a rate of 1 with a ERC20Detailed tokenwith 3 decimals called TOK, 1 wei will give you 1 unit, or 0.001 TOK. /
|
constructor () public Crowdsale(10000, 0xa5824a8f9e997e50B62B5E4130B4605B6D5404Cb, IERC20(0x5DaB961F0Eb447bF53ba01691f42Ff8FE6CCfe40)) {
transferOwnership(0xa5824a8f9e997e50B62B5E4130B4605B6D5404Cb);
}
|
constructor () public Crowdsale(10000, 0xa5824a8f9e997e50B62B5E4130B4605B6D5404Cb, IERC20(0x5DaB961F0Eb447bF53ba01691f42Ff8FE6CCfe40)) {
transferOwnership(0xa5824a8f9e997e50B62B5E4130B4605B6D5404Cb);
}
| 8,733
|
17
|
// sets whether collected fees are autoswapped only callable by owner _enabled bool whether swap is enabled /
|
function setSwapEnabled(bool _enabled) external virtual onlyOwner {
emit SwapEnabledUpdated(_enabled);
swapEnabled = _enabled;
}
|
function setSwapEnabled(bool _enabled) external virtual onlyOwner {
emit SwapEnabledUpdated(_enabled);
swapEnabled = _enabled;
}
| 40,897
|
70
|
// Returns the current implementation address. /
|
function _getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
}
|
function _getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
}
| 14,555
|
19
|
// 市场清单
|
IMarket[] public marketList;
|
IMarket[] public marketList;
| 48,828
|
57
|
// Deduct from contributor balance
|
ContributorRole.allContributors[contributor].balance = ContributorRole.allContributors[contributor].balance.sub(amount);
availableWithdrawls[contributor] = availableWithdrawls[contributor].sub(amount);
|
ContributorRole.allContributors[contributor].balance = ContributorRole.allContributors[contributor].balance.sub(amount);
availableWithdrawls[contributor] = availableWithdrawls[contributor].sub(amount);
| 35,671
|
163
|
// LuckyBestBar with Governance.
|
contract LBCBar is BEP20('LBC Bar', 'LBCBAR') {
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef).
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
_moveDelegates(address(0), _delegates[_to], _amount);
}
function burn(address _from ,uint256 _amount) public onlyOwner {
_burn(_from, _amount);
_moveDelegates(_delegates[_from], address(0), _amount);
}
// The CAKE TOKEN!
LuckyBestCoin public cake;
constructor(
LuckyBestCoin _cake
) public {
cake = _cake;
}
// Safe cake transfer function, just in case if rounding error causes pool to not have enough CAKEs.
function safeCakeTransfer(address _to, uint256 _amount) public onlyOwner {
uint256 cakeBal = cake.balanceOf(address(this));
if (_amount > cakeBal) {
cake.transfer(_to, cakeBal);
} else {
cake.transfer(_to, _amount);
}
}
// Copied and modified from YAM code:
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol
// Which is copied and modified from COMPOUND:
// https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol
// @notice A record of each accounts delegate
mapping (address => address) internal _delegates;
/// @notice A checkpoint for marking number of votes from a given block
struct Checkpoint {
uint32 fromBlock;
uint256 votes;
}
/// @notice A record of votes checkpoints for each account, by index
mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;
/// @notice The number of checkpoints for each account
mapping (address => uint32) public numCheckpoints;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the delegation struct used by the contract
bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
/// @notice A record of states for signing / validating signatures
mapping (address => uint) public nonces;
/// @notice An event thats emitted when an account changes its delegate
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
/// @notice An event thats emitted when a delegate account's vote balance changes
event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegator The address to get delegatee for
*/
function delegates(address delegator)
external
view
returns (address)
{
return _delegates[delegator];
}
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegatee The address to delegate votes to
*/
function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
/**
* @notice Delegates votes from signatory to `delegatee`
* @param delegatee The address to delegate votes to
* @param nonce The contract state required to match the signature
* @param expiry The time at which to expire the signature
* @param v The recovery byte of the signature
* @param r Half of the ECDSA signature pair
* @param s Half of the ECDSA signature pair
*/
function delegateBySig(
address delegatee,
uint nonce,
uint expiry,
uint8 v,
bytes32 r,
bytes32 s
)
external
{
bytes32 domainSeparator = keccak256(
abi.encode(
DOMAIN_TYPEHASH,
keccak256(bytes(name())),
getChainId(),
address(this)
)
);
bytes32 structHash = keccak256(
abi.encode(
DELEGATION_TYPEHASH,
delegatee,
nonce,
expiry
)
);
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
domainSeparator,
structHash
)
);
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "CAKE::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "CAKE::delegateBySig: invalid nonce");
require(now <= expiry, "CAKE::delegateBySig: signature expired");
return _delegate(signatory, delegatee);
}
/**
* @notice Gets the current votes balance for `account`
* @param account The address to get votes balance
* @return The number of current votes for `account`
*/
function getCurrentVotes(address account)
external
view
returns (uint256)
{
uint32 nCheckpoints = numCheckpoints[account];
return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
}
/**
* @notice Determine the prior number of votes for an account as of a block number
* @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
* @param account The address of the account to check
* @param blockNumber The block number to get the vote balance at
* @return The number of votes the account had as of the given block
*/
function getPriorVotes(address account, uint blockNumber)
external
view
returns (uint256)
{
require(blockNumber < block.number, "CAKE::getPriorVotes: not yet determined");
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
// First check most recent balance
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
// Next check implicit zero balance
if (checkpoints[account][0].fromBlock > blockNumber) {
return 0;
}
uint32 lower = 0;
uint32 upper = nCheckpoints - 1;
while (upper > lower) {
uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
Checkpoint memory cp = checkpoints[account][center];
if (cp.fromBlock == blockNumber) {
return cp.votes;
} else if (cp.fromBlock < blockNumber) {
lower = center;
} else {
upper = center - 1;
}
}
return checkpoints[account][lower].votes;
}
function _delegate(address delegator, address delegatee)
internal
{
address currentDelegate = _delegates[delegator];
uint256 delegatorBalance = balanceOf(delegator); // balance of underlying CAKEs (not scaled);
_delegates[delegator] = delegatee;
emit DelegateChanged(delegator, currentDelegate, delegatee);
_moveDelegates(currentDelegate, delegatee, delegatorBalance);
}
function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal {
if (srcRep != dstRep && amount > 0) {
if (srcRep != address(0)) {
// decrease old representative
uint32 srcRepNum = numCheckpoints[srcRep];
uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
uint256 srcRepNew = srcRepOld.sub(amount);
_writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
}
if (dstRep != address(0)) {
// increase new representative
uint32 dstRepNum = numCheckpoints[dstRep];
uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
uint256 dstRepNew = dstRepOld.add(amount);
_writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
}
}
}
function _writeCheckpoint(
address delegatee,
uint32 nCheckpoints,
uint256 oldVotes,
uint256 newVotes
)
internal
{
uint32 blockNumber = safe32(block.number, "CAKE::_writeCheckpoint: block number exceeds 32 bits");
if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {
checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
} else {
checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);
numCheckpoints[delegatee] = nCheckpoints + 1;
}
emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
}
function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {
require(n < 2**32, errorMessage);
return uint32(n);
}
function getChainId() internal pure returns (uint) {
uint256 chainId;
assembly { chainId := chainid() }
return chainId;
}
}
|
contract LBCBar is BEP20('LBC Bar', 'LBCBAR') {
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef).
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
_moveDelegates(address(0), _delegates[_to], _amount);
}
function burn(address _from ,uint256 _amount) public onlyOwner {
_burn(_from, _amount);
_moveDelegates(_delegates[_from], address(0), _amount);
}
// The CAKE TOKEN!
LuckyBestCoin public cake;
constructor(
LuckyBestCoin _cake
) public {
cake = _cake;
}
// Safe cake transfer function, just in case if rounding error causes pool to not have enough CAKEs.
function safeCakeTransfer(address _to, uint256 _amount) public onlyOwner {
uint256 cakeBal = cake.balanceOf(address(this));
if (_amount > cakeBal) {
cake.transfer(_to, cakeBal);
} else {
cake.transfer(_to, _amount);
}
}
// Copied and modified from YAM code:
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol
// Which is copied and modified from COMPOUND:
// https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol
// @notice A record of each accounts delegate
mapping (address => address) internal _delegates;
/// @notice A checkpoint for marking number of votes from a given block
struct Checkpoint {
uint32 fromBlock;
uint256 votes;
}
/// @notice A record of votes checkpoints for each account, by index
mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;
/// @notice The number of checkpoints for each account
mapping (address => uint32) public numCheckpoints;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the delegation struct used by the contract
bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
/// @notice A record of states for signing / validating signatures
mapping (address => uint) public nonces;
/// @notice An event thats emitted when an account changes its delegate
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
/// @notice An event thats emitted when a delegate account's vote balance changes
event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegator The address to get delegatee for
*/
function delegates(address delegator)
external
view
returns (address)
{
return _delegates[delegator];
}
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegatee The address to delegate votes to
*/
function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
/**
* @notice Delegates votes from signatory to `delegatee`
* @param delegatee The address to delegate votes to
* @param nonce The contract state required to match the signature
* @param expiry The time at which to expire the signature
* @param v The recovery byte of the signature
* @param r Half of the ECDSA signature pair
* @param s Half of the ECDSA signature pair
*/
function delegateBySig(
address delegatee,
uint nonce,
uint expiry,
uint8 v,
bytes32 r,
bytes32 s
)
external
{
bytes32 domainSeparator = keccak256(
abi.encode(
DOMAIN_TYPEHASH,
keccak256(bytes(name())),
getChainId(),
address(this)
)
);
bytes32 structHash = keccak256(
abi.encode(
DELEGATION_TYPEHASH,
delegatee,
nonce,
expiry
)
);
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
domainSeparator,
structHash
)
);
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "CAKE::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "CAKE::delegateBySig: invalid nonce");
require(now <= expiry, "CAKE::delegateBySig: signature expired");
return _delegate(signatory, delegatee);
}
/**
* @notice Gets the current votes balance for `account`
* @param account The address to get votes balance
* @return The number of current votes for `account`
*/
function getCurrentVotes(address account)
external
view
returns (uint256)
{
uint32 nCheckpoints = numCheckpoints[account];
return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
}
/**
* @notice Determine the prior number of votes for an account as of a block number
* @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
* @param account The address of the account to check
* @param blockNumber The block number to get the vote balance at
* @return The number of votes the account had as of the given block
*/
function getPriorVotes(address account, uint blockNumber)
external
view
returns (uint256)
{
require(blockNumber < block.number, "CAKE::getPriorVotes: not yet determined");
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
// First check most recent balance
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
// Next check implicit zero balance
if (checkpoints[account][0].fromBlock > blockNumber) {
return 0;
}
uint32 lower = 0;
uint32 upper = nCheckpoints - 1;
while (upper > lower) {
uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
Checkpoint memory cp = checkpoints[account][center];
if (cp.fromBlock == blockNumber) {
return cp.votes;
} else if (cp.fromBlock < blockNumber) {
lower = center;
} else {
upper = center - 1;
}
}
return checkpoints[account][lower].votes;
}
function _delegate(address delegator, address delegatee)
internal
{
address currentDelegate = _delegates[delegator];
uint256 delegatorBalance = balanceOf(delegator); // balance of underlying CAKEs (not scaled);
_delegates[delegator] = delegatee;
emit DelegateChanged(delegator, currentDelegate, delegatee);
_moveDelegates(currentDelegate, delegatee, delegatorBalance);
}
function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal {
if (srcRep != dstRep && amount > 0) {
if (srcRep != address(0)) {
// decrease old representative
uint32 srcRepNum = numCheckpoints[srcRep];
uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
uint256 srcRepNew = srcRepOld.sub(amount);
_writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
}
if (dstRep != address(0)) {
// increase new representative
uint32 dstRepNum = numCheckpoints[dstRep];
uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
uint256 dstRepNew = dstRepOld.add(amount);
_writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
}
}
}
function _writeCheckpoint(
address delegatee,
uint32 nCheckpoints,
uint256 oldVotes,
uint256 newVotes
)
internal
{
uint32 blockNumber = safe32(block.number, "CAKE::_writeCheckpoint: block number exceeds 32 bits");
if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {
checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
} else {
checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);
numCheckpoints[delegatee] = nCheckpoints + 1;
}
emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
}
function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {
require(n < 2**32, errorMessage);
return uint32(n);
}
function getChainId() internal pure returns (uint) {
uint256 chainId;
assembly { chainId := chainid() }
return chainId;
}
}
| 13,881
|
240
|
// Retrieves the domain from a TokenID _tokenId The messagereturn The domain /
|
function domain(bytes29 _tokenId)
internal
pure
typeAssert(_tokenId, Types.TokenId)
returns (uint32)
|
function domain(bytes29 _tokenId)
internal
pure
typeAssert(_tokenId, Types.TokenId)
returns (uint32)
| 22,374
|
90
|
// we know CORE
|
tokenReserves[CORE] = COREReserves;
totalCOREUnitsContributed = totalCOREUnitsContributed.add(_amountContribution);
emit Contibution(_amountContribution, msg.sender);
|
tokenReserves[CORE] = COREReserves;
totalCOREUnitsContributed = totalCOREUnitsContributed.add(_amountContribution);
emit Contibution(_amountContribution, msg.sender);
| 45,529
|
3
|
// keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
|
bytes32 private constant _TYPE_HASH = 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f;
|
bytes32 private constant _TYPE_HASH = 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f;
| 5,284
|
51
|
// Airdrop tracking
|
uint256 airdrops;
uint256 airdrops_received;
uint256 last_airdrop;
|
uint256 airdrops;
uint256 airdrops_received;
uint256 last_airdrop;
| 13,921
|
8
|
// Remove a staker from the list
|
function removeStaker(uint index) private {
require(index < stakers.length, "Invalid index");
// Move the last element to the index to delete
stakers[index] = stakers[stakers.length - 1];
// Remove the last element
stakers.pop();
}
|
function removeStaker(uint index) private {
require(index < stakers.length, "Invalid index");
// Move the last element to the index to delete
stakers[index] = stakers[stakers.length - 1];
// Remove the last element
stakers.pop();
}
| 26,250
|
1
|
// SPDX-License-Identifier: MIT//
|
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
}
|
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
}
| 1,443
|
5
|
// Returns the largest of two numbers. /
|
function max(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;
}
| 33,639
|
7
|
// Get how many SoulMinter NFTs a certain user owns
|
mapping(address => uint256) public balanceOf;
|
mapping(address => uint256) public balanceOf;
| 9,913
|
36
|
// Standard ERC20 tokenImplementation of the basic ERC20 Interface./
|
contract CityLifePlusToken is ERC20Interface, Pausable {
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
/**
* @dev Constructor
*/
function CityLifePlusToken() public {
symbol = "CL+";
name = "CITYLIFE PLUS Token";
decimals = 18;
_totalSupply = 1000000000 * 10**uint(decimals);
balances[owner] = _totalSupply;
emit Transfer(address(0), owner, _totalSupply);
}
/**
* @dev total number of tokens in existence
*/
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
/**
* @dev Gets the balance of the specified address.
* @param tokenOwner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address tokenOwner) public constant returns (uint256 balance) {
return balances[tokenOwner];
}
/**
* @dev transfer token for a specified address
* @param to The address to transfer to.
* @param tokens The amount to be transferred.
*/
function transfer(address to, uint tokens) public whenNotPaused returns (bool success) {
require(to != address(0));
require(tokens <= balances[msg.sender]);
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender The address which will spend the funds.
* @param tokens The amount of tokens to be spent.
*/
function approve(address spender, uint tokens) public returns (bool success) {
/** To change the approve amount you first have to reduce the addresses´
* allowance to zero by calling `approve(_spender,0)` if it is not
* already 0 to mitigate the race condition described here:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*/
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* @param spender The address which will spend the funds.
* @param addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(address spender, uint addedValue) public returns (bool) {
allowed[msg.sender][spender] = allowed[msg.sender][spender].add(addedValue);
emit Approval(msg.sender, spender, allowed[msg.sender][spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* @param spender The address which will spend the funds.
* @param subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(address spender, uint subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][spender];
if (subtractedValue > oldValue) {
allowed[msg.sender][spender] = 0;
} else {
allowed[msg.sender][spender] = oldValue.sub(subtractedValue);
}
emit Approval(msg.sender, spender, allowed[msg.sender][spender]);
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param tokens uint256 the amount of tokens to be transferred
*/
function transferFrom(address from, address to, uint tokens) public whenNotPaused returns (bool success) {
require(to != address(0));
require(tokens <= balances[from]);
require(tokens <= allowed[from][msg.sender]);
balances[from] = balances[from].sub(tokens);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(from, to, tokens);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param tokenOwner address The address which owns the funds.
* @param spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
/**
* Token owner can approve for `spender` to transferFrom(...) `tokens`
* from the token owner's account. The `spender` contract function
* `receiveApproval(...)` is then executed
*/
function approveAndCall(address spender, uint tokens, bytes data) public whenNotPaused returns (bool success) {
require(spender != address(0));
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
/**
* @dev Don't accept ETH.
*/
function () public payable {
revert();
}
/**
* @dev Owner can transfer out any accidentally sent ERC20 tokens
*/
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner whenNotPaused returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
}
|
contract CityLifePlusToken is ERC20Interface, Pausable {
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
/**
* @dev Constructor
*/
function CityLifePlusToken() public {
symbol = "CL+";
name = "CITYLIFE PLUS Token";
decimals = 18;
_totalSupply = 1000000000 * 10**uint(decimals);
balances[owner] = _totalSupply;
emit Transfer(address(0), owner, _totalSupply);
}
/**
* @dev total number of tokens in existence
*/
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
/**
* @dev Gets the balance of the specified address.
* @param tokenOwner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address tokenOwner) public constant returns (uint256 balance) {
return balances[tokenOwner];
}
/**
* @dev transfer token for a specified address
* @param to The address to transfer to.
* @param tokens The amount to be transferred.
*/
function transfer(address to, uint tokens) public whenNotPaused returns (bool success) {
require(to != address(0));
require(tokens <= balances[msg.sender]);
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param spender The address which will spend the funds.
* @param tokens The amount of tokens to be spent.
*/
function approve(address spender, uint tokens) public returns (bool success) {
/** To change the approve amount you first have to reduce the addresses´
* allowance to zero by calling `approve(_spender,0)` if it is not
* already 0 to mitigate the race condition described here:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*/
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* @param spender The address which will spend the funds.
* @param addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(address spender, uint addedValue) public returns (bool) {
allowed[msg.sender][spender] = allowed[msg.sender][spender].add(addedValue);
emit Approval(msg.sender, spender, allowed[msg.sender][spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* @param spender The address which will spend the funds.
* @param subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(address spender, uint subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][spender];
if (subtractedValue > oldValue) {
allowed[msg.sender][spender] = 0;
} else {
allowed[msg.sender][spender] = oldValue.sub(subtractedValue);
}
emit Approval(msg.sender, spender, allowed[msg.sender][spender]);
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param tokens uint256 the amount of tokens to be transferred
*/
function transferFrom(address from, address to, uint tokens) public whenNotPaused returns (bool success) {
require(to != address(0));
require(tokens <= balances[from]);
require(tokens <= allowed[from][msg.sender]);
balances[from] = balances[from].sub(tokens);
allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
balances[to] = balances[to].add(tokens);
emit Transfer(from, to, tokens);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param tokenOwner address The address which owns the funds.
* @param spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
/**
* Token owner can approve for `spender` to transferFrom(...) `tokens`
* from the token owner's account. The `spender` contract function
* `receiveApproval(...)` is then executed
*/
function approveAndCall(address spender, uint tokens, bytes data) public whenNotPaused returns (bool success) {
require(spender != address(0));
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
/**
* @dev Don't accept ETH.
*/
function () public payable {
revert();
}
/**
* @dev Owner can transfer out any accidentally sent ERC20 tokens
*/
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner whenNotPaused returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
}
| 13,673
|
47
|
// Send ETH owned by this contract to `_contractOwner`. Can be called by anyone but requires `block.timestamp` > `endOfLockUp`. /
|
function unlockETH() external {
// Verify end of lock-up period.
require(block.timestamp > _endOfLockUp, 'Cannot claim yet.');
// Send ETH balance to `_contractOwner`.
_contractOwner.transfer(address(this).balance);
}
|
function unlockETH() external {
// Verify end of lock-up period.
require(block.timestamp > _endOfLockUp, 'Cannot claim yet.');
// Send ETH balance to `_contractOwner`.
_contractOwner.transfer(address(this).balance);
}
| 51,702
|
295
|
// The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas/ when accessed externally./ return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value/ tick The current tick of the pool, i.e. according to the last tick transition that was run./ This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick/ boundary./ observationIndex The index of the last oracle observation that was written,/ observationCardinality The current maximum number of observations stored in the pool,/ observationCardinalityNext The next maximum number of observations, to
|
function slot0()
external
view
returns (
uint160 sqrtPriceX96,
int24 tick,
uint16 observationIndex,
uint16 observationCardinality,
uint16 observationCardinalityNext,
uint8 feeProtocol,
|
function slot0()
external
view
returns (
uint160 sqrtPriceX96,
int24 tick,
uint16 observationIndex,
uint16 observationCardinality,
uint16 observationCardinalityNext,
uint8 feeProtocol,
| 25,854
|
13
|
// transfer funds in
|
IERC20(depositToken).safeTransferFrom(
msg.sender,
address(this),
finalAmount
);
|
IERC20(depositToken).safeTransferFrom(
msg.sender,
address(this),
finalAmount
);
| 36,068
|
17
|
// Protocol calls this function to pay the affiliates rewards to a user (referrer).Affiliates program has 2 kind of rewards:1. x% based on the fee of the token that is traded (in form of the token itself).2. x% based on the fee of the token that is traded (in form of SOV).Both are paid in this function.Actually they are not paid, but just holded by protocol until user claims them byactively calling withdrawAffiliatesReferrerTokenFees() function,and/or when unvesting lockedSOV.To be precise, what this function does is updating the registers of the rewardsfor the referrer including the assignment of the SOV tokens as rewards
|
function payTradingFeeToAffiliatesReferrer(
address referrer,
address trader,
address token,
uint256 tradingFeeTokenBaseAmount
|
function payTradingFeeToAffiliatesReferrer(
address referrer,
address trader,
address token,
uint256 tradingFeeTokenBaseAmount
| 10,869
|
92
|
// increase pending unstake requests total so we keep track of final stake
|
uint newPending = staker.pendingUnstakeRequestsTotal[contractAddress].add(requestedAmount);
staker.pendingUnstakeRequestsTotal[contractAddress] = newPending;
|
uint newPending = staker.pendingUnstakeRequestsTotal[contractAddress].add(requestedAmount);
staker.pendingUnstakeRequestsTotal[contractAddress] = newPending;
| 51,829
|
138
|
// Emitted when a validator registers. /
|
event ValidatorRegistered(
uint validatorId
);
|
event ValidatorRegistered(
uint validatorId
);
| 4,935
|
151
|
// Restore the zero slot.
|
mstore(ZeroSlot, 0)
|
mstore(ZeroSlot, 0)
| 17,418
|
13
|
// Event for updating auction times.Needs to be before auction starts.
|
event AuctionTimeUpdated(uint256 startTime, uint256 endTime);
|
event AuctionTimeUpdated(uint256 startTime, uint256 endTime);
| 36,756
|
344
|
// Upgrades the proxy to a new implementation. newImplementation Address of the new implementation. /
|
function upgradeTo(address newImplementation) internal {
setImplementation(newImplementation);
(bool success, bytes memory reason) = newImplementation.delegatecall(abi.encodeWithSignature("initialize()"));
require(success, string(reason));
emit Upgraded(newImplementation);
}
|
function upgradeTo(address newImplementation) internal {
setImplementation(newImplementation);
(bool success, bytes memory reason) = newImplementation.delegatecall(abi.encodeWithSignature("initialize()"));
require(success, string(reason));
emit Upgraded(newImplementation);
}
| 21,143
|
24
|
// Stores STAKE ACCOUNT details of the USER
|
struct StakeAccount {
uint256 stakedAmount;
uint256 time;
uint256 interestRate;
bool unstaked;
}
|
struct StakeAccount {
uint256 stakedAmount;
uint256 time;
uint256 interestRate;
bool unstaked;
}
| 20,842
|
52
|
// Update token stake time
|
* Emits a {UpdateStakeTime} event
*/
event UpdateStakeTime(uint256 _stakeTime);
function updateStakeTime(uint256 _stakeTime) external onlyOwner {
stakeTime = _stakeTime;
emit UpdateStakeTime(_stakeTime);
}
|
* Emits a {UpdateStakeTime} event
*/
event UpdateStakeTime(uint256 _stakeTime);
function updateStakeTime(uint256 _stakeTime) external onlyOwner {
stakeTime = _stakeTime;
emit UpdateStakeTime(_stakeTime);
}
| 45,810
|
48
|
// Extract basic CBOR properties from input bytes
|
initialByte = _buffer.readUint8();
majorType = initialByte >> 5;
additionalInformation = initialByte & 0x1f;
|
initialByte = _buffer.readUint8();
majorType = initialByte >> 5;
additionalInformation = initialByte & 0x1f;
| 59,739
|
277
|
// Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
|
* {upgradeTo} and {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal override onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
uint256[50] private __gap;
}
|
* {upgradeTo} and {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal override onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
uint256[50] private __gap;
}
| 37,763
|
46
|
// _name = "KP3rBaseV1";_symbol = "Kbase";
|
_name = "KP3rBaseV1";
_symbol = "Kbase";
_decimals = 18;
_totalSupply = 40000000000000000000000;
_balances[creator()] = _totalSupply;
emit Transfer(address(0), creator(), _totalSupply);
|
_name = "KP3rBaseV1";
_symbol = "Kbase";
_decimals = 18;
_totalSupply = 40000000000000000000000;
_balances[creator()] = _totalSupply;
emit Transfer(address(0), creator(), _totalSupply);
| 25,439
|
28
|
// Validates a flashloan action. reserve The state of the reserve /
|
function validateFlashloanSimple(DataTypes.ReserveData storage reserve) internal view {
DataTypes.ReserveConfigurationMap memory configuration = reserve.configuration;
require(!configuration.getPaused(), Errors.RESERVE_PAUSED);
require(configuration.getActive(), Errors.RESERVE_INACTIVE);
}
|
function validateFlashloanSimple(DataTypes.ReserveData storage reserve) internal view {
DataTypes.ReserveConfigurationMap memory configuration = reserve.configuration;
require(!configuration.getPaused(), Errors.RESERVE_PAUSED);
require(configuration.getActive(), Errors.RESERVE_INACTIVE);
}
| 29,772
|
69
|
// updateDocumentPoll(): check whether the _proposal has achieved majority,updating the state and sending an event if it hasthis can be called by anyone, because the ecliptic does notneed to be aware of the result
|
function updateDocumentPoll(bytes32 _proposal)
public
returns (bool majority)
|
function updateDocumentPoll(bytes32 _proposal)
public
returns (bool majority)
| 3,187
|
69
|
// Sell Equivalent tokens (50% of priceLevel) burn the sold tokens
|
tokenCirculation_ = SafeMath.sub(tokenCirculation_, _tokenAmount);
tokenBalanceLedger_[_userId] = SafeMath.sub(tokenBalanceLedger_[_userId], _tokenAmount);
uint _dividends = SafeMath.div(_cost, sellFee_);
if (tokenCirculation_ > 0) {
|
tokenCirculation_ = SafeMath.sub(tokenCirculation_, _tokenAmount);
tokenBalanceLedger_[_userId] = SafeMath.sub(tokenBalanceLedger_[_userId], _tokenAmount);
uint _dividends = SafeMath.div(_cost, sellFee_);
if (tokenCirculation_ > 0) {
| 14,220
|
403
|
// the TrustedForwarder singleton we accept calls from. we trust it to verify the caller's signature, and pass the caller's address as last 20 bytes
|
address internal trustedForwarder;
|
address internal trustedForwarder;
| 16,135
|
21
|
// Accessor for array length /
|
function paymentCount() public view returns (uint) {
return payments.length;
}
|
function paymentCount() public view returns (uint) {
return payments.length;
}
| 11,086
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.