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
8
// validate mapping for root to child
require(rootToChildTokens[rootToken] == childToken, "FxERC20RootTunnel: INVALID_MAPPING_ON_EXIT");
require(rootToChildTokens[rootToken] == childToken, "FxERC20RootTunnel: INVALID_MAPPING_ON_EXIT");
16,601
35
// Extend the decimals to 1e18.
return mul_(uint256(price), 10**(18 - uint256(registry.decimals(base, quote))));
return mul_(uint256(price), 10**(18 - uint256(registry.decimals(base, quote))));
25,536
168
// dev/artist gets the first 15 WNW NFTS minting many of these myself since last project had very few takers
_safeMint( t1, 0); _safeMint( t2, 1); _safeMint( t2, 2); _safeMint( t2, 3); _safeMint( t2, 4); _safeMint( t2, 5); _safeMint( t2, 6); _safeMint( t2, 7); _safeMint( t2, 8); _safeMint( t2, 9);
_safeMint( t1, 0); _safeMint( t2, 1); _safeMint( t2, 2); _safeMint( t2, 3); _safeMint( t2, 4); _safeMint( t2, 5); _safeMint( t2, 6); _safeMint( t2, 7); _safeMint( t2, 8); _safeMint( t2, 9);
16,219
66
// See {IRadRouter-sellerEscrowWithdraw}. /
function sellerEscrowWithdraw(address _ledger, uint256 _assetId) external virtual override returns (bool success) { require(_ledger != address(0), 'Asset ledger cannot be the zero address'); IERC721 ledger = IERC721(_ledger); address owner = Ledgers[_ledger].Assets[_assetId].owner; require(msg.sender == owner || msg.sender == administrator_, 'Only the asset owner or Rad administrator can change asset ownership'); require(ledger.isApprovedForAll(owner, address(this)), 'Must set Rad Router as an operator for all assets before depositing to escrow'); Ledgers[_ledger].Assets[_assetId].creator.wallet = address(0); Ledgers[_ledger].Assets[_assetId].creator.share = 0;
function sellerEscrowWithdraw(address _ledger, uint256 _assetId) external virtual override returns (bool success) { require(_ledger != address(0), 'Asset ledger cannot be the zero address'); IERC721 ledger = IERC721(_ledger); address owner = Ledgers[_ledger].Assets[_assetId].owner; require(msg.sender == owner || msg.sender == administrator_, 'Only the asset owner or Rad administrator can change asset ownership'); require(ledger.isApprovedForAll(owner, address(this)), 'Must set Rad Router as an operator for all assets before depositing to escrow'); Ledgers[_ledger].Assets[_assetId].creator.wallet = address(0); Ledgers[_ledger].Assets[_assetId].creator.share = 0;
85,260
15
// filter name + condition checks
bytes32 _name = NameFilter.nameFilter(_nameString);
bytes32 _name = NameFilter.nameFilter(_nameString);
5,529
75
// amount of ether raised in sale
uint256 public totalEtherRaised;
uint256 public totalEtherRaised;
21,155
5
// Make sure _proposalNames length < 255
require(_proposalNames.length <= 255, "Proposals must be less than 255"); protocolAddresses = _protocolAddresses; voterBaseLogic = _voterBaseLogic; pollName = _pollName; pollType = _pollType; startTime = _startTime; endTime = _startTime + _duration; require(_startTime <= _startTime + _duration, "Invalid Times"); for (uint8 i = 0; i < _proposalNames.length; i++) { proposals.push(Proposal({name: _proposalNames[i], voteCount: 0, voteWeight: 0}));
require(_proposalNames.length <= 255, "Proposals must be less than 255"); protocolAddresses = _protocolAddresses; voterBaseLogic = _voterBaseLogic; pollName = _pollName; pollType = _pollType; startTime = _startTime; endTime = _startTime + _duration; require(_startTime <= _startTime + _duration, "Invalid Times"); for (uint8 i = 0; i < _proposalNames.length; i++) { proposals.push(Proposal({name: _proposalNames[i], voteCount: 0, voteWeight: 0}));
14,827
128
// emit CleanUpClub event
emit DeactivateMembersInTier(_clubId, _tierId, totalDeactivatedMembers);
emit DeactivateMembersInTier(_clubId, _tierId, totalDeactivatedMembers);
5,434
286
// we didn't reach the target, so take the remainder of the maximum input as fee
feeAmount = uint256(amountRemaining) - amountIn;
feeAmount = uint256(amountRemaining) - amountIn;
46,933
661
// Underflow checked above
require(uint256(underlyingAmountExternal) == msg.value, "ETH Balance");
require(uint256(underlyingAmountExternal) == msg.value, "ETH Balance");
16,131
8
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in the array, and then remove the last element (sometimes called as 'swap and pop'). This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1;
uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1;
14,728
11
// There should be no overflow, but just in case (at the end of sale, maybe somebody will send too much eth for remaining supply, so we will return it back to sender)
if (overflow > 0) SafeTransferLib.forceSafeTransferETH(msg.sender, overflow);
if (overflow > 0) SafeTransferLib.forceSafeTransferETH(msg.sender, overflow);
24,022
16
// Use the MQ queue length as nonce
uint40 nonce = IMessageQueue(messageQueue).getQueueLength(); bytes memory xDomainCalldata = Lib_CrossDomainUtils.encodeXDomainCalldata( _target, msg.sender, _message, nonce );
uint40 nonce = IMessageQueue(messageQueue).getQueueLength(); bytes memory xDomainCalldata = Lib_CrossDomainUtils.encodeXDomainCalldata( _target, msg.sender, _message, nonce );
23,555
125
// Earn/ETH LP token contract address
address public LPtokenAddress; address public devAddress;
address public LPtokenAddress; address public devAddress;
34,554
411
// round 2
ark(i, q, 5179144822360023508491245509308555580251733042407187134628755730783052214509); sbox_full(i, q); mix(i, q);
ark(i, q, 5179144822360023508491245509308555580251733042407187134628755730783052214509); sbox_full(i, q); mix(i, q);
9,308
56
// Return the log in base 10, following the selected rounding direction, of a positive value. Returns 0 if given 0./
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } }
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } }
11,013
0
// list of merchants who are able to receive the underlying ERC-20 tokens
mapping (address => bool) internal merchantList ;
mapping (address => bool) internal merchantList ;
23,504
28
// method to remove an accepted voting portal. votingPortals list of addresses of the voting machines that are no longer valid removing a voting portal effectively removes a voting machine /
function removeVotingPortals(address[] calldata votingPortals) external;
function removeVotingPortals(address[] calldata votingPortals) external;
9,295
39
// uint bonusEth = (krkAmount.mul(investorsCirculatingEthEarnings)).div(circulatingKrk);
uint bonusEth = (circulatingUserKrk[userAddress].mul(circulatingUserKrk[userAddress]).mul(investorsCirculatingEthEarnings)).div(circulatingKrk.mul(circulatingKrk)); return bonusEth;
uint bonusEth = (circulatingUserKrk[userAddress].mul(circulatingUserKrk[userAddress]).mul(investorsCirculatingEthEarnings)).div(circulatingKrk.mul(circulatingKrk)); return bonusEth;
20,135
5
// Function returns current (with accrual) pool sizereturn Current pool size /
function poolSize() external view returns (uint256) { return _poolSize(_accrueInterestVirtual()); }
function poolSize() external view returns (uint256) { return _poolSize(_accrueInterestVirtual()); }
8,299
34
// Note: can be made external into a utility contract (used for deployment)
function getResolverAddressesRequired() external view returns (bytes32[MAX_ADDRESSES_FROM_RESOLVER] memory addressesRequired)
function getResolverAddressesRequired() external view returns (bytes32[MAX_ADDRESSES_FROM_RESOLVER] memory addressesRequired)
24,347
32
// Get the config for symbol symbol The symbol of the config to getreturn The config object /
function getTokenConfigBySymbol(string memory symbol) public view returns (TokenConfig memory) { return getTokenConfigBySymbolHash(keccak256(abi.encodePacked(symbol))); }
function getTokenConfigBySymbol(string memory symbol) public view returns (TokenConfig memory) { return getTokenConfigBySymbolHash(keccak256(abi.encodePacked(symbol))); }
53,884
1,112
// Time last paused for both pauses
uint256 public lastPausePartialTime; uint256 public lastPauseTime;
uint256 public lastPausePartialTime; uint256 public lastPauseTime;
84,870
15
// Gets the address of the controllerreturn Returns an address /
function getControllerAddress () public view returns (address) { return _controllerAddress; }
function getControllerAddress () public view returns (address) { return _controllerAddress; }
13,291
18
// Validate AC holders
function addACOwners(uint8[] calldata ACtokenIDs,address[] calldata addresses) external onlyOwner{ require(ACtokenIDs.length == addresses.length); for (uint256 i = 0; i < addresses.length; i++) { require(ACtokenIDs[i]>=1 && ACtokenIDs[i] <= MAX_AC_SUPPLY); _AC_owner[ACtokenIDs[i]] = addresses[i]; if (!_AC_added[ACtokenIDs[i]]){ _AC_added[ACtokenIDs[i]] = true; registeredACs.push(ACtokenIDs[i]); } } }
function addACOwners(uint8[] calldata ACtokenIDs,address[] calldata addresses) external onlyOwner{ require(ACtokenIDs.length == addresses.length); for (uint256 i = 0; i < addresses.length; i++) { require(ACtokenIDs[i]>=1 && ACtokenIDs[i] <= MAX_AC_SUPPLY); _AC_owner[ACtokenIDs[i]] = addresses[i]; if (!_AC_added[ACtokenIDs[i]]){ _AC_added[ACtokenIDs[i]] = true; registeredACs.push(ACtokenIDs[i]); } } }
60,035
0
// DATA VARIABLES // EVENT DEFINITIONS/
struct Flight { string flight; bool isRegistered; uint8 statusCode; uint256 updatedTimestamp; address airline; }
struct Flight { string flight; bool isRegistered; uint8 statusCode; uint256 updatedTimestamp; address airline; }
37,983
203
// --------------------------------Dividends (10% to stock owner, 2,5% to node owner per annum)------------------------------------
function dividends(uint _node) public returns (bool _result, uint _dividends) { var (x,y,) = nodesVars.getNodeInfo(_node); uint _stockAmount = sCVars.StockOwnersBuyPrice[msg.sender][_node].sumAmount; uint _sumAmount = sCVars.StockOwnersBuyPrice[msg.sender][_node].sumAmount; if(_sumAmount > 0) { uint _stockAverageBuyPrice = sCVars.StockOwnersBuyPrice[msg.sender][_node].sumPriceAmount/_sumAmount; uint _dividendsBase = _stockAmount*_stockAverageBuyPrice; uint _averageDate = sCVars.StockOwnersBuyPrice[msg.sender][_node].sumDateAmount/_sumAmount; //Stock owner`s dividends uint _div = (block.timestamp - _averageDate)*_dividendsBase/(10*31536000);//31536000 seconds in year sCVars.balanceOf[msg.sender] += _div; //Node owner`s dividends uint _nodeDividends = (block.timestamp - _averageDate)*_dividendsBase/(40*31536000);//31536000 seconds in year sCVars.balanceOf[y] += _nodeDividends; sCVars.StockOwnersBuyPrice[msg.sender][_node].sumDateAmount = block.timestamp*_stockAmount;//set new average dividends date totalSupply += _div + _div/4; _dividends = _div + _div/4; Transfer(this, msg.sender, _div); Transfer(this, y, _div/4); _result = true; } }
function dividends(uint _node) public returns (bool _result, uint _dividends) { var (x,y,) = nodesVars.getNodeInfo(_node); uint _stockAmount = sCVars.StockOwnersBuyPrice[msg.sender][_node].sumAmount; uint _sumAmount = sCVars.StockOwnersBuyPrice[msg.sender][_node].sumAmount; if(_sumAmount > 0) { uint _stockAverageBuyPrice = sCVars.StockOwnersBuyPrice[msg.sender][_node].sumPriceAmount/_sumAmount; uint _dividendsBase = _stockAmount*_stockAverageBuyPrice; uint _averageDate = sCVars.StockOwnersBuyPrice[msg.sender][_node].sumDateAmount/_sumAmount; //Stock owner`s dividends uint _div = (block.timestamp - _averageDate)*_dividendsBase/(10*31536000);//31536000 seconds in year sCVars.balanceOf[msg.sender] += _div; //Node owner`s dividends uint _nodeDividends = (block.timestamp - _averageDate)*_dividendsBase/(40*31536000);//31536000 seconds in year sCVars.balanceOf[y] += _nodeDividends; sCVars.StockOwnersBuyPrice[msg.sender][_node].sumDateAmount = block.timestamp*_stockAmount;//set new average dividends date totalSupply += _div + _div/4; _dividends = _div + _div/4; Transfer(this, msg.sender, _div); Transfer(this, y, _div/4); _result = true; } }
50,897
6
// overflow/underflow is possible, but prevented externally by limiting both tickSpacing and tick
next = initialized ? (compressed - int24(bitPos - BitMath.mostSignificantBit(masked))) * tickSpacing : (compressed - int24(bitPos)) * tickSpacing;
next = initialized ? (compressed - int24(bitPos - BitMath.mostSignificantBit(masked))) * tickSpacing : (compressed - int24(bitPos)) * tickSpacing;
25,033
16
// We also require that all deposit requests are processed
require(lastBlock.numDepositRequestsCommitted == S.depositChain.length, "DEPOSITS_NOT_PROCESSED");
require(lastBlock.numDepositRequestsCommitted == S.depositChain.length, "DEPOSITS_NOT_PROCESSED");
40,543
11
// Reverts if no vesting schedule matches the passed identifier./
modifier onlyIfVestingScheduleExists(bytes32 vestingScheduleId) { require(vestingSchedules[vestingScheduleId].initialized == true); _; }
modifier onlyIfVestingScheduleExists(bytes32 vestingScheduleId) { require(vestingSchedules[vestingScheduleId].initialized == true); _; }
23,570
6
// mapping of tokenIds to the address of the accountability partner
mapping(uint256 => address) public tokenIdToAccountabilityPartner;
mapping(uint256 => address) public tokenIdToAccountabilityPartner;
64,172
248
// Stores the initial parameters of the mediator._bridgeContract the address of the AMB bridge contract._mediatorContract the address of the mediator contract on the other network._dailyLimitMaxPerTxMinPerTxArray array with limit values for the assets to be bridged to the other network. [ 0 = dailyLimit, 1 = maxPerTx, 2 = minPerTx ]_executionDailyLimitExecutionMaxPerTxArray array with limit values for the assets bridged from the other network. [ 0 = executionDailyLimit, 1 = executionMaxPerTx ]_requestGasLimit the gas limit for the message execution._owner address of the owner of the mediator contract./
function initialize( address _bridgeContract, address _mediatorContract, uint256[3] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256[2] _executionDailyLimitExecutionMaxPerTxArray, // [ 0 = _executionDailyLimit, 1 = _executionMaxPerTx ] uint256 _requestGasLimit, address _owner
function initialize( address _bridgeContract, address _mediatorContract, uint256[3] _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ] uint256[2] _executionDailyLimitExecutionMaxPerTxArray, // [ 0 = _executionDailyLimit, 1 = _executionMaxPerTx ] uint256 _requestGasLimit, address _owner
51,583
284
// borrowMarket.totalSupply does not need to be updated
borrowMarket.supplyRateMantissa = localResults.newSupplyRateMantissa_ProtocolUnderwaterAsset; borrowMarket.supplyIndex = localResults.newSupplyIndex_UnderwaterAsset; borrowMarket.borrowRateMantissa = localResults.newBorrowRateMantissa_ProtocolUnderwaterAsset; borrowMarket.borrowIndex = localResults.newBorrowIndex_UnderwaterAsset;
borrowMarket.supplyRateMantissa = localResults.newSupplyRateMantissa_ProtocolUnderwaterAsset; borrowMarket.supplyIndex = localResults.newSupplyIndex_UnderwaterAsset; borrowMarket.borrowRateMantissa = localResults.newBorrowRateMantissa_ProtocolUnderwaterAsset; borrowMarket.borrowIndex = localResults.newBorrowIndex_UnderwaterAsset;
3,698
25
// TLCreatorContractFactory/Contract factory for TL creator contracts/deploys any contract compatible with the InitializableInterface above/transientlabs.xyz/ @custom:version 2.6.2
contract TLCreatorContractFactory is Ownable { /*////////////////////////////////////////////////////////////////////////// Structs //////////////////////////////////////////////////////////////////////////*/ struct ContractType { string name; address[] implementations; } /*////////////////////////////////////////////////////////////////////////// State Variables //////////////////////////////////////////////////////////////////////////*/ ContractType[] private _contractTypes; /*////////////////////////////////////////////////////////////////////////// Events //////////////////////////////////////////////////////////////////////////*/ /// @dev event emitted whenever a contract type is added event ContractTypeAdded(uint256 indexed contractTypeId, address indexed firstImplementation, string name); /// @dev event emitted whenever an implementation is added for a contract type event ImplementationAdded(uint256 indexed contractTypeId, address indexed implementation); /// @dev event emitted whenever a contract is deployed event ContractDeployed(address indexed contractAddress, address indexed implementationAddress, address indexed sender); /*////////////////////////////////////////////////////////////////////////// Constructor //////////////////////////////////////////////////////////////////////////*/ constructor() Ownable() {} /*////////////////////////////////////////////////////////////////////////// Ownership Functions //////////////////////////////////////////////////////////////////////////*/ /// @notice Function to add a contract type /// @dev only callable by the factory owner /// @param name The new contract type name /// @param implementation The first implementation address to add function addContractType(string memory name, address implementation) external onlyOwner { address[] memory implementations = new address[](1); implementations[0] = implementation; _contractTypes.push(ContractType(name, implementations)); uint256 contractTypeId = _contractTypes.length - 1; emit ContractTypeAdded(contractTypeId, implementation, name); } /// @notice Function to add an implementation contract for a type /// @dev only callable by the factory owner /// @param contractTypeId The contract type id /// @param implementation The new implementation address to add function addContractImplementation(uint256 contractTypeId, address implementation) external onlyOwner { ContractType storage contractType = _contractTypes[contractTypeId]; contractType.implementations.push(implementation); emit ImplementationAdded(contractTypeId, implementation); } /*////////////////////////////////////////////////////////////////////////// Contract Creation Functions //////////////////////////////////////////////////////////////////////////*/ /// @notice Function to deploy the latest implementation contract for a contract type /// @param contractTypeId The contract type id /// @param contractName The deployed contract name /// @param contractSymbol The deployed contract symbol /// @param defaultRoyaltyRecipient The default royalty recipient /// @param defaultRoyaltyPercentage The default royalty percentage /// @param initOwner The initial owner of the deployed contract /// @param admins The intial admins on the contract /// @param enableStory The initial state of story inscriptions on the deployed contract /// @param blockListRegistry The blocklist registry /// @return contractAddress The deployed contract address function deployLatestImplementation( uint256 contractTypeId, string memory contractName, string memory contractSymbol, address defaultRoyaltyRecipient, uint256 defaultRoyaltyPercentage, address initOwner, address[] memory admins, bool enableStory, address blockListRegistry ) external returns (address contractAddress) { ContractType memory contractType = _contractTypes[contractTypeId]; address implementation = contractType.implementations[contractType.implementations.length - 1]; return _deployContract( implementation, contractName, contractSymbol, defaultRoyaltyRecipient, defaultRoyaltyPercentage, initOwner, admins, enableStory, blockListRegistry ); } /// @notice Function to deploy a specific implementation contract for a contract type /// @param contractTypeId The contract type id /// @param implementationIndex The index specifying the implementation contract /// @param contractName The deployed contract name /// @param contractSymbol The deployed contract symbol /// @param defaultRoyaltyRecipient The default royalty recipient /// @param defaultRoyaltyPercentage The default royalty percentage /// @param initOwner The initial owner of the deployed contract /// @param admins The intial admins on the contract /// @param enableStory The initial state of story inscriptions on the deployed contract /// @param blockListRegistry The blocklist registry /// @return contractAddress The deployed contract address function deployImplementation( uint256 contractTypeId, uint256 implementationIndex, string memory contractName, string memory contractSymbol, address defaultRoyaltyRecipient, uint256 defaultRoyaltyPercentage, address initOwner, address[] memory admins, bool enableStory, address blockListRegistry ) external returns (address contractAddress) { ContractType memory contractType = _contractTypes[contractTypeId]; address implementation = contractType.implementations[implementationIndex]; return _deployContract( implementation, contractName, contractSymbol, defaultRoyaltyRecipient, defaultRoyaltyPercentage, initOwner, admins, enableStory, blockListRegistry ); } /*////////////////////////////////////////////////////////////////////////// View Functions //////////////////////////////////////////////////////////////////////////*/ /// @notice Function to get all contract types /// @return contractTypes A list of contract type structs function getContractTypes() external view returns (ContractType[] memory contractTypes) { return _contractTypes; } /// @notice Function to get contract type info by id /// @param contractTypeId The contract type id /// @return contractType A contract type struct function getContractType(uint256 contractTypeId) external view returns (ContractType memory contractType) { return _contractTypes[contractTypeId]; } /*////////////////////////////////////////////////////////////////////////// Internal Functions //////////////////////////////////////////////////////////////////////////*/ /// @notice Internal function to deploy a contract /// @param implementation The implementation address /// @param contractName The deployed contract name /// @param contractSymbol The deployed contract symbol /// @param defaultRoyaltyRecipient The default royalty recipient /// @param defaultRoyaltyPercentage The default royalty percentage /// @param initOwner The initial owner of the deployed contract /// @param admins The intial admins on the contract /// @param enableStory The initial state of story inscriptions on the deployed contract /// @param blockListRegistry The blocklist registry /// @return contractAddress The deployed contract address function _deployContract( address implementation, string memory contractName, string memory contractSymbol, address defaultRoyaltyRecipient, uint256 defaultRoyaltyPercentage, address initOwner, address[] memory admins, bool enableStory, address blockListRegistry ) private returns (address contractAddress) { contractAddress = Clones.clone(implementation); InitializableInterface(contractAddress).initialize( contractName, contractSymbol, defaultRoyaltyRecipient, defaultRoyaltyPercentage, initOwner, admins, enableStory, blockListRegistry ); emit ContractDeployed(contractAddress, implementation, msg.sender); return contractAddress; } }
contract TLCreatorContractFactory is Ownable { /*////////////////////////////////////////////////////////////////////////// Structs //////////////////////////////////////////////////////////////////////////*/ struct ContractType { string name; address[] implementations; } /*////////////////////////////////////////////////////////////////////////// State Variables //////////////////////////////////////////////////////////////////////////*/ ContractType[] private _contractTypes; /*////////////////////////////////////////////////////////////////////////// Events //////////////////////////////////////////////////////////////////////////*/ /// @dev event emitted whenever a contract type is added event ContractTypeAdded(uint256 indexed contractTypeId, address indexed firstImplementation, string name); /// @dev event emitted whenever an implementation is added for a contract type event ImplementationAdded(uint256 indexed contractTypeId, address indexed implementation); /// @dev event emitted whenever a contract is deployed event ContractDeployed(address indexed contractAddress, address indexed implementationAddress, address indexed sender); /*////////////////////////////////////////////////////////////////////////// Constructor //////////////////////////////////////////////////////////////////////////*/ constructor() Ownable() {} /*////////////////////////////////////////////////////////////////////////// Ownership Functions //////////////////////////////////////////////////////////////////////////*/ /// @notice Function to add a contract type /// @dev only callable by the factory owner /// @param name The new contract type name /// @param implementation The first implementation address to add function addContractType(string memory name, address implementation) external onlyOwner { address[] memory implementations = new address[](1); implementations[0] = implementation; _contractTypes.push(ContractType(name, implementations)); uint256 contractTypeId = _contractTypes.length - 1; emit ContractTypeAdded(contractTypeId, implementation, name); } /// @notice Function to add an implementation contract for a type /// @dev only callable by the factory owner /// @param contractTypeId The contract type id /// @param implementation The new implementation address to add function addContractImplementation(uint256 contractTypeId, address implementation) external onlyOwner { ContractType storage contractType = _contractTypes[contractTypeId]; contractType.implementations.push(implementation); emit ImplementationAdded(contractTypeId, implementation); } /*////////////////////////////////////////////////////////////////////////// Contract Creation Functions //////////////////////////////////////////////////////////////////////////*/ /// @notice Function to deploy the latest implementation contract for a contract type /// @param contractTypeId The contract type id /// @param contractName The deployed contract name /// @param contractSymbol The deployed contract symbol /// @param defaultRoyaltyRecipient The default royalty recipient /// @param defaultRoyaltyPercentage The default royalty percentage /// @param initOwner The initial owner of the deployed contract /// @param admins The intial admins on the contract /// @param enableStory The initial state of story inscriptions on the deployed contract /// @param blockListRegistry The blocklist registry /// @return contractAddress The deployed contract address function deployLatestImplementation( uint256 contractTypeId, string memory contractName, string memory contractSymbol, address defaultRoyaltyRecipient, uint256 defaultRoyaltyPercentage, address initOwner, address[] memory admins, bool enableStory, address blockListRegistry ) external returns (address contractAddress) { ContractType memory contractType = _contractTypes[contractTypeId]; address implementation = contractType.implementations[contractType.implementations.length - 1]; return _deployContract( implementation, contractName, contractSymbol, defaultRoyaltyRecipient, defaultRoyaltyPercentage, initOwner, admins, enableStory, blockListRegistry ); } /// @notice Function to deploy a specific implementation contract for a contract type /// @param contractTypeId The contract type id /// @param implementationIndex The index specifying the implementation contract /// @param contractName The deployed contract name /// @param contractSymbol The deployed contract symbol /// @param defaultRoyaltyRecipient The default royalty recipient /// @param defaultRoyaltyPercentage The default royalty percentage /// @param initOwner The initial owner of the deployed contract /// @param admins The intial admins on the contract /// @param enableStory The initial state of story inscriptions on the deployed contract /// @param blockListRegistry The blocklist registry /// @return contractAddress The deployed contract address function deployImplementation( uint256 contractTypeId, uint256 implementationIndex, string memory contractName, string memory contractSymbol, address defaultRoyaltyRecipient, uint256 defaultRoyaltyPercentage, address initOwner, address[] memory admins, bool enableStory, address blockListRegistry ) external returns (address contractAddress) { ContractType memory contractType = _contractTypes[contractTypeId]; address implementation = contractType.implementations[implementationIndex]; return _deployContract( implementation, contractName, contractSymbol, defaultRoyaltyRecipient, defaultRoyaltyPercentage, initOwner, admins, enableStory, blockListRegistry ); } /*////////////////////////////////////////////////////////////////////////// View Functions //////////////////////////////////////////////////////////////////////////*/ /// @notice Function to get all contract types /// @return contractTypes A list of contract type structs function getContractTypes() external view returns (ContractType[] memory contractTypes) { return _contractTypes; } /// @notice Function to get contract type info by id /// @param contractTypeId The contract type id /// @return contractType A contract type struct function getContractType(uint256 contractTypeId) external view returns (ContractType memory contractType) { return _contractTypes[contractTypeId]; } /*////////////////////////////////////////////////////////////////////////// Internal Functions //////////////////////////////////////////////////////////////////////////*/ /// @notice Internal function to deploy a contract /// @param implementation The implementation address /// @param contractName The deployed contract name /// @param contractSymbol The deployed contract symbol /// @param defaultRoyaltyRecipient The default royalty recipient /// @param defaultRoyaltyPercentage The default royalty percentage /// @param initOwner The initial owner of the deployed contract /// @param admins The intial admins on the contract /// @param enableStory The initial state of story inscriptions on the deployed contract /// @param blockListRegistry The blocklist registry /// @return contractAddress The deployed contract address function _deployContract( address implementation, string memory contractName, string memory contractSymbol, address defaultRoyaltyRecipient, uint256 defaultRoyaltyPercentage, address initOwner, address[] memory admins, bool enableStory, address blockListRegistry ) private returns (address contractAddress) { contractAddress = Clones.clone(implementation); InitializableInterface(contractAddress).initialize( contractName, contractSymbol, defaultRoyaltyRecipient, defaultRoyaltyPercentage, initOwner, admins, enableStory, blockListRegistry ); emit ContractDeployed(contractAddress, implementation, msg.sender); return contractAddress; } }
36,944
157
// Update state for remove_liquidity
tranche_interest_earned[epoch][uint256(Tranche.S)] = wind_down.tranche_S_interest; tranche_interest_earned[epoch][uint256(Tranche.AA)] = 0; tranche_interest_earned[epoch][uint256(Tranche.A)] = wind_down.tranche_A_interest;
tranche_interest_earned[epoch][uint256(Tranche.S)] = wind_down.tranche_S_interest; tranche_interest_earned[epoch][uint256(Tranche.AA)] = 0; tranche_interest_earned[epoch][uint256(Tranche.A)] = wind_down.tranche_A_interest;
28,151
2
// The price coefficient. Chosen such that at 1 token total supplythe amount in reserve is 0.5 ether and token price is 1 Ether.
int constant price_coeff = -0x296ABF784A358468C;
int constant price_coeff = -0x296ABF784A358468C;
24,807
22
// the ongoing operations.
mapping(bytes32 => PendingState) pendings; bytes32[] pendingsIndex;
mapping(bytes32 => PendingState) pendings; bytes32[] pendingsIndex;
56,979
14
// Given an input amount of an asset and pair reserves, returns maximum output amount of the other asset Assumes swap fee is 0.30% amountIn input asset reserveIn size of input asset reserve reserveOut size of output asset reservereturn maximum output amount /
function _getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) private pure returns (uint) { uint amountInWithFee = amountIn.mul(997); uint numerator = amountInWithFee.mul(reserveOut); uint denominator = reserveIn.mul(1000).add(amountInWithFee); return numerator.div(denominator); }
function _getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) private pure returns (uint) { uint amountInWithFee = amountIn.mul(997); uint numerator = amountInWithFee.mul(reserveOut); uint denominator = reserveIn.mul(1000).add(amountInWithFee); return numerator.div(denominator); }
43,798
157
// Accepts transfer of admin rights. msg.sender must be pendingAdmin Admin function for pending admin to accept role and update adminreturn uint 0=success, otherwise a failure (see ErrorReporter.sol for details) /
function _acceptAdmin() public returns (uint256) { // Check caller is pendingAdmin and pendingAdmin ≠ address(0) if (msg.sender != pendingAdmin || msg.sender == address(0)) { return fail( Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK ); } // Save current values for inclusion in log address oldAdmin = admin; address oldPendingAdmin = pendingAdmin; // Store admin with value pendingAdmin admin = pendingAdmin; // Clear the pending value pendingAdmin = address(0); emit NewAdmin(oldAdmin, admin); emit NewPendingAdmin(oldPendingAdmin, pendingAdmin); return uint256(Error.NO_ERROR); }
function _acceptAdmin() public returns (uint256) { // Check caller is pendingAdmin and pendingAdmin ≠ address(0) if (msg.sender != pendingAdmin || msg.sender == address(0)) { return fail( Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK ); } // Save current values for inclusion in log address oldAdmin = admin; address oldPendingAdmin = pendingAdmin; // Store admin with value pendingAdmin admin = pendingAdmin; // Clear the pending value pendingAdmin = address(0); emit NewAdmin(oldAdmin, admin); emit NewPendingAdmin(oldPendingAdmin, pendingAdmin); return uint256(Error.NO_ERROR); }
19,765
86
// IMPORTANT: Contracts derived from {GSNRecipient} should never use `msg.data`, and use {_msgData} instead. /
function _msgData() internal view returns (bytes memory) { if (msg.sender != _relayHub) { return msg.data; } else {
function _msgData() internal view returns (bytes memory) { if (msg.sender != _relayHub) { return msg.data; } else {
16,082
260
// Retrieve themaintenance dividend balance of any single address. /
function EmaintenancedividendsOf(address _customerAddress) view public returns(uint256)
function EmaintenancedividendsOf(address _customerAddress) view public returns(uint256)
4,220
40
// Reverts if not in crowdsale time range. /
modifier onlyWhileOpen() { require(isOpen(), "TimedCrowdsale: not open"); _; }
modifier onlyWhileOpen() { require(isOpen(), "TimedCrowdsale: not open"); _; }
16,944
283
// Item supply data may not be reduced below the circulating supply.
require(itemGroups[_groupId].circulatingSupply >= _data.supplyData, "Super1155: you may not decrease supply below the circulating amount"); itemGroups[_groupId].supplyData = _data.supplyData;
require(itemGroups[_groupId].circulatingSupply >= _data.supplyData, "Super1155: you may not decrease supply below the circulating amount"); itemGroups[_groupId].supplyData = _data.supplyData;
46,493
11
// renewals
error NON_RENEWABLE_LOCK(); error LOCK_HAS_CHANGED(); error NOT_READY_FOR_RENEWAL();
error NON_RENEWABLE_LOCK(); error LOCK_HAS_CHANGED(); error NOT_READY_FOR_RENEWAL();
2,200
4
// If the fourthDigit is 7, 8 or 9, rounds up to the next data point
responseValue = _cachedDataPoints[truncatedZ + 100];
responseValue = _cachedDataPoints[truncatedZ + 100];
70,564
1
// ! ],! "expected": [! "0"! ]
//! }, { //! "name": "ordinar", //! "input": [ //! { //! "entry": "main", //! "calldata": [ //! "42" //! ] //! }
//! }, { //! "name": "ordinar", //! "input": [ //! { //! "entry": "main", //! "calldata": [ //! "42" //! ] //! }
20,437
0
// SesnseToken Constructor Runs only on initial contract creation./
constructor() public { totalSupply = INITIAL_SUPPLY; // Set the total supply balances[msg.sender] = INITIAL_SUPPLY; // Creator address is assigned all emit Transfer(0x0, msg.sender, INITIAL_SUPPLY); }
constructor() public { totalSupply = INITIAL_SUPPLY; // Set the total supply balances[msg.sender] = INITIAL_SUPPLY; // Creator address is assigned all emit Transfer(0x0, msg.sender, INITIAL_SUPPLY); }
42,467
251
// Can't do this while a progressive update is happening
require(gradualUpdate.startBlock == 0, "ERR_NO_UPDATE_DURING_GRADUAL"); SmartPoolManager.verifyTokenCompliance(token); emit NewTokenCommitted(token, address(this), msg.sender);
require(gradualUpdate.startBlock == 0, "ERR_NO_UPDATE_DURING_GRADUAL"); SmartPoolManager.verifyTokenCompliance(token); emit NewTokenCommitted(token, address(this), msg.sender);
47,188
278
// Getter to return the base implementation contract to call methods from/ Don't expose base contract to parent due to need to call private internal base functions
function base() private view returns (IBaseERC721Interface) { return IBaseERC721Interface(address(this)); }
function base() private view returns (IBaseERC721Interface) { return IBaseERC721Interface(address(this)); }
37,468
4
// spend up to the allowance of the token in
uint256 maxSpend = aToB ? maxSpendTokenA : maxSpendTokenB; if (amountIn > maxSpend) { amountIn = maxSpend; }
uint256 maxSpend = aToB ? maxSpendTokenA : maxSpendTokenB; if (amountIn > maxSpend) { amountIn = maxSpend; }
13,292
350
// Mark the Vault as initialized.
isInitialized = true;
isInitialized = true;
21,518
102
// Set the reward model parameters
_dataStorage.setGlobalRewardPerBlock(_globalRewardPerBlock); _dataStorage.setGlobalRewardDecrement(_globalRewardDecrement); _dataStorage.setGlobalRewardTotalAmount(_globalRewardTotalAmount); uint256 rewardAmount = _delta.mul(_dataStorage.getRewardParamUpdateRewardPerBlock());
_dataStorage.setGlobalRewardPerBlock(_globalRewardPerBlock); _dataStorage.setGlobalRewardDecrement(_globalRewardDecrement); _dataStorage.setGlobalRewardTotalAmount(_globalRewardTotalAmount); uint256 rewardAmount = _delta.mul(_dataStorage.getRewardParamUpdateRewardPerBlock());
9,969
27
// override from Editable
function parentAddress() public view returns (address) { return libraryAddress; }
function parentAddress() public view returns (address) { return libraryAddress; }
29,620
69
// Create the new EthereumPaymentRequest.
EthereumPaymentRequest memory ethereumPaymentRequest = EthereumPaymentRequest({ shop: msg.sender, note: _note, value: _value, shopId: _shopId, completed: false, rejected: false });
EthereumPaymentRequest memory ethereumPaymentRequest = EthereumPaymentRequest({ shop: msg.sender, note: _note, value: _value, shopId: _shopId, completed: false, rejected: false });
6,838
114
// only use to prevent sniper buys in the first blocks.
if (gasLimitActive && automatedMarketMakerPairs[from]) { require(tx.gasprice <= gasPriceLimit, "Gas price exceeds limit."); }
if (gasLimitActive && automatedMarketMakerPairs[from]) { require(tx.gasprice <= gasPriceLimit, "Gas price exceeds limit."); }
3,990
155
// Clear withdrawn
stakeDetails.withdrawnAmount = 0;
stakeDetails.withdrawnAmount = 0;
26,715
61
// Counts the number of nonoverlapping occurrences of `needle` in `self`. self The slice to search. needle The text to search for in `self`.return The number of occurrences of `needle` found in `self`. /
function count(slice self, slice needle) internal pure returns (uint cnt) { uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr) + needle._len; while (ptr <= self._ptr + self._len) { cnt++; ptr = findPtr(self._len - (ptr - self._ptr), ptr, needle._len, needle._ptr) + needle._len; } }
function count(slice self, slice needle) internal pure returns (uint cnt) { uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr) + needle._len; while (ptr <= self._ptr + self._len) { cnt++; ptr = findPtr(self._len - (ptr - self._ptr), ptr, needle._len, needle._ptr) + needle._len; } }
86,539
218
// Transfer current claimable premiums (for stakers) to core Sherlock address/Callable by everyone/Funds will be transferred to Sherlock core contract
function claimPremiumsForStakers() external;
function claimPremiumsForStakers() external;
12,845
167
// Token record data structure bound is token bound to pool ready has token been initialized lastDenormUpdate timestamp of last denorm change denorm denormalized weight desiredDenorm desired denormalized weight (used for incremental changes) index index of address in tokens array balance token balance /
struct Record { bool bound; bool ready; uint40 lastDenormUpdate; uint96 denorm; uint96 desiredDenorm; uint8 index; uint256 balance; }
struct Record { bool bound; bool ready; uint40 lastDenormUpdate; uint96 denorm; uint96 desiredDenorm; uint8 index; uint256 balance; }
75,773
83
// Sets `amount` as the allowance of `spender` over the `owner`s tokens. This is internal function is equivalent to `approve`, and can be used toe.g. set automatic allowances for certain subsystems, etc.
* Emits an {Approval} event. * * Requirements: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } }
* Emits an {Approval} event. * * Requirements: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } }
2,367
58
// GeneralERC20 dYdX Interface for using ERC20 Tokens. We have to use a special interface to call ERC20 functions sothat we dont automatically revert when calling non-compliant tokens that have no return value fortransfer(), transferFrom(), or approve(). /
interface GeneralERC20 { function totalSupply( ) external view returns (uint256); function balanceOf( address who ) external view returns (uint256); function allowance( address owner, address spender ) external view returns (uint256); function transfer( address to, uint256 value ) external; function transferFrom( address from, address to, uint256 value ) external; function approve( address spender, uint256 value ) external; }
interface GeneralERC20 { function totalSupply( ) external view returns (uint256); function balanceOf( address who ) external view returns (uint256); function allowance( address owner, address spender ) external view returns (uint256); function transfer( address to, uint256 value ) external; function transferFrom( address from, address to, uint256 value ) external; function approve( address spender, uint256 value ) external; }
31,311
79
// Cast a int256 to a uint256, revert on underflow/y The int256 to be casted/ return z The casted integer, now type uint256
function toUint256(int256 y) internal pure returns (uint256 z) { require(y >= 0, "SafeCast: bad uint256"); z = uint256(y); }
function toUint256(int256 y) internal pure returns (uint256 z) { require(y >= 0, "SafeCast: bad uint256"); z = uint256(y); }
4,061
157
// Owner may change the percent of insurance fees referrers receive. _referPercent The percent of fees referrers receive. 50 == 5%./
{ require(_referPercent <= 500, "Cannot give referrer more than 50% of rewards."); referPercent = _referPercent; }
{ require(_referPercent <= 500, "Cannot give referrer more than 50% of rewards."); referPercent = _referPercent; }
20,081
50
// Helper function for check that _underlineContract supports some interface accordingly ERC165. So for check IERC721 support use _interfaceId like this:/bytes4(keccak256('balanceOf(address)')) == 0x70a08231bytes4(keccak256('ownerOf(uint256)')) == 0x6352211ebytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3bytes4(keccak256('getApproved(uint256)')) == 0x081812fcbytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872ddbytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0ebytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^ 0xa22cb465 ^ 0xe985e9c ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd _INTERFACE_ID_ERC721 = 0x80ac58cd;bytes4(keccak256('name()')) == 0x06fdde03bytes4(keccak256('symbol()')) == 0x95d89b41bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139fbytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f; bytes4(keccak256('totalSupply()')) == 0x18160dddbytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7 => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63;_underlineContractcontract
function isERC721(address _underlineContract, bytes4 _interfaceId) public view returns (bool) { return _underlineContract.supportsInterface(_interfaceId); }
function isERC721(address _underlineContract, bytes4 _interfaceId) public view returns (bool) { return _underlineContract.supportsInterface(_interfaceId); }
58,692
89
// return Number of transactions, both enabled and disabled, in transactions list. /
function transactionsSize() external view returns (uint256)
function transactionsSize() external view returns (uint256)
54,381
165
// Adapted from https:github.com/makerdao/dss-proxy-actions/blob/master/src/DssProxyActions.solL183
function _getWipeDart( VatLike vat, uint256 dai, address urn, bytes32 ilk
function _getWipeDart( VatLike vat, uint256 dai, address urn, bytes32 ilk
3,344
752
// Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to theirpercentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20contract. /
function release(IERC20Upgradeable token, address account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = token.balanceOf(address(this)) + totalReleased(token); uint256 payment = _pendingPayment(account, totalReceived, released(token, account)); require(payment != 0, "PaymentSplitter: account is not due payment"); _erc20Released[token][account] += payment; _erc20TotalReleased[token] += payment; SafeERC20Upgradeable.safeTransfer(token, account, payment); emit ERC20PaymentReleased(token, account, payment); }
function release(IERC20Upgradeable token, address account) public virtual { require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = token.balanceOf(address(this)) + totalReleased(token); uint256 payment = _pendingPayment(account, totalReceived, released(token, account)); require(payment != 0, "PaymentSplitter: account is not due payment"); _erc20Released[token][account] += payment; _erc20TotalReleased[token] += payment; SafeERC20Upgradeable.safeTransfer(token, account, payment); emit ERC20PaymentReleased(token, account, payment); }
11,432
6
// Returns the amount of tokens owned by `account`./
function balanceOf(address account) external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
37,107
43
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator. This will give us the correct result modulo 2256. Since the precoditions guarantee that the outcome is less than 2256, this is the final result. We don't need to compute the high bits of the result and prod1 is no longer required.
result = prod0 * inv; return result;
result = prod0 * inv; return result;
19,455
91
// _newAddress new address of the platform/Change the wallet of the platform. The one that will receive the platform fee when the raffle is closed./ Only the admin can change this
function setDestinationAddress( address payable _newAddress
function setDestinationAddress( address payable _newAddress
39,295
37
// get AT contracts number /
function getTotalATContracts() external view returns(uint256) { return ATContractsList.length; }
function getTotalATContracts() external view returns(uint256) { return ATContractsList.length; }
12,451
902
// ServiceRegistry contract This contract supports the service discovery process by allowing indexers toregister their service url and any other relevant information. /
contract ServiceRegistry is ServiceRegistryV1Storage, GraphUpgradeable, IServiceRegistry { // -- Events -- event ServiceRegistered(address indexed indexer, string url, string geohash); event ServiceUnregistered(address indexed indexer); /** * @dev Check if the caller is authorized (indexer or operator) */ function _isAuth(address _indexer) internal view returns (bool) { return msg.sender == _indexer || staking().isOperator(msg.sender, _indexer) == true; } /** * @dev Initialize this contract. */ function initialize(address _controller) external onlyImpl { Managed._initialize(_controller); } /** * @dev Register an indexer service * @param _url URL of the indexer service * @param _geohash Geohash of the indexer service location */ function register(string calldata _url, string calldata _geohash) external override { _register(msg.sender, _url, _geohash); } /** * @dev Register an indexer service * @param _indexer Address of the indexer * @param _url URL of the indexer service * @param _geohash Geohash of the indexer service location */ function registerFor( address _indexer, string calldata _url, string calldata _geohash ) external override { _register(_indexer, _url, _geohash); } /** * @dev Internal: Register an indexer service * @param _indexer Address of the indexer * @param _url URL of the indexer service * @param _geohash Geohash of the indexer service location */ function _register( address _indexer, string calldata _url, string calldata _geohash ) private { require(_isAuth(_indexer), "!auth"); require(bytes(_url).length > 0, "Service must specify a URL"); services[_indexer] = IndexerService(_url, _geohash); emit ServiceRegistered(_indexer, _url, _geohash); } /** * @dev Unregister an indexer service */ function unregister() external override { _unregister(msg.sender); } /** * @dev Unregister an indexer service * @param _indexer Address of the indexer */ function unregisterFor(address _indexer) external override { _unregister(_indexer); } /** * @dev Unregister an indexer service * @param _indexer Address of the indexer */ function _unregister(address _indexer) private { require(_isAuth(_indexer), "!auth"); require(isRegistered(_indexer), "Service already unregistered"); delete services[_indexer]; emit ServiceUnregistered(_indexer); } /** * @dev Return the registration status of an indexer service * @return True if the indexer service is registered */ function isRegistered(address _indexer) public override view returns (bool) { return bytes(services[_indexer].url).length > 0; } }
contract ServiceRegistry is ServiceRegistryV1Storage, GraphUpgradeable, IServiceRegistry { // -- Events -- event ServiceRegistered(address indexed indexer, string url, string geohash); event ServiceUnregistered(address indexed indexer); /** * @dev Check if the caller is authorized (indexer or operator) */ function _isAuth(address _indexer) internal view returns (bool) { return msg.sender == _indexer || staking().isOperator(msg.sender, _indexer) == true; } /** * @dev Initialize this contract. */ function initialize(address _controller) external onlyImpl { Managed._initialize(_controller); } /** * @dev Register an indexer service * @param _url URL of the indexer service * @param _geohash Geohash of the indexer service location */ function register(string calldata _url, string calldata _geohash) external override { _register(msg.sender, _url, _geohash); } /** * @dev Register an indexer service * @param _indexer Address of the indexer * @param _url URL of the indexer service * @param _geohash Geohash of the indexer service location */ function registerFor( address _indexer, string calldata _url, string calldata _geohash ) external override { _register(_indexer, _url, _geohash); } /** * @dev Internal: Register an indexer service * @param _indexer Address of the indexer * @param _url URL of the indexer service * @param _geohash Geohash of the indexer service location */ function _register( address _indexer, string calldata _url, string calldata _geohash ) private { require(_isAuth(_indexer), "!auth"); require(bytes(_url).length > 0, "Service must specify a URL"); services[_indexer] = IndexerService(_url, _geohash); emit ServiceRegistered(_indexer, _url, _geohash); } /** * @dev Unregister an indexer service */ function unregister() external override { _unregister(msg.sender); } /** * @dev Unregister an indexer service * @param _indexer Address of the indexer */ function unregisterFor(address _indexer) external override { _unregister(_indexer); } /** * @dev Unregister an indexer service * @param _indexer Address of the indexer */ function _unregister(address _indexer) private { require(_isAuth(_indexer), "!auth"); require(isRegistered(_indexer), "Service already unregistered"); delete services[_indexer]; emit ServiceUnregistered(_indexer); } /** * @dev Return the registration status of an indexer service * @return True if the indexer service is registered */ function isRegistered(address _indexer) public override view returns (bool) { return bytes(services[_indexer].url).length > 0; } }
84,747
20
// This position is saved to storage to make the logic around borrowing uniform. This is slightly gas inefficient but ok given the ability to ensure no diverging logic.
uint256 positionId = state.savePosition(newPosition); newPosition = borrow( positionId, collateralAmount, borrowAmount ); return (
uint256 positionId = state.savePosition(newPosition); newPosition = borrow( positionId, collateralAmount, borrowAmount ); return (
36,590
7
// Add a value to a set. O(1). Returns true if the value was added to the set, that is if it was notalready present. /
function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } }
function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } }
81
97
// Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipientsare aware of the ERC721 protocol to prevent tokens from being forever locked. Requirements: - `from` cannot be the zero address.- `to` cannot be the zero address.- `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. ); address indexed owner, address indexed operator, bool approved ); * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; }
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. ); address indexed owner, address indexed operator, bool approved ); * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; }
27,730
20
// Set the quoteKey of the OptionMarket._contractAddress The address of the OptionMarket. _quoteKey The key of the quoteAsset. /
function setQuoteKey(address _contractAddress, bytes32 _quoteKey) public override onlyOwner { quoteKey[_contractAddress] = _quoteKey; emit QuoteKeySet(_contractAddress, _quoteKey); }
function setQuoteKey(address _contractAddress, bytes32 _quoteKey) public override onlyOwner { quoteKey[_contractAddress] = _quoteKey; emit QuoteKeySet(_contractAddress, _quoteKey); }
13,529
15
// fetch the commitment
Commitment storage c = commitments[_commitmentId];
Commitment storage c = commitments[_commitmentId];
33,725
46
// Given a token Id, returns a byte array that is supposed to be converted into string.
function getMetadata(uint256 _tokenId, string memory) public pure returns (bytes32[4] memory buffer, uint256 count) { if (_tokenId == 1) { buffer[0] = "Hello World! :D"; count = 15; } else if (_tokenId == 2) { buffer[0] = "I would definitely choose a medi"; buffer[1] = "um length string."; count = 49; } else if (_tokenId == 3) { buffer[0] = "Lorem ipsum dolor sit amet, mi e"; buffer[1] = "st accumsan dapibus augue lorem,"; buffer[2] = " tristique vestibulum id, libero"; buffer[3] = " suscipit varius sapien aliquam."; count = 128; } }
function getMetadata(uint256 _tokenId, string memory) public pure returns (bytes32[4] memory buffer, uint256 count) { if (_tokenId == 1) { buffer[0] = "Hello World! :D"; count = 15; } else if (_tokenId == 2) { buffer[0] = "I would definitely choose a medi"; buffer[1] = "um length string."; count = 49; } else if (_tokenId == 3) { buffer[0] = "Lorem ipsum dolor sit amet, mi e"; buffer[1] = "st accumsan dapibus augue lorem,"; buffer[2] = " tristique vestibulum id, libero"; buffer[3] = " suscipit varius sapien aliquam."; count = 128; } }
15,880
3
// Tạo tác giả
function taotacgia() public { Nhom17.push(Tacgia(18520102,'Pham Nhat Minh')); Nhom17.push(Tacgia(18521694,'Huynh Ngoc Son')); Nhom17.push(Tacgia(18520580,'Nguyen Thanh Dat')); Nhom17.push(Tacgia(18521693,'Huynh Nhat Khanh')); }
function taotacgia() public { Nhom17.push(Tacgia(18520102,'Pham Nhat Minh')); Nhom17.push(Tacgia(18521694,'Huynh Ngoc Son')); Nhom17.push(Tacgia(18520580,'Nguyen Thanh Dat')); Nhom17.push(Tacgia(18521693,'Huynh Nhat Khanh')); }
37,870
17
// Tech Development195,000,000 (15%)
uint constant public maxTechSupply = 195000000 * E18;
uint constant public maxTechSupply = 195000000 * E18;
11,162
81
// Modifica el precio que el owner desea cobrar, los fees se mantienen intactos.
function setPrice(string memory _cid, uint256 _price) external { require( !pause && (msg.sender == indexOfCid[_cid].owner),"NFT not access"); indexOfCid[_cid].price=_price; emit priceChanged(_cid,_price); }
function setPrice(string memory _cid, uint256 _price) external { require( !pause && (msg.sender == indexOfCid[_cid].owner),"NFT not access"); indexOfCid[_cid].price=_price; emit priceChanged(_cid,_price); }
1,117
104
// START OF BULL BANK SPECIFIC CODE BullBank is an exact copy of BooBankthe Bull burns a variable quantity of the transfer amount, and gives the recipient the equivalent Bear token
using SafeMath for uint256; address public devaddr;
using SafeMath for uint256; address public devaddr;
23,331
3
// Mint NFTs from the ArcaneCharacters contract.Users can specify what characterId they want to mint. Users can claim once.There is a limit on how many are distributed. It requires RUNE balance to be > 0. /
function mintCollectible( address _tokenReceiver, string calldata _tokenURI, uint8 _characterId
function mintCollectible( address _tokenReceiver, string calldata _tokenURI, uint8 _characterId
35,134
26
// token
if(!_inSwap && _tradingOpen && from != uniswapV2Pair) { require(cooldown[from].buy < block.timestamp + (15 seconds), "plz wait."); uint contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance > 0) { if(_useImpactFeeSetter) { if(contractTokenBalance > (balanceOf(uniswapV2Pair) * _feeRate) / 100) { contractTokenBalance = (balanceOf(uniswapV2Pair) * _feeRate) / 100; }
if(!_inSwap && _tradingOpen && from != uniswapV2Pair) { require(cooldown[from].buy < block.timestamp + (15 seconds), "plz wait."); uint contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance > 0) { if(_useImpactFeeSetter) { if(contractTokenBalance > (balanceOf(uniswapV2Pair) * _feeRate) / 100) { contractTokenBalance = (balanceOf(uniswapV2Pair) * _feeRate) / 100; }
48,997
166
// transfer amount, it will take tax, marketing, liquidity fee
_tokenTransfer(from, to, amount, takeFee);
_tokenTransfer(from, to, amount, takeFee);
21,078
3
// constructor/ initializes a logic contract/major the major version of this contract/minor the minor version of this contract/patch the patch version of this contract
function CapChatLogic(uint8 major, uint8 minor, uint8 patch) { owner = msg.sender; version[0] = major; version[1] = minor; version[2] = patch; }
function CapChatLogic(uint8 major, uint8 minor, uint8 patch) { owner = msg.sender; version[0] = major; version[1] = minor; version[2] = patch; }
29,741
4
// get the proposal token for this /
function getProposed(address idx) public view returns (address proposal) { proposal = _getProposal[idx]; }
function getProposed(address idx) public view returns (address proposal) { proposal = _getProposal[idx]; }
38,305
224
// The total value of the reserve-owned assets denominated in USDCreturn Reserve total value /
function reserveBalance() public view returns (uint256) { uint256 internalBalance = _balanceOf(registry().usdc(), address(this)); uint256 vaultBalance = _balanceOfVault(); return internalBalance.add(vaultBalance); }
function reserveBalance() public view returns (uint256) { uint256 internalBalance = _balanceOf(registry().usdc(), address(this)); uint256 vaultBalance = _balanceOfVault(); return internalBalance.add(vaultBalance); }
63,152
202
// Emitted when the global max wallet claim count is updated.
event MaxWalletClaimCountUpdated(uint256 count);
event MaxWalletClaimCountUpdated(uint256 count);
71,860
142
// return "TUSD";
return "TUSD_ILT";
return "TUSD_ILT";
18,603
48
// Stop sale in case of emergency (i.e. circuit breaker)/Only allowed to be called by the owner
function stopSale() onlyBy(owner) external { isStopped = true; }
function stopSale() onlyBy(owner) external { isStopped = true; }
10,260
8
// Compute b^(e.w) by splitting it into (b^e)(b^0.w). Use `bpowi` for `b^e` and `bpowK` for k iterations of approximation of b^0.w
function bpow(uint256 base, uint256 exp) internal pure returns (uint256) { require(base >= MIN_BPOW_BASE, "ERR_BPOW_BASE_TOO_LOW"); require(base <= MAX_BPOW_BASE, "ERR_BPOW_BASE_TOO_HIGH"); uint256 whole = bfloor(exp); uint256 remain = bsub(exp, whole); uint256 wholePow = bpowi(base, btoi(whole)); if (remain == 0) { return wholePow; } uint256 partialResult = bpowApprox(base, remain, BPOW_PRECISION); return bmul(wholePow, partialResult); }
function bpow(uint256 base, uint256 exp) internal pure returns (uint256) { require(base >= MIN_BPOW_BASE, "ERR_BPOW_BASE_TOO_LOW"); require(base <= MAX_BPOW_BASE, "ERR_BPOW_BASE_TOO_HIGH"); uint256 whole = bfloor(exp); uint256 remain = bsub(exp, whole); uint256 wholePow = bpowi(base, btoi(whole)); if (remain == 0) { return wholePow; } uint256 partialResult = bpowApprox(base, remain, BPOW_PRECISION); return bmul(wholePow, partialResult); }
19,421
23
// Returns the roll amount of a request requestId id of random requestreturn amount of the roll of the request /
function getRollRequestAmount(bytes32 requestId) internal view returns(uint256) { uint256[3][] memory bets = _rollRequestsBets[requestId]; uint256 amount = 0; for (uint index = 0; index < bets.length; index++) { uint256 betAmount = bets[index][2]; amount += betAmount; } return amount; }
function getRollRequestAmount(bytes32 requestId) internal view returns(uint256) { uint256[3][] memory bets = _rollRequestsBets[requestId]; uint256 amount = 0; for (uint index = 0; index < bets.length; index++) { uint256 betAmount = bets[index][2]; amount += betAmount; } return amount; }
2,890
169
// .when sell
else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) { require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount!"); }
else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) { require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount!"); }
41,711
34
// internal function to calculate attack strength based on rarity
function _calculateAttackStrength(uint256 _rarity) internal view returns (uint256) { address sender = msg.sender; uint256 attackStrength; if (_rarity == 1) { attackStrength = _getRandomNumber(2, 6, sender); // Set attack strength between 2 and 5 for rarity 1 (Common) } else if (_rarity == 2) { attackStrength = _getRandomNumber(3, 7, sender); // Set attack strength between 3 and 6 for rarity 2 (Uncommon) } else if (_rarity == 3) { attackStrength = _getRandomNumber(4, 8, sender); // Set attack strength between 4 and 7 for rarity 3 (Rare) } else if (_rarity == 4) { attackStrength = _getRandomNumber(5, 9, sender); // Set attack strength between 5 and 8 for rarity 4 (Very Rare) } else if (_rarity == 5) { attackStrength = _getRandomNumber(8, 10, sender); // Set attack strength between 8 and 10 for rarity 5 (Mythical) } else { attackStrength = 0; // Set attack strength to 0 for other rarities } return attackStrength; }
function _calculateAttackStrength(uint256 _rarity) internal view returns (uint256) { address sender = msg.sender; uint256 attackStrength; if (_rarity == 1) { attackStrength = _getRandomNumber(2, 6, sender); // Set attack strength between 2 and 5 for rarity 1 (Common) } else if (_rarity == 2) { attackStrength = _getRandomNumber(3, 7, sender); // Set attack strength between 3 and 6 for rarity 2 (Uncommon) } else if (_rarity == 3) { attackStrength = _getRandomNumber(4, 8, sender); // Set attack strength between 4 and 7 for rarity 3 (Rare) } else if (_rarity == 4) { attackStrength = _getRandomNumber(5, 9, sender); // Set attack strength between 5 and 8 for rarity 4 (Very Rare) } else if (_rarity == 5) { attackStrength = _getRandomNumber(8, 10, sender); // Set attack strength between 8 and 10 for rarity 5 (Mythical) } else { attackStrength = 0; // Set attack strength to 0 for other rarities } return attackStrength; }
6,533
100
// add the deposited tokens into existing balance
balances[msg.sender].available_token_balance += tokens;
balances[msg.sender].available_token_balance += tokens;
8,125
0
// WETH Distribution Token
IERC20 public distributionToken = IERC20(WETH);
IERC20 public distributionToken = IERC20(WETH);
10,140
137
// Check that the new bid is sufficiently higher than the previous bid.
require( amount.sub(auctions[tokenId].amount) >= MIN_BID_INCREMENT, "Must bid more than last bid by MIN_BID_INCREMENT amount" );
require( amount.sub(auctions[tokenId].amount) >= MIN_BID_INCREMENT, "Must bid more than last bid by MIN_BID_INCREMENT amount" );
44,582
200
// CHEAT Functions for Testing//CHEAT Functions for Testing//CHEAT Functions for Testing--No Nonce/ /This is a cheat for demo purposes, will delete upon actual launch/
// function theLazyCoon(TellorStorage.TellorStorageStruct storage self,address _address, uint _amount) public { // self.uintVars[total_supply] += _amount; // TellorTransfer.updateBalanceAtNow(self.balances[_address],_amount); // }
// function theLazyCoon(TellorStorage.TellorStorageStruct storage self,address _address, uint _amount) public { // self.uintVars[total_supply] += _amount; // TellorTransfer.updateBalanceAtNow(self.balances[_address],_amount); // }
41,784
45
// gets number of accounts registered and reserved. return returns the size of the accounts array./
function getAccountsLength() external view returns (uint) { return accounts.length; }
function getAccountsLength() external view returns (uint) { return accounts.length; }
29,543