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
288
// duration: amount of time during which the poll can be voted on
uint256 duration;
uint256 duration;
37,017
78
// List of actions grouped as a recipe/name Name of the recipe useful for logging what recipe is executing/callData Array of calldata inputs to each action/subData Used only as part of strategy, subData injected from StrategySub.subData/actionIds Array of identifiers for actions - bytes4(keccak256(ActionName))/paramMapping Describes how inputs to functions are piped from return/subbed values
struct Recipe { string name; bytes[] callData; bytes32[] subData; bytes4[] actionIds; uint8[][] paramMapping; }
struct Recipe { string name; bytes[] callData; bytes32[] subData; bytes4[] actionIds; uint8[][] paramMapping; }
43,492
154
// Payment info
baseGas, gasPrice, gasToken, refundReceiver,
baseGas, gasPrice, gasToken, refundReceiver,
51,503
10
// Cannot query item that already disabled
error CallerQueryDisableItem();
error CallerQueryDisableItem();
24,285
43
// Returns the owner of the NFT specified by `tokenId`. /
function ownerOf(uint256 tokenId) external view returns (address _owner);
function ownerOf(uint256 tokenId) external view returns (address _owner);
14,521
21
// Stores a new address in the EIP1967 admin slot.
function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin; }
function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin; }
24,285
261
// Fetches Observations `beforeOrAt` and `atOrAfter` a `_target`, eg: where [`beforeOrAt`, `atOrAfter`] is satisfied. The result may be the same Observation, or adjacent Observations.The answer must be contained in the array used when the target is located within the stored Observation. boundaries: older than the most recent Observation and younger, or the same age as, the oldest Observation. If `_newestObservationIndex` is less than `_oldestObservationIndex`, it means that we've wrapped around the circular buffer. So the most recent observation will be at `_oldestObservationIndex + _cardinality - 1`, at the beginning of the circular buffer._observations List of Observations to search through._newestObservationIndex Index of
function binarySearch( Observation[MAX_CARDINALITY] storage _observations, uint24 _newestObservationIndex, uint24 _oldestObservationIndex, uint32 _target, uint24 _cardinality, uint32 _time
function binarySearch( Observation[MAX_CARDINALITY] storage _observations, uint24 _newestObservationIndex, uint24 _oldestObservationIndex, uint32 _target, uint24 _cardinality, uint32 _time
42,473
1
// Burn function
function burn(uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); event Burn(address indexed burner, uint256 value);
function burn(uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); event Burn(address indexed burner, uint256 value);
29,815
35
// Checking if voter has enough votes count to add own proposal.
require(kks.getVoterVotesCount(msg.sender) / kks.getVotesPerProposal() > kks.getVoterProposalsCount(msg.sender));
require(kks.getVoterVotesCount(msg.sender) / kks.getVotesPerProposal() > kks.getVoterProposalsCount(msg.sender));
27,118
69
// A struct that stores a component's external position details including virtual unit and anyauxiliary data.virtualUnit Virtual value of a component's EXTERNAL position. dataArbitrary data /
struct ExternalPosition { int256 virtualUnit; bytes data; }
struct ExternalPosition { int256 virtualUnit; bytes data; }
10,903
106
// Disables the use of the specified circuit./blockType The type of the block/blockSize The number of requests handled in the block/blockVersion The block version (i.e. which circuit version needs to be used)
function disableCircuit( uint8 blockType, uint16 blockSize, uint8 blockVersion ) external virtual;
function disableCircuit( uint8 blockType, uint16 blockSize, uint8 blockVersion ) external virtual;
23,945
167
// A helper contract with helper modifiers to allow access to original contract creator only
contract ImmutableOwner { address public immutable immutableOwner; modifier onlyImmutableOwner { require(msg.sender == immutableOwner, "IO: Access denied"); _; } constructor(address _immutableOwner) { immutableOwner = _immutableOwner; } }
contract ImmutableOwner { address public immutable immutableOwner; modifier onlyImmutableOwner { require(msg.sender == immutableOwner, "IO: Access denied"); _; } constructor(address _immutableOwner) { immutableOwner = _immutableOwner; } }
12,590
10
// Withdraws capital out of idleFinance amount - the amount to withdrawreturn the number of tokens to return to the vault /
function _divest(uint256 amount, uint256) internal override returns (uint256) { // TODO: withdraw capital from idleFinance return idleTokenInstance.redeemIdleToken(amount); }
function _divest(uint256 amount, uint256) internal override returns (uint256) { // TODO: withdraw capital from idleFinance return idleTokenInstance.redeemIdleToken(amount); }
31,134
10
// If we've finished a halving period, reduce the amount
if (nextSlash == 0) { nextSlash = halvingPeriod - 1; vestingAmount = vestingAmount / 2; } else {
if (nextSlash == 0) { nextSlash = halvingPeriod - 1; vestingAmount = vestingAmount / 2; } else {
9,132
36
// performs chained estimateAmountsOut calculations on any number of pairs
function estimateAmountsOut(address factory, uint amountIn, address[] calldata path) internal view returns (uint[] memory amounts) { require(path.length >= 2, 'FeSwapLibrary: INVALID_PATH'); amounts = new uint[](path.length); amounts[0] = amountIn; for (uint i = 0; i < path.length - 1; i++) { (uint reserveIn, uint reserveOut, ) = culculatePairPools(factory, path[i], path[i + 1]); amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut); } }
function estimateAmountsOut(address factory, uint amountIn, address[] calldata path) internal view returns (uint[] memory amounts) { require(path.length >= 2, 'FeSwapLibrary: INVALID_PATH'); amounts = new uint[](path.length); amounts[0] = amountIn; for (uint i = 0; i < path.length - 1; i++) { (uint reserveIn, uint reserveOut, ) = culculatePairPools(factory, path[i], path[i + 1]); amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut); } }
56,228
49
// Boooots
mapping (address => bool) private isBot; event ExcludeFromFees(address indexed account, bool isExcluded); event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value); event SwapAndLiquidity(uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity);
mapping (address => bool) private isBot; event ExcludeFromFees(address indexed account, bool isExcluded); event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value); event SwapAndLiquidity(uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiquidity);
18,680
12
// Prevents a contract from calling itself, directly or indirectly. If you mark a function `nonReentrant`, you should alsomark it `external`. Calling one nonReentrant function fromanother is not supported. Instead, you can implement a`private` function doing the actual work, and a `external`wrapper marked as `nonReentrant`. /
modifier nonReentrant() { require(!rentrancy_lock); rentrancy_lock = true; _; rentrancy_lock = false; }
modifier nonReentrant() { require(!rentrancy_lock); rentrancy_lock = true; _; rentrancy_lock = false; }
3,372
71
// Requirements
require( (msg.sender == _from) || isApprovedForAll(_from, msg.sender), "ERC1155#safeBatchTransferFrom: INVALID_OPERATOR" ); require( _to != address(0), "ERC1155#safeBatchTransferFrom: INVALID_RECIPIENT" ); _safeBatchTransferFrom(_from, _to, _ids, _amounts);
require( (msg.sender == _from) || isApprovedForAll(_from, msg.sender), "ERC1155#safeBatchTransferFrom: INVALID_OPERATOR" ); require( _to != address(0), "ERC1155#safeBatchTransferFrom: INVALID_RECIPIENT" ); _safeBatchTransferFrom(_from, _to, _ids, _amounts);
2,291
3
// Set royalty receiver to the contract creator, at 10% (default denominator is 10000).
_setDefaultRoyalty(0x89D22d046DBB487E32E07440794CD2B913Aa0B72, 420);
_setDefaultRoyalty(0x89D22d046DBB487E32E07440794CD2B913Aa0B72, 420);
26,166
720
// Allows the guardianAddress to execute protocol actions _targetContractRegistryKey - key in registry of target contract _callValue - amount of wei if a token transfer is involved _functionSignature - function signature of the function to be executed if proposal is successful _callData - encoded value(s) to call function with if proposal is successful /
function guardianExecuteTransaction( bytes32 _targetContractRegistryKey, uint256 _callValue, string calldata _functionSignature, bytes calldata _callData ) external
function guardianExecuteTransaction( bytes32 _targetContractRegistryKey, uint256 _callValue, string calldata _functionSignature, bytes calldata _callData ) external
41,531
15
// The EIP-712 typehash for the delegation struct used by the contract
bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
3,443
16
// called by the owner to unpause, returns to normal state /
function unpause() onlyOwner whenPaused public returns (bool) { paused = false; emit Unpause(); return true; }
function unpause() onlyOwner whenPaused public returns (bool) { paused = false; emit Unpause(); return true; }
26,885
1
// Minimum eth price for deposit This attribute is required for all future versions, as it isaccessed directly from Erc20DepositLogic2 contract /
uint256 public minimumEthInput;
uint256 public minimumEthInput;
168
28
// Guarantees that the msg.sender is an owner or operator of the given NFT. _tokenId ID of the NFT to validate. /
modifier canOperate(uint256 _tokenId) { address tokenOwner = idToOwner[_tokenId]; require(tokenOwner == msg.sender || ownerToOperators[tokenOwner][msg.sender]); _; }
modifier canOperate(uint256 _tokenId) { address tokenOwner = idToOwner[_tokenId]; require(tokenOwner == msg.sender || ownerToOperators[tokenOwner][msg.sender]); _; }
3,843
57
// Skip if caller has SUPER permission for value transfers
if (hasSuperTransferValue && !isCallDataPresent && value > 0) return;
if (hasSuperTransferValue && !isCallDataPresent && value > 0) return;
48,461
30
// Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. spender The address which will spend the funds. value The amount of tokens to be spent. /
function approve(address spender, uint256 value) public returns (bool) { _approve(msg.sender, spender, value); return true; }
function approve(address spender, uint256 value) public returns (bool) { _approve(msg.sender, spender, value); return true; }
17,818
5
// Checks Mcd registry and replaces the proxy addr if owner changed
contract DFSProxyRegistry is AdminAuth, UtilHelper { IProxyRegistry public mcdRegistry = IProxyRegistry(MKR_PROXY_REGISTRY); mapping(address => address) public changedOwners; mapping(address => address[]) public additionalProxies; /// @notice Changes the proxy that is returned for the user /// @dev Used when the user changed DSProxy ownership himself function changeMcdOwner(address _user, address _proxy) public onlyOwner { if (IDSProxy(_proxy).owner() == _user) { changedOwners[_user] = _proxy; } } /// @notice Returns the proxy address associated with the user account /// @dev If user changed ownership of DSProxy admin can hardcode replacement function getMcdProxy(address _user) public view returns (address) { address proxyAddr = mcdRegistry.proxies(_user); // if check changed proxies if (changedOwners[_user] != address(0)) { return changedOwners[_user]; } return proxyAddr; } function addAdditionalProxy(address _user, address _proxy) public onlyOwner { if (IDSProxy(_proxy).owner() == _user) { additionalProxies[_user].push(_proxy); } } function getAllProxies(address _user) public view returns (address, address[] memory) { return (getMcdProxy(_user), additionalProxies[_user]); } }
contract DFSProxyRegistry is AdminAuth, UtilHelper { IProxyRegistry public mcdRegistry = IProxyRegistry(MKR_PROXY_REGISTRY); mapping(address => address) public changedOwners; mapping(address => address[]) public additionalProxies; /// @notice Changes the proxy that is returned for the user /// @dev Used when the user changed DSProxy ownership himself function changeMcdOwner(address _user, address _proxy) public onlyOwner { if (IDSProxy(_proxy).owner() == _user) { changedOwners[_user] = _proxy; } } /// @notice Returns the proxy address associated with the user account /// @dev If user changed ownership of DSProxy admin can hardcode replacement function getMcdProxy(address _user) public view returns (address) { address proxyAddr = mcdRegistry.proxies(_user); // if check changed proxies if (changedOwners[_user] != address(0)) { return changedOwners[_user]; } return proxyAddr; } function addAdditionalProxy(address _user, address _proxy) public onlyOwner { if (IDSProxy(_proxy).owner() == _user) { additionalProxies[_user].push(_proxy); } } function getAllProxies(address _user) public view returns (address, address[] memory) { return (getMcdProxy(_user), additionalProxies[_user]); } }
22,386
8
// ============================= ADMIN FUNCTIONS =============================
function burn(uint16 tokenId) external onlyRole(ADMIN) { _burn(tokenId); }
function burn(uint16 tokenId) external onlyRole(ADMIN) { _burn(tokenId); }
8,050
5
// return true if whitelist is currently enabled, false otherwise /
function isWhitelistEnabled() public view returns(bool isReallyWhitelistEnabled) { return maxWhitelistLength > 0; }
function isWhitelistEnabled() public view returns(bool isReallyWhitelistEnabled) { return maxWhitelistLength > 0; }
4,885
173
// Just in case Eth does some crazy stuff
function setPrice(uint256 _newPrice) public onlyOwner { _price = _newPrice; }
function setPrice(uint256 _newPrice) public onlyOwner { _price = _newPrice; }
39,242
15
// store in each slot to prevent fresh SSTOREs in swaps this data will not be used because the initialized boolean is still false
for (uint16 i = current; i < next; i++) self[i].blockTimestamp = 1; return next;
for (uint16 i = current; i < next; i++) self[i].blockTimestamp = 1; return next;
24,972
137
// The calculated steal percentage.
uint256 calculatedStealPercentage = stealPercentage;
uint256 calculatedStealPercentage = stealPercentage;
10,104
28
// Get cash balance of this cToken in the underlying assetreturn The quantity of underlying asset owned by this contract /
function getCash() external view returns (uint) { delegateToViewAndReturn(); }
function getCash() external view returns (uint) { delegateToViewAndReturn(); }
4,212
940
// Contract Variables: Internal Accounting // The bonds posted by each proposer
mapping(address => Bond) public bonds;
mapping(address => Bond) public bonds;
57,057
269
// Transfer to recipient
msg.sender.transfer(currentComponentQuantity);
msg.sender.transfer(currentComponentQuantity);
27,601
45
// require(factoryInterface.isProgramFactoryContract() == true);
Factory = factoryInterface;
Factory = factoryInterface;
8,338
11
// Gets the farm pair data for a given MasterChef./chefAddress The address of the MasterChef./whitelistedPids Array of all ids of pools that are whitelisted and valid to have their farm data returned.
function getFarmPairs(address chefAddress, uint256[] calldata whitelistedPids) public view returns (FarmPair[] memory)
function getFarmPairs(address chefAddress, uint256[] calldata whitelistedPids) public view returns (FarmPair[] memory)
1,145
46
// Se aprueba al contrato exchenge a tomar los tokens /
token = ERC20(srcToken);
token = ERC20(srcToken);
7,169
7
// isTransferFreezeTokens returns true when transferring frozen tokens
function isTransferFreezeTokens(address account, uint256 amount) public view returns (bool) { if (block.timestamp > _secondUnfreezeDate){ return false; } if (_firstUnfreezeDate < block.timestamp && block.timestamp < _secondUnfreezeDate) { if (balanceOf(account) - getFreezeTokens(account, 1) < amount) { return true; } } if (block.timestamp < _firstUnfreezeDate) { if (balanceOf(account) - getFreezeTokens(account, 0) < amount) { return true; } } return false; }
function isTransferFreezeTokens(address account, uint256 amount) public view returns (bool) { if (block.timestamp > _secondUnfreezeDate){ return false; } if (_firstUnfreezeDate < block.timestamp && block.timestamp < _secondUnfreezeDate) { if (balanceOf(account) - getFreezeTokens(account, 1) < amount) { return true; } } if (block.timestamp < _firstUnfreezeDate) { if (balanceOf(account) - getFreezeTokens(account, 0) < amount) { return true; } } return false; }
50,040
218
// charge exit fee
uint256 fee=_chargeJoinAndExitFee(SmartPoolStorage.FeeType.EXIT_FEE,amount); uint256 exitAmount=amount.sub(fee); uint256 tokenAmount = calcKfToToken(exitAmount);
uint256 fee=_chargeJoinAndExitFee(SmartPoolStorage.FeeType.EXIT_FEE,amount); uint256 exitAmount=amount.sub(fee); uint256 tokenAmount = calcKfToToken(exitAmount);
20,976
104
// fix the debt
debts[asset][positionOwner] = getTotalDebt(asset, positionOwner); liquidationBlock[asset][positionOwner] = block.number; liquidationPrice[asset][positionOwner] = initialPrice;
debts[asset][positionOwner] = getTotalDebt(asset, positionOwner); liquidationBlock[asset][positionOwner] = block.number; liquidationPrice[asset][positionOwner] = initialPrice;
18,955
2
// Chainlink VRF related parameters
address public constant LINK_TOKEN = 0xb0897686c545045aFc77CF20eC7A532E3120E0F1; address public constant VRF_COORDINATOR = 0x3d2341ADb2D31f1c5530cDC622016af293177AE0; bytes32 public keyHash = 0xf86195cf7690c55907b2b611ebb7343a6f649bff128701cc542f0569e2c549da; uint public chainlinkFee = 100000000000000; // 0.0001 LINK uint maxReward = 20000 ether;
address public constant LINK_TOKEN = 0xb0897686c545045aFc77CF20eC7A532E3120E0F1; address public constant VRF_COORDINATOR = 0x3d2341ADb2D31f1c5530cDC622016af293177AE0; bytes32 public keyHash = 0xf86195cf7690c55907b2b611ebb7343a6f649bff128701cc542f0569e2c549da; uint public chainlinkFee = 100000000000000; // 0.0001 LINK uint maxReward = 20000 ether;
47,957
47
// Verify inclusion in allowlist
(bool validMerkleProof, uint256 merkleProofIndex) = verifyClaimMerkleProof( activeConditionId, _msgSender(), _tokenId, _quantity, _proofs, _proofMaxQuantityPerTransaction ); if (validMerkleProof && _proofMaxQuantityPerTransaction > 0) {
(bool validMerkleProof, uint256 merkleProofIndex) = verifyClaimMerkleProof( activeConditionId, _msgSender(), _tokenId, _quantity, _proofs, _proofMaxQuantityPerTransaction ); if (validMerkleProof && _proofMaxQuantityPerTransaction > 0) {
46,305
121
// check return value
require(returnValue.length == 0 || (returnValue.length == 32 && (returnValue[31] != 0)));
require(returnValue.length == 0 || (returnValue.length == 32 && (returnValue[31] != 0)));
6,273
89
// disable adding to whitelist forever
function renounceWhitelist() public onlyOwner { // adding to whitelist has been disabled forever: canWhitelist = false; }
function renounceWhitelist() public onlyOwner { // adding to whitelist has been disabled forever: canWhitelist = false; }
14,950
7
// if (number < 0) digits = 1;enable this line if '-' counts as a digit
while (number != 0) { number /= 10; digits++; }
while (number != 0) { number /= 10; digits++; }
46,992
76
// Adds a new contract to the registry/_id Id of contract/_contractAddr Address of the contract/_waitPeriod Amount of time to wait before a contract address can be changed
function addNewContract( bytes32 _id, address _contractAddr, uint256 _waitPeriod
function addNewContract( bytes32 _id, address _contractAddr, uint256 _waitPeriod
377
206
// Stake any san tokens, whether they originated through the above deposit or some other means (e.g. migration)
uint256 _sanTokenBalance = balanceOfSanToken(); if (_sanTokenBalance > 0) { IAngleGauge(sanTokenGauge).deposit(_sanTokenBalance); }
uint256 _sanTokenBalance = balanceOfSanToken(); if (_sanTokenBalance > 0) { IAngleGauge(sanTokenGauge).deposit(_sanTokenBalance); }
31,567
17
// Mint token ID 0 / don't allow any user mints
_setupNewToken(newContractURI, 0);
_setupNewToken(newContractURI, 0);
24,019
103
// return the current state of the escrow. /
function state() public view returns (State) { return _state; }
function state() public view returns (State) { return _state; }
14,143
37
// LEAVE AS OWNER
LiquidityAddress = payable(owner()); //Liquidity Pool Token Owner. Gets set to BURN after inital LP is created. Excluded[dead] = true; ExcludedFromTax[_msgSender()] = true; ExcludedFromTax[dead] = true; ExcludedFromTax[address(this)] = true; ExcludedFromTax[MarketingAddress] = true; ExcludedFromTax[AppDevelopAddress] = true; ExcludedFromTax[DevAddress] = true; MaxWalletExclude[address(this)] = true; MaxWalletExclude[_msgSender()] = true;
LiquidityAddress = payable(owner()); //Liquidity Pool Token Owner. Gets set to BURN after inital LP is created. Excluded[dead] = true; ExcludedFromTax[_msgSender()] = true; ExcludedFromTax[dead] = true; ExcludedFromTax[address(this)] = true; ExcludedFromTax[MarketingAddress] = true; ExcludedFromTax[AppDevelopAddress] = true; ExcludedFromTax[DevAddress] = true; MaxWalletExclude[address(this)] = true; MaxWalletExclude[_msgSender()] = true;
66,298
195
// returns the amount of keys you would get given an amount of eth.-functionhash- 0xce89c80c _rID round ID you want price for _eth amount of eth sent inreturn keys received /
function calcKeysReceived(uint256 _rID, uint256 _eth) public view returns (uint256)
function calcKeysReceived(uint256 _rID, uint256 _eth) public view returns (uint256)
38,204
4
// Bird Standard API Requestid: "1"key: "bird_rating"value: "0.4" => 400000000000000000arrivedBirds: 0resolved: true/falseaddr: 0x...response: response from off-chain oracles nest: approved off-chain oracles nest/addresses and keep track of vote (1=not voted, 2=voted) /
struct BirdRequest { uint id; string url; string key; uint value; uint arrivedBirds; bool resolved; address addr; mapping(uint => uint) response; mapping(address => uint) nest; }
struct BirdRequest { uint id; string url; string key; uint value; uint arrivedBirds; bool resolved; address addr; mapping(uint => uint) response; mapping(address => uint) nest; }
36,470
81
// Redistributes the specified amount among the current holders via the reflect.financealgorithm, i.e. by updating the _reflectedSupply (_rSupply) which ultimately adjusts thecurrent rate used by `tokenFromReflection` and, in turn, the value returns from `balanceOf`./
function _redistribute(uint256 amount, uint256 currentRate, uint256 fee) internal { uint256 tFee = amount.mul(fee).div(FEES_DIVISOR); uint256 rFee = tFee.mul(currentRate); _reflectedSupply = _reflectedSupply.sub(rFee); collectedFeeTotal = collectedFeeTotal.add(tFee); }
function _redistribute(uint256 amount, uint256 currentRate, uint256 fee) internal { uint256 tFee = amount.mul(fee).div(FEES_DIVISOR); uint256 rFee = tFee.mul(currentRate); _reflectedSupply = _reflectedSupply.sub(rFee); collectedFeeTotal = collectedFeeTotal.add(tFee); }
274
12
// is current transaction a transfer
bool transfer;
bool transfer;
18,473
16
// events ERC20 events
event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval( address indexed _owner, address indexed _spender, uint256 _value );
event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval( address indexed _owner, address indexed _spender, uint256 _value );
7,372
67
// How much tokens this crowdsale has credited for each investor address
mapping (address => uint256) public tokenAmountOf;
mapping (address => uint256) public tokenAmountOf;
39,582
7
// The number of choices for the arbitrator. Kleros is currently able to provide ruling values of up to 2^256 - 2.
uint256 public constant NUMBER_OF_CHOICES_FOR_ARBITRATOR = type(uint256).max - 1;
uint256 public constant NUMBER_OF_CHOICES_FOR_ARBITRATOR = type(uint256).max - 1;
15,005
39
// function with logarithmic characteristic (in else) if the reputation is lower than 2, then they can only add one later on can implement this logarithmic weighting or delete and replace with modifier?
function validateReputationChange(address _sender, bytes32 _nameId, uint8 _reputationAdded) internal view returns (bool _result){ uint80 _reputation = reputationRegistry[_sender][_nameId]; if (_reputation < 2 ) { _reputationAdded == 1 ? _result = true: _result = false; } // this is the logarithmic, if your rep is 4 you can add 2, 8 can add 4 else { 2**_reputationAdded <= _reputation ? _result = true: _result = false; } }
function validateReputationChange(address _sender, bytes32 _nameId, uint8 _reputationAdded) internal view returns (bool _result){ uint80 _reputation = reputationRegistry[_sender][_nameId]; if (_reputation < 2 ) { _reputationAdded == 1 ? _result = true: _result = false; } // this is the logarithmic, if your rep is 4 you can add 2, 8 can add 4 else { 2**_reputationAdded <= _reputation ? _result = true: _result = false; } }
38,521
200
// Topping 2
TIERS[4] = [1355, 1400, 1400, 1400];
TIERS[4] = [1355, 1400, 1400, 1400];
24,804
5
// withdraw
actionsWithdraw[0] = Dydx.ActionArgs( { actionType: 1, accountId: 0, amount: Dydx.AssetAmount( { sign: false, denomination: 0, ref: 0, value: amount.value
actionsWithdraw[0] = Dydx.ActionArgs( { actionType: 1, accountId: 0, amount: Dydx.AssetAmount( { sign: false, denomination: 0, ref: 0, value: amount.value
31,106
2
// Returns the current quorum numerator. See {quorumDenominator}. /
function quorumNumerator() public view virtual returns (uint256) { return _quorumNumeratorHistory._checkpoints.length == 0 ? _quorumNumerator : _quorumNumeratorHistory.latest(); }
function quorumNumerator() public view virtual returns (uint256) { return _quorumNumeratorHistory._checkpoints.length == 0 ? _quorumNumerator : _quorumNumeratorHistory.latest(); }
37,543
6
// Returns an `Bytes32Slot` with member `value` located at `slot`. /
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } }
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } }
16,176
32
// Return the total supply of the token This function is part of the ERC20 standard
* @return {"supply": "The token supply"} */ function totalSupply() public view returns (uint256 supply) { return totalSupply; }
* @return {"supply": "The token supply"} */ function totalSupply() public view returns (uint256 supply) { return totalSupply; }
42,138
26
// remove a role from an address addr address roleName the name of the role /
function removeRole(address addr, string roleName) internal
function removeRole(address addr, string roleName) internal
24,243
222
// === Marketplace ====
address private _payee;
address private _payee;
39,220
2
// set key SupportedStandards:LSP3UniversalProfile
_setData(_LSP3_SUPPORTED_STANDARDS_KEY, _LSP3_SUPPORTED_STANDARDS_VALUE);
_setData(_LSP3_SUPPORTED_STANDARDS_KEY, _LSP3_SUPPORTED_STANDARDS_VALUE);
34,193
1
// 0 = closed/not a user1 = normal2 = og
uint8 status; Post[] posts;
uint8 status; Post[] posts;
16,662
28
// Finalize the unstake of multiple tokens after the timeToUnstake is elapsed; caller must own the tokens. tokenIds Token ids to be processed /
function staking_finalizeUnstaking(uint256[] calldata tokenIds) external { uint256 _amount = tokenIds.length; for (uint256 i; i < _amount; ) { uint256 _id = tokenIds[i]; _revertIfNotTokenOwner(_id); _fulfillUnstaking_F5f(_id); unchecked {++i;} } }
function staking_finalizeUnstaking(uint256[] calldata tokenIds) external { uint256 _amount = tokenIds.length; for (uint256 i; i < _amount; ) { uint256 _id = tokenIds[i]; _revertIfNotTokenOwner(_id); _fulfillUnstaking_F5f(_id); unchecked {++i;} } }
5,945
13
// the convention is that the inputs are sorted, this removes ambiguity about tree structure
if (a < b) { return keccak256(abi.encode(a, b)); } else {
if (a < b) { return keccak256(abi.encode(a, b)); } else {
3,410
95
// used by the messaging library to publish verified payload_srcChainId - the source chain identifier_srcAddress - the source contract (as bytes) at the source chain_dstAddress - the address on destination chain_nonce - the unbound message ordering nonce_gasLimit - the gas limit for external contract execution_payload - verified payload to send to the destination contract
function receivePayload( uint16 _srcChainId, bytes calldata _srcAddress, address _dstAddress, uint64 _nonce, uint256 _gasLimit, bytes calldata _payload ) external;
function receivePayload( uint16 _srcChainId, bytes calldata _srcAddress, address _dstAddress, uint64 _nonce, uint256 _gasLimit, bytes calldata _payload ) external;
27,184
71
// The basic entry point to participate the crowdsale process. Pay for funding, get invested tokens back in the sender address. /
function buy() public payable { invest(msg.sender); }
function buy() public payable { invest(msg.sender); }
13,863
245
// Updates the current staking amount of the protocol total. /
addAllValue(_value);
addAllValue(_value);
2,747
261
// creates a new pool requirements: - the caller must be the network contract- the pool should have been whitelisted- the pool isn't already defined in the collection /
function createPool(Token token) external;
function createPool(Token token) external;
45,762
522
//
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor(address router, address factory) public { initialSetup(router, factory); // _name = name; // _symbol = symbol; // _decimals = 18; // _totalSupply = initialSupply; // _balances[address(this)] = initialSupply; // contractStartTimestamp = block.timestamp; // // UNISWAP // IUniswapV2Router02(router != address(0) ? router : 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f); // For testing // IUniswapV2Factory(factory != address(0) ? factory : 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f); // For testing }
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor(address router, address factory) public { initialSetup(router, factory); // _name = name; // _symbol = symbol; // _decimals = 18; // _totalSupply = initialSupply; // _balances[address(this)] = initialSupply; // contractStartTimestamp = block.timestamp; // // UNISWAP // IUniswapV2Router02(router != address(0) ? router : 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f); // For testing // IUniswapV2Factory(factory != address(0) ? factory : 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f); // For testing }
9,362
187
// check if a merkle proof and the sender is eligible for presale
function isEligibleForPresaleMerkle(bytes32[] calldata _merkleProof) external view returns (bool) { bytes32 leaf = keccak256(abi.encodePacked(msg.sender)); // hash the address of the sender return MerkleProof.verify(_merkleProof, _merkleRoot, leaf); // verify that the sender's address is valid for the merkle proof }
function isEligibleForPresaleMerkle(bytes32[] calldata _merkleProof) external view returns (bool) { bytes32 leaf = keccak256(abi.encodePacked(msg.sender)); // hash the address of the sender return MerkleProof.verify(_merkleProof, _merkleRoot, leaf); // verify that the sender's address is valid for the merkle proof }
31,169
7
// 3. Compute the accrued interest value over the past time
(uint totalLoan_, uint totalLoanable_, uint interestRate_) = ( totalLoan, totalLoanable, interestRate ); // gas saving by avoiding multiple SLOADs IBetaConfig config = IBetaConfig(IBetaBank(betaBank).config()); IBetaInterestModel model = IBetaInterestModel(IBetaBank(betaBank).interestModel()); uint interest = (interestRate_ * totalLoan_ * timePassed) / (365 days) / 1e18;
(uint totalLoan_, uint totalLoanable_, uint interestRate_) = ( totalLoan, totalLoanable, interestRate ); // gas saving by avoiding multiple SLOADs IBetaConfig config = IBetaConfig(IBetaBank(betaBank).config()); IBetaInterestModel model = IBetaInterestModel(IBetaBank(betaBank).interestModel()); uint interest = (interestRate_ * totalLoan_ * timePassed) / (365 days) / 1e18;
28,132
35
// Converts vouchers to equivalent amount of wei. _value amount of vouchers (vouchers) to convert to amount of weireturn A uint256 specifying the amount of wei. /
function toWei(uint256 _value) external view returns (uint256);
function toWei(uint256 _value) external view returns (uint256);
50,787
57
// Overflows are incredibly unrealistic. balance or numberMinted overflow if current value of either + quantity > 1.8e19 (264) - 1 updatedIndex overflows if _currentIndex + quantity > 1.2e77 (2256) - 1
unchecked { _addressData[to].balance += uint64(quantity); _addressData[to].numberMinted += uint64(quantity); _ownerships[startTokenId].addr = to; _ownerships[startTokenId].startTimestamp = uint64(block.timestamp); uint256 updatedIndex = startTokenId; uint256 endTokenId = calculateEndTokenId(startTokenId, quantity);
unchecked { _addressData[to].balance += uint64(quantity); _addressData[to].numberMinted += uint64(quantity); _ownerships[startTokenId].addr = to; _ownerships[startTokenId].startTimestamp = uint64(block.timestamp); uint256 updatedIndex = startTokenId; uint256 endTokenId = calculateEndTokenId(startTokenId, quantity);
24,196
931
// user -> token -> AccountData
mapping(address => mapping(address => AccountData)) public accountData; mapping(address => RateData) public tokenRates; WhitelistSettings public whitelistSettings; bool public stage1Locked;
mapping(address => mapping(address => AccountData)) public accountData; mapping(address => RateData) public tokenRates; WhitelistSettings public whitelistSettings; bool public stage1Locked;
47,651
1
// Factory ensures that the tokens are sorted.
require(_token0 != address(0), "ZERO_ADDRESS"); require(_token0 != _token1, "IDENTICAL_ADDRESSES"); require(_token0 != address(this), "INVALID_TOKEN"); require(_token1 != address(this), "INVALID_TOKEN"); require(_swapFee <= MAX_FEE, "INVALID_SWAP_FEE"); token0 = _token0; token1 = _token1; swapFee = _swapFee;
require(_token0 != address(0), "ZERO_ADDRESS"); require(_token0 != _token1, "IDENTICAL_ADDRESSES"); require(_token0 != address(this), "INVALID_TOKEN"); require(_token1 != address(this), "INVALID_TOKEN"); require(_swapFee <= MAX_FEE, "INVALID_SWAP_FEE"); token0 = _token0; token1 = _token1; swapFee = _swapFee;
10,765
300
// at this point it may be the case that we shouldn&39;t allow the ballot to be created. (It&39;s an official ballot for a basic tier democracy where the Nth most recent ballot was created within the last 30 days.) We should now check for payment
uint extraBallotFee = payments.getBasicExtraBallotFeeWei(); require(msg.value >= extraBallotFee, "!extra-b-fee");
uint extraBallotFee = payments.getBasicExtraBallotFeeWei(); require(msg.value >= extraBallotFee, "!extra-b-fee");
22,438
116
// Refund transaction - return the bet amount of a roll that was not processed in a due timeframe. Processing such blocks is not possible due to EVM limitations (see BET_EXPIRATION_BLOCKS comment above for details). In case you ever find yourself in a situation like this, just contact the AceDice support, however nothing precludes you from invoking this method yourself.
function refundBet(uint commit) external { // Check that bet is in 'active' state. Bet storage bet = bets[commit]; uint amount = bet.amount; require (amount != 0, "Bet should be in an 'active' state"); // Check that bet has already expired. require (block.number > bet.placeBlockNumber + BET_EXPIRATION_BLOCKS, "Blockhash can't be queried by EVM."); // Move bet into 'processed' state, release funds. bet.amount = 0; uint diceWinAmount; uint jackpotFee; (diceWinAmount, jackpotFee) = getDiceWinAmount(amount, bet.rollUnder); lockedInBets -= uint128(diceWinAmount); jackpotSize -= uint128(jackpotFee); // Send the refund. sendFunds(bet.gambler, amount, amount, 0, 0, 0); }
function refundBet(uint commit) external { // Check that bet is in 'active' state. Bet storage bet = bets[commit]; uint amount = bet.amount; require (amount != 0, "Bet should be in an 'active' state"); // Check that bet has already expired. require (block.number > bet.placeBlockNumber + BET_EXPIRATION_BLOCKS, "Blockhash can't be queried by EVM."); // Move bet into 'processed' state, release funds. bet.amount = 0; uint diceWinAmount; uint jackpotFee; (diceWinAmount, jackpotFee) = getDiceWinAmount(amount, bet.rollUnder); lockedInBets -= uint128(diceWinAmount); jackpotSize -= uint128(jackpotFee); // Send the refund. sendFunds(bet.gambler, amount, amount, 0, 0, 0); }
67,565
30
// get content by plain string name
function getContentByName(ContentMapping storage self, string _name) public view returns (Content storage _content, bool exists) { bytes32 _hash = generateContentID(_name); return (self.data[_hash], self.data[_hash].addedOn != 0); }
function getContentByName(ContentMapping storage self, string _name) public view returns (Content storage _content, bool exists) { bytes32 _hash = generateContentID(_name); return (self.data[_hash], self.data[_hash].addedOn != 0); }
55,101
0
// Emulates the `calldataload` opcode on the embedded Exchange calldata,/which is accessed through `signedExchangeTransaction`./offsetOffset into the Exchange calldata./ return valueCorresponding 32 byte value stored at `offset`.
function exchangeCalldataload(uint256 offset) internal pure returns (bytes32 value)
function exchangeCalldataload(uint256 offset) internal pure returns (bytes32 value)
38,715
14
// air drop proof: keccak256(prefix, keccak256(_channelId, _id, msg.sender))
function retrieveAirdrop( bytes32 _h, uint8 _v, bytes32 _r, bytes32 _s, bytes32 _channelId, uint256 _id) public returns (bool)
function retrieveAirdrop( bytes32 _h, uint8 _v, bytes32 _r, bytes32 _s, bytes32 _channelId, uint256 _id) public returns (bool)
40,016
1
// Abstract contract for interfacing with the DateTime contract./
function isLeapYear(uint256 year) external pure returns (bool); function getYear(uint timestamp) external pure returns (uint256); function getMonth(uint timestamp) external pure returns (uint256); function getDay(uint timestamp) external pure returns (uint256); function getHour(uint timestamp) external pure returns (uint256); function getMinute(uint timestamp) external pure returns (uint256); function getSecond(uint timestamp) external pure returns (uint256); function getWeekday(uint timestamp) external pure returns (uint256); function toTimestamp(uint256 year, uint256 month, uint256 day) external returns (uint timestamp); function toTimestamp(uint256 year, uint256 month, uint256 day, uint256 hour) external returns (uint timestamp);
function isLeapYear(uint256 year) external pure returns (bool); function getYear(uint timestamp) external pure returns (uint256); function getMonth(uint timestamp) external pure returns (uint256); function getDay(uint timestamp) external pure returns (uint256); function getHour(uint timestamp) external pure returns (uint256); function getMinute(uint timestamp) external pure returns (uint256); function getSecond(uint timestamp) external pure returns (uint256); function getWeekday(uint timestamp) external pure returns (uint256); function toTimestamp(uint256 year, uint256 month, uint256 day) external returns (uint timestamp); function toTimestamp(uint256 year, uint256 month, uint256 day, uint256 hour) external returns (uint timestamp);
15,897
39
// TAX SELLERS EXTRA 8% WHO SELL WITHIN 24 HOURS
if (_buyMap[from] != 0 && (_buyMap[from] + (24 hours) >= block.timestamp)) { _feeAddr1 = 3; _feeAddr2 = 5; } else {
if (_buyMap[from] != 0 && (_buyMap[from] + (24 hours) >= block.timestamp)) { _feeAddr1 = 3; _feeAddr2 = 5; } else {
52,483
97
// subtract the FIRST_EPOCH_DELAY, so that we can count all epochs as lasting EPOCH_DURATION
uint256 totalEpochsPassed = timePassed.sub(FIRST_EPOCH_DELAY).div(EPOCH_DURATION);
uint256 totalEpochsPassed = timePassed.sub(FIRST_EPOCH_DELAY).div(EPOCH_DURATION);
20,183
176
// Set the Oracle that pushes the havven price to this contract /
function setOracle(address _oracle) external optionalProxy_onlyOwner
function setOracle(address _oracle) external optionalProxy_onlyOwner
64,869
40
// Remove a rebase hook. _index Index of the transaction to remove. /
function removeTransaction(uint256 _index) external onlyGovernance { require(_index < transactions.length, "index out of bounds"); if (_index < transactions.length - 1) { transactions[_index] = transactions[transactions.length - 1]; } transactions.pop(); }
function removeTransaction(uint256 _index) external onlyGovernance { require(_index < transactions.length, "index out of bounds"); if (_index < transactions.length - 1) { transactions[_index] = transactions[transactions.length - 1]; } transactions.pop(); }
24,898
20
// notice Redeems an NFTVoucher for an actual NFT, creating it in the process./ param redeemer The address of the account which will receive the NFT upon success./ param voucher A signed NFTVoucher that describes the NFT to be redeemed.
function redeem(address redeemer, NFTVoucher calldata voucher) public payable returns (uint256) { // make sure signature is valid and get the address of the signer address signer = _verify(voucher); // make sure that the signer is authorized to mint NFTs require(hasRole(MINTER_ROLE, signer), "Signature invalid or unauthorized"); // make sure that the redeemer is paying enough to cover the buyer's cost require(msg.value >= voucher.minPrice, "Insufficient funds to redeem"); // first assign the token to the signer, to establish provenance on-chain _mint(signer, voucher.tokenId, 1, voucher); _setURI(voucher.tokenId, voucher.uri); // transfer the token to the redeemer _safeTransferFrom(signer, redeemer, voucher.tokenId); // record payment to signer's withdrawal balance pendingWithdrawals[signer] += msg.value; //you return the tkenID return voucher.tokenId; }
function redeem(address redeemer, NFTVoucher calldata voucher) public payable returns (uint256) { // make sure signature is valid and get the address of the signer address signer = _verify(voucher); // make sure that the signer is authorized to mint NFTs require(hasRole(MINTER_ROLE, signer), "Signature invalid or unauthorized"); // make sure that the redeemer is paying enough to cover the buyer's cost require(msg.value >= voucher.minPrice, "Insufficient funds to redeem"); // first assign the token to the signer, to establish provenance on-chain _mint(signer, voucher.tokenId, 1, voucher); _setURI(voucher.tokenId, voucher.uri); // transfer the token to the redeemer _safeTransferFrom(signer, redeemer, voucher.tokenId); // record payment to signer's withdrawal balance pendingWithdrawals[signer] += msg.value; //you return the tkenID return voucher.tokenId; }
33,268
2
// addresses are locked from transfer after minting or burning
uint256 private constant BLOCK_LOCK_COUNT = 6;
uint256 private constant BLOCK_LOCK_COUNT = 6;
713
68
// recover cosigner
address cosigner = ecrecover(operationHash, v, r, s);
address cosigner = ecrecover(operationHash, v, r, s);
22,683
67
// creates the token to be sold. override this method to have crowdsale of a specific mintable token.
function createTokenContract() internal returns (MintableToken) { return new MintableToken(); }
function createTokenContract() internal returns (MintableToken) { return new MintableToken(); }
4,783
115
// pause all coin transfer/
function pause() public onlyOwner whenNotPaused { _pause(); }
function pause() public onlyOwner whenNotPaused { _pause(); }
10,309
3
// ----- CONSTRUCTOR -----
constructor( string memory _bURI, string memory _name, string memory _symbol, address _vrfCoordinator, address _link, bytes32 _keyHash, uint256 _fee, address _proxyRegistryAddress, address _claimingContractAddress,
constructor( string memory _bURI, string memory _name, string memory _symbol, address _vrfCoordinator, address _link, bytes32 _keyHash, uint256 _fee, address _proxyRegistryAddress, address _claimingContractAddress,
67,921
33
// Emit the UserLoanRepaid event
emit UserLoanRepaid(_tokenIds[0], msg.value, userLoan.amount);
emit UserLoanRepaid(_tokenIds[0], msg.value, userLoan.amount);
31,520
143
// If we just need the withdrawable, then query credit array value.
if (reportWithdrawable) { for (uint256 i; i < numOfCreditPositions; ++i) { uint32 position = creditPositions[i];
if (reportWithdrawable) { for (uint256 i; i < numOfCreditPositions; ++i) { uint32 position = creditPositions[i];
42,293
7
// Withdraws `tokenAmount` of collateral of type `collateralType` from account `accountId`. accountId The id of the account that is making the withdrawal. collateralType The address of the token to be withdrawn. tokenAmount The amount being withdrawn, denominated in the token's native decimal representation. Requirements: - `msg.sender` must be the owner of the account, have the `ADMIN` permission, or have the `WITHDRAW` permission. Emits a {Withdrawn} event./
function withdraw(uint128 accountId, address collateralType, uint256 tokenAmount) external;
function withdraw(uint128 accountId, address collateralType, uint256 tokenAmount) external;
26,030