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
21
// Lottery
function splitPot() canClearing() private
function splitPot() canClearing() private
4,299
13
// TODO: should not change if not enough proposals
function toVotingState() internal { toState(States.Voting); votingDeadline = block.timestamp + votingLifetime; emit StateChanged(States.Proposal, States.Voting); }
function toVotingState() internal { toState(States.Voting); votingDeadline = block.timestamp + votingLifetime; emit StateChanged(States.Proposal, States.Voting); }
50,749
333
// Need to call again to make sure everything is correct
updateRewardAndBalance(staker_address, false); emit WithdrawLocked(staker_address, liquidity, kek_id, destination_address);
updateRewardAndBalance(staker_address, false); emit WithdrawLocked(staker_address, liquidity, kek_id, destination_address);
12,179
55
// rebalances an existing Basket/First calculates the rewards the basket has built up, then sets the new allocations and communicates the deltas to the vault/Finally it locks or unlocks tokens/_basketId Basket ID (tokenID) in the BasketToken (NFT) contract./_deltaAllocations delta allocations set by the user of the basket. Allocations are scaled (so1E18).
function rebalanceBasket( uint256 _basketId, int256[][] memory _deltaAllocations
function rebalanceBasket( uint256 _basketId, int256[][] memory _deltaAllocations
22,333
187
// Maximum token supply. Reduced to `type(uint96).max` (2^96^ - 1) to fit COMP interface. /
function _maxSupply() internal view virtual override returns (uint224) { return type(uint96).max; }
function _maxSupply() internal view virtual override returns (uint224) { return type(uint96).max; }
26,853
204
// Schedules a WolframAlpha query to Oraclize to determine the winner of the competition. /
function queryWinningTeam(uint256 delay) private { oraclize_query(delay, "WolframAlpha", "FIFA World Cup 2018 Winner"); WinningTeamQuerySent("FIFA World Cup 2018 Winner"); }
function queryWinningTeam(uint256 delay) private { oraclize_query(delay, "WolframAlpha", "FIFA World Cup 2018 Winner"); WinningTeamQuerySent("FIFA World Cup 2018 Winner"); }
66,051
63
// 尚未开始解锁
if (timeRemained >= vesting.term) { return 0; }
if (timeRemained >= vesting.term) { return 0; }
32,059
166
// via https:github.com/oraclize/ethereum-api/blob/master/oraclizeAPI_0.5.sol
function strConcat( string memory _a, string memory _b, string memory _c, string memory _d, string memory _e
function strConcat( string memory _a, string memory _b, string memory _c, string memory _d, string memory _e
50,689
12
// check if mortgage payment if complete, if complete, then release the property
function checkMortgagePayoff(){ if(balances[loan.actorAccounts.mortgageHolder] ==loan.monthlyPayment.pi*12*loan.loanTerms.term && balances[loan.actorAccounts.insurer] ==loan.monthlyPayment.tax*12*loan.loanTerms.term && balances[loan.actorAccounts.irs] ==loan.monthlyPayment.insurance*12*loan.loanTerms.term ){ loan.property.owner = loanApplicant; LienReleased(loan.property.owner); } }
function checkMortgagePayoff(){ if(balances[loan.actorAccounts.mortgageHolder] ==loan.monthlyPayment.pi*12*loan.loanTerms.term && balances[loan.actorAccounts.insurer] ==loan.monthlyPayment.tax*12*loan.loanTerms.term && balances[loan.actorAccounts.irs] ==loan.monthlyPayment.insurance*12*loan.loanTerms.term ){ loan.property.owner = loanApplicant; LienReleased(loan.property.owner); } }
38,418
50
// The total amount of wei given
uint totalWeiGiven;
uint totalWeiGiven;
7,447
129
// Add the ETH and token to LP. The LP tokens will be sent to burnAccount. No one will have access to them, so the liquidity will be locked forever.
_uniswapV2Router.addLiquidityETH{value: ethAmount}(
_uniswapV2Router.addLiquidityETH{value: ethAmount}(
21,709
3
// repay the loan
uint256 amountOwing = amounts[i] + premiums[i]; IERC20(assets[i]).approve(address(POOL), amountOwing);
uint256 amountOwing = amounts[i] + premiums[i]; IERC20(assets[i]).approve(address(POOL), amountOwing);
52,870
183
// returns the maximum stable rate borrow size, in percentage of the available liquidity./
function getMaxStableRateBorrowSizePercent() external pure returns (uint256) { return MAX_STABLE_RATE_BORROW_SIZE_PERCENT; }
function getMaxStableRateBorrowSizePercent() external pure returns (uint256) { return MAX_STABLE_RATE_BORROW_SIZE_PERCENT; }
15,125
31
// Adjust the extraction ratio newRatio The new extraction ratio /
function adjustRatio(uint newRatio) external onlyOwner { require(newRatio <= 1e18, "invalid ratio"); uint oldRatio = ratio; ratio = newRatio; emit RatioUpdated(oldRatio, newRatio); }
function adjustRatio(uint newRatio) external onlyOwner { require(newRatio <= 1e18, "invalid ratio"); uint oldRatio = ratio; ratio = newRatio; emit RatioUpdated(oldRatio, newRatio); }
12,519
67
// Transfer `amount` tokens from `sender` to `recipient` as long as`msg.sender` has sufficient allowance. sender address The account to transfer tokens from. recipient address The account to transfer tokens to. amount uint256 The amount of tokens to transfer.return A boolean indicating whether the transfer was successful. /
function transferFrom( address sender, address recipient, uint256 amount
function transferFrom( address sender, address recipient, uint256 amount
30,760
64
// 设置是否开启
* @param {Object} bool */ function setactive(bool tags) public onlyOwner { actived = tags; }
* @param {Object} bool */ function setactive(bool tags) public onlyOwner { actived = tags; }
18,915
72
// Transfers mintership of the contract to a new account (`newMinter`).Can only be called by the current minter. /
function transferMintership(address newMinter) public virtual onlyMinter { require(newMinter != address(0), "Mintable: new minter is the zero address"); emit MintershipTransferred(_minter, newMinter); _minter = newMinter; }
function transferMintership(address newMinter) public virtual onlyMinter { require(newMinter != address(0), "Mintable: new minter is the zero address"); emit MintershipTransferred(_minter, newMinter); _minter = newMinter; }
41,932
15
// Max number of cars to gift (includes unicorns)
uint256 public constant MAX_CARS_TO_GIFT = 99;
uint256 public constant MAX_CARS_TO_GIFT = 99;
32,132
24
// Returns the platform fee bps and recipient.
function getPlatformFeeInfo() external view returns (address, uint16) { return (platformFeeRecipient, uint16(platformFeeBps)); }
function getPlatformFeeInfo() external view returns (address, uint16) { return (platformFeeRecipient, uint16(platformFeeBps)); }
9,719
91
// if (_addr == address(0)) { _addr == msg.sender; }
uint256 _pID = pIDxAddr_[_addr]; return ( _pID, plyr_[_pID].name, plyr_[_pID].laff, plyr_[_pID].eth, plyr_[_pID].cosd, plyr_[_pID].cosc,
uint256 _pID = pIDxAddr_[_addr]; return ( _pID, plyr_[_pID].name, plyr_[_pID].laff, plyr_[_pID].eth, plyr_[_pID].cosd, plyr_[_pID].cosc,
39,772
1
// Probability in % that a rare variant occurs
uint8 constant RARE_VARIANT_PROBABILITY = 2;
uint8 constant RARE_VARIANT_PROBABILITY = 2;
22,757
6
// frontend calls to add funds to task
function fundTask(uint256 amount) public payable{ amount = amount * 10**18; // require(msg.sender == taskOwner, "Task: Only Task Owner can fund this contract."); // require(TOKEN.balanceOf(msg.sender) >= amount, "Task: insufficient funds."); require(msg.sender.balance >= amount, "Task: insufficient funds."); require(msg.value == amount, "Task: Unmatching funds."); feeCalculations(amount); }
function fundTask(uint256 amount) public payable{ amount = amount * 10**18; // require(msg.sender == taskOwner, "Task: Only Task Owner can fund this contract."); // require(TOKEN.balanceOf(msg.sender) >= amount, "Task: insufficient funds."); require(msg.sender.balance >= amount, "Task: insufficient funds."); require(msg.value == amount, "Task: Unmatching funds."); feeCalculations(amount); }
14,173
5
// By default only owner and parent contract are authorized to call any of the functions with this modifier.That includes SetPermission functions meaning only owner and parent can change permissions.
modifier RestrictedCall() { require(_APICall(msg.sig, msg.sender)); if(true) { _; } }
modifier RestrictedCall() { require(_APICall(msg.sig, msg.sender)); if(true) { _; } }
1,239
2
// The ID of the project to pay when this contract receives funds.
uint256 public immutable override projectId;
uint256 public immutable override projectId;
23,652
17
// Find the owner of an NFT/NFTs assigned to zero address are considered invalid, and queries/about them do throw./_bankID The identifier for an NFT/ return owner_ The address of the owner of the NFT
function ownerOf(uint256 _bankID) external view returns (address owner_) { owner_ = s.banks[_bankID].owner; require(owner_ != address(0), "BankFacet: invalid _bankID"); }
function ownerOf(uint256 _bankID) external view returns (address owner_) { owner_ = s.banks[_bankID].owner; require(owner_ != address(0), "BankFacet: invalid _bankID"); }
17,865
23
// pending onchain txs have not been executed - revert pending deposits and withdrawals back into offchain balances
} else { //txCount[1] > channel.txCount[1]
} else { //txCount[1] > channel.txCount[1]
1,901
18
// verify checkpoint inclusion
_checkBlockMembershipInCheckpoint( blockNumber, payload.getBlockTime(), payload.getTxRoot(), receiptRoot, payload.getHeaderNumber(), payload.getBlockProof() ); ExitPayloadReader.LogTopics memory topics = log.getTopics();
_checkBlockMembershipInCheckpoint( blockNumber, payload.getBlockTime(), payload.getTxRoot(), receiptRoot, payload.getHeaderNumber(), payload.getBlockProof() ); ExitPayloadReader.LogTopics memory topics = log.getTopics();
27,298
51
// uint amount3;
address tokenIn; address tokenOut; assembly{ third32bytes:=calldataload(68) amount2:= and(shr(8,third32bytes),0xffffffffffffffffffffff) needap:=and(third32bytes,0xf0) type2:=and(third32bytes,0x0f) let fourth32bytes:=calldataload(100)
address tokenIn; address tokenOut; assembly{ third32bytes:=calldataload(68) amount2:= and(shr(8,third32bytes),0xffffffffffffffffffffff) needap:=and(third32bytes,0xf0) type2:=and(third32bytes,0x0f) let fourth32bytes:=calldataload(100)
30,065
1
// FIXME: check who is sending the recommendation
ipfs_hash = _ipfs_hash; recipient = _recipient;
ipfs_hash = _ipfs_hash; recipient = _recipient;
40,069
67
// This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployedbehind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to anexternal initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /// @dev Returns true if and only if the function is running in the constructor function _isConstructor() private view returns (bool) { return !Address.isContract(address(this)); } }
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /// @dev Returns true if and only if the function is running in the constructor function _isConstructor() private view returns (bool) { return !Address.isContract(address(this)); } }
517
111
// Emits a {ValidatorWasDisabled} event.Requirements:- Validator must not already be disabled. /
function disableValidator(uint validatorId) external checkValidatorExists(validatorId) onlyAdmin { require(_trustedValidators[validatorId], "Validator is already disabled"); _trustedValidators[validatorId] = false; uint position = _find(trustedValidatorsList, validatorId); if (position < trustedValidatorsList.length) { trustedValidatorsList[position] = trustedValidatorsList[trustedValidatorsList.length.sub(1)]; }
function disableValidator(uint validatorId) external checkValidatorExists(validatorId) onlyAdmin { require(_trustedValidators[validatorId], "Validator is already disabled"); _trustedValidators[validatorId] = false; uint position = _find(trustedValidatorsList, validatorId); if (position < trustedValidatorsList.length) { trustedValidatorsList[position] = trustedValidatorsList[trustedValidatorsList.length.sub(1)]; }
81,575
139
// Whether further changes to the token URI have been disabled.
bool public _isFinalized = false;
bool public _isFinalized = false;
19,339
54
// To be raised when the current ruling is appealed._disputeID ID of the dispute._arbitrable The contract which created the dispute. /
event AppealDecision(uint indexed _disputeID, Arbitrable indexed _arbitrable);
event AppealDecision(uint indexed _disputeID, Arbitrable indexed _arbitrable);
20,508
386
// This funcion allows the contract owner to add more locked distribution tokens, along with the associated "unlock schedule". These locked tokens immediately begin unlocking linearly over the duraction of durationSec timeframe. amount Number of distribution tokens to lock. These are transferred from the caller. durationSec Length of time to linear unlock the tokens. /
function lockTokens(uint256 amount, uint256 durationSec) external onlyOwner
function lockTokens(uint256 amount, uint256 durationSec) external onlyOwner
5,320
57
// triggered when counted
event Counted(address _sender, uint256 _intervals); uint256 constant _day = 24 * 60 * 60 * 1 seconds; bytes5 internal _td = bytes5("day"); bytes5 internal _tw = bytes5("week"); bytes5 internal _tm = bytes5("month"); bytes5 internal _ty = bytes5("year"); uint256 internal _creation;
event Counted(address _sender, uint256 _intervals); uint256 constant _day = 24 * 60 * 60 * 1 seconds; bytes5 internal _td = bytes5("day"); bytes5 internal _tw = bytes5("week"); bytes5 internal _tm = bytes5("month"); bytes5 internal _ty = bytes5("year"); uint256 internal _creation;
49,943
15
// Freezes minting on smart contract forever /
uint8 internal _mintFrozen;
uint8 internal _mintFrozen;
40,491
128
// Propose delisting the tokenAddress from the whitelist.The proposer needs to commit minimum deposit amount. /
function proposeDelistWhitelist(address tokenAddress) external override { bytes32 proposeId = _generateUnregisterWhitelistProposeId( DelistParameters({tokenAddress: tokenAddress}) ); uint32 blockTime = block.timestamp.toUint32(); uint32 preVoteDeadline = blockTime + _preVoteLength; uint32 mainVoteDeadline = blockTime + _totalVoteLength; uint128 appliedMinimumVote = (_taxTokenContract.totalSupply().mul(_minimumVoteE4) / 10**4) .toUint128(); uint128 appliedMinCommit = (_taxTokenContract.totalSupply().mul(_minimumCommitE4) / 10**4) .toUint128(); uint32 expiration = _expirationLength; require( _proposeStatus[proposeId].mainVoteDeadline == 0 || (_proposeStatus[proposeId].lockin == false && _proposeStatus[proposeId].preVoteDeadline + _proposeStatus[proposeId].expiration < block.timestamp) || (_proposeStatus[proposeId].lockin == true && _proposeStatus[proposeId].mainVoteDeadline + _proposeStatus[proposeId].expiration < block.timestamp), "the proposal should not conflict with the ongoing proposal" ); require( _taxTokenContract.getOracleAddress(tokenAddress) != address(0), "the tokenAddress is not whitelisted" ); _proposalList.push(proposeId); _proposeStatus[proposeId] = ProposeStatus({ preVoteDeadline: preVoteDeadline, mainVoteDeadline: mainVoteDeadline, expiration: expiration, appliedMinimumVote: appliedMinimumVote, currentApprovalVoteSum: appliedMinCommit, currentDenialVoteSum: 0, lockin: false, applied: false }); _proposeDelist[proposeId] = DelistParameters({tokenAddress: tokenAddress}); bytes32 account = keccak256(abi.encode(proposeId, msg.sender)); _amountOfVotes[account].approval = _amountOfVotes[account] .approval .add(appliedMinCommit) .toUint128(); _lockStakingToken(msg.sender, appliedMinCommit); emit LogProposeDelistWhiteList( proposeId, tokenAddress, preVoteDeadline, mainVoteDeadline, expiration ); emit LogDeposit(proposeId, msg.sender, true, appliedMinCommit); }
function proposeDelistWhitelist(address tokenAddress) external override { bytes32 proposeId = _generateUnregisterWhitelistProposeId( DelistParameters({tokenAddress: tokenAddress}) ); uint32 blockTime = block.timestamp.toUint32(); uint32 preVoteDeadline = blockTime + _preVoteLength; uint32 mainVoteDeadline = blockTime + _totalVoteLength; uint128 appliedMinimumVote = (_taxTokenContract.totalSupply().mul(_minimumVoteE4) / 10**4) .toUint128(); uint128 appliedMinCommit = (_taxTokenContract.totalSupply().mul(_minimumCommitE4) / 10**4) .toUint128(); uint32 expiration = _expirationLength; require( _proposeStatus[proposeId].mainVoteDeadline == 0 || (_proposeStatus[proposeId].lockin == false && _proposeStatus[proposeId].preVoteDeadline + _proposeStatus[proposeId].expiration < block.timestamp) || (_proposeStatus[proposeId].lockin == true && _proposeStatus[proposeId].mainVoteDeadline + _proposeStatus[proposeId].expiration < block.timestamp), "the proposal should not conflict with the ongoing proposal" ); require( _taxTokenContract.getOracleAddress(tokenAddress) != address(0), "the tokenAddress is not whitelisted" ); _proposalList.push(proposeId); _proposeStatus[proposeId] = ProposeStatus({ preVoteDeadline: preVoteDeadline, mainVoteDeadline: mainVoteDeadline, expiration: expiration, appliedMinimumVote: appliedMinimumVote, currentApprovalVoteSum: appliedMinCommit, currentDenialVoteSum: 0, lockin: false, applied: false }); _proposeDelist[proposeId] = DelistParameters({tokenAddress: tokenAddress}); bytes32 account = keccak256(abi.encode(proposeId, msg.sender)); _amountOfVotes[account].approval = _amountOfVotes[account] .approval .add(appliedMinCommit) .toUint128(); _lockStakingToken(msg.sender, appliedMinCommit); emit LogProposeDelistWhiteList( proposeId, tokenAddress, preVoteDeadline, mainVoteDeadline, expiration ); emit LogDeposit(proposeId, msg.sender, true, appliedMinCommit); }
29,087
7
// Function to grant the USER_ROLE to a specific address account Address of the account to grant role /
function grantUserRole(address account) public { _grantRole(USER_ROLE, account); }
function grantUserRole(address account) public { _grantRole(USER_ROLE, account); }
11,021
283
// @inheritdoc IPopsicleV3Optimizer
address public immutable override token0;
address public immutable override token0;
4,199
21
// uint16 currencyId,uint256 maturity,uint256 settlementDate
MarketParameters memory market = getMarketNoRevert(currencyId,threeMonthMaturity,threeMonthMaturity) ;
MarketParameters memory market = getMarketNoRevert(currencyId,threeMonthMaturity,threeMonthMaturity) ;
33,101
49
// File: contracts/uniswapv2/UniswapV2Factory.sol
pragma solidity =0.6.12; contract UniswapV2Factory is IUniswapV2Factory { address public override feeTo; address public override feeToSetter; address public override migrator;
pragma solidity =0.6.12; contract UniswapV2Factory is IUniswapV2Factory { address public override feeTo; address public override feeToSetter; address public override migrator;
30,990
6
// Initializes the ZRX treasury and creates the default/staking pool./stakingProxy_ The 0x staking proxy contract./params Immutable treasury parameters.
constructor( IStaking stakingProxy_, TreasuryParameters memory params ) public
constructor( IStaking stakingProxy_, TreasuryParameters memory params ) public
14,096
255
// Wrapped Ether address
address internal weth;
address internal weth;
35,879
14
// DotTokenContract /
contract DotTokenContract is ERC20Capped, ERC20Burnable, ERC1363, Roles, TokenRecover, Pausable { // indicates if transfer is enabled bool private _transferEnabled = false; /** * Emitted during transfer enabling */ event TransferEnabled(); /** * Tokens can be moved only after if transfer enabled or if you are an approved operator. */ modifier canTransfer(address from) { require( _transferEnabled || hasRole(OPERATOR_ROLE, from), "DotTokenContract: transfer is not enabled or from does not have the OPERATOR role" ); _; } modifier validDestination( address to ) { require(to != address(0x0)); require(to != address(this) ); _; } constructor( string memory name, string memory symbol, uint8 decimals, uint256 cap, uint256 initialSupply, bool transferEnabled ) public ERC20Capped(cap) ERC1363(name, symbol) { require( cap == initialSupply, "DotTokenContract: cap must be equal to initialSupply" ); _setupDecimals(decimals); if (initialSupply > 0) { _mint(owner(), initialSupply); } if (transferEnabled) { enableTransfer(); } } /** * @return if transfer is enabled or not. */ function transferEnabled() public view returns (bool) { return _transferEnabled; } /** * Transfer tokens to a specified address. * @param to The address to transfer to * @param value The amount to be transferred * @return A boolean that indicates if the operation was successful. */ function transfer(address to, uint256 value) public virtual override(ERC20) validDestination(to) canTransfer(_msgSender()) whenNotPaused returns (bool) { return super.transfer(to, value); } /** * Transfer tokens from one address to another. * @param from The address which you want to send tokens from * @param to The address which you want to transfer to * @param value the amount of tokens to be transferred * @return A boolean that indicates if the operation was successful. */ function transferFrom(address from, address to, uint256 value) public virtual override(ERC20) validDestination(to) canTransfer(from) whenNotPaused returns (bool) { return super.transferFrom(from, to, value); } function approve(address spender, uint256 amount) public virtual override(ERC20) whenNotPaused returns (bool) { return super.approve(spender, amount); } function increaseAllowance(address spender, uint256 addedValue) public virtual override(ERC20) whenNotPaused returns (bool) { return super.increaseAllowance(spender, addedValue); } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual override(ERC20) whenNotPaused returns (bool) { return super.decreaseAllowance(spender, subtractedValue); } /** * Function to enable transfers. */ function enableTransfer() public onlyOwner { _transferEnabled = true; emit TransferEnabled(); } /** * See {ERC20-_beforeTokenTransfer}. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20, ERC20Capped) validDestination(to) { super._beforeTokenTransfer(from, to, amount); } }
contract DotTokenContract is ERC20Capped, ERC20Burnable, ERC1363, Roles, TokenRecover, Pausable { // indicates if transfer is enabled bool private _transferEnabled = false; /** * Emitted during transfer enabling */ event TransferEnabled(); /** * Tokens can be moved only after if transfer enabled or if you are an approved operator. */ modifier canTransfer(address from) { require( _transferEnabled || hasRole(OPERATOR_ROLE, from), "DotTokenContract: transfer is not enabled or from does not have the OPERATOR role" ); _; } modifier validDestination( address to ) { require(to != address(0x0)); require(to != address(this) ); _; } constructor( string memory name, string memory symbol, uint8 decimals, uint256 cap, uint256 initialSupply, bool transferEnabled ) public ERC20Capped(cap) ERC1363(name, symbol) { require( cap == initialSupply, "DotTokenContract: cap must be equal to initialSupply" ); _setupDecimals(decimals); if (initialSupply > 0) { _mint(owner(), initialSupply); } if (transferEnabled) { enableTransfer(); } } /** * @return if transfer is enabled or not. */ function transferEnabled() public view returns (bool) { return _transferEnabled; } /** * Transfer tokens to a specified address. * @param to The address to transfer to * @param value The amount to be transferred * @return A boolean that indicates if the operation was successful. */ function transfer(address to, uint256 value) public virtual override(ERC20) validDestination(to) canTransfer(_msgSender()) whenNotPaused returns (bool) { return super.transfer(to, value); } /** * Transfer tokens from one address to another. * @param from The address which you want to send tokens from * @param to The address which you want to transfer to * @param value the amount of tokens to be transferred * @return A boolean that indicates if the operation was successful. */ function transferFrom(address from, address to, uint256 value) public virtual override(ERC20) validDestination(to) canTransfer(from) whenNotPaused returns (bool) { return super.transferFrom(from, to, value); } function approve(address spender, uint256 amount) public virtual override(ERC20) whenNotPaused returns (bool) { return super.approve(spender, amount); } function increaseAllowance(address spender, uint256 addedValue) public virtual override(ERC20) whenNotPaused returns (bool) { return super.increaseAllowance(spender, addedValue); } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual override(ERC20) whenNotPaused returns (bool) { return super.decreaseAllowance(spender, subtractedValue); } /** * Function to enable transfers. */ function enableTransfer() public onlyOwner { _transferEnabled = true; emit TransferEnabled(); } /** * See {ERC20-_beforeTokenTransfer}. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20, ERC20Capped) validDestination(to) { super._beforeTokenTransfer(from, to, amount); } }
32,340
8
// 0xa9059cbb = bytes4(keccak256("transfer(address,uint256)"))
abi.encodeWithSelector(0xa9059cbb, to, amount) ); require(success && (data.length == 0 || abi.decode(data, (bool)))); // ERC20 Transfer failed
abi.encodeWithSelector(0xa9059cbb, to, amount) ); require(success && (data.length == 0 || abi.decode(data, (bool)))); // ERC20 Transfer failed
9,313
5
// Helper library to compute polymarket proxy wallet addresses
library PolyProxyLib { /// @notice Gets the polymarket proxy address for a signer /// @param signer - Address of the signer function getProxyWalletAddress(address signer, address implementation, address deployer) internal pure returns (address proxyWallet) { return _computeCreate2Address(deployer, implementation, keccak256(abi.encodePacked(signer))); } function _computeCreate2Address(address from, address target, bytes32 salt) internal pure returns (address) { bytes32 bytecodeHash = keccak256(_computeCreationCode(from, target)); bytes32 _data = keccak256(abi.encodePacked(bytes1(0xff), from, salt, bytecodeHash)); return address(uint160(uint256(_data))); } function _computeCreationCode(address deployer, address target) internal pure returns (bytes memory clone) { bytes memory consData = abi.encodeWithSignature("cloneConstructor(bytes)", new bytes(0)); bytes memory buffer = new bytes(99); assembly { mstore(add(buffer, 0x20), 0x3d3d606380380380913d393d73bebebebebebebebebebebebebebebebebebebe) mstore(add(buffer, 0x2d), mul(deployer, 0x01000000000000000000000000)) mstore(add(buffer, 0x41), 0x5af4602a57600080fd5b602d8060366000396000f3363d3d373d3d3d363d73be) mstore(add(buffer, 0x60), mul(target, 0x01000000000000000000000000)) mstore(add(buffer, 116), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) } // clone = bytes.concat(buffer, consData); clone = abi.encodePacked(buffer, consData); return clone; } }
library PolyProxyLib { /// @notice Gets the polymarket proxy address for a signer /// @param signer - Address of the signer function getProxyWalletAddress(address signer, address implementation, address deployer) internal pure returns (address proxyWallet) { return _computeCreate2Address(deployer, implementation, keccak256(abi.encodePacked(signer))); } function _computeCreate2Address(address from, address target, bytes32 salt) internal pure returns (address) { bytes32 bytecodeHash = keccak256(_computeCreationCode(from, target)); bytes32 _data = keccak256(abi.encodePacked(bytes1(0xff), from, salt, bytecodeHash)); return address(uint160(uint256(_data))); } function _computeCreationCode(address deployer, address target) internal pure returns (bytes memory clone) { bytes memory consData = abi.encodeWithSignature("cloneConstructor(bytes)", new bytes(0)); bytes memory buffer = new bytes(99); assembly { mstore(add(buffer, 0x20), 0x3d3d606380380380913d393d73bebebebebebebebebebebebebebebebebebebe) mstore(add(buffer, 0x2d), mul(deployer, 0x01000000000000000000000000)) mstore(add(buffer, 0x41), 0x5af4602a57600080fd5b602d8060366000396000f3363d3d373d3d3d363d73be) mstore(add(buffer, 0x60), mul(target, 0x01000000000000000000000000)) mstore(add(buffer, 116), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) } // clone = bytes.concat(buffer, consData); clone = abi.encodePacked(buffer, consData); return clone; } }
1,381
37
// ------------------------------------------------------------------------ Don't accept ETH ------------------------------------------------------------------------
function () external payable { revert(); }
function () external payable { revert(); }
30,492
25
// Cancel transfer and get sent ether back. Only transfer sender cancancel transfer. _transitAddress transit address assigned to transferreturn True if success. /
function cancelTransfer(address _transitAddress) public returns (bool success) { Transfer memory transferOrder = transferDct[_transitAddress]; // only sender can cancel transfer; require(msg.sender == transferOrder.from); delete transferDct[_transitAddress]; // transfer ether to recipient's address msg.sender.transfer(transferOrder.amount); // log cancel event emit LogCancel(msg.sender, _transitAddress); return true; }
function cancelTransfer(address _transitAddress) public returns (bool success) { Transfer memory transferOrder = transferDct[_transitAddress]; // only sender can cancel transfer; require(msg.sender == transferOrder.from); delete transferDct[_transitAddress]; // transfer ether to recipient's address msg.sender.transfer(transferOrder.amount); // log cancel event emit LogCancel(msg.sender, _transitAddress); return true; }
37,568
7
// Peak may request withdrawl of any token. This may also be used to withdraw all liquidity when deprecating the controller/
function withdraw(IERC20 token, uint amount) public onlyPeak { amount = amount.min(token.balanceOf(address(this))); token.safeTransfer(msg.sender, amount); }
function withdraw(IERC20 token, uint amount) public onlyPeak { amount = amount.min(token.balanceOf(address(this))); token.safeTransfer(msg.sender, amount); }
7,772
150
// Total amount of ether withdrawed
uint256 public weiWithdrawed = 0;
uint256 public weiWithdrawed = 0;
33,553
283
// Adds the {flashLoan} method, which provides flash loan support at the tokenlevel. By default there is no fee, but this can be changed by overriding {flashFee}./ Returns the maximum amount of tokens available for loan. token The address of the token that is requested.return The amount of token that can be loaned. /
function maxFlashLoan(address token) public view virtual override returns (uint256) { return token == address(this) ? type(uint256).max - ERC20.totalSupply() : 0; }
function maxFlashLoan(address token) public view virtual override returns (uint256) { return token == address(this) ? type(uint256).max - ERC20.totalSupply() : 0; }
44,911
69
// Increase total supply by `_val` _val Value to increasereturn Operation status / solhint-disable-next-line no-unused-vars
function incTotalSupply(uint _val) external onlyOwner returns (bool) { return false; }
function incTotalSupply(uint _val) external onlyOwner returns (bool) { return false; }
30,484
7
// address of the active staking contracts
address[] public activeContracts; event GasCostSet(uint256 newGasCost); event CollectInterestTimeThresholdSet( uint256 newCollectInterestTimeThreshold ); event InterestMultiplierSet(uint8 newInterestMultiplier); event GasCostExceptInterestCollectSet( uint256 newGasCostExceptInterestCollect );
address[] public activeContracts; event GasCostSet(uint256 newGasCost); event CollectInterestTimeThresholdSet( uint256 newCollectInterestTimeThreshold ); event InterestMultiplierSet(uint8 newInterestMultiplier); event GasCostExceptInterestCollectSet( uint256 newGasCostExceptInterestCollect );
4,893
14
// decode init data
(uint256[] memory _hatIds, ClaimType[] memory _claimTypes) = abi.decode(_initData, (uint256[], ClaimType[])); _setHatsClaimabilityMemory(_hatIds, _claimTypes);
(uint256[] memory _hatIds, ClaimType[] memory _claimTypes) = abi.decode(_initData, (uint256[], ClaimType[])); _setHatsClaimabilityMemory(_hatIds, _claimTypes);
28,773
9
// Send VNET Token /
function sendVNET(address _to, uint256 _amount) external onlyOwner { assert(vnetToken.transfer(_to, _amount)); }
function sendVNET(address _to, uint256 _amount) external onlyOwner { assert(vnetToken.transfer(_to, _amount)); }
9,336
15
// This contract is called through the proxy.//_protocolConfig BNPLProtocolConfig contract address/_configurator BNPL contract platform configurator address/_minimumBankNodeBondedAmount The minimum BankNode bonded amount required to create the bankNode/_loanOverdueGracePeriod Loan overdue grace period (secs)/_bankNodeLendingRewards BankNodeLendingRewards contract address/_bnplKYCStore BNPLKYCStore contract address
function initialize( IBNPLProtocolConfig _protocolConfig, address _configurator, uint256 _minimumBankNodeBondedAmount, uint256 _loanOverdueGracePeriod, BankNodeLendingRewards _bankNodeLendingRewards, BNPLKYCStore _bnplKYCStore ) external;
function initialize( IBNPLProtocolConfig _protocolConfig, address _configurator, uint256 _minimumBankNodeBondedAmount, uint256 _loanOverdueGracePeriod, BankNodeLendingRewards _bankNodeLendingRewards, BNPLKYCStore _bnplKYCStore ) external;
43,091
35
// Q_AC AC
t = proof.state_polys_openings_at_z[0].copy(); t.mul_assign(proof.state_polys_openings_at_z[2]); scaled = vk.gate_setup_commitments[5].point_mul(t); result.point_add_assign(scaled);
t = proof.state_polys_openings_at_z[0].copy(); t.mul_assign(proof.state_polys_openings_at_z[2]); scaled = vk.gate_setup_commitments[5].point_mul(t); result.point_add_assign(scaled);
20,732
34
// get the total amount of balance this user has in offer
uint256 nTotalOffers = getTotalInOffer(_aInvestor);
uint256 nTotalOffers = getTotalInOffer(_aInvestor);
8,606
6
// Indexing for shitcoins array
mapping(string => uint16) shitcoin_index;
mapping(string => uint16) shitcoin_index;
34,281
44
// Emits a {MinDelayChange} event. Requirements: - the caller must be the timelock itself. This can only be achieved by scheduling and later executingan operation where the timelock is the target and the data is the ABI-encoded call to this function. /
function updateDelay(uint256 newDelay) external virtual { address sender = _msgSender(); if (sender != address(this)) { revert TimelockUnauthorizedCaller(sender); }
function updateDelay(uint256 newDelay) external virtual { address sender = _msgSender(); if (sender != address(this)) { revert TimelockUnauthorizedCaller(sender); }
1,527
1
// variables around the ramp management of A, the amplification coefficientn(n - 1) see https:www.curve.fi/stableswap-paper.pdf for details
uint256 initialA; uint256 futureA; uint256 initialATime; uint256 futureATime;
uint256 initialA; uint256 futureA; uint256 initialATime; uint256 futureATime;
9,233
89
// disable adding to whitelist forever
function renounceWhitelist() public onlyOwner { // adding to whitelist has been disabled forever: canWhitelist = false; }
function renounceWhitelist() public onlyOwner { // adding to whitelist has been disabled forever: canWhitelist = false; }
14,886
222
// Trading
bytes4 public constant TAKE_ORDER_SELECTOR = bytes4( keccak256("takeOrder(address,bytes,bytes)") );
bytes4 public constant TAKE_ORDER_SELECTOR = bytes4( keccak256("takeOrder(address,bytes,bytes)") );
52,510
19
// Get allowance return Return amount allowed to spend from '_owner' by '_spender'/
function allowance(address _owner, address _spender) public constant returns (uint256 _remaining) { return allowances[_owner][_spender]; }
function allowance(address _owner, address _spender) public constant returns (uint256 _remaining) { return allowances[_owner][_spender]; }
8,201
10
// Calculates the price of the pair token using the formula of weighted geometric mean. ethTotal_0 Total eth for token 0. ethTotal_1 Total eth for token 1. /
function getWeightedGeometricMean(uint256 ethTotal_0, uint256 ethTotal_1) internal view returns (uint256)
function getWeightedGeometricMean(uint256 ethTotal_0, uint256 ethTotal_1) internal view returns (uint256)
56,441
1
// Changes voted group. This call revokes all current votes for currently voted group./ votedGroupIndex is the index of votedGroup in SavingsCELO votes. This is expected to be 0 since/ SavingsCELO is supposed to be voting only for one group.// lesser.../greater... parameters are needed to perform Election.revokePending and Election.revokeActive/ calls. See Election contract for more details.// NOTE: changeVotedGroup can be used to clear out all votes even if SavingsCELO is voting for multiple/ groups. This can be useful if SavingsCELO is in a weird voting state before VoterV1 contract is installed/ as the voter contract.
function changeVotedGroup( address newGroup, uint256 votedGroupIndex, address lesserAfterPendingRevoke, address greaterAfterPendingRevoke, address lesserAfterActiveRevoke,
function changeVotedGroup( address newGroup, uint256 votedGroupIndex, address lesserAfterPendingRevoke, address greaterAfterPendingRevoke, address lesserAfterActiveRevoke,
40,134
50
// if person income limit lesser than the daily ROI
else if(player[_playerAddress].incomeLimitLeft !=0) { uint256 temp; temp = player[_playerAddress].incomeLimitLeft; player[_playerAddress].incomeLimitLeft = 0; player[_playerAddress].dailyIncome = player[_playerAddress].dailyIncome.add(temp); player[_playerAddress].lastSettledTime = now; emit dailyPayoutEvent( _playerAddress, temp, now); referralBonusTransferDailyROI(_playerAddress, temp); }
else if(player[_playerAddress].incomeLimitLeft !=0) { uint256 temp; temp = player[_playerAddress].incomeLimitLeft; player[_playerAddress].incomeLimitLeft = 0; player[_playerAddress].dailyIncome = player[_playerAddress].dailyIncome.add(temp); player[_playerAddress].lastSettledTime = now; emit dailyPayoutEvent( _playerAddress, temp, now); referralBonusTransferDailyROI(_playerAddress, temp); }
21,941
43
// // Transferable tokenStandardToken modified with transfert on/off mechanism. /
contract TransferableToken is StandardToken,Ownable { /** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @dev TRANSFERABLE MECANISM SECTION * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ event Transferable(); event UnTransferable(); bool public transferable = false; mapping (address => bool) public whitelisted; /** CONSTRUCTOR **/ constructor() StandardToken() Ownable() public { whitelisted[msg.sender] = true; } /** MODIFIERS **/ /** * @dev Modifier to make a function callable only when the contract is not transferable. */ modifier whenNotTransferable() { require(!transferable); _; } /** * @dev Modifier to make a function callable only when the contract is transferable. */ modifier whenTransferable() { require(transferable); _; } /** * @dev Modifier to make a function callable only when the caller can transfert token. */ modifier canTransfert() { if(!transferable){ require (whitelisted[msg.sender]); } _; } /** OWNER ONLY FUNCTIONS **/ /** * @dev called by the owner to allow transferts, triggers Transferable state */ function allowTransfert() onlyOwner whenNotTransferable public { transferable = true; emit Transferable(); } /** * @dev called by the owner to restrict transferts, returns to untransferable state */ function restrictTransfert() onlyOwner whenTransferable public { transferable = false; emit UnTransferable(); } /** @dev Allows the owner to add addresse that can bypass the transfer lock. **/ function whitelist(address _address) onlyOwner public { require(_address != 0x0); whitelisted[_address] = true; } /** @dev Allows the owner to remove addresse that can bypass the transfer lock. **/ function restrict(address _address) onlyOwner public { require(_address != 0x0); whitelisted[_address] = false; } /** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @dev Strandard transferts overloaded API * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ function transfer(address _to, uint256 _value) public canTransfert returns (bool) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public canTransfert returns (bool) { return super.transferFrom(_from, _to, _value); } /** * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. We recommend to use use increaseApproval * and decreaseApproval functions instead ! * https://github.com/ethereum/EIPs/issues/20#issuecomment-263555598 */ function approve(address _spender, uint256 _value) public canTransfert returns (bool) { return super.approve(_spender, _value); } function increaseApproval(address _spender, uint _addedValue) public canTransfert returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval(address _spender, uint _subtractedValue) public canTransfert returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } }
contract TransferableToken is StandardToken,Ownable { /** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @dev TRANSFERABLE MECANISM SECTION * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ event Transferable(); event UnTransferable(); bool public transferable = false; mapping (address => bool) public whitelisted; /** CONSTRUCTOR **/ constructor() StandardToken() Ownable() public { whitelisted[msg.sender] = true; } /** MODIFIERS **/ /** * @dev Modifier to make a function callable only when the contract is not transferable. */ modifier whenNotTransferable() { require(!transferable); _; } /** * @dev Modifier to make a function callable only when the contract is transferable. */ modifier whenTransferable() { require(transferable); _; } /** * @dev Modifier to make a function callable only when the caller can transfert token. */ modifier canTransfert() { if(!transferable){ require (whitelisted[msg.sender]); } _; } /** OWNER ONLY FUNCTIONS **/ /** * @dev called by the owner to allow transferts, triggers Transferable state */ function allowTransfert() onlyOwner whenNotTransferable public { transferable = true; emit Transferable(); } /** * @dev called by the owner to restrict transferts, returns to untransferable state */ function restrictTransfert() onlyOwner whenTransferable public { transferable = false; emit UnTransferable(); } /** @dev Allows the owner to add addresse that can bypass the transfer lock. **/ function whitelist(address _address) onlyOwner public { require(_address != 0x0); whitelisted[_address] = true; } /** @dev Allows the owner to remove addresse that can bypass the transfer lock. **/ function restrict(address _address) onlyOwner public { require(_address != 0x0); whitelisted[_address] = false; } /** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @dev Strandard transferts overloaded API * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ function transfer(address _to, uint256 _value) public canTransfert returns (bool) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) public canTransfert returns (bool) { return super.transferFrom(_from, _to, _value); } /** * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. We recommend to use use increaseApproval * and decreaseApproval functions instead ! * https://github.com/ethereum/EIPs/issues/20#issuecomment-263555598 */ function approve(address _spender, uint256 _value) public canTransfert returns (bool) { return super.approve(_spender, _value); } function increaseApproval(address _spender, uint _addedValue) public canTransfert returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval(address _spender, uint _subtractedValue) public canTransfert returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } }
6,831
102
// set withdrawn to true
hasWithdrawn[_msgSender()] = true;
hasWithdrawn[_msgSender()] = true;
15,590
252
// res += valcoefficients[42].
res := addmod(res, mulmod(val, /*coefficients[42]*/ mload(0x940), PRIME), PRIME)
res := addmod(res, mulmod(val, /*coefficients[42]*/ mload(0x940), PRIME), PRIME)
19,592
89
// Name and symbol of the non fungible token, as defined in ERC721.
string internal constant NAME = "GAME Credits ERC721"; string internal constant SYMBOL = "GAME"; bytes4 private constant ON_ERC721_RECEIVED = bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"));
string internal constant NAME = "GAME Credits ERC721"; string internal constant SYMBOL = "GAME"; bytes4 private constant ON_ERC721_RECEIVED = bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"));
26,564
24
// transfer tokens
function transfer(address _to, uint256 _value) public returns (bool success) { require(_balanceOf[msg.sender] >= _value); _transfer(msg.sender, _to, _value); return true; }
function transfer(address _to, uint256 _value) public returns (bool success) { require(_balanceOf[msg.sender] >= _value); _transfer(msg.sender, _to, _value); return true; }
43,935
33
// RBAC (Role-Based Access Control) Matt Condon (@Shrugs) Stores and provides setters and getters for roles and addresses.Supports unlimited numbers of roles and addresses.This RBAC method uses strings to key roles. It may be beneficialfor you to write your own implementation of this interface using Enums or similar.It's also recommended that you define constants in the contract, like ROLE_ADMIN below,to avoid typos. /
contract RBAC { using Roles for Roles.Role; mapping (string => Roles.Role) private roles; event RoleAdded(address indexed operator, string role); event RoleRemoved(address indexed operator, string role); /** * @dev reverts if addr does not have role * @param _operator address * @param _role the name of the role * // reverts */ function checkRole(address _operator, string _role) view public { roles[_role].check(_operator); } /** * @dev determine if addr has role * @param _operator address * @param _role the name of the role * @return bool */ function hasRole(address _operator, string _role) view public returns (bool) { return roles[_role].has(_operator); } /** * @dev add a role to an address * @param _operator address * @param _role the name of the role */ function addRole(address _operator, string _role) internal { roles[_role].add(_operator); emit RoleAdded(_operator, _role); } /** * @dev remove a role from an address * @param _operator address * @param _role the name of the role */ function removeRole(address _operator, string _role) internal { roles[_role].remove(_operator); emit RoleRemoved(_operator, _role); } /** * @dev modifier to scope access to a single role (uses msg.sender as addr) * @param _role the name of the role * // reverts */ modifier onlyRole(string _role) { checkRole(msg.sender, _role); _; } }
contract RBAC { using Roles for Roles.Role; mapping (string => Roles.Role) private roles; event RoleAdded(address indexed operator, string role); event RoleRemoved(address indexed operator, string role); /** * @dev reverts if addr does not have role * @param _operator address * @param _role the name of the role * // reverts */ function checkRole(address _operator, string _role) view public { roles[_role].check(_operator); } /** * @dev determine if addr has role * @param _operator address * @param _role the name of the role * @return bool */ function hasRole(address _operator, string _role) view public returns (bool) { return roles[_role].has(_operator); } /** * @dev add a role to an address * @param _operator address * @param _role the name of the role */ function addRole(address _operator, string _role) internal { roles[_role].add(_operator); emit RoleAdded(_operator, _role); } /** * @dev remove a role from an address * @param _operator address * @param _role the name of the role */ function removeRole(address _operator, string _role) internal { roles[_role].remove(_operator); emit RoleRemoved(_operator, _role); } /** * @dev modifier to scope access to a single role (uses msg.sender as addr) * @param _role the name of the role * // reverts */ modifier onlyRole(string _role) { checkRole(msg.sender, _role); _; } }
41,980
12
// Checks if provided address has tokens of current DAO_participantAddress Address of potential participant return boolean indicating if the address has at least one token/
function isParticipant(address _participantAddress) external constant returns (bool) { return token.balanceOf(_participantAddress) > 0; }
function isParticipant(address _participantAddress) external constant returns (bool) { return token.balanceOf(_participantAddress) > 0; }
35,949
6
// remove one's vote from the previous choice first
if (hadVote) removeVote(prev_choice);
if (hadVote) removeVote(prev_choice);
21,651
474
// Either portfolioId, hack or bug
revert(ERROR_CORE_UNKNOWN_POSITION_TYPE);
revert(ERROR_CORE_UNKNOWN_POSITION_TYPE);
29,543
52
// Other
function getCurrentBlockNumber() public view returns(uint256 blockNumber) { return block.number; }
function getCurrentBlockNumber() public view returns(uint256 blockNumber) { return block.number; }
30,443
3
// There's only one cCHEESE, but it can be shared in slices of 0.00000000000000001 /
contract Cheese is ERC20, ERC20Burnable { address vault = address(0x93282c09B426a3961D304726f47105498A8d30B4); // the cCHEESE FREEZER constructor() ERC20("cCHEESE", "CHEESE") { uint256 total = 1 * 10 ** decimals(); _mint(msg.sender, total); // 0.25 goes to the freezer super.transfer(vault, total/4); } function transfer(address recipient, uint256 amount) override public returns (bool) { _burn(msg.sender, 1); return super.transfer(recipient, amount-1); } }
contract Cheese is ERC20, ERC20Burnable { address vault = address(0x93282c09B426a3961D304726f47105498A8d30B4); // the cCHEESE FREEZER constructor() ERC20("cCHEESE", "CHEESE") { uint256 total = 1 * 10 ** decimals(); _mint(msg.sender, total); // 0.25 goes to the freezer super.transfer(vault, total/4); } function transfer(address recipient, uint256 amount) override public returns (bool) { _burn(msg.sender, 1); return super.transfer(recipient, amount-1); } }
18,672
12
// ------------------------------------------------------------------------ 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) { // prevent transfer to 0x0, use burn instead require(to != address(0)); require(balances[msg.sender] >= tokens ); require(balances[to] + tokens >= balances[to]); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender,to,tokens); return true; }
function transfer(address to, uint tokens) public returns (bool success) { // prevent transfer to 0x0, use burn instead require(to != address(0)); require(balances[msg.sender] >= tokens ); require(balances[to] + tokens >= balances[to]); balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender,to,tokens); return true; }
39,312
128
// On January 02, 2022 @ UTC 23:59 = FTST2625/100000 (2.625% of final total supply of tokens) to the wallet [E].
if (order == 7) {
if (order == 7) {
63,735
5
// Test unexpected revert
Multicall.Call[] memory calls = new Multicall.Call[](2); calls[0] = Multicall.Call( address(callee), abi.encodeWithSignature("getBlockHash(uint256)", block.number) ); calls[1] = Multicall.Call(address(callee), abi.encodeWithSignature("thisMethodReverts()") ); vm.expectRevert(bytes("")); multicall.aggregate(calls);
Multicall.Call[] memory calls = new Multicall.Call[](2); calls[0] = Multicall.Call( address(callee), abi.encodeWithSignature("getBlockHash(uint256)", block.number) ); calls[1] = Multicall.Call(address(callee), abi.encodeWithSignature("thisMethodReverts()") ); vm.expectRevert(bytes("")); multicall.aggregate(calls);
30,085
77
// address of the current voting strategy to use on the governancereturn address of the voting strategy /
function getPowerStrategy() external view returns (IGovernancePowerStrategy);
function getPowerStrategy() external view returns (IGovernancePowerStrategy);
15,931
6
// verify that the number of elements is larger than 2 and odd
require(path.length > 2 && path.length % 2 == 1, "ERR_INVALID_PATH"); uint256 amount = sourceAmount;
require(path.length > 2 && path.length % 2 == 1, "ERR_INVALID_PATH"); uint256 amount = sourceAmount;
4,956
2
// require() verifica che, se una condizione è valida, ritorna un messaggio personalizzato di errore
require(campaign.deadline < block.timestamp , "The deadline should be a date in the future."); campaign.owner = _owner; campaign.title = _title; campaign.description = _description; campaign.target = _target; campaign.deadline = _deadline; campaign.amountCollected = 0; campaign.image = _image;
require(campaign.deadline < block.timestamp , "The deadline should be a date in the future."); campaign.owner = _owner; campaign.title = _title; campaign.description = _description; campaign.target = _target; campaign.deadline = _deadline; campaign.amountCollected = 0; campaign.image = _image;
15,406
356
// transfer USDC received back to pool and decrease amountInvested
holyPool.returnInvested(USDCReceived);
holyPool.returnInvested(USDCReceived);
41,489
2
// pool related functions //Creates the pool of swappable tokens _tokenAaddress Address of token A contract_tokenBaddress Address of token B contract_tokenAsupplySupply of tokens A in the pool_tokenBsupplySupply of tokens B in the pool_slippageMaximum slippage_exchangeRateThe price of token B in token A/
function createPool( address _tokenAaddress, address _tokenBaddress, uint256 _tokenAsupply, uint256 _tokenBsupply, uint256 _slippage, uint256 _exchangeRate ) external
function createPool( address _tokenAaddress, address _tokenBaddress, uint256 _tokenAsupply, uint256 _tokenBsupply, uint256 _slippage, uint256 _exchangeRate ) external
52,917
123
// Computes the entropy used to generate the random number.The blockhash of the lock end block is XOR'd with the secret revealed by the owner.return The computed entropy value /
function _entropy() internal view returns (uint256) { return uint256(blockhash(lockEndBlock) ^ secret); }
function _entropy() internal view returns (uint256) { return uint256(blockhash(lockEndBlock) ^ secret); }
7,332
147
// 86400 - 1 day
oraclizeBalance = oraclizeBalance.sub(oraclize_getPrice("URL")); //request to oraclize
oraclizeBalance = oraclizeBalance.sub(oraclize_getPrice("URL")); //request to oraclize
37,436
387
// Pool token state variables
string poolName; string symbol; uint _totalSupply; mapping(address => uint) balanceOf; mapping(address => mapping(address => uint)) allowance; mapping(address => uint) nonces;
string poolName; string symbol; uint _totalSupply; mapping(address => uint) balanceOf; mapping(address => mapping(address => uint)) allowance; mapping(address => uint) nonces;
29,176
49
// Class constructor creates the main CSportsContest smart contract instance.
constructor(uint256 _cut) public { require(_cut <= 10000); ownerCut = _cut; // All C-level roles are the message sender ceoAddress = msg.sender; cfoAddress = msg.sender; cooAddress = msg.sender; commissionerAddress = msg.sender; // Create a contest to take up the 0th slot. // Create it in the canceled state with no teams. // This is to deal with the fact that mappings return 0 // when queried with non-existent keys. Contest memory _contest = Contest({ scoringOracleAddress: commissionerAddress, gameSetId: 0, maxMinEntries: 0, numWinners: 0, winnersToPay: 0, startTime: 0, endTime: 0, creator: msg.sender, entryFee: 0, prizeAmount: 0, remainingPrizeAmount: 0, status: ContestStatus.Canceled, payoutKey: PayoutKey(0), name: "mythical", teamIds: new uint32[](0) }); contests.push(_contest); }
constructor(uint256 _cut) public { require(_cut <= 10000); ownerCut = _cut; // All C-level roles are the message sender ceoAddress = msg.sender; cfoAddress = msg.sender; cooAddress = msg.sender; commissionerAddress = msg.sender; // Create a contest to take up the 0th slot. // Create it in the canceled state with no teams. // This is to deal with the fact that mappings return 0 // when queried with non-existent keys. Contest memory _contest = Contest({ scoringOracleAddress: commissionerAddress, gameSetId: 0, maxMinEntries: 0, numWinners: 0, winnersToPay: 0, startTime: 0, endTime: 0, creator: msg.sender, entryFee: 0, prizeAmount: 0, remainingPrizeAmount: 0, status: ContestStatus.Canceled, payoutKey: PayoutKey(0), name: "mythical", teamIds: new uint32[](0) }); contests.push(_contest); }
48,446
97
// Trigger sweep
PaymentHandler(address(uint160(handlers[i]))).sweepTokens(tokenContract);
PaymentHandler(address(uint160(handlers[i]))).sweepTokens(tokenContract);
34,157
116
// unset the value
has = false;
has = false;
71,366
30
// Constructor for creating the uRaiden microtransfer channels contract./_token_address The address of the Token used by the uRaiden contract./_challenge_period A fixed number of blocks representing the challenge period./ We enforce a minimum of 500 blocks waiting period./ after a sender requests the closing of the channel without the receiver's signature.
function RaidenMicroTransferChannels(address _token_address, uint32 _challenge_period) public { event ChannelCloseRequested( address indexed _sender, address indexed _receiver, uint32 indexed _open_block_number, uint192 _balance); event ChannelSettled( address indexed _sender, address indexed _receiver, uint32 indexed _open_block_number, uint192 _balance); require(_token_address != 0x0); require(addressHasCode(_token_address)); require(_challenge_period >= 500); token = Token(_token_address); // Check if the contract is indeed a token contract require(token.totalSupply() > 0); challenge_period = _challenge_period; }
function RaidenMicroTransferChannels(address _token_address, uint32 _challenge_period) public { event ChannelCloseRequested( address indexed _sender, address indexed _receiver, uint32 indexed _open_block_number, uint192 _balance); event ChannelSettled( address indexed _sender, address indexed _receiver, uint32 indexed _open_block_number, uint192 _balance); require(_token_address != 0x0); require(addressHasCode(_token_address)); require(_challenge_period >= 500); token = Token(_token_address); // Check if the contract is indeed a token contract require(token.totalSupply() > 0); challenge_period = _challenge_period; }
4,459
140
// Claim all pie accrued by the holders holders The addresses to claim PIE for pTokens The list of markets to claim PIE in borrowers Whether or not to claim PIE earned by borrowing suppliers Whether or not to claim PIE earned by supplying /
function claimPie(address[] memory holders, address[] memory pTokens, bool borrowers, bool suppliers) public { for (uint i = 0; i < pTokens.length; i++) { address pToken = pTokens[i]; require(markets[pToken].isListed, "market must be listed"); if (borrowers == true) { Exp memory borrowIndex = Exp({mantissa: PTokenInterface(pToken).borrowIndex()}); updatePieBorrowIndex(pToken, borrowIndex); for (uint j = 0; j < holders.length; j++) { distributeBorrowerPie(pToken, holders[j], borrowIndex, true); } } if (suppliers == true) { updatePieSupplyIndex(pToken); for (uint j = 0; j < holders.length; j++) { distributeSupplierPie(pToken, holders[j], true); } } } }
function claimPie(address[] memory holders, address[] memory pTokens, bool borrowers, bool suppliers) public { for (uint i = 0; i < pTokens.length; i++) { address pToken = pTokens[i]; require(markets[pToken].isListed, "market must be listed"); if (borrowers == true) { Exp memory borrowIndex = Exp({mantissa: PTokenInterface(pToken).borrowIndex()}); updatePieBorrowIndex(pToken, borrowIndex); for (uint j = 0; j < holders.length; j++) { distributeBorrowerPie(pToken, holders[j], borrowIndex, true); } } if (suppliers == true) { updatePieSupplyIndex(pToken); for (uint j = 0; j < holders.length; j++) { distributeSupplierPie(pToken, holders[j], true); } } } }
76,782
25
// Allow the current owner to remove an Admin
function removeAdmin(address _adminAddress) public onlyOwner{ require(adminsmap[_adminAddress].isAdmin == true,"Sorry,address is not an admin"); require(adminIndex > 1,"Atleast one admin is required"); require(_adminAddress != owner,"owner cannot be removed"); delete adminsmap[_adminAddress]; adminIndex -= 1; emit AdminRemoved( _adminAddress,adminIndex); }
function removeAdmin(address _adminAddress) public onlyOwner{ require(adminsmap[_adminAddress].isAdmin == true,"Sorry,address is not an admin"); require(adminIndex > 1,"Atleast one admin is required"); require(_adminAddress != owner,"owner cannot be removed"); delete adminsmap[_adminAddress]; adminIndex -= 1; emit AdminRemoved( _adminAddress,adminIndex); }
20,536
20
// An array of all the DividendSnapshot so far
DividendSnapshot[] dividendSnapshots;
DividendSnapshot[] dividendSnapshots;
7,240
27
// oods_coefficients[17]/ mload(add(context, 0x5be0)), res += c_18(f_1(x) - f_1(g^255z)) / (x - g^255z).
res := add( res, mulmod(mulmod(/*(x - g^255 * z)^(-1)*/ mload(add(denominatorsPtr, 0x8a0)),
res := add( res, mulmod(mulmod(/*(x - g^255 * z)^(-1)*/ mload(add(denominatorsPtr, 0x8a0)),
28,827
181
// Update non rebasing supply
nonRebasingSupply = nonRebasingSupply.add(balanceOf(_account));
nonRebasingSupply = nonRebasingSupply.add(balanceOf(_account));
25,953
3
// modifier inState(State expectedState, uint id){require(order_list[id].currentState == expectedState); _;}
modifier timePassedRefund(uint256 id, uint256 time) { require(now - order_list[id].OrderTime >= time); require(order_list[id].deposit != 0); require(msg.sender == order_list[id].buyer); require(order_list[id].currentState == State.AWAITING_DELIVERY); _; }
modifier timePassedRefund(uint256 id, uint256 time) { require(now - order_list[id].OrderTime >= time); require(order_list[id].deposit != 0); require(msg.sender == order_list[id].buyer); require(order_list[id].currentState == State.AWAITING_DELIVERY); _; }
24,983
101
// Check is user registered//_user user address// return status
function isRegisteredUser(address _user) public view returns (bool) { return memberAddress2index[_user] != 0; }
function isRegisteredUser(address _user) public view returns (bool) { return memberAddress2index[_user] != 0; }
19,295