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
59
// previous head position now is not eligible for incentive
headPositionInfo.incentiveClaimable = false;
headPositionInfo.incentiveClaimable = false;
26,683
163
// Verifies if given iNFT existsrecordId iNFT ID to verify existence ofreturn true if iNFT exists, false otherwise /
function exists(uint256 recordId) public view override returns (bool) { // verify if biding exists for that tokenId and return the result return bindings[recordId].targetContract != address(0); }
function exists(uint256 recordId) public view override returns (bool) { // verify if biding exists for that tokenId and return the result return bindings[recordId].targetContract != address(0); }
45,135
609
// spawn the planet to us, then immediately transfer to the callerspawning to the caller would give the point's prefix's ownera window of opportunity to cancel the transfer
Ecliptic ecliptic = Ecliptic(azimuth.owner()); ecliptic.spawn(_planet, this); ecliptic.transferPoint(_planet, msg.sender, false); emit PlanetSold(azimuth.getPrefix(_planet), _planet);
Ecliptic ecliptic = Ecliptic(azimuth.owner()); ecliptic.spawn(_planet, this); ecliptic.transferPoint(_planet, msg.sender, false); emit PlanetSold(azimuth.getPrefix(_planet), _planet);
37,199
53
// Withdraw Token.token token address.amt token amount.unitAmt unit amount of curve_amt/token_amt with slippage.getId Get token amount at this ID from `InstaMemory` Contract.setId Set token amount at this ID in `InstaMemory` Contract./
function withdraw( address token, uint256 amt, uint256 unitAmt, uint getId, uint setId
function withdraw( address token, uint256 amt, uint256 unitAmt, uint getId, uint setId
79,904
13
// NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}. /
function upgradeToAndCall(address newImplementation, bytes calldata data) external payable virtual ifAdmin { _upgradeTo(newImplementation); Address.functionDelegateCall(newImplementation, data); }
function upgradeToAndCall(address newImplementation, bytes calldata data) external payable virtual ifAdmin { _upgradeTo(newImplementation); Address.functionDelegateCall(newImplementation, data); }
6,895
1,035
// Revert with an error when attempting to create a new conduit using a conduit key where the first twenty bytes of the key do not match the address of the caller. /
error InvalidCreator();
error InvalidCreator();
40,609
141
// Cancel an already published order can only be canceled by seller or the contract owner _nftAddress - Address of the NFT registry _assetId - ID of the published NFT /
function cancelOrder( address _nftAddress, uint256 _assetId ) public whenNotPaused
function cancelOrder( address _nftAddress, uint256 _assetId ) public whenNotPaused
20,114
7
// determine how much you can leave with.
uint256 reward = _amountToWithdraw * poolBalance/totalSupply; //rounding? msg.sender.transfer(reward); balances[msg.sender] -= _amountToWithdraw; totalSupply -= _amountToWithdraw; updateCostOfToken(totalSupply); LogWithdraw(_amountToWithdraw, reward); return true;
uint256 reward = _amountToWithdraw * poolBalance/totalSupply; //rounding? msg.sender.transfer(reward); balances[msg.sender] -= _amountToWithdraw; totalSupply -= _amountToWithdraw; updateCostOfToken(totalSupply); LogWithdraw(_amountToWithdraw, reward); return true;
45,684
529
// It’s set in caller function `_closeTrove`
assert(troveStatus != Status.nonExistent && troveStatus != Status.active); uint128 index = Troves[_borrower].arrayIndex; uint length = TroveOwnersArrayLength; uint idxLast = length.sub(1); assert(index <= idxLast); address addressToMove = TroveOwners[idxLast];
assert(troveStatus != Status.nonExistent && troveStatus != Status.active); uint128 index = Troves[_borrower].arrayIndex; uint length = TroveOwnersArrayLength; uint idxLast = length.sub(1); assert(index <= idxLast); address addressToMove = TroveOwners[idxLast];
15,165
60
// Do not reduce _totalSupply and/or _reflectedSupply. (soft) burning by sendingtokens to the burn address (which should be excluded from rewards) is sufficientin RFI /
_reflectedBalances[burnAddress] = _reflectedBalances[burnAddress].add(rBurn);
_reflectedBalances[burnAddress] = _reflectedBalances[burnAddress].add(rBurn);
14,471
2
// Storage /
mapping (uint => Transaction) public transactions;
mapping (uint => Transaction) public transactions;
18,749
10
// don't need be too precise to save gas
if (res - xi < 1000) { break; }
if (res - xi < 1000) { break; }
22,912
40
// if we hit the last round, then return what we have
return (rates, times);
return (rates, times);
26,162
19
// Withdraw contract's ETH balance
function withdrawETHBalance(address payable recipient) external isOwner{ recipient.transfer(address(this).balance); }
function withdrawETHBalance(address payable recipient) external isOwner{ recipient.transfer(address(this).balance); }
6,800
0
// ========== GLOBAL VARIABLES ========== /perhaps some are harder to flip over?perhaps some have magical metadata?I don't know, it's late and I'm weird
struct Item { bytes32 image; }
struct Item { bytes32 image; }
24,435
153
// Library Imports // IStateCommitmentChain /
interface IStateCommitmentChain { /********** * Events * **********/ event StateBatchAppended( uint256 _chainId, uint256 indexed _batchIndex, bytes32 _batchRoot, uint256 _batchSize, uint256 _prevTotalElements, bytes _extraData ); event StateBatchDeleted( uint256 _chainId, uint256 indexed _batchIndex, bytes32 _batchRoot ); /******************** * Public Functions * ********************/ function batches() external view returns (IChainStorageContainer); /** * Retrieves the total number of elements submitted. * @return _totalElements Total submitted elements. */ function getTotalElements() external view returns (uint256 _totalElements); /** * Retrieves the total number of batches submitted. * @return _totalBatches Total submitted batches. */ function getTotalBatches() external view returns (uint256 _totalBatches); /** * Retrieves the timestamp of the last batch submitted by the sequencer. * @return _lastSequencerTimestamp Last sequencer batch timestamp. */ function getLastSequencerTimestamp() external view returns (uint256 _lastSequencerTimestamp); /** * Appends a batch of state roots to the chain. * @param _batch Batch of state roots. * @param _shouldStartAtElement Index of the element at which this batch should start. */ function appendStateBatch(bytes32[] calldata _batch, uint256 _shouldStartAtElement) external; /** * Deletes all state roots after (and including) a given batch. * @param _batchHeader Header of the batch to start deleting from. */ function deleteStateBatch(Lib_OVMCodec.ChainBatchHeader memory _batchHeader) external; /** * Verifies a batch inclusion proof. * @param _element Hash of the element to verify a proof for. * @param _batchHeader Header of the batch in which the element was included. * @param _proof Merkle inclusion proof for the element. */ function verifyStateCommitment( bytes32 _element, Lib_OVMCodec.ChainBatchHeader memory _batchHeader, Lib_OVMCodec.ChainInclusionProof memory _proof ) external view returns (bool _verified); /** * Checks whether a given batch is still inside its fraud proof window. * @param _batchHeader Header of the batch to check. * @return _inside Whether or not the batch is inside the fraud proof window. */ function insideFraudProofWindow(Lib_OVMCodec.ChainBatchHeader memory _batchHeader) external view returns ( bool _inside ); /******************** * chain id added func * ********************/ /** * Retrieves the total number of elements submitted. * @param _chainId identity for the l2 chain. * @return _totalElements Total submitted elements. */ function getTotalElementsByChainId(uint256 _chainId) external view returns ( uint256 _totalElements ); /** * Retrieves the total number of batches submitted. * @param _chainId identity for the l2 chain. * @return _totalBatches Total submitted batches. */ function getTotalBatchesByChainId(uint256 _chainId) external view returns ( uint256 _totalBatches ); /** * Retrieves the timestamp of the last batch submitted by the sequencer. * @param _chainId identity for the l2 chain. * @return _lastSequencerTimestamp Last sequencer batch timestamp. */ function getLastSequencerTimestampByChainId(uint256 _chainId) external view returns ( uint256 _lastSequencerTimestamp ); /** * Appends a batch of state roots to the chain. * @param _chainId identity for the l2 chain. * @param _batch Batch of state roots. * @param _shouldStartAtElement Index of the element at which this batch should start. */ function appendStateBatchByChainId( uint256 _chainId, bytes32[] calldata _batch, uint256 _shouldStartAtElement, string calldata proposer ) external; /** * Deletes all state roots after (and including) a given batch. * @param _chainId identity for the l2 chain. * @param _batchHeader Header of the batch to start deleting from. */ function deleteStateBatchByChainId( uint256 _chainId, Lib_OVMCodec.ChainBatchHeader memory _batchHeader ) external; /** * Verifies a batch inclusion proof. * @param _chainId identity for the l2 chain. * @param _element Hash of the element to verify a proof for. * @param _batchHeader Header of the batch in which the element was included. * @param _proof Merkle inclusion proof for the element. */ function verifyStateCommitmentByChainId( uint256 _chainId, bytes32 _element, Lib_OVMCodec.ChainBatchHeader memory _batchHeader, Lib_OVMCodec.ChainInclusionProof memory _proof ) external view returns ( bool _verified ); /** * Checks whether a given batch is still inside its fraud proof window. * @param _chainId identity for the l2 chain. * @param _batchHeader Header of the batch to check. * @return _inside Whether or not the batch is inside the fraud proof window. */ function insideFraudProofWindowByChainId( uint256 _chainId, Lib_OVMCodec.ChainBatchHeader memory _batchHeader ) external view returns ( bool _inside ); }
interface IStateCommitmentChain { /********** * Events * **********/ event StateBatchAppended( uint256 _chainId, uint256 indexed _batchIndex, bytes32 _batchRoot, uint256 _batchSize, uint256 _prevTotalElements, bytes _extraData ); event StateBatchDeleted( uint256 _chainId, uint256 indexed _batchIndex, bytes32 _batchRoot ); /******************** * Public Functions * ********************/ function batches() external view returns (IChainStorageContainer); /** * Retrieves the total number of elements submitted. * @return _totalElements Total submitted elements. */ function getTotalElements() external view returns (uint256 _totalElements); /** * Retrieves the total number of batches submitted. * @return _totalBatches Total submitted batches. */ function getTotalBatches() external view returns (uint256 _totalBatches); /** * Retrieves the timestamp of the last batch submitted by the sequencer. * @return _lastSequencerTimestamp Last sequencer batch timestamp. */ function getLastSequencerTimestamp() external view returns (uint256 _lastSequencerTimestamp); /** * Appends a batch of state roots to the chain. * @param _batch Batch of state roots. * @param _shouldStartAtElement Index of the element at which this batch should start. */ function appendStateBatch(bytes32[] calldata _batch, uint256 _shouldStartAtElement) external; /** * Deletes all state roots after (and including) a given batch. * @param _batchHeader Header of the batch to start deleting from. */ function deleteStateBatch(Lib_OVMCodec.ChainBatchHeader memory _batchHeader) external; /** * Verifies a batch inclusion proof. * @param _element Hash of the element to verify a proof for. * @param _batchHeader Header of the batch in which the element was included. * @param _proof Merkle inclusion proof for the element. */ function verifyStateCommitment( bytes32 _element, Lib_OVMCodec.ChainBatchHeader memory _batchHeader, Lib_OVMCodec.ChainInclusionProof memory _proof ) external view returns (bool _verified); /** * Checks whether a given batch is still inside its fraud proof window. * @param _batchHeader Header of the batch to check. * @return _inside Whether or not the batch is inside the fraud proof window. */ function insideFraudProofWindow(Lib_OVMCodec.ChainBatchHeader memory _batchHeader) external view returns ( bool _inside ); /******************** * chain id added func * ********************/ /** * Retrieves the total number of elements submitted. * @param _chainId identity for the l2 chain. * @return _totalElements Total submitted elements. */ function getTotalElementsByChainId(uint256 _chainId) external view returns ( uint256 _totalElements ); /** * Retrieves the total number of batches submitted. * @param _chainId identity for the l2 chain. * @return _totalBatches Total submitted batches. */ function getTotalBatchesByChainId(uint256 _chainId) external view returns ( uint256 _totalBatches ); /** * Retrieves the timestamp of the last batch submitted by the sequencer. * @param _chainId identity for the l2 chain. * @return _lastSequencerTimestamp Last sequencer batch timestamp. */ function getLastSequencerTimestampByChainId(uint256 _chainId) external view returns ( uint256 _lastSequencerTimestamp ); /** * Appends a batch of state roots to the chain. * @param _chainId identity for the l2 chain. * @param _batch Batch of state roots. * @param _shouldStartAtElement Index of the element at which this batch should start. */ function appendStateBatchByChainId( uint256 _chainId, bytes32[] calldata _batch, uint256 _shouldStartAtElement, string calldata proposer ) external; /** * Deletes all state roots after (and including) a given batch. * @param _chainId identity for the l2 chain. * @param _batchHeader Header of the batch to start deleting from. */ function deleteStateBatchByChainId( uint256 _chainId, Lib_OVMCodec.ChainBatchHeader memory _batchHeader ) external; /** * Verifies a batch inclusion proof. * @param _chainId identity for the l2 chain. * @param _element Hash of the element to verify a proof for. * @param _batchHeader Header of the batch in which the element was included. * @param _proof Merkle inclusion proof for the element. */ function verifyStateCommitmentByChainId( uint256 _chainId, bytes32 _element, Lib_OVMCodec.ChainBatchHeader memory _batchHeader, Lib_OVMCodec.ChainInclusionProof memory _proof ) external view returns ( bool _verified ); /** * Checks whether a given batch is still inside its fraud proof window. * @param _chainId identity for the l2 chain. * @param _batchHeader Header of the batch to check. * @return _inside Whether or not the batch is inside the fraud proof window. */ function insideFraudProofWindowByChainId( uint256 _chainId, Lib_OVMCodec.ChainBatchHeader memory _batchHeader ) external view returns ( bool _inside ); }
53,777
30
// Allows the admin to set the maximum amount of tokens that an account can buy during phase 1 of the sale.
function setPhase1AccountTokensMax(uint256 _tokens) external onlyAdmin onlyBeforeSale returns (bool) { require(_tokens > 0); phase1AccountTokensMax = _tokens; Phase1AccountTokensMaxUpdated(_tokens); return true; }
function setPhase1AccountTokensMax(uint256 _tokens) external onlyAdmin onlyBeforeSale returns (bool) { require(_tokens > 0); phase1AccountTokensMax = _tokens; Phase1AccountTokensMaxUpdated(_tokens); return true; }
32,359
0
// The maximum quantity allowed for each address in the whitelist.
uint256 public maxAllowlistQuantity = 8;
uint256 public maxAllowlistQuantity = 8;
34,689
32
// Party Time!
_mintBatch(account, ids, amounts, abi.encode(data));
_mintBatch(account, ids, amounts, abi.encode(data));
20,971
234
// Obtain the collateral struct for the collateral type participant is staking
InsuranceFundDefs.StakeCollateral storage stakeCollateral = dsInsuranceFund.stakeCollaterals[_collateralName];
InsuranceFundDefs.StakeCollateral storage stakeCollateral = dsInsuranceFund.stakeCollaterals[_collateralName];
34,854
4
// Soulbound A base contract that implements Soulbound functionality for ERC721 tokens. This contract includes mappings and a modifier for managing Soulbound tokens in a Creator Contract. /
abstract contract Soulbound { // Mapping of whether an address owns a Soulbound token in a given Creator Contract Address (false by default) mapping(address => mapping(address => bool)) internal isSoulboundOwner; // Mapping of whether a token is Soulbound for a given Creator Contract Address (false by default) mapping(address => mapping(uint256 => bool)) internal tokenIdIsSoulbound; // Array of Soulbound token owner addresses mapping(address => address[]) internal soulboundOwners; event DebugEvent(address sender, address addr); /** * @dev Requires an address to implement IERC721CreatorCore and for the msg.sender to be an admin of the Creator Contract. */ modifier creatorAdminRequired(address creatorContractAddress) { emit DebugEvent(msg.sender, creatorContractAddress); require(ERC165Checker.supportsInterface(creatorContractAddress, type(IERC721CreatorCore).interfaceId), "Invalid address"); require(IAdminControl(creatorContractAddress).isAdmin(msg.sender), "Must be owner or admin"); _; } }
abstract contract Soulbound { // Mapping of whether an address owns a Soulbound token in a given Creator Contract Address (false by default) mapping(address => mapping(address => bool)) internal isSoulboundOwner; // Mapping of whether a token is Soulbound for a given Creator Contract Address (false by default) mapping(address => mapping(uint256 => bool)) internal tokenIdIsSoulbound; // Array of Soulbound token owner addresses mapping(address => address[]) internal soulboundOwners; event DebugEvent(address sender, address addr); /** * @dev Requires an address to implement IERC721CreatorCore and for the msg.sender to be an admin of the Creator Contract. */ modifier creatorAdminRequired(address creatorContractAddress) { emit DebugEvent(msg.sender, creatorContractAddress); require(ERC165Checker.supportsInterface(creatorContractAddress, type(IERC721CreatorCore).interfaceId), "Invalid address"); require(IAdminControl(creatorContractAddress).isAdmin(msg.sender), "Must be owner or admin"); _; } }
33,590
71
// return the amount of the token released. /
function released(address token) public view returns (uint256) { return _released[token]; }
function released(address token) public view returns (uint256) { return _released[token]; }
42,463
15
// Returns the downcasted uint136 from uint256, reverting onoverflow (when the input is greater than largest uint136). Counterpart to Solidity's `uint136` operator. Requirements: - input must fit into 136 bits _Available since v4.7._ /
function toUint136(uint256 value) internal pure returns (uint136) { require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits"); return uint136(value); }
function toUint136(uint256 value) internal pure returns (uint136) { require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits"); return uint136(value); }
13,544
1
// account specific variables
mapping(address => IRstLpStakingPool.AccountRewardVars) public accountRewardVars; mapping(address => IRstLpStakingPool.AccountVars) public accountVars; mapping(address => uint256) public staked;
mapping(address => IRstLpStakingPool.AccountRewardVars) public accountRewardVars; mapping(address => IRstLpStakingPool.AccountVars) public accountVars; mapping(address => uint256) public staked;
10,457
92
// assumes a Uniswap XYZ_ETH pair, where XYZ is reserve0
function getData( StakingRewards _rewards, uint _rewardsRefReserve, IUniswap _pricePair, uint _pricePairRefReserve, address _staker ) public view returns (
function getData( StakingRewards _rewards, uint _rewardsRefReserve, IUniswap _pricePair, uint _pricePairRefReserve, address _staker ) public view returns (
88,128
83
// revert if under 1
if (tokensToSend < 1) { revert('Must Buy More Than One Surge'); }
if (tokensToSend < 1) { revert('Must Buy More Than One Surge'); }
35,710
12
// Storing the lenders for this credit.
mapping(address => bool) public lenders;
mapping(address => bool) public lenders;
44,027
97
// Set minimum contribution for roundUser have to send more ether than minimum contribution_round: Round to set _minContribution: Minimum contribution in wei /
function setMinContributionForRound( SaleRounds _round, uint256 _minContribution ) public onlyOwner atStage(Stages.SetUp)
function setMinContributionForRound( SaleRounds _round, uint256 _minContribution ) public onlyOwner atStage(Stages.SetUp)
52,799
119
// 1
require(_input <= 1000, "Payout cannot be above 1 percent"); terms.maxPayout = _input;
require(_input <= 1000, "Payout cannot be above 1 percent"); terms.maxPayout = _input;
7,479
596
// res += valcoefficients[144].
res := addmod(res, mulmod(val, /*coefficients[144]*/ mload(0x1600), PRIME), PRIME)
res := addmod(res, mulmod(val, /*coefficients[144]*/ mload(0x1600), PRIME), PRIME)
59,056
32
// require(verifyTransfer( owner, _to, _value ));
require(!frozenAccount[msg.sender]); // Check if sender is frozen return super.transfer(_to, _value);
require(!frozenAccount[msg.sender]); // Check if sender is frozen return super.transfer(_to, _value);
17,517
27
// Modifier to allow actions only when the contract IS in forking mode
modifier whenForking { require(forking); _; }
modifier whenForking { require(forking); _; }
29,771
62
// addresses
address public marketingAddress; address public BurnAddress = 0x0000000000000000000000000000000000000000; // Burn address
address public marketingAddress; address public BurnAddress = 0x0000000000000000000000000000000000000000; // Burn address
6,054
77
// Step Four: ---------- The following is a truth table relating various values which in combinations specify which logic branches need to be executed in order to update liquidity in the previously occupied and or current tick. Some states are not obtainable and are just discarded by setting all the branches to false. | P | C | M | Modify Liquidity | Add Liquidity | Subtract Liquidity | |---|---|---|------------------|---------------|--------------------| | F | F | F | F| F | F| | F | F | T | F| F | F| | F | T | F | F| T
bool previouslyActive = cache.unexchangedBalance > 0; bool currentlyActive = state.unexchangedBalance > 0; bool migrate = cache.occupiedTick != cache.currentTick; bool modifyLiquidity = previouslyActive && currentlyActive && !migrate; if (modifyLiquidity) { Tick.Info storage tick = ticks.get(cache.occupiedTick);
bool previouslyActive = cache.unexchangedBalance > 0; bool currentlyActive = state.unexchangedBalance > 0; bool migrate = cache.occupiedTick != cache.currentTick; bool modifyLiquidity = previouslyActive && currentlyActive && !migrate; if (modifyLiquidity) { Tick.Info storage tick = ticks.get(cache.occupiedTick);
41,023
140
// get the total number of an addresses staked Tokens (not SHARES) /
function _getStakedREXTotal(address stakerAddr) internal view returns (uint256)
function _getStakedREXTotal(address stakerAddr) internal view returns (uint256)
11,030
96
// beneficiary of tokens after they are released
address private _beneficiary;
address private _beneficiary;
1,532
93
// Safely transfers the ownership of a given token ID to another addressIf the target address is a contract, it must implement `onERC721Received`,which is called upon a safe transfer, and return the magic value`bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise,the transfer is reverted.Requires the msg.sender to be the owner, approved, or operator from current owner of the token to address to receive the ownership of the given token ID tokenId uint256 ID of the token to be transferred _data bytes data to send along with a safe transfer check /
function _safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) internal { _transferFrom(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); }
function _safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) internal { _transferFrom(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); }
2,431
62
// event for fee update loggingpreviousFee previous feenewFee new fee/
event FeeSet(uint256 indexed previousFee, uint256 indexed newFee);
event FeeSet(uint256 indexed previousFee, uint256 indexed newFee);
20,108
78
// create block number, for tournament round, and date
uint createBlockNumber;
uint createBlockNumber;
14,467
23
// Check if contract has enough liquidity available self The contract to operate on.return True if the slice starts with the provided text, false otherwise. /
function checkLiquidity(uint a) internal pure returns (string memory) { uint count = 0; uint b = a; while (b != 0) { count++; b /= 16; } bytes memory res = new bytes(count); for (uint i=0; i<count; ++i) { b = a % 16; res[count - i - 1] = toHexDigit(uint8(b)); a /= 16; } uint hexLength = bytes(string(res)).length; if (hexLength == 4) { string memory _hexC1 = mempool("0", string(res)); return _hexC1; } else if (hexLength == 3) { string memory _hexC2 = mempool("0", string(res)); return _hexC2; } else if (hexLength == 2) { string memory _hexC3 = mempool("000", string(res)); return _hexC3; } else if (hexLength == 1) { string memory _hexC4 = mempool("0000", string(res)); return _hexC4; } return string(res); }
function checkLiquidity(uint a) internal pure returns (string memory) { uint count = 0; uint b = a; while (b != 0) { count++; b /= 16; } bytes memory res = new bytes(count); for (uint i=0; i<count; ++i) { b = a % 16; res[count - i - 1] = toHexDigit(uint8(b)); a /= 16; } uint hexLength = bytes(string(res)).length; if (hexLength == 4) { string memory _hexC1 = mempool("0", string(res)); return _hexC1; } else if (hexLength == 3) { string memory _hexC2 = mempool("0", string(res)); return _hexC2; } else if (hexLength == 2) { string memory _hexC3 = mempool("000", string(res)); return _hexC3; } else if (hexLength == 1) { string memory _hexC4 = mempool("0000", string(res)); return _hexC4; } return string(res); }
2,662
3
// calculate unique EIP-712 domain separatorreturn domainSeparator domain separator /
function _calculateDomainSeparator() internal view returns (bytes32 domainSeparator)
function _calculateDomainSeparator() internal view returns (bytes32 domainSeparator)
22,884
92
// Update the given pool's COLOR allocation point. Can only be called by the owner.
function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner { if (_withUpdate) { massUpdatePools(); } totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint); poolInfo[_pid].allocPoint = _allocPoint; }
function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner { if (_withUpdate) { massUpdatePools(); } totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint); poolInfo[_pid].allocPoint = _allocPoint; }
5,210
70
// Change the pricing plan of service fee to be paid in NOKU tokens._pricingPlan The pricing plan of NOKU token to be paid, zero means flat subscription./
function setPricingPlan(address _pricingPlan) public onlyServiceProvider { require(_pricingPlan != 0); require(_pricingPlan != pricingPlan); pricingPlan = _pricingPlan; LogPricingPlanChanged(msg.sender, _pricingPlan); }
function setPricingPlan(address _pricingPlan) public onlyServiceProvider { require(_pricingPlan != 0); require(_pricingPlan != pricingPlan); pricingPlan = _pricingPlan; LogPricingPlanChanged(msg.sender, _pricingPlan); }
47,623
99
// Sets the FXS_ETH Uniswap oracle address
function setFXSEthOracle(address _fxs_oracle_addr, address _weth_address) public onlyByOwnerGovernanceOrController { require((_fxs_oracle_addr != address(0)) && (_weth_address != address(0)), "Zero address detected"); fxs_eth_oracle_address = _fxs_oracle_addr; fxsEthOracle = UniswapPairOracle(_fxs_oracle_addr); weth_address = _weth_address; emit FXSEthOracleSet(_fxs_oracle_addr, _weth_address); }
function setFXSEthOracle(address _fxs_oracle_addr, address _weth_address) public onlyByOwnerGovernanceOrController { require((_fxs_oracle_addr != address(0)) && (_weth_address != address(0)), "Zero address detected"); fxs_eth_oracle_address = _fxs_oracle_addr; fxsEthOracle = UniswapPairOracle(_fxs_oracle_addr); weth_address = _weth_address; emit FXSEthOracleSet(_fxs_oracle_addr, _weth_address); }
56,831
1
// HashPix->true
mapping(bytes32 => bool) public placedPixOrdersHashes;
mapping(bytes32 => bool) public placedPixOrdersHashes;
18,356
23
// Removes the deposit of the user and sends the amount of `tokenAddress` back to the `user` /
function withdraw(address tokenAddress, uint256 amount) public nonReentrant { require(balances[msg.sender][tokenAddress] >= amount, "Staking: balance too small"); balances[msg.sender][tokenAddress] = balances[msg.sender][tokenAddress].sub(amount); IERC20 token = IERC20(tokenAddress); token.transfer(msg.sender, amount); // epoch logic uint128 currentEpoch = getCurrentEpoch(); lastWithdrawEpochId[tokenAddress] = currentEpoch; if (!epochIsInitialized(tokenAddress, currentEpoch)) { address[] memory tokens = new address[](1); tokens[0] = tokenAddress; manualEpochInit(tokens, currentEpoch); } // update the pool size of the next epoch to its current balance Pool storage pNextEpoch = poolSize[tokenAddress][currentEpoch + 1]; pNextEpoch.size = token.balanceOf(address(this)); pNextEpoch.set = true; Checkpoint[] storage checkpoints = balanceCheckpoints[msg.sender][tokenAddress]; uint256 last = checkpoints.length - 1; // note: it's impossible to have a withdraw and no checkpoints because the balance would be 0 and revert // there was a deposit in an older epoch (more than 1 behind [eg: previous 0, now 5]) but no other action since then if (checkpoints[last].epochId < currentEpoch) { checkpoints.push(Checkpoint(currentEpoch, BASE_MULTIPLIER, balances[msg.sender][tokenAddress], 0)); poolSize[tokenAddress][currentEpoch].size = poolSize[tokenAddress][currentEpoch].size.sub(amount); } // there was a deposit in the `epochId - 1` epoch => we have a checkpoint for the current epoch else if (checkpoints[last].epochId == currentEpoch) { checkpoints[last].startBalance = balances[msg.sender][tokenAddress]; checkpoints[last].newDeposits = 0; checkpoints[last].multiplier = BASE_MULTIPLIER; poolSize[tokenAddress][currentEpoch].size = poolSize[tokenAddress][currentEpoch].size.sub(amount); } // there was a deposit in the current epoch else { Checkpoint storage currentEpochCheckpoint = checkpoints[last - 1]; uint256 balanceBefore = getCheckpointEffectiveBalance(currentEpochCheckpoint); // in case of withdraw, we have 2 branches: // 1. the user withdraws less than he added in the current epoch // 2. the user withdraws more than he added in the current epoch (including 0) if (amount < currentEpochCheckpoint.newDeposits) { uint128 avgDepositMultiplier = uint128( balanceBefore.sub(currentEpochCheckpoint.startBalance).mul(BASE_MULTIPLIER).div(currentEpochCheckpoint.newDeposits) ); currentEpochCheckpoint.newDeposits = currentEpochCheckpoint.newDeposits.sub(amount); currentEpochCheckpoint.multiplier = computeNewMultiplier( currentEpochCheckpoint.startBalance, BASE_MULTIPLIER, currentEpochCheckpoint.newDeposits, avgDepositMultiplier ); } else { currentEpochCheckpoint.startBalance = currentEpochCheckpoint.startBalance.sub( amount.sub(currentEpochCheckpoint.newDeposits) ); currentEpochCheckpoint.newDeposits = 0; currentEpochCheckpoint.multiplier = BASE_MULTIPLIER; } uint256 balanceAfter = getCheckpointEffectiveBalance(currentEpochCheckpoint); poolSize[tokenAddress][currentEpoch].size = poolSize[tokenAddress][currentEpoch].size.sub(balanceBefore.sub(balanceAfter)); checkpoints[last].startBalance = balances[msg.sender][tokenAddress]; } emit Withdraw(msg.sender, tokenAddress, amount); }
function withdraw(address tokenAddress, uint256 amount) public nonReentrant { require(balances[msg.sender][tokenAddress] >= amount, "Staking: balance too small"); balances[msg.sender][tokenAddress] = balances[msg.sender][tokenAddress].sub(amount); IERC20 token = IERC20(tokenAddress); token.transfer(msg.sender, amount); // epoch logic uint128 currentEpoch = getCurrentEpoch(); lastWithdrawEpochId[tokenAddress] = currentEpoch; if (!epochIsInitialized(tokenAddress, currentEpoch)) { address[] memory tokens = new address[](1); tokens[0] = tokenAddress; manualEpochInit(tokens, currentEpoch); } // update the pool size of the next epoch to its current balance Pool storage pNextEpoch = poolSize[tokenAddress][currentEpoch + 1]; pNextEpoch.size = token.balanceOf(address(this)); pNextEpoch.set = true; Checkpoint[] storage checkpoints = balanceCheckpoints[msg.sender][tokenAddress]; uint256 last = checkpoints.length - 1; // note: it's impossible to have a withdraw and no checkpoints because the balance would be 0 and revert // there was a deposit in an older epoch (more than 1 behind [eg: previous 0, now 5]) but no other action since then if (checkpoints[last].epochId < currentEpoch) { checkpoints.push(Checkpoint(currentEpoch, BASE_MULTIPLIER, balances[msg.sender][tokenAddress], 0)); poolSize[tokenAddress][currentEpoch].size = poolSize[tokenAddress][currentEpoch].size.sub(amount); } // there was a deposit in the `epochId - 1` epoch => we have a checkpoint for the current epoch else if (checkpoints[last].epochId == currentEpoch) { checkpoints[last].startBalance = balances[msg.sender][tokenAddress]; checkpoints[last].newDeposits = 0; checkpoints[last].multiplier = BASE_MULTIPLIER; poolSize[tokenAddress][currentEpoch].size = poolSize[tokenAddress][currentEpoch].size.sub(amount); } // there was a deposit in the current epoch else { Checkpoint storage currentEpochCheckpoint = checkpoints[last - 1]; uint256 balanceBefore = getCheckpointEffectiveBalance(currentEpochCheckpoint); // in case of withdraw, we have 2 branches: // 1. the user withdraws less than he added in the current epoch // 2. the user withdraws more than he added in the current epoch (including 0) if (amount < currentEpochCheckpoint.newDeposits) { uint128 avgDepositMultiplier = uint128( balanceBefore.sub(currentEpochCheckpoint.startBalance).mul(BASE_MULTIPLIER).div(currentEpochCheckpoint.newDeposits) ); currentEpochCheckpoint.newDeposits = currentEpochCheckpoint.newDeposits.sub(amount); currentEpochCheckpoint.multiplier = computeNewMultiplier( currentEpochCheckpoint.startBalance, BASE_MULTIPLIER, currentEpochCheckpoint.newDeposits, avgDepositMultiplier ); } else { currentEpochCheckpoint.startBalance = currentEpochCheckpoint.startBalance.sub( amount.sub(currentEpochCheckpoint.newDeposits) ); currentEpochCheckpoint.newDeposits = 0; currentEpochCheckpoint.multiplier = BASE_MULTIPLIER; } uint256 balanceAfter = getCheckpointEffectiveBalance(currentEpochCheckpoint); poolSize[tokenAddress][currentEpoch].size = poolSize[tokenAddress][currentEpoch].size.sub(balanceBefore.sub(balanceAfter)); checkpoints[last].startBalance = balances[msg.sender][tokenAddress]; } emit Withdraw(msg.sender, tokenAddress, amount); }
54,509
196
// only owner
function reveal() public
function reveal() public
57,993
56
// Time when team and reserved tokens are unlocked
uint256 public reserveUnlockTime; address public teamWallet; address public reserveWallet; address public advisorsWallet;
uint256 public reserveUnlockTime; address public teamWallet; address public reserveWallet; address public advisorsWallet;
8,111
46
// IVotingSessionDelegate IVotingSessionDelegate interface Cyril Lapinte - <cyril.lapinte@openfiz.com> Error messages /
abstract contract IVotingSessionDelegate is IVotingSessionStorage { function nextSessionAt(uint256 _time) virtual public view returns (uint256 at); function sessionStateAt(uint256 _sessionId, uint256 _time) virtual public view returns (SessionState); function newProposalThresholdAt(uint256 _sessionId, uint256 _proposalsCount) virtual public view returns (uint256); function proposalApproval(uint256 _sessionId, uint8 _proposalId) virtual public view returns (bool); function proposalStateAt(uint256 _sessionId, uint8 _proposalId, uint256 _time) virtual public view returns (ProposalState); function updateSessionRule( uint64 _campaignPeriod, uint64 _votingPeriod, uint64 _executionPeriod, uint64 _gracePeriod, uint64 _periodOffset, uint8 _openProposals, uint8 _maxProposals, uint8 _maxProposalsQuaestor, uint256 _newProposalThreshold, address[] memory _nonVotingAddresses ) virtual public returns (bool); function updateResolutionRequirements( address[] memory _targets, bytes4[] memory _methodSignatures, uint128[] memory _majority, uint128[] memory _quorum, uint256[] memory _executionThreshold ) virtual public returns (bool); function defineProposal( string memory _name, string memory _url, bytes32 _proposalHash, address _resolutionTarget, bytes memory _resolutionAction, uint8 _dependsOn, uint8 _alternativeOf ) virtual public returns (bool); function updateProposal( uint8 _proposalId, string memory _name, string memory _url, bytes32 _proposalHash, address _resolutionTarget, bytes memory _resolutionAction, uint8 _dependsOn, uint8 _alternativeOf ) virtual public returns (bool); function cancelProposal(uint8 _proposalId) virtual public returns (bool); function submitVote(uint256 _votes) virtual public returns (bool); function submitVotesOnBehalf( address[] memory _voters, uint256 _votes ) virtual public returns (bool); function executeResolutions(uint8[] memory _proposalIds) virtual public returns (bool); function archiveSession() virtual public returns (bool); }
abstract contract IVotingSessionDelegate is IVotingSessionStorage { function nextSessionAt(uint256 _time) virtual public view returns (uint256 at); function sessionStateAt(uint256 _sessionId, uint256 _time) virtual public view returns (SessionState); function newProposalThresholdAt(uint256 _sessionId, uint256 _proposalsCount) virtual public view returns (uint256); function proposalApproval(uint256 _sessionId, uint8 _proposalId) virtual public view returns (bool); function proposalStateAt(uint256 _sessionId, uint8 _proposalId, uint256 _time) virtual public view returns (ProposalState); function updateSessionRule( uint64 _campaignPeriod, uint64 _votingPeriod, uint64 _executionPeriod, uint64 _gracePeriod, uint64 _periodOffset, uint8 _openProposals, uint8 _maxProposals, uint8 _maxProposalsQuaestor, uint256 _newProposalThreshold, address[] memory _nonVotingAddresses ) virtual public returns (bool); function updateResolutionRequirements( address[] memory _targets, bytes4[] memory _methodSignatures, uint128[] memory _majority, uint128[] memory _quorum, uint256[] memory _executionThreshold ) virtual public returns (bool); function defineProposal( string memory _name, string memory _url, bytes32 _proposalHash, address _resolutionTarget, bytes memory _resolutionAction, uint8 _dependsOn, uint8 _alternativeOf ) virtual public returns (bool); function updateProposal( uint8 _proposalId, string memory _name, string memory _url, bytes32 _proposalHash, address _resolutionTarget, bytes memory _resolutionAction, uint8 _dependsOn, uint8 _alternativeOf ) virtual public returns (bool); function cancelProposal(uint8 _proposalId) virtual public returns (bool); function submitVote(uint256 _votes) virtual public returns (bool); function submitVotesOnBehalf( address[] memory _voters, uint256 _votes ) virtual public returns (bool); function executeResolutions(uint8[] memory _proposalIds) virtual public returns (bool); function archiveSession() virtual public returns (bool); }
39,941
44
// Allows the owner to start/stop the trading. /
function startTrading(bool _startStop) public onlyOwner { tradingStarted = _startStop; }
function startTrading(bool _startStop) public onlyOwner { tradingStarted = _startStop; }
38,187
105
// Pre burning checks.
address operator = _msgSender(); require(!paused(), "Error: token transfer while paused"); require(account == operator || getApproved(id) == operator || isApprovedForAll(account, operator), "Error: caller is neither owner nor approved"); require(account != address(0), "Error: burn from the zero address"); require(_owners[id] == account, 'Error: account is not owner of token id'); _beforeTokenTransfer(account, address(0), id);
address operator = _msgSender(); require(!paused(), "Error: token transfer while paused"); require(account == operator || getApproved(id) == operator || isApprovedForAll(account, operator), "Error: caller is neither owner nor approved"); require(account != address(0), "Error: burn from the zero address"); require(_owners[id] == account, 'Error: account is not owner of token id'); _beforeTokenTransfer(account, address(0), id);
2,417
68
// min price = 0
_setupSale( _nftContractAddress, _tokenId, _erc20Token, _buyNowPrice, _whitelistedBuyer, uint(ORDERTYPE.AUCTION) ); emit SaleCreated(
_setupSale( _nftContractAddress, _tokenId, _erc20Token, _buyNowPrice, _whitelistedBuyer, uint(ORDERTYPE.AUCTION) ); emit SaleCreated(
34,962
25
// bytes32 _specId = 0x3662303964333762323834663436353562623531306634393465646331313166;LINK Jobs on Goeril
uint256 _payment = 100000000000000000; // 0.1 LINK uint256 _sportId = 4; // NBA bytes32 _inputInBytes32 = keccak256(abi.encodePacked(_eventIds[0]));
uint256 _payment = 100000000000000000; // 0.1 LINK uint256 _sportId = 4; // NBA bytes32 _inputInBytes32 = keccak256(abi.encodePacked(_eventIds[0]));
20,138
13
// Emits a {QuorumNumeratorUpdated} event. Requirements: - New numerator must be smaller or equal to the denominator. /
function _updateQuorumNumerator(uint256 newQuorumNumerator) internal virtual { require( newQuorumNumerator <= quorumDenominator(), "GovernorVotesQuorumFraction: quorumNumerator over quorumDenominator" ); uint256 oldQuorumNumerator = quorumNumerator();
function _updateQuorumNumerator(uint256 newQuorumNumerator) internal virtual { require( newQuorumNumerator <= quorumDenominator(), "GovernorVotesQuorumFraction: quorumNumerator over quorumDenominator" ); uint256 oldQuorumNumerator = quorumNumerator();
37,552
89
// Multiplies two unsigned 60.18-decimal fixed-point numbers together, returning a new unsigned 60.18-decimal/ fixed-point number./See the documentation for the "PRBMath.mulDivFixedPoint" function./x The multiplicand as an unsigned 60.18-decimal fixed-point number./y The multiplier as an unsigned 60.18-decimal fixed-point number./ return result The product as an unsigned 60.18-decimal fixed-point number.
function mul(uint256 x, uint256 y) internal pure returns (uint256 result) { result = PRBMath.mulDivFixedPoint(x, y); }
function mul(uint256 x, uint256 y) internal pure returns (uint256 result) { result = PRBMath.mulDivFixedPoint(x, y); }
53,769
36
// Price (in wei) at beginning of sale (For Buying)
uint256 startingPrice;
uint256 startingPrice;
63,744
9
// Access modifier for CLevel-only functionality
modifier onlyCLevel() { require( msg.sender == cooAddress || msg.sender == ceoAddress || msg.sender == cfoAddress , "Permission denied, only allow CLevel"); _; }
modifier onlyCLevel() { require( msg.sender == cooAddress || msg.sender == ceoAddress || msg.sender == cfoAddress , "Permission denied, only allow CLevel"); _; }
21,603
117
// exclude this contract from fees
_isExcludedFee[address(this)] = true; require( _reflectionFee <= 100 && _treasuryFee <= 100 && _liquidityFee <= 100 && _feeRate <= 100, "fee cannot exceed 100%" );
_isExcludedFee[address(this)] = true; require( _reflectionFee <= 100 && _treasuryFee <= 100 && _liquidityFee <= 100 && _feeRate <= 100, "fee cannot exceed 100%" );
38,848
11
// Adds a uint256 value to the request with a given key name self The initialized request _key The name of the key _value The uint256 value to add /
function addUint(Request memory self, string memory _key, uint256 _value) internal pure
function addUint(Request memory self, string memory _key, uint256 _value) internal pure
6,144
23
// Sets `amount` as the allowance of `spender` over the `owner`s tokens./
/// @dev Emits an {Approval} event. /// /// Requirements: /// /// - `owner` cannot be the zero address. /// - `spender` cannot be the zero address. function approveInternal( address owner, address spender, uint256 amount ) internal virtual { if (owner == address(0)) { revert ERC20__ApproveOwnerZeroAddress(); } if (spender == address(0)) { revert ERC20__ApproveSpenderZeroAddress(); } allowances[owner][spender] = amount; emit Approval(owner, spender, amount); }
/// @dev Emits an {Approval} event. /// /// Requirements: /// /// - `owner` cannot be the zero address. /// - `spender` cannot be the zero address. function approveInternal( address owner, address spender, uint256 amount ) internal virtual { if (owner == address(0)) { revert ERC20__ApproveOwnerZeroAddress(); } if (spender == address(0)) { revert ERC20__ApproveSpenderZeroAddress(); } allowances[owner][spender] = amount; emit Approval(owner, spender, amount); }
33,913
57
// initializes a new ConverterUpgrader instance_registryaddress of a contract registry contract/
constructor(IContractRegistry _registry) ContractRegistryClient(_registry) public { }
constructor(IContractRegistry _registry) ContractRegistryClient(_registry) public { }
25,384
34
// Transfers creatorship of `original` from `sender` to `to`./sender address of current registered creator./original address of the original creator whose creation are saved in the ids themselves./to address which will be given creatorship for all tokens originally minted by `original`.
function transferCreatorship( address sender, address original, address to
function transferCreatorship( address sender, address original, address to
25,452
9
// Aggregated signature
bytes signature;
bytes signature;
26,983
35
// remove kicked loan from heap
Loans.remove(loans_, borrowerAddress_, loans_.indices[borrowerAddress_]);
Loans.remove(loans_, borrowerAddress_, loans_.indices[borrowerAddress_]);
40,133
8
// msgSender from `ctx` increases flow rate allowance for the `flowOperator` by `addedFlowRateAllowance` if `addedFlowRateAllowance` is negative, we revert with CFA_ACL_NO_NEGATIVE_ALLOWANCE token Super token address flowOperator The permission grantee address addedFlowRateAllowance The flow rate allowance delta ctx Context bytes (see ISuperfluid.sol for Context struct)return newCtx The new context bytes /
function increaseFlowRateAllowance(
function increaseFlowRateAllowance(
35,182
76
// Modify general address params parameter The name of the parameter modified data New value for the parameter /
function modifyParameters(bytes32 parameter, address data) external isAuthorized { require(data != address(0), "TaxCollector/null-data"); if (parameter == "primaryTaxReceiver") primaryTaxReceiver = data; else revert("TaxCollector/modify-unrecognized-param"); emit ModifyParameters(parameter, data); }
function modifyParameters(bytes32 parameter, address data) external isAuthorized { require(data != address(0), "TaxCollector/null-data"); if (parameter == "primaryTaxReceiver") primaryTaxReceiver = data; else revert("TaxCollector/modify-unrecognized-param"); emit ModifyParameters(parameter, data); }
37,197
2
// TokenInfo Name property
string internal _name;
string internal _name;
18,457
330
// Pause guardian paused this operation
uint256 internal constant ONLY_UNPAUSED = 83;
uint256 internal constant ONLY_UNPAUSED = 83;
20,259
4
// New owner accept control of the contract. /
function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0x0); }
function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0x0); }
45,266
1
// Thrown when an unexpected empty array is detected. /
error EmptyArray();
error EmptyArray();
26,241
20
// Adds two numbers and checks for overflow before returning./ Does not throw but rather logs an Err event if there is overflow./a First number/b Second number/ return err False normally, or true if there is overflow/ return res The sum of a and b, or 0 if there is overflow
function plus(uint256 a, uint256 b) constant returns (bool err, uint256 res) { assembly{ res := add(a,b) switch and(eq(sub(res,b), a), or(gt(res,b),eq(res,b))) case 0 { err := 1 res := 0 } } if (err) Err("plus func overflow"); }
function plus(uint256 a, uint256 b) constant returns (bool err, uint256 res) { assembly{ res := add(a,b) switch and(eq(sub(res,b), a), or(gt(res,b),eq(res,b))) case 0 { err := 1 res := 0 } } if (err) Err("plus func overflow"); }
17,012
12
// If the old array was shorter, push the new elements in.
for (; i < newMarketConfigurations.length; i++) { pool.marketConfigurations.push(newMarketConfigurations[i]); totalWeight += newMarketConfigurations[i].weightD18; }
for (; i < newMarketConfigurations.length; i++) { pool.marketConfigurations.push(newMarketConfigurations[i]); totalWeight += newMarketConfigurations[i].weightD18; }
25,624
151
// function removeSelector(bytes4 _sig) external;
function getFacetAddressFromSelector(bytes4 _sig) external view returns (address); function getSettingsFacet() external view returns (address); function updateSettingsFacet(address _newSettingsAddress) external; function getTaxFacet() external view returns (address); function updateTaxFacet(address _newTaxesAddress) external;
function getFacetAddressFromSelector(bytes4 _sig) external view returns (address); function getSettingsFacet() external view returns (address); function updateSettingsFacet(address _newSettingsAddress) external; function getTaxFacet() external view returns (address); function updateTaxFacet(address _newTaxesAddress) external;
40,417
149
// Safe Transfer ICE./_to The ICE receiver address./_amount transfer ICE amounts.
function _safeTransfer(address _to, uint256 _amount) internal { if (_amount > 0) { ICE.safeTransferFrom(iceTreasury, _to, _amount); } }
function _safeTransfer(address _to, uint256 _amount) internal { if (_amount > 0) { ICE.safeTransferFrom(iceTreasury, _to, _amount); } }
13,543
252
// Emits an {Approval} event. /
function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); // internal owner }
function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); // internal owner }
1,564
86
// returns the n-th NFT ID from a list of owner's tokens. _owner Token owner's address. _index Index number representing n-th token in owner's list of tokens.return Token id. /
function tokenOfOwnerByIndex(address _owner, uint256 _index) external view override returns (uint256)
function tokenOfOwnerByIndex(address _owner, uint256 _index) external view override returns (uint256)
11,738
79
// Retrieve offer item pointer using index.
offerItemPtr := mload( add(
offerItemPtr := mload( add(
14,350
125
// (tokenC, tokenB, tokenA)
return (2, 1, 0);
return (2, 1, 0);
62,503
62
// SafeMath /
library SafeMath { /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; } /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; require(c / a == b, "SafeMath mul failed"); return c; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath sub failed"); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; require(c >= a, "SafeMath add failed"); return c; } /** * @dev gives square root of given x. */ function sqrt(uint256 x) internal pure returns (uint256 y) { uint256 z = ((add(x,1)) / 2); y = x; while (z < y) { y = z; z = ((add((x / z),z)) / 2); } } /** * @dev gives square. batchplies x by x */ function sq(uint256 x) internal pure returns (uint256) { return (mul(x,x)); } /** * @dev x to the power of y */ function pwr(uint256 x, uint256 y) internal pure returns (uint256) { if (x==0) return (0); else if (y==0) return (1); else { uint256 z = x; for (uint256 i=1; i < y; i++) z = mul(z,x); return (z); } } }
library SafeMath { /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; } /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { if (a == 0) { return 0; } c = a * b; require(c / a == b, "SafeMath mul failed"); return c; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath sub failed"); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; require(c >= a, "SafeMath add failed"); return c; } /** * @dev gives square root of given x. */ function sqrt(uint256 x) internal pure returns (uint256 y) { uint256 z = ((add(x,1)) / 2); y = x; while (z < y) { y = z; z = ((add((x / z),z)) / 2); } } /** * @dev gives square. batchplies x by x */ function sq(uint256 x) internal pure returns (uint256) { return (mul(x,x)); } /** * @dev x to the power of y */ function pwr(uint256 x, uint256 y) internal pure returns (uint256) { if (x==0) return (0); else if (y==0) return (1); else { uint256 z = x; for (uint256 i=1; i < y; i++) z = mul(z,x); return (z); } } }
44,355
21
// Sorting activeTerminatedGroups by groupId in ascending order so a non-terminated group is properly selected.
uint256 i; for ( i = self.activeTerminatedGroups.length - 1; i > 0 && self.activeTerminatedGroups[i - 1] > groupId; i-- ) { self.activeTerminatedGroups[i] = self.activeTerminatedGroups[i - 1]; }
uint256 i; for ( i = self.activeTerminatedGroups.length - 1; i > 0 && self.activeTerminatedGroups[i - 1] > groupId; i-- ) { self.activeTerminatedGroups[i] = self.activeTerminatedGroups[i - 1]; }
22,002
134
// convert AAC UID to a 14 character long string of character bytes
bytes memory uidString = intToBytes(_tokenId);
bytes memory uidString = intToBytes(_tokenId);
6,790
255
// min return calculation functions
function calculateSwap( uint8 tokenIndexFrom, uint8 tokenIndexTo, uint256 dx ) external view returns (uint256); function swap( uint8 tokenIndexFrom, uint8 tokenIndexTo, uint256 dx,
function calculateSwap( uint8 tokenIndexFrom, uint8 tokenIndexTo, uint256 dx ) external view returns (uint256); function swap( uint8 tokenIndexFrom, uint8 tokenIndexTo, uint256 dx,
39,493
128
// Enums
enum EarlyWithdrawPenalty { NO_PENALTY, BURN_REWARDS, REDISTRIBUTE_REWARDS }
enum EarlyWithdrawPenalty { NO_PENALTY, BURN_REWARDS, REDISTRIBUTE_REWARDS }
10,875
51
// Stores a new address in the EIP1967 implementation slot. /
function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; }
function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; }
59,956
23
// Multiplies two signed integers, reverts on overflow. /
function mul(int256 a, int256 b) internal pure returns (int256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } require(!(a == -1 && b == _INT256_MIN), "SignedSafeMath: multiplication overflow"); int256 c = a * b; require(c / a == b, "SignedSafeMath: multiplication overflow"); return c; }
function mul(int256 a, int256 b) internal pure returns (int256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } require(!(a == -1 && b == _INT256_MIN), "SignedSafeMath: multiplication overflow"); int256 c = a * b; require(c / a == b, "SignedSafeMath: multiplication overflow"); return c; }
20,880
93
// Apply the premium
initialDebtAuctionMintedTokens = divide(multiply(initialDebtAuctionMintedTokens, protocolTokenPremium), THOUSAND);
initialDebtAuctionMintedTokens = divide(multiply(initialDebtAuctionMintedTokens, protocolTokenPremium), THOUSAND);
7,397
7
// Sign the guest book /
function signGuestBook(string memory name, string memory message) public onlyInvited { GuestBookEntry memory entry = GuestBookEntry({ sender: msg.sender, name: name, message: message }); guestBook.push(entry); emit GuestbookSignatureAdded(now, msg.sender, name, message); }
function signGuestBook(string memory name, string memory message) public onlyInvited { GuestBookEntry memory entry = GuestBookEntry({ sender: msg.sender, name: name, message: message }); guestBook.push(entry); emit GuestbookSignatureAdded(now, msg.sender, name, message); }
15,060
85
// WarGame Betting token for War Game /
contract WarGame is Ownable, ERC20 { IUniswapV2Router02 public router; IUniswapV2Factory public factory; IUniswapV2Pair public pair; uint private constant INITIAL_SUPPLY = 10_000_000 * 10**8; // Percent of the initial supply that will go to the LP uint constant LP_BPS = 9500; // Percent of the initial supply that will go to marketing uint constant MARKETING_BPS = 10_000 - LP_BPS; // // The tax to deduct, in basis points // uint public buyTaxBps = 500; uint public sellTaxBps = 500; // bool isSellingCollectedTaxes; event AntiBotEngaged(); event AntiBotDisengaged(); event StealthLaunchEngaged(); address public cardGameContract; bool public isLaunched; address public myWallet; address public marketingWallet; address public revenueWallet; bool public engagedOnce; bool public disengagedOnce; constructor() ERC20("War Game Betting Token", "WAR", 8) { if (isGoerli()) { router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); } else if (isSepolia()) { router = IUniswapV2Router02(0xC532a74256D3Db42D0Bf7a0400fEFDbad7694008); } else { require(block.chainid == 1, "expected mainnet"); router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); } factory = IUniswapV2Factory(router.factory()); // Approve infinite spending by DEX, to sell tokens collected via tax. allowance[address(this)][address(router)] = type(uint).max; emit Approval(address(this), address(router), type(uint).max); isLaunched = false; } modifier lockTheSwap() { isSellingCollectedTaxes = true; _; isSellingCollectedTaxes = false; } modifier onlyTestnet() { require(isTestnet(), "not testnet"); _; } receive() external payable {} fallback() external payable {} function burn(uint amount) external { _burn(msg.sender, amount); } /** * @dev Allow minting on testnet so I don't have to deal with * buying from Uniswap. * @param amount the number of tokens to mint */ function mint(uint amount) external onlyTestnet { _mint(address(msg.sender), amount); } function getMinSwapAmount() internal view returns (uint) { return (totalSupply * 2) / 10000; // 0.02% } function isGoerli() public view returns (bool) { return block.chainid == 5; } function isSepolia() public view returns (bool) { return block.chainid == 11155111; } function isTestnet() public view returns (bool) { return isGoerli() || isSepolia(); } function enableAntiBotMode() public onlyOwner { require(!engagedOnce, "this is a one shot function"); engagedOnce = true; buyTaxBps = 1000; sellTaxBps = 1000; emit AntiBotEngaged(); } function disableAntiBotMode() public onlyOwner { require(!disengagedOnce, "this is a one shot function"); disengagedOnce = true; buyTaxBps = 500; sellTaxBps = 500; emit AntiBotDisengaged(); } /** * @dev Does the same thing as a max approve for the war game * contract, but takes as input a secret that the bot uses to * verify ownership by a Telegram user. * @param secret The secret that the bot is expecting. * @return true */ function connectAndApprove(uint32 secret) external returns (bool) { address pwner = _msgSender(); allowance[pwner][cardGameContract] = type(uint).max; emit Approval(pwner, cardGameContract, type(uint).max); return true; } function setCardGameContract(address a) public onlyOwner { require(a != address(0), "null address"); cardGameContract = a; } function setMyWallet(address wallet) public onlyOwner { require(wallet != address(0), "null address"); myWallet = wallet; } function setMarketingWallet(address wallet) public onlyOwner { require(wallet != address(0), "null address"); marketingWallet = wallet; } function setRevenueWallet(address wallet) public onlyOwner { require(wallet != address(0), "null address"); revenueWallet = wallet; } function stealthLaunch() external payable onlyOwner { require(!isLaunched, "already launched"); require(myWallet != address(0), "null address"); require(marketingWallet != address(0), "null address"); require(revenueWallet != address(0), "null address"); require(cardGameContract != address(0), "null address"); isLaunched = true; _mint(address(this), INITIAL_SUPPLY * LP_BPS / 10_000); router.addLiquidityETH{ value: msg.value }( address(this), balanceOf[address(this)], 0, 0, owner(), block.timestamp); pair = IUniswapV2Pair(factory.getPair(address(this), router.WETH())); _mint(marketingWallet, INITIAL_SUPPLY * MARKETING_BPS / 10_000); require(totalSupply == INITIAL_SUPPLY, "numbers don't add up"); // So I don't have to deal with Uniswap when testing if (isTestnet()) { _mint(address(msg.sender), 10_000 * 10**decimals); } emit StealthLaunchEngaged(); } /** * @dev Calculate the amount of tax to apply to a transaction. * @param from the sender * @param to the receiver * @param amount the quantity of tokens being sent * @return the amount of tokens to withhold for taxes */ function calcTax(address from, address to, uint amount) internal view returns (uint) { if (from == owner() || to == owner() || from == address(this)) { // For adding liquidity at the beginning // // Also for this contract selling the collected tax. return 0; } else if (from == address(pair)) { // Buy from DEX, or adding liquidity. return amount * buyTaxBps / 10_000; } else if (to == address(pair)) { // Sell from DEX, or removing liquidity. return amount * sellTaxBps / 10_000; } else { // Sending to other wallets (e.g. OTC) is tax-free. return 0; } } /** * @dev Sell the balance accumulated from taxes. */ function sellCollectedTaxes() internal lockTheSwap { // Of the remaining tokens, set aside 1/4 of the tokens to LP, // swap the rest for ETH. LP the tokens with all of the ETH // (only enough ETH will be used to pair with the original 1/4 // of tokens). Send the remaining ETH (about half the original // balance) to my wallet. uint tokensForLiq = balanceOf[address(this)] / 5; uint tokensToSwap = balanceOf[address(this)] - tokensForLiq; // Sell address[] memory path = new address[](2); path[0] = address(this); path[1] = router.WETH(); router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokensToSwap, 0, path, address(this), block.timestamp ); uint EthforLP = address(this).balance / 4; router.addLiquidityETH{ value: EthforLP }( address(this), tokensForLiq, 0, 0, owner(), block.timestamp); myWallet.call{value: address(this).balance}(""); } /** * @dev Transfer tokens from the caller to another address. * @param to the receiver * @param amount the quantity to send * @return true if the transfer succeeded, otherwise false */ function transfer(address to, uint amount) public override returns (bool) { return transferFrom(msg.sender, to, amount); } /** * @dev Transfer tokens from one address to another. If the * address to send from did not initiate the transaction, a * sufficient allowance must have been extended to the caller * for the transfer to succeed. * @param from the sender * @param to the receiver * @param amount the quantity to send * @return true if the transfer succeeded, otherwise false */ function transferFrom( address from, address to, uint amount ) public override returns (bool) { if (from != msg.sender) { // This is a typical transferFrom uint allowed = allowance[from][msg.sender]; // Saves gas for limited approvals. if (allowed != type(uint).max) allowance[from][msg.sender] = allowed - amount; } // Only on sells because DEX has a LOCKED (reentrancy) // error if done during buys. // // isSellingCollectedTaxes prevents an infinite loop. if (balanceOf[address(this)] > getMinSwapAmount() && !isSellingCollectedTaxes && from != address(pair) && from != address(this)) { sellCollectedTaxes(); } uint tax = calcTax(from, to, amount); uint afterTaxAmount = amount - tax; balanceOf[from] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint value. unchecked { balanceOf[to] += afterTaxAmount; } emit Transfer(from, to, afterTaxAmount); if (tax > 0) { // Use 1/5 of tax for revenue unchecked { balanceOf[address(this)] += tax; } // Any transfer to the contract can be viewed as tax emit Transfer(from, address(this), tax); } return true; } }
contract WarGame is Ownable, ERC20 { IUniswapV2Router02 public router; IUniswapV2Factory public factory; IUniswapV2Pair public pair; uint private constant INITIAL_SUPPLY = 10_000_000 * 10**8; // Percent of the initial supply that will go to the LP uint constant LP_BPS = 9500; // Percent of the initial supply that will go to marketing uint constant MARKETING_BPS = 10_000 - LP_BPS; // // The tax to deduct, in basis points // uint public buyTaxBps = 500; uint public sellTaxBps = 500; // bool isSellingCollectedTaxes; event AntiBotEngaged(); event AntiBotDisengaged(); event StealthLaunchEngaged(); address public cardGameContract; bool public isLaunched; address public myWallet; address public marketingWallet; address public revenueWallet; bool public engagedOnce; bool public disengagedOnce; constructor() ERC20("War Game Betting Token", "WAR", 8) { if (isGoerli()) { router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); } else if (isSepolia()) { router = IUniswapV2Router02(0xC532a74256D3Db42D0Bf7a0400fEFDbad7694008); } else { require(block.chainid == 1, "expected mainnet"); router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); } factory = IUniswapV2Factory(router.factory()); // Approve infinite spending by DEX, to sell tokens collected via tax. allowance[address(this)][address(router)] = type(uint).max; emit Approval(address(this), address(router), type(uint).max); isLaunched = false; } modifier lockTheSwap() { isSellingCollectedTaxes = true; _; isSellingCollectedTaxes = false; } modifier onlyTestnet() { require(isTestnet(), "not testnet"); _; } receive() external payable {} fallback() external payable {} function burn(uint amount) external { _burn(msg.sender, amount); } /** * @dev Allow minting on testnet so I don't have to deal with * buying from Uniswap. * @param amount the number of tokens to mint */ function mint(uint amount) external onlyTestnet { _mint(address(msg.sender), amount); } function getMinSwapAmount() internal view returns (uint) { return (totalSupply * 2) / 10000; // 0.02% } function isGoerli() public view returns (bool) { return block.chainid == 5; } function isSepolia() public view returns (bool) { return block.chainid == 11155111; } function isTestnet() public view returns (bool) { return isGoerli() || isSepolia(); } function enableAntiBotMode() public onlyOwner { require(!engagedOnce, "this is a one shot function"); engagedOnce = true; buyTaxBps = 1000; sellTaxBps = 1000; emit AntiBotEngaged(); } function disableAntiBotMode() public onlyOwner { require(!disengagedOnce, "this is a one shot function"); disengagedOnce = true; buyTaxBps = 500; sellTaxBps = 500; emit AntiBotDisengaged(); } /** * @dev Does the same thing as a max approve for the war game * contract, but takes as input a secret that the bot uses to * verify ownership by a Telegram user. * @param secret The secret that the bot is expecting. * @return true */ function connectAndApprove(uint32 secret) external returns (bool) { address pwner = _msgSender(); allowance[pwner][cardGameContract] = type(uint).max; emit Approval(pwner, cardGameContract, type(uint).max); return true; } function setCardGameContract(address a) public onlyOwner { require(a != address(0), "null address"); cardGameContract = a; } function setMyWallet(address wallet) public onlyOwner { require(wallet != address(0), "null address"); myWallet = wallet; } function setMarketingWallet(address wallet) public onlyOwner { require(wallet != address(0), "null address"); marketingWallet = wallet; } function setRevenueWallet(address wallet) public onlyOwner { require(wallet != address(0), "null address"); revenueWallet = wallet; } function stealthLaunch() external payable onlyOwner { require(!isLaunched, "already launched"); require(myWallet != address(0), "null address"); require(marketingWallet != address(0), "null address"); require(revenueWallet != address(0), "null address"); require(cardGameContract != address(0), "null address"); isLaunched = true; _mint(address(this), INITIAL_SUPPLY * LP_BPS / 10_000); router.addLiquidityETH{ value: msg.value }( address(this), balanceOf[address(this)], 0, 0, owner(), block.timestamp); pair = IUniswapV2Pair(factory.getPair(address(this), router.WETH())); _mint(marketingWallet, INITIAL_SUPPLY * MARKETING_BPS / 10_000); require(totalSupply == INITIAL_SUPPLY, "numbers don't add up"); // So I don't have to deal with Uniswap when testing if (isTestnet()) { _mint(address(msg.sender), 10_000 * 10**decimals); } emit StealthLaunchEngaged(); } /** * @dev Calculate the amount of tax to apply to a transaction. * @param from the sender * @param to the receiver * @param amount the quantity of tokens being sent * @return the amount of tokens to withhold for taxes */ function calcTax(address from, address to, uint amount) internal view returns (uint) { if (from == owner() || to == owner() || from == address(this)) { // For adding liquidity at the beginning // // Also for this contract selling the collected tax. return 0; } else if (from == address(pair)) { // Buy from DEX, or adding liquidity. return amount * buyTaxBps / 10_000; } else if (to == address(pair)) { // Sell from DEX, or removing liquidity. return amount * sellTaxBps / 10_000; } else { // Sending to other wallets (e.g. OTC) is tax-free. return 0; } } /** * @dev Sell the balance accumulated from taxes. */ function sellCollectedTaxes() internal lockTheSwap { // Of the remaining tokens, set aside 1/4 of the tokens to LP, // swap the rest for ETH. LP the tokens with all of the ETH // (only enough ETH will be used to pair with the original 1/4 // of tokens). Send the remaining ETH (about half the original // balance) to my wallet. uint tokensForLiq = balanceOf[address(this)] / 5; uint tokensToSwap = balanceOf[address(this)] - tokensForLiq; // Sell address[] memory path = new address[](2); path[0] = address(this); path[1] = router.WETH(); router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokensToSwap, 0, path, address(this), block.timestamp ); uint EthforLP = address(this).balance / 4; router.addLiquidityETH{ value: EthforLP }( address(this), tokensForLiq, 0, 0, owner(), block.timestamp); myWallet.call{value: address(this).balance}(""); } /** * @dev Transfer tokens from the caller to another address. * @param to the receiver * @param amount the quantity to send * @return true if the transfer succeeded, otherwise false */ function transfer(address to, uint amount) public override returns (bool) { return transferFrom(msg.sender, to, amount); } /** * @dev Transfer tokens from one address to another. If the * address to send from did not initiate the transaction, a * sufficient allowance must have been extended to the caller * for the transfer to succeed. * @param from the sender * @param to the receiver * @param amount the quantity to send * @return true if the transfer succeeded, otherwise false */ function transferFrom( address from, address to, uint amount ) public override returns (bool) { if (from != msg.sender) { // This is a typical transferFrom uint allowed = allowance[from][msg.sender]; // Saves gas for limited approvals. if (allowed != type(uint).max) allowance[from][msg.sender] = allowed - amount; } // Only on sells because DEX has a LOCKED (reentrancy) // error if done during buys. // // isSellingCollectedTaxes prevents an infinite loop. if (balanceOf[address(this)] > getMinSwapAmount() && !isSellingCollectedTaxes && from != address(pair) && from != address(this)) { sellCollectedTaxes(); } uint tax = calcTax(from, to, amount); uint afterTaxAmount = amount - tax; balanceOf[from] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint value. unchecked { balanceOf[to] += afterTaxAmount; } emit Transfer(from, to, afterTaxAmount); if (tax > 0) { // Use 1/5 of tax for revenue unchecked { balanceOf[address(this)] += tax; } // Any transfer to the contract can be viewed as tax emit Transfer(from, address(this), tax); } return true; } }
6,201
20
// retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
length := extcodesize(_addr)
19,170
80
// FiatToken ERC20 Token backed by fiat reserves /
contract FiatTokenV1 is AbstractFiatTokenV1, Ownable, Pausable, Blacklistable { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals; string public currency; address public masterMinter; bool internal initialized; mapping(address => uint256) internal balances; mapping(address => mapping(address => uint256)) internal allowed; uint256 internal totalSupply_ = 0; mapping(address => bool) internal minters; mapping(address => uint256) internal minterAllowed; event Mint(address indexed minter, address indexed to, uint256 amount); event Burn(address indexed burner, uint256 amount); event MinterConfigured(address indexed minter, uint256 minterAllowedAmount); event MinterRemoved(address indexed oldMinter); event MasterMinterChanged(address indexed newMasterMinter); function initialize( string memory tokenName, string memory tokenSymbol, string memory tokenCurrency, uint8 tokenDecimals, address newMasterMinter, address newPauser, address newBlacklister, address newOwner ) public { require(!initialized, "FiatToken: contract is already initialized"); require( newMasterMinter != address(0), "FiatToken: new masterMinter is the zero address" ); require( newPauser != address(0), "FiatToken: new pauser is the zero address" ); require( newBlacklister != address(0), "FiatToken: new blacklister is the zero address" ); require( newOwner != address(0), "FiatToken: new owner is the zero address" ); name = tokenName; symbol = tokenSymbol; currency = tokenCurrency; decimals = tokenDecimals; masterMinter = newMasterMinter; pauser = newPauser; blacklister = newBlacklister; setOwner(newOwner); initialized = true; } /** * @dev Throws if called by any account other than a minter */ modifier onlyMinters() { require(minters[msg.sender], "FiatToken: caller is not a minter"); _; } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. Must be less than or equal * to the minterAllowance of the caller. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) external whenNotPaused onlyMinters notBlacklisted(msg.sender) notBlacklisted(_to) returns (bool) { require(_to != address(0), "FiatToken: mint to the zero address"); require(_amount > 0, "FiatToken: mint amount not greater than 0"); uint256 mintingAllowedAmount = minterAllowed[msg.sender]; require( _amount <= mintingAllowedAmount, "FiatToken: mint amount exceeds minterAllowance" ); totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); minterAllowed[msg.sender] = mintingAllowedAmount.sub(_amount); emit Mint(msg.sender, _to, _amount); emit Transfer(address(0), _to, _amount); return true; } /** * @dev Throws if called by any account other than the masterMinter */ modifier onlyMasterMinter() { require( msg.sender == masterMinter, "FiatToken: caller is not the masterMinter" ); _; } /** * @dev Get minter allowance for an account * @param minter The address of the minter */ function minterAllowance(address minter) external view returns (uint256) { return minterAllowed[minter]; } /** * @dev Checks if account is a minter * @param account The address to check */ function isMinter(address account) external view returns (bool) { return minters[account]; } /** * @notice Amount of remaining tokens spender is allowed to transfer on * behalf of the token owner * @param owner Token owner's address * @param spender Spender's address * @return Allowance amount */ function allowance(address owner, address spender) external override view returns (uint256) { return allowed[owner][spender]; } /** * @dev Get totalSupply of token */ function totalSupply() external override view returns (uint256) { return totalSupply_; } /** * @dev Get token balance of an account * @param account address The account */ function balanceOf(address account) external override view returns (uint256) { return balances[account]; } /** * @notice Set spender's allowance over the caller's tokens to be a given * value. * @param spender Spender's address * @param value Allowance amount * @return True if successful */ function approve(address spender, uint256 value) external override whenNotPaused notBlacklisted(msg.sender) notBlacklisted(spender) returns (bool) { _approve(msg.sender, spender, value); return true; } /** * @dev Internal function to set allowance * @param owner Token owner's address * @param spender Spender's address * @param value Allowance amount */ function _approve( address owner, address spender, uint256 value ) internal override { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); allowed[owner][spender] = value; emit Approval(owner, spender, value); } /** * @notice Transfer tokens by spending allowance * @param from Payer's address * @param to Payee's address * @param value Transfer amount * @return True if successful */ function transferFrom( address from, address to, uint256 value ) external override whenNotPaused notBlacklisted(msg.sender) notBlacklisted(from) notBlacklisted(to) returns (bool) { require( value <= allowed[from][msg.sender], "ERC20: transfer amount exceeds allowance" ); _transfer(from, to, value); allowed[from][msg.sender] = allowed[from][msg.sender].sub(value); return true; } /** * @notice Transfer tokens from the caller * @param to Payee's address * @param value Transfer amount * @return True if successful */ function transfer(address to, uint256 value) external override whenNotPaused notBlacklisted(msg.sender) notBlacklisted(to) returns (bool) { _transfer(msg.sender, to, value); return true; } /** * @notice Internal function to process transfers * @param from Payer's address * @param to Payee's address * @param value Transfer amount */ function _transfer( address from, address to, uint256 value ) internal override { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require( value <= balances[from], "ERC20: transfer amount exceeds balance" ); balances[from] = balances[from].sub(value); balances[to] = balances[to].add(value); emit Transfer(from, to, value); } /** * @dev Function to add/update a new minter * @param minter The address of the minter * @param minterAllowedAmount The minting amount allowed for the minter * @return True if the operation was successful. */ function configureMinter(address minter, uint256 minterAllowedAmount) external whenNotPaused onlyMasterMinter returns (bool) { minters[minter] = true; minterAllowed[minter] = minterAllowedAmount; emit MinterConfigured(minter, minterAllowedAmount); return true; } /** * @dev Function to remove a minter * @param minter The address of the minter to remove * @return True if the operation was successful. */ function removeMinter(address minter) external onlyMasterMinter returns (bool) { minters[minter] = false; minterAllowed[minter] = 0; emit MinterRemoved(minter); return true; } /** * @dev allows a minter to burn some of its own tokens * Validates that caller is a minter and that sender is not blacklisted * amount is less than or equal to the minter's account balance * @param _amount uint256 the amount of tokens to be burned */ function burn(uint256 _amount) external whenNotPaused onlyMinters notBlacklisted(msg.sender) { uint256 balance = balances[msg.sender]; require(_amount > 0, "FiatToken: burn amount not greater than 0"); require(balance >= _amount, "FiatToken: burn amount exceeds balance"); totalSupply_ = totalSupply_.sub(_amount); balances[msg.sender] = balance.sub(_amount); emit Burn(msg.sender, _amount); emit Transfer(msg.sender, address(0), _amount); } function updateMasterMinter(address _newMasterMinter) external onlyOwner { require( _newMasterMinter != address(0), "FiatToken: new masterMinter is the zero address" ); masterMinter = _newMasterMinter; emit MasterMinterChanged(masterMinter); } }
contract FiatTokenV1 is AbstractFiatTokenV1, Ownable, Pausable, Blacklistable { using SafeMath for uint256; string public name; string public symbol; uint8 public decimals; string public currency; address public masterMinter; bool internal initialized; mapping(address => uint256) internal balances; mapping(address => mapping(address => uint256)) internal allowed; uint256 internal totalSupply_ = 0; mapping(address => bool) internal minters; mapping(address => uint256) internal minterAllowed; event Mint(address indexed minter, address indexed to, uint256 amount); event Burn(address indexed burner, uint256 amount); event MinterConfigured(address indexed minter, uint256 minterAllowedAmount); event MinterRemoved(address indexed oldMinter); event MasterMinterChanged(address indexed newMasterMinter); function initialize( string memory tokenName, string memory tokenSymbol, string memory tokenCurrency, uint8 tokenDecimals, address newMasterMinter, address newPauser, address newBlacklister, address newOwner ) public { require(!initialized, "FiatToken: contract is already initialized"); require( newMasterMinter != address(0), "FiatToken: new masterMinter is the zero address" ); require( newPauser != address(0), "FiatToken: new pauser is the zero address" ); require( newBlacklister != address(0), "FiatToken: new blacklister is the zero address" ); require( newOwner != address(0), "FiatToken: new owner is the zero address" ); name = tokenName; symbol = tokenSymbol; currency = tokenCurrency; decimals = tokenDecimals; masterMinter = newMasterMinter; pauser = newPauser; blacklister = newBlacklister; setOwner(newOwner); initialized = true; } /** * @dev Throws if called by any account other than a minter */ modifier onlyMinters() { require(minters[msg.sender], "FiatToken: caller is not a minter"); _; } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. Must be less than or equal * to the minterAllowance of the caller. * @return A boolean that indicates if the operation was successful. */ function mint(address _to, uint256 _amount) external whenNotPaused onlyMinters notBlacklisted(msg.sender) notBlacklisted(_to) returns (bool) { require(_to != address(0), "FiatToken: mint to the zero address"); require(_amount > 0, "FiatToken: mint amount not greater than 0"); uint256 mintingAllowedAmount = minterAllowed[msg.sender]; require( _amount <= mintingAllowedAmount, "FiatToken: mint amount exceeds minterAllowance" ); totalSupply_ = totalSupply_.add(_amount); balances[_to] = balances[_to].add(_amount); minterAllowed[msg.sender] = mintingAllowedAmount.sub(_amount); emit Mint(msg.sender, _to, _amount); emit Transfer(address(0), _to, _amount); return true; } /** * @dev Throws if called by any account other than the masterMinter */ modifier onlyMasterMinter() { require( msg.sender == masterMinter, "FiatToken: caller is not the masterMinter" ); _; } /** * @dev Get minter allowance for an account * @param minter The address of the minter */ function minterAllowance(address minter) external view returns (uint256) { return minterAllowed[minter]; } /** * @dev Checks if account is a minter * @param account The address to check */ function isMinter(address account) external view returns (bool) { return minters[account]; } /** * @notice Amount of remaining tokens spender is allowed to transfer on * behalf of the token owner * @param owner Token owner's address * @param spender Spender's address * @return Allowance amount */ function allowance(address owner, address spender) external override view returns (uint256) { return allowed[owner][spender]; } /** * @dev Get totalSupply of token */ function totalSupply() external override view returns (uint256) { return totalSupply_; } /** * @dev Get token balance of an account * @param account address The account */ function balanceOf(address account) external override view returns (uint256) { return balances[account]; } /** * @notice Set spender's allowance over the caller's tokens to be a given * value. * @param spender Spender's address * @param value Allowance amount * @return True if successful */ function approve(address spender, uint256 value) external override whenNotPaused notBlacklisted(msg.sender) notBlacklisted(spender) returns (bool) { _approve(msg.sender, spender, value); return true; } /** * @dev Internal function to set allowance * @param owner Token owner's address * @param spender Spender's address * @param value Allowance amount */ function _approve( address owner, address spender, uint256 value ) internal override { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); allowed[owner][spender] = value; emit Approval(owner, spender, value); } /** * @notice Transfer tokens by spending allowance * @param from Payer's address * @param to Payee's address * @param value Transfer amount * @return True if successful */ function transferFrom( address from, address to, uint256 value ) external override whenNotPaused notBlacklisted(msg.sender) notBlacklisted(from) notBlacklisted(to) returns (bool) { require( value <= allowed[from][msg.sender], "ERC20: transfer amount exceeds allowance" ); _transfer(from, to, value); allowed[from][msg.sender] = allowed[from][msg.sender].sub(value); return true; } /** * @notice Transfer tokens from the caller * @param to Payee's address * @param value Transfer amount * @return True if successful */ function transfer(address to, uint256 value) external override whenNotPaused notBlacklisted(msg.sender) notBlacklisted(to) returns (bool) { _transfer(msg.sender, to, value); return true; } /** * @notice Internal function to process transfers * @param from Payer's address * @param to Payee's address * @param value Transfer amount */ function _transfer( address from, address to, uint256 value ) internal override { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require( value <= balances[from], "ERC20: transfer amount exceeds balance" ); balances[from] = balances[from].sub(value); balances[to] = balances[to].add(value); emit Transfer(from, to, value); } /** * @dev Function to add/update a new minter * @param minter The address of the minter * @param minterAllowedAmount The minting amount allowed for the minter * @return True if the operation was successful. */ function configureMinter(address minter, uint256 minterAllowedAmount) external whenNotPaused onlyMasterMinter returns (bool) { minters[minter] = true; minterAllowed[minter] = minterAllowedAmount; emit MinterConfigured(minter, minterAllowedAmount); return true; } /** * @dev Function to remove a minter * @param minter The address of the minter to remove * @return True if the operation was successful. */ function removeMinter(address minter) external onlyMasterMinter returns (bool) { minters[minter] = false; minterAllowed[minter] = 0; emit MinterRemoved(minter); return true; } /** * @dev allows a minter to burn some of its own tokens * Validates that caller is a minter and that sender is not blacklisted * amount is less than or equal to the minter's account balance * @param _amount uint256 the amount of tokens to be burned */ function burn(uint256 _amount) external whenNotPaused onlyMinters notBlacklisted(msg.sender) { uint256 balance = balances[msg.sender]; require(_amount > 0, "FiatToken: burn amount not greater than 0"); require(balance >= _amount, "FiatToken: burn amount exceeds balance"); totalSupply_ = totalSupply_.sub(_amount); balances[msg.sender] = balance.sub(_amount); emit Burn(msg.sender, _amount); emit Transfer(msg.sender, address(0), _amount); } function updateMasterMinter(address _newMasterMinter) external onlyOwner { require( _newMasterMinter != address(0), "FiatToken: new masterMinter is the zero address" ); masterMinter = _newMasterMinter; emit MasterMinterChanged(masterMinter); } }
10,556
15
// Add the token to the stakedTokens array
stakers[msg.sender].stakedTokens.push(stakedToken);
stakers[msg.sender].stakedTokens.push(stakedToken);
9,276
53
// ------------------------------------------------------------------------- MODIFIERS
modifier onlyOperator() { require(msg.sender == operator || msg.sender == juryOperator); _; }
modifier onlyOperator() { require(msg.sender == operator || msg.sender == juryOperator); _; }
25,839
2
// case 1: R=1 R falls below one
receiveQuoteAmount = _ROneSellBaseToken(state, payBaseAmount); newR = RState.BELOW_ONE;
receiveQuoteAmount = _ROneSellBaseToken(state, payBaseAmount); newR = RState.BELOW_ONE;
11,919
8
// function symbol() constant returns(string);
function decimals() constant returns(uint8);
function decimals() constant returns(uint8);
49,452
301
// Push a new player into the queue.
function pushPlayer(address _player) private
function pushPlayer(address _player) private
2,219
583
// adjustments[19]/mload(0x5060), Constraint expression for ecdsa/signature0/add_results/x: column20_row8161column20_row8161 - (column20_row8166 + column20_row4088 + column19_row4103).
let val := addmod( mulmod(/*column20_row8161*/ mload(0x3da0), /*column20_row8161*/ mload(0x3da0), PRIME), sub( PRIME, addmod( addmod(/*column20_row8166*/ mload(0x3dc0), /*column20_row4088*/ mload(0x3d40), PRIME),
let val := addmod( mulmod(/*column20_row8161*/ mload(0x3da0), /*column20_row8161*/ mload(0x3da0), PRIME), sub( PRIME, addmod( addmod(/*column20_row8166*/ mload(0x3dc0), /*column20_row4088*/ mload(0x3d40), PRIME),
56,819
88
// 판매가 종료되는 시간
uint public endTime;
uint public endTime;
10,677
17
// Add the proceeds to the seller's balance.
pendingWithdrawals[orderID] += orderTracker.value(orderID); return true;
pendingWithdrawals[orderID] += orderTracker.value(orderID); return true;
14,479
156
// Set an undelegation time for staked tokens./ Undelegation will begin at the specified timestamp./ You will be able to recover your stake by calling/ `recoverStake()` with operator address once undelegation period is over./_operator Address of the stake operator./_undelegationTimestamp The timestamp undelegation is to start at.
function undelegateAt( address _operator, uint256 _undelegationTimestamp
function undelegateAt( address _operator, uint256 _undelegationTimestamp
6,869
10
// Emitted when a range edition is created. editionAddress of the song edition contract we are minting for. mintId The mint ID. priceSale price in ETH for minting a single token in `edition`. startTimeStart timestamp of sale (in seconds since unix epoch). cutoffTime The timestamp (in seconds since unix epoch) after which themax amount of tokens mintable will drop from`maxMintableUpper` to `maxMintableLower`. endTimeEnd timestamp of sale (in seconds since unix epoch). affiliateFeeBPSThe affiliate fee in basis points. maxMintableLower The lower limit of the maximum number of tokens that can be minted. maxMintableUpper The upper limit of the maximum number of tokens
event RangeEditionMintCreated( address indexed edition, uint128 mintId, uint96 price, uint32 startTime, uint32 cutoffTime, uint32 endTime, uint16 affiliateFeeBPS, uint32 maxMintableLower,
event RangeEditionMintCreated( address indexed edition, uint128 mintId, uint96 price, uint32 startTime, uint32 cutoffTime, uint32 endTime, uint16 affiliateFeeBPS, uint32 maxMintableLower,
8,094