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
25
// list of Vesting contracts, tokens for these contracts won't be slashed if unstaked by governance
mapping(address => bool) public vestingWhitelist;
mapping(address => bool) public vestingWhitelist;
20,508
208
// add contribution into the contributions array account Address being contributing weiAmount Amount of wei contributed tokenAmount Amount of token received /
function addBalance(address account, uint256 weiAmount, uint256 tokenAmount) public onlyOperator { if (!_contributors[account].exists) { _addresses.push(account); _contributors[account].exists = true; } _contributors[account].weiAmount = _contributors[account].weiAmount.add(weiAmount); _contributors[account].tokenAmount = _contributors[account].tokenAmount.add(tokenAmount); _totalWeiRaised = _totalWeiRaised.add(weiAmount); _totalSoldTokens = _totalSoldTokens.add(tokenAmount); }
function addBalance(address account, uint256 weiAmount, uint256 tokenAmount) public onlyOperator { if (!_contributors[account].exists) { _addresses.push(account); _contributors[account].exists = true; } _contributors[account].weiAmount = _contributors[account].weiAmount.add(weiAmount); _contributors[account].tokenAmount = _contributors[account].tokenAmount.add(tokenAmount); _totalWeiRaised = _totalWeiRaised.add(weiAmount); _totalSoldTokens = _totalSoldTokens.add(tokenAmount); }
34,376
128
// --- Observations ---
struct ConverterFeedObservation { uint timestamp; uint timeAdjustedPrice; }
struct ConverterFeedObservation { uint timestamp; uint timeAdjustedPrice; }
37,583
7
// Recreate Sheets on sister-chain exact as they exist on this chain
for(uint256 i = 0; i < numSheetFighters; i++) { calls[i] = _buildData(sheetFighterIds[i]); }
for(uint256 i = 0; i < numSheetFighters; i++) { calls[i] = _buildData(sheetFighterIds[i]); }
33,809
69
// Reverts to the previous address immediately/In case the new version has a fault, a quick way to fallback to the old contract/_id Id of contract
function revertToPreviousAddress(bytes4 _id) public onlyOwner { if (!(entries[_id].exists)){ revert EntryNonExistentError(_id); } if (previousAddresses[_id] == address(0)){ revert EmptyPrevAddrError(_id); } address currentAddr = entries[_id].contractAddr; entries[_id].contractAddr = previousAddresses[_id]; emit RevertToPreviousAddress(msg.sender, _id, currentAddr, previousAddresses[_id]); }
function revertToPreviousAddress(bytes4 _id) public onlyOwner { if (!(entries[_id].exists)){ revert EntryNonExistentError(_id); } if (previousAddresses[_id] == address(0)){ revert EmptyPrevAddrError(_id); } address currentAddr = entries[_id].contractAddr; entries[_id].contractAddr = previousAddresses[_id]; emit RevertToPreviousAddress(msg.sender, _id, currentAddr, previousAddresses[_id]); }
40,323
167
// To call to go to a new period. TRUSTED. /
function passPeriod() public { require(now-lastPeriodChange >= timePerPeriod[uint8(period)]); if (period == Period.Activation) { rnBlock = block.number + 1; rng.requestRN(rnBlock); period = Period.Draw; } else if (period == Period.Draw) { randomNumber = rng.getUncorrelatedRN(rnBlock); require(randomNumber != 0); period = Period.Vote; } else if (period == Period.Vote) { period = Period.Appeal; } else if (period == Period.Appeal) { period = Period.Execution; } else if (period == Period.Execution) { period = Period.Activation; ++session; segmentSize = 0; rnBlock = 0; randomNumber = 0; } lastPeriodChange = now; NewPeriod(period, session); }
function passPeriod() public { require(now-lastPeriodChange >= timePerPeriod[uint8(period)]); if (period == Period.Activation) { rnBlock = block.number + 1; rng.requestRN(rnBlock); period = Period.Draw; } else if (period == Period.Draw) { randomNumber = rng.getUncorrelatedRN(rnBlock); require(randomNumber != 0); period = Period.Vote; } else if (period == Period.Vote) { period = Period.Appeal; } else if (period == Period.Appeal) { period = Period.Execution; } else if (period == Period.Execution) { period = Period.Activation; ++session; segmentSize = 0; rnBlock = 0; randomNumber = 0; } lastPeriodChange = now; NewPeriod(period, session); }
49,040
16
// storing the token amount in the smart-contract
token.transferFrom(msg.sender, address(this), _amount);
token.transferFrom(msg.sender, address(this), _amount);
477
55
// repay allows user to return some of the debt of the specified token the repay does not collect any fees and is not validating the user's total collateral to debt position.
function repay(address _token, uint256 _amount) public nonReentrant returns (uint256) { return _repay(_token, _amount); }
function repay(address _token, uint256 _amount) public nonReentrant returns (uint256) { return _repay(_token, _amount); }
3,881
161
// Remove the player from the pending bets queue by setting the address to 0x0
pendingBetsQueue[index] = address(0x0);
pendingBetsQueue[index] = address(0x0);
57,864
0
// Used to show data about the finished game, it shows the choice of winner-loser and the address of the winner
event Winner( string loserAnnouncement, string winnerAnnouncement, address winner );
event Winner( string loserAnnouncement, string winnerAnnouncement, address winner );
39,450
36
// A mapping keeping track of which ChainFaceIDs are currently contained within the contract./We cannot rely on depositedChainFacesArray as the source of truth as to which ChainFaces are/deposited in the contract. This is because burnTokensAndWithdrawChainFaces() allows a user to /withdraw a ChainFace "out of order" of the order that they are stored in the array. Since it /would be prohibitively expensive to shift the entire array once we've withdrawn a single /element, we instead maintain this mapping to determine whether an element is still contained /in the contract or not.
mapping (uint256 => bool) private chainFaceIsDepositedInContract;
mapping (uint256 => bool) private chainFaceIsDepositedInContract;
16,140
25
// withdraw from stakedao and curvePool
IStakeDao sdecrv = IStakeDao(sdecrvAddress); sdecrv.withdraw(sdecrvToWithdraw); uint256 ecrvBalance = sdecrv.token().balanceOf(address(this)); uint256 ethReceived = curvePool.remove_liquidity_one_coin(ecrvBalance, 0, minEth);
IStakeDao sdecrv = IStakeDao(sdecrvAddress); sdecrv.withdraw(sdecrvToWithdraw); uint256 ecrvBalance = sdecrv.token().balanceOf(address(this)); uint256 ethReceived = curvePool.remove_liquidity_one_coin(ecrvBalance, 0, minEth);
57,209
184
// aura prefix
string[] private element = [ "Angelic", "Dark", "Demonic", "Earth", "Electric", "Fire", "Ice", "Radiant",
string[] private element = [ "Angelic", "Dark", "Demonic", "Earth", "Electric", "Fire", "Ice", "Radiant",
38,504
127
// VaultManagerParameters /
contract VaultManagerParameters is Auth { // determines the minimum percentage of COL token part in collateral, 0 decimals mapping(address => uint) public minColPercent; // determines the maximum percentage of COL token part in collateral, 0 decimals mapping(address => uint) public maxColPercent; // map token to initial collateralization ratio; 0 decimals mapping(address => uint) public initialCollateralRatio; // map token to liquidation ratio; 0 decimals mapping(address => uint) public liquidationRatio; // map token to liquidation discount; 3 decimals mapping(address => uint) public liquidationDiscount; // map token to devaluation period in blocks mapping(address => uint) public devaluationPeriod; constructor(address _vaultParameters) public Auth(_vaultParameters) {} /** * @notice Only manager is able to call this function * @dev Sets ability to use token as the main collateral * @param asset The address of the main collateral token * @param stabilityFeeValue The percentage of the year stability fee (3 decimals) * @param liquidationFeeValue The liquidation fee percentage (0 decimals) * @param initialCollateralRatioValue The initial collateralization ratio * @param liquidationRatioValue The liquidation ratio * @param liquidationDiscountValue The liquidation discount (3 decimals) * @param devaluationPeriodValue The devaluation period in blocks * @param usdpLimit The USDP token issue limit * @param oracles The enabled oracles type IDs * @param minColP The min percentage of COL value in position (0 decimals) * @param maxColP The max percentage of COL value in position (0 decimals) **/ function setCollateral( address asset, uint stabilityFeeValue, uint liquidationFeeValue, uint initialCollateralRatioValue, uint liquidationRatioValue, uint liquidationDiscountValue, uint devaluationPeriodValue, uint usdpLimit, uint[] calldata oracles, uint minColP, uint maxColP ) external onlyManager { vaultParameters.setCollateral(asset, stabilityFeeValue, liquidationFeeValue, usdpLimit, oracles); setInitialCollateralRatio(asset, initialCollateralRatioValue); setLiquidationRatio(asset, liquidationRatioValue); setDevaluationPeriod(asset, devaluationPeriodValue); setLiquidationDiscount(asset, liquidationDiscountValue); setColPartRange(asset, minColP, maxColP); } /** * @notice Only manager is able to call this function * @dev Sets the initial collateral ratio * @param asset The address of the main collateral token * @param newValue The collateralization ratio (0 decimals) **/ function setInitialCollateralRatio(address asset, uint newValue) public onlyManager { require(newValue != 0 && newValue <= 100, "Unit Protocol: INCORRECT_COLLATERALIZATION_VALUE"); initialCollateralRatio[asset] = newValue; } /** * @notice Only manager is able to call this function * @dev Sets the liquidation ratio * @param asset The address of the main collateral token * @param newValue The liquidation ratio (0 decimals) **/ function setLiquidationRatio(address asset, uint newValue) public onlyManager { require(newValue != 0 && newValue >= initialCollateralRatio[asset], "Unit Protocol: INCORRECT_COLLATERALIZATION_VALUE"); liquidationRatio[asset] = newValue; } /** * @notice Only manager is able to call this function * @dev Sets the liquidation discount * @param asset The address of the main collateral token * @param newValue The liquidation discount (3 decimals) **/ function setLiquidationDiscount(address asset, uint newValue) public onlyManager { require(newValue < 1e5, "Unit Protocol: INCORRECT_DISCOUNT_VALUE"); liquidationDiscount[asset] = newValue; } /** * @notice Only manager is able to call this function * @dev Sets the devaluation period of collateral after liquidation * @param asset The address of the main collateral token * @param newValue The devaluation period in blocks **/ function setDevaluationPeriod(address asset, uint newValue) public onlyManager { require(newValue != 0, "Unit Protocol: INCORRECT_DEVALUATION_VALUE"); devaluationPeriod[asset] = newValue; } /** * @notice Only manager is able to call this function * @dev Sets the percentage range of the COL token part for specific collateral token * @param asset The address of the main collateral token * @param min The min percentage (0 decimals) * @param max The max percentage (0 decimals) **/ function setColPartRange(address asset, uint min, uint max) public onlyManager { require(max <= 100 && min <= max, "Unit Protocol: WRONG_RANGE"); minColPercent[asset] = min; maxColPercent[asset] = max; } }
contract VaultManagerParameters is Auth { // determines the minimum percentage of COL token part in collateral, 0 decimals mapping(address => uint) public minColPercent; // determines the maximum percentage of COL token part in collateral, 0 decimals mapping(address => uint) public maxColPercent; // map token to initial collateralization ratio; 0 decimals mapping(address => uint) public initialCollateralRatio; // map token to liquidation ratio; 0 decimals mapping(address => uint) public liquidationRatio; // map token to liquidation discount; 3 decimals mapping(address => uint) public liquidationDiscount; // map token to devaluation period in blocks mapping(address => uint) public devaluationPeriod; constructor(address _vaultParameters) public Auth(_vaultParameters) {} /** * @notice Only manager is able to call this function * @dev Sets ability to use token as the main collateral * @param asset The address of the main collateral token * @param stabilityFeeValue The percentage of the year stability fee (3 decimals) * @param liquidationFeeValue The liquidation fee percentage (0 decimals) * @param initialCollateralRatioValue The initial collateralization ratio * @param liquidationRatioValue The liquidation ratio * @param liquidationDiscountValue The liquidation discount (3 decimals) * @param devaluationPeriodValue The devaluation period in blocks * @param usdpLimit The USDP token issue limit * @param oracles The enabled oracles type IDs * @param minColP The min percentage of COL value in position (0 decimals) * @param maxColP The max percentage of COL value in position (0 decimals) **/ function setCollateral( address asset, uint stabilityFeeValue, uint liquidationFeeValue, uint initialCollateralRatioValue, uint liquidationRatioValue, uint liquidationDiscountValue, uint devaluationPeriodValue, uint usdpLimit, uint[] calldata oracles, uint minColP, uint maxColP ) external onlyManager { vaultParameters.setCollateral(asset, stabilityFeeValue, liquidationFeeValue, usdpLimit, oracles); setInitialCollateralRatio(asset, initialCollateralRatioValue); setLiquidationRatio(asset, liquidationRatioValue); setDevaluationPeriod(asset, devaluationPeriodValue); setLiquidationDiscount(asset, liquidationDiscountValue); setColPartRange(asset, minColP, maxColP); } /** * @notice Only manager is able to call this function * @dev Sets the initial collateral ratio * @param asset The address of the main collateral token * @param newValue The collateralization ratio (0 decimals) **/ function setInitialCollateralRatio(address asset, uint newValue) public onlyManager { require(newValue != 0 && newValue <= 100, "Unit Protocol: INCORRECT_COLLATERALIZATION_VALUE"); initialCollateralRatio[asset] = newValue; } /** * @notice Only manager is able to call this function * @dev Sets the liquidation ratio * @param asset The address of the main collateral token * @param newValue The liquidation ratio (0 decimals) **/ function setLiquidationRatio(address asset, uint newValue) public onlyManager { require(newValue != 0 && newValue >= initialCollateralRatio[asset], "Unit Protocol: INCORRECT_COLLATERALIZATION_VALUE"); liquidationRatio[asset] = newValue; } /** * @notice Only manager is able to call this function * @dev Sets the liquidation discount * @param asset The address of the main collateral token * @param newValue The liquidation discount (3 decimals) **/ function setLiquidationDiscount(address asset, uint newValue) public onlyManager { require(newValue < 1e5, "Unit Protocol: INCORRECT_DISCOUNT_VALUE"); liquidationDiscount[asset] = newValue; } /** * @notice Only manager is able to call this function * @dev Sets the devaluation period of collateral after liquidation * @param asset The address of the main collateral token * @param newValue The devaluation period in blocks **/ function setDevaluationPeriod(address asset, uint newValue) public onlyManager { require(newValue != 0, "Unit Protocol: INCORRECT_DEVALUATION_VALUE"); devaluationPeriod[asset] = newValue; } /** * @notice Only manager is able to call this function * @dev Sets the percentage range of the COL token part for specific collateral token * @param asset The address of the main collateral token * @param min The min percentage (0 decimals) * @param max The max percentage (0 decimals) **/ function setColPartRange(address asset, uint min, uint max) public onlyManager { require(max <= 100 && min <= max, "Unit Protocol: WRONG_RANGE"); minColPercent[asset] = min; maxColPercent[asset] = max; } }
44,902
308
// Will
USDC.transfer( 0x31920DF2b31B5f7ecf65BDb2c497DE31d299d472, yearlyToMonthlyUSD(84000, 1) );
USDC.transfer( 0x31920DF2b31B5f7ecf65BDb2c497DE31d299d472, yearlyToMonthlyUSD(84000, 1) );
36,812
7
// Mapping for stroing interface ids of supported interfaces
mapping(bytes4 => bool) private _supportedInterfaces; bytes4 internal constant MAGIC_ON_ERC721_RECEIVED = 0x150b7a02; event Transfer( address indexed _from, address indexed _to, uint256 indexed _tokenId );
mapping(bytes4 => bool) private _supportedInterfaces; bytes4 internal constant MAGIC_ON_ERC721_RECEIVED = 0x150b7a02; event Transfer( address indexed _from, address indexed _to, uint256 indexed _tokenId );
14,078
3
// vaultId of vault to settle
uint256 vaultId;
uint256 vaultId;
14,454
28
// Moves `amount` tokens from the caller's account to `recipient`. Returns a boolean value indicating whether the operation succeeded. Emits a {Transfer} event./
function transfer(address recipient, uint256 amount) external returns(bool);
function transfer(address recipient, uint256 amount) external returns(bool);
38,863
11
// Check _fee, _adminFee and set fee parameters
require(_fee < SwapUtils.MAX_SWAP_FEE, "_fee exceeds maximum"); require(_adminFee < SwapUtils.MAX_ADMIN_FEE, "_adminFee exceeds maximum");
require(_fee < SwapUtils.MAX_SWAP_FEE, "_fee exceeds maximum"); require(_adminFee < SwapUtils.MAX_ADMIN_FEE, "_adminFee exceeds maximum");
3,610
58
// return return token sizes
function getTokenSizes(uint256 _tokenId) public exists(_tokenId) view returns (uint256, uint256) { Token memory token = allMinedTokens[allTokensIndex[_tokenId]]; return (token.sizeA, token.sizeB); }
function getTokenSizes(uint256 _tokenId) public exists(_tokenId) view returns (uint256, uint256) { Token memory token = allMinedTokens[allTokensIndex[_tokenId]]; return (token.sizeA, token.sizeB); }
36,633
129
// Checks & Calculations Determine the liquidation amount in collateral units (i.e. how much debt is liquidator going to repay)
uint256 _liquidationAmountInCollateralUnits = ((_totalBorrow.toAmount(_sharesToLiquidate, false) * _exchangeRate) / EXCHANGE_PRECISION);
uint256 _liquidationAmountInCollateralUnits = ((_totalBorrow.toAmount(_sharesToLiquidate, false) * _exchangeRate) / EXCHANGE_PRECISION);
24,538
400
// Return a validator's linked nodes.Requirements:- Validator ID must exist. /
function getValidatorNodeIndexes(uint validatorId) external view returns (uint[] memory) { ValidatorService validatorService = ValidatorService(contractManager.getValidatorService()); require(validatorService.validatorExists(validatorId), "Validator ID does not exist"); return validatorToNodeIndexes[validatorId]; }
function getValidatorNodeIndexes(uint validatorId) external view returns (uint[] memory) { ValidatorService validatorService = ValidatorService(contractManager.getValidatorService()); require(validatorService.validatorExists(validatorId), "Validator ID does not exist"); return validatorToNodeIndexes[validatorId]; }
69,319
6
// throw
require (msg.sender == owner); _;
require (msg.sender == owner); _;
7,969
66
// Returns the division of two unsigned integers, with a division by zero flag. _Available since v3.4._/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } }
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } }
21,793
246
// Pending administrator for this contract/
address public pendingAdmin;
address public pendingAdmin;
10,764
71
// bmul overflow
uint c1 = c0 + (b / 2); require(c1 >= c0, "ERR_DIV_INTERNAL");
uint c1 = c0 + (b / 2); require(c1 >= c0, "ERR_DIV_INTERNAL");
34,512
22
// Returns the address of the owner of the NFT. NFTs assigned to the zero address areconsidered invalid, and queries about them do throw. _tokenId The identifier for an NFT.return _owner Address of _tokenId owner. /
function ownerOf(uint256 _tokenId) external view override returns (address _owner)
function ownerOf(uint256 _tokenId) external view override returns (address _owner)
18,989
7
// Denominator for transaction fee calculation; 100 = 1%
uint256 txFeeDenominator = 100;
uint256 txFeeDenominator = 100;
9,239
29
// adds an ETH deposit, mints an ERC721 token, and transfersits ownership to another account account that will be the owner of this deposit (can withdraw) initialPenaltyPercent initial penalty percent for deposit commitPeriod period during which a withdrawal results in penalty and no bonusreturn ERC721 tokenId of this deposit /
function depositETHFor( address account, uint initialPenaltyPercent, uint commitPeriod ) external payable validCommitment(initialPenaltyPercent, commitPeriod) returns (uint tokenId)
function depositETHFor( address account, uint initialPenaltyPercent, uint commitPeriod ) external payable validCommitment(initialPenaltyPercent, commitPeriod) returns (uint tokenId)
24,322
193
// Encodes some bytes to the base64 representation
function encode(bytes memory data) internal pure returns (string memory) { uint256 len = data.length; if (len == 0) return ""; // multiply by 4/3 rounded up uint256 encodedLen = 4 * ((len + 2) / 3); // Add some extra buffer at the end bytes memory result = new bytes(encodedLen + 32); bytes memory table = TABLE; assembly { let tablePtr := add(table, 1) let resultPtr := add(result, 32) for { let i := 0 } lt(i, len) { } { i := add(i, 3) let input := and(mload(add(data, i)), 0xffffff) let out := mload(add(tablePtr, and(shr(18, input), 0x3F))) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(shr(12, input), 0x3F))), 0xFF)) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(shr(6, input), 0x3F))), 0xFF)) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(input, 0x3F))), 0xFF)) out := shl(224, out) mstore(resultPtr, out) resultPtr := add(resultPtr, 4) } switch mod(len, 3) case 1 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) } case 2 { mstore(sub(resultPtr, 1), shl(248, 0x3d)) } mstore(result, encodedLen) } return string(result); }
function encode(bytes memory data) internal pure returns (string memory) { uint256 len = data.length; if (len == 0) return ""; // multiply by 4/3 rounded up uint256 encodedLen = 4 * ((len + 2) / 3); // Add some extra buffer at the end bytes memory result = new bytes(encodedLen + 32); bytes memory table = TABLE; assembly { let tablePtr := add(table, 1) let resultPtr := add(result, 32) for { let i := 0 } lt(i, len) { } { i := add(i, 3) let input := and(mload(add(data, i)), 0xffffff) let out := mload(add(tablePtr, and(shr(18, input), 0x3F))) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(shr(12, input), 0x3F))), 0xFF)) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(shr(6, input), 0x3F))), 0xFF)) out := shl(8, out) out := add(out, and(mload(add(tablePtr, and(input, 0x3F))), 0xFF)) out := shl(224, out) mstore(resultPtr, out) resultPtr := add(resultPtr, 4) } switch mod(len, 3) case 1 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) } case 2 { mstore(sub(resultPtr, 1), shl(248, 0x3d)) } mstore(result, encodedLen) } return string(result); }
76,367
0
// bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
* function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * }
* function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * }
1,414
479
// Calculate DSD cost
Decimal.D256 memory ethSpent = Decimal.D256({ value: (startGas - gasleft() + 41000).mul(uint256(fastGasPrice)) // approximate used gas for tx });
Decimal.D256 memory ethSpent = Decimal.D256({ value: (startGas - gasleft() + 41000).mul(uint256(fastGasPrice)) // approximate used gas for tx });
30,801
400
// to get the contract staked by a staker _stakerAddress is the address of the staker _stakerIndex is the index of stakerreturn the address of staked contract /
function getStakerStakedContractByIndex( address _stakerAddress, uint _stakerIndex ) public view returns (address stakedContractAddress)
function getStakerStakedContractByIndex( address _stakerAddress, uint _stakerIndex ) public view returns (address stakedContractAddress)
54,632
45
// Function that returns the (dynamic) price of selling a single token.
function sellPrice() public constant returns (uint) { var eth = getEtherForTokens(1 finney); var fee = div(eth, 10); return eth - fee; }
function sellPrice() public constant returns (uint) { var eth = getEtherForTokens(1 finney); var fee = div(eth, 10); return eth - fee; }
33,629
30
// Check that this grant doesn't exceed the total amount of tokens currently available for vesting.
require(totalVesting.add(_amount) <= greed.balanceOf(address(this))); revocables[_beneficiary] = _revocable; durations[_beneficiary] = _duration; cliffs[_beneficiary] = _start.add(_cliff); starts[_beneficiary] = _start; amounts[_beneficiary] = _amount; totalVesting = totalVesting.add(_amount);
require(totalVesting.add(_amount) <= greed.balanceOf(address(this))); revocables[_beneficiary] = _revocable; durations[_beneficiary] = _duration; cliffs[_beneficiary] = _start.add(_cliff); starts[_beneficiary] = _start; amounts[_beneficiary] = _amount; totalVesting = totalVesting.add(_amount);
19,405
71
// 如果奖励>0 发送奖励
if (_reward > 0) _safeTransfer(tokens[i], account, _reward); emit ClaimRewards(msg.sender, tokens[i], _reward);
if (_reward > 0) _safeTransfer(tokens[i], account, _reward); emit ClaimRewards(msg.sender, tokens[i], _reward);
28,232
5
// 🀀🀁🀂🀃🀄🀅🀆🀇🀈🀉🀊🀋🀌🀍🀎🀏🀐🀑🀒🀓🀔🀕🀖🀗🀘🀙🀚🀛🀜🀝🀞🀟🀠🀡🀪 ×4
require(total <= 4, "only 4 tiles");
require(total <= 4, "only 4 tiles");
4,383
182
// Establish path from Dai to Ether.
(address[] memory path, uint256[] memory amounts) = _createPathAndAmounts( address(_DAI), _WETH, false );
(address[] memory path, uint256[] memory amounts) = _createPathAndAmounts( address(_DAI), _WETH, false );
78,223
118
// LooksRare marketplace transfer manager.
address public looksrare = 0xf42aa99F011A1fA7CDA90E5E98b277E306BcA83e;
address public looksrare = 0xf42aa99F011A1fA7CDA90E5E98b277E306BcA83e;
6,566
5
// when we have enough participants
if (player_count == required_number_players) { bet_blocknumber=block.number; }
if (player_count == required_number_players) { bet_blocknumber=block.number; }
12,086
58
// player vs player optimized seeds ante up slots
startingOptions[0]=0; startingOptions[1]=0; startingOptions[2]=0; startingOptions[3]=precision*(random(2)); // between 0 and 1 startingOptions[4]=precision*(random(3)+1); // between 1 and 3 startingOptions[5]=precision*(random(2)+3); // between 3 and 4 startingOptions[6]=precision*(random(3)+4); // between 4 and 6 startingOptions[7]=precision*(random(3)+5); // between 5 and 7 startingOptions[8]=precision*(random(3)+8); // between 8 and 10 startingOptions[9]=precision*(random(3)+8); // between 8 and 10
startingOptions[0]=0; startingOptions[1]=0; startingOptions[2]=0; startingOptions[3]=precision*(random(2)); // between 0 and 1 startingOptions[4]=precision*(random(3)+1); // between 1 and 3 startingOptions[5]=precision*(random(2)+3); // between 3 and 4 startingOptions[6]=precision*(random(3)+4); // between 4 and 6 startingOptions[7]=precision*(random(3)+5); // between 5 and 7 startingOptions[8]=precision*(random(3)+8); // between 8 and 10 startingOptions[9]=precision*(random(3)+8); // between 8 and 10
51,953
34
// Calculates the common logarithm of x.//First checks if x is an exact power of ten and it stops if yes. If it's not, calculates the common/ logarithm based on the insight that log10(x) = log2(x) / log2(10).// Requirements:/ - All from "log2".// Caveats:/ - All from "log2".//x The unsigned 60.18-decimal fixed-point number for which to calculate the common logarithm./ return result The common logarithm as an unsigned 60.18-decimal fixed-point number.
function log10(uint256 x) internal pure returns (uint256 result) { require(x >= SCALE); // Note that the "mul" in this block is the assembly mul operation, not the "mul" function defined in this contract. // prettier-ignore assembly { switch x case 1 { result := mul(SCALE, sub(0, 18)) } case 10 { result := mul(SCALE, sub(1, 18)) } case 100 { result := mul(SCALE, sub(2, 18)) } case 1000 { result := mul(SCALE, sub(3, 18)) } case 10000 { result := mul(SCALE, sub(4, 18)) } case 100000 { result := mul(SCALE, sub(5, 18)) } case 1000000 { result := mul(SCALE, sub(6, 18)) } case 10000000 { result := mul(SCALE, sub(7, 18)) } case 100000000 { result := mul(SCALE, sub(8, 18)) } case 1000000000 { result := mul(SCALE, sub(9, 18)) } case 10000000000 { result := mul(SCALE, sub(10, 18)) } case 100000000000 { result := mul(SCALE, sub(11, 18)) } case 1000000000000 { result := mul(SCALE, sub(12, 18)) } case 10000000000000 { result := mul(SCALE, sub(13, 18)) } case 100000000000000 { result := mul(SCALE, sub(14, 18)) } case 1000000000000000 { result := mul(SCALE, sub(15, 18)) } case 10000000000000000 { result := mul(SCALE, sub(16, 18)) } case 100000000000000000 { result := mul(SCALE, sub(17, 18)) } case 1000000000000000000 { result := 0 } case 10000000000000000000 { result := SCALE } case 100000000000000000000 { result := mul(SCALE, 2) } case 1000000000000000000000 { result := mul(SCALE, 3) } case 10000000000000000000000 { result := mul(SCALE, 4) } case 100000000000000000000000 { result := mul(SCALE, 5) } case 1000000000000000000000000 { result := mul(SCALE, 6) } case 10000000000000000000000000 { result := mul(SCALE, 7) } case 100000000000000000000000000 { result := mul(SCALE, 8) } case 1000000000000000000000000000 { result := mul(SCALE, 9) } case 10000000000000000000000000000 { result := mul(SCALE, 10) } case 100000000000000000000000000000 { result := mul(SCALE, 11) } case 1000000000000000000000000000000 { result := mul(SCALE, 12) } case 10000000000000000000000000000000 { result := mul(SCALE, 13) } case 100000000000000000000000000000000 { result := mul(SCALE, 14) } case 1000000000000000000000000000000000 { result := mul(SCALE, 15) } case 10000000000000000000000000000000000 { result := mul(SCALE, 16) } case 100000000000000000000000000000000000 { result := mul(SCALE, 17) } case 1000000000000000000000000000000000000 { result := mul(SCALE, 18) } case 10000000000000000000000000000000000000 { result := mul(SCALE, 19) } case 100000000000000000000000000000000000000 { result := mul(SCALE, 20) } case 1000000000000000000000000000000000000000 { result := mul(SCALE, 21) } case 10000000000000000000000000000000000000000 { result := mul(SCALE, 22) } case 100000000000000000000000000000000000000000 { result := mul(SCALE, 23) } case 1000000000000000000000000000000000000000000 { result := mul(SCALE, 24) } case 10000000000000000000000000000000000000000000 { result := mul(SCALE, 25) } case 100000000000000000000000000000000000000000000 { result := mul(SCALE, 26) } case 1000000000000000000000000000000000000000000000 { result := mul(SCALE, 27) } case 10000000000000000000000000000000000000000000000 { result := mul(SCALE, 28) } case 100000000000000000000000000000000000000000000000 { result := mul(SCALE, 29) } case 1000000000000000000000000000000000000000000000000 { result := mul(SCALE, 30) } case 10000000000000000000000000000000000000000000000000 { result := mul(SCALE, 31) } case 100000000000000000000000000000000000000000000000000 { result := mul(SCALE, 32) } case 1000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 33) } case 10000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 34) } case 100000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 35) } case 1000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 36) } case 10000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 37) } case 100000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 38) } case 1000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 39) } case 10000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 40) } case 100000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 41) } case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 42) } case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 43) } case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 44) } case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 45) } case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 46) } case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 47) } case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 48) } case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 49) } case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 50) } case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 51) } case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 52) } case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 53) } case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 54) } case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 55) } case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 56) } case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 57) } case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 58) } case 100000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 59) } default { result := MAX_UD60x18 } } if (result == MAX_UD60x18) { // Do the fixed-point division inline to save gas. The denominator is log2(10). unchecked { result = (log2(x) * SCALE) / 332192809488736234; } } }
function log10(uint256 x) internal pure returns (uint256 result) { require(x >= SCALE); // Note that the "mul" in this block is the assembly mul operation, not the "mul" function defined in this contract. // prettier-ignore assembly { switch x case 1 { result := mul(SCALE, sub(0, 18)) } case 10 { result := mul(SCALE, sub(1, 18)) } case 100 { result := mul(SCALE, sub(2, 18)) } case 1000 { result := mul(SCALE, sub(3, 18)) } case 10000 { result := mul(SCALE, sub(4, 18)) } case 100000 { result := mul(SCALE, sub(5, 18)) } case 1000000 { result := mul(SCALE, sub(6, 18)) } case 10000000 { result := mul(SCALE, sub(7, 18)) } case 100000000 { result := mul(SCALE, sub(8, 18)) } case 1000000000 { result := mul(SCALE, sub(9, 18)) } case 10000000000 { result := mul(SCALE, sub(10, 18)) } case 100000000000 { result := mul(SCALE, sub(11, 18)) } case 1000000000000 { result := mul(SCALE, sub(12, 18)) } case 10000000000000 { result := mul(SCALE, sub(13, 18)) } case 100000000000000 { result := mul(SCALE, sub(14, 18)) } case 1000000000000000 { result := mul(SCALE, sub(15, 18)) } case 10000000000000000 { result := mul(SCALE, sub(16, 18)) } case 100000000000000000 { result := mul(SCALE, sub(17, 18)) } case 1000000000000000000 { result := 0 } case 10000000000000000000 { result := SCALE } case 100000000000000000000 { result := mul(SCALE, 2) } case 1000000000000000000000 { result := mul(SCALE, 3) } case 10000000000000000000000 { result := mul(SCALE, 4) } case 100000000000000000000000 { result := mul(SCALE, 5) } case 1000000000000000000000000 { result := mul(SCALE, 6) } case 10000000000000000000000000 { result := mul(SCALE, 7) } case 100000000000000000000000000 { result := mul(SCALE, 8) } case 1000000000000000000000000000 { result := mul(SCALE, 9) } case 10000000000000000000000000000 { result := mul(SCALE, 10) } case 100000000000000000000000000000 { result := mul(SCALE, 11) } case 1000000000000000000000000000000 { result := mul(SCALE, 12) } case 10000000000000000000000000000000 { result := mul(SCALE, 13) } case 100000000000000000000000000000000 { result := mul(SCALE, 14) } case 1000000000000000000000000000000000 { result := mul(SCALE, 15) } case 10000000000000000000000000000000000 { result := mul(SCALE, 16) } case 100000000000000000000000000000000000 { result := mul(SCALE, 17) } case 1000000000000000000000000000000000000 { result := mul(SCALE, 18) } case 10000000000000000000000000000000000000 { result := mul(SCALE, 19) } case 100000000000000000000000000000000000000 { result := mul(SCALE, 20) } case 1000000000000000000000000000000000000000 { result := mul(SCALE, 21) } case 10000000000000000000000000000000000000000 { result := mul(SCALE, 22) } case 100000000000000000000000000000000000000000 { result := mul(SCALE, 23) } case 1000000000000000000000000000000000000000000 { result := mul(SCALE, 24) } case 10000000000000000000000000000000000000000000 { result := mul(SCALE, 25) } case 100000000000000000000000000000000000000000000 { result := mul(SCALE, 26) } case 1000000000000000000000000000000000000000000000 { result := mul(SCALE, 27) } case 10000000000000000000000000000000000000000000000 { result := mul(SCALE, 28) } case 100000000000000000000000000000000000000000000000 { result := mul(SCALE, 29) } case 1000000000000000000000000000000000000000000000000 { result := mul(SCALE, 30) } case 10000000000000000000000000000000000000000000000000 { result := mul(SCALE, 31) } case 100000000000000000000000000000000000000000000000000 { result := mul(SCALE, 32) } case 1000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 33) } case 10000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 34) } case 100000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 35) } case 1000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 36) } case 10000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 37) } case 100000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 38) } case 1000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 39) } case 10000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 40) } case 100000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 41) } case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 42) } case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 43) } case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 44) } case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 45) } case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 46) } case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 47) } case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 48) } case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 49) } case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 50) } case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 51) } case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 52) } case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 53) } case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 54) } case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 55) } case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 56) } case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 57) } case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 58) } case 100000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 59) } default { result := MAX_UD60x18 } } if (result == MAX_UD60x18) { // Do the fixed-point division inline to save gas. The denominator is log2(10). unchecked { result = (log2(x) * SCALE) / 332192809488736234; } } }
14,698
111
// This internal minting function allows inheriting contracts/ to mint tokens in the way they wish./account the address which will receive the token./amount the amount of token which they will receive/This function is virtual so that it can be overridden, if you/are reviewing this contract for security you should ensure to/check for overrides
function _mint(address account, uint256 amount) internal virtual { // Add tokens to the account balanceOf[account] = balanceOf[account] + amount; // Emit an event to track the minting emit Transfer(address(0), account, amount); }
function _mint(address account, uint256 amount) internal virtual { // Add tokens to the account balanceOf[account] = balanceOf[account] + amount; // Emit an event to track the minting emit Transfer(address(0), account, amount); }
25,590
37
// Method for setting royalty/_tokenId TokenId/_royalty Royalty
function registerRoyalty( address _nftAddress, uint256 _tokenId, uint8 _royalty
function registerRoyalty( address _nftAddress, uint256 _tokenId, uint8 _royalty
49,420
73
// _resetTokenPrice// Internal function to set token price to 0 for a given contract. _originContract address of ERC721 contract. _tokenId uin256 id of the token. /
function _resetTokenPrice(address _originContract, uint256 _tokenId) internal
function _resetTokenPrice(address _originContract, uint256 _tokenId) internal
2,504
120
// Returns the count of all existing NFTokens. /
function totalSupply() external view returns (uint256)
function totalSupply() external view returns (uint256)
22,049
103
// return the current state of the escrow. /
function state() public view returns (State) { return _state; }
function state() public view returns (State) { return _state; }
33,402
53
// Claim all bought tokens. Available tokens will be sent to transaction sender address if unlocked /
function claim() public whenNotPaused { claimFor(msg.sender); }
function claim() public whenNotPaused { claimFor(msg.sender); }
38,388
6
// Execute a queued tx
if (isActionQueued(_vault, stack.signHash)){ require(relayer[_vault].queuedTransactions[stack.signHash] < block.timestamp, "KR: Time not expired"); (stack.success, stack.returnData) = address(this).call(_data); require(stack.success, "KR: Internal call failed"); if(relayer[_vault].queue.length > 0) { removeQueue(_vault, stack.signHash); }
if (isActionQueued(_vault, stack.signHash)){ require(relayer[_vault].queuedTransactions[stack.signHash] < block.timestamp, "KR: Time not expired"); (stack.success, stack.returnData) = address(this).call(_data); require(stack.success, "KR: Internal call failed"); if(relayer[_vault].queue.length > 0) { removeQueue(_vault, stack.signHash); }
27,103
144
// initializes bond parameters_vestingTermSeconds uint_vestingTerm uint_discount uint_maxPayout uint_fee uint_maxDebt uint_initialDebt uint_soldBondsLimitUsd uint_useWhitelist bool_useCircuitBreaker bool_prematureReturnRate uint_limitBondCount uint /
function initializeBondTerms( uint _vestingTermSeconds, uint _vestingTerm, uint _discount, uint _maxPayout, uint _fee, uint _maxDebt, uint _initialDebt, uint _soldBondsLimitUsd, bool _useWhitelist,
function initializeBondTerms( uint _vestingTermSeconds, uint _vestingTerm, uint _discount, uint _maxPayout, uint _fee, uint _maxDebt, uint _initialDebt, uint _soldBondsLimitUsd, bool _useWhitelist,
15,208
31
// Harvest proceeds for transaction sender to `to`./pid The index of the pool. See `poolInfo`./to Receiver of the rewards.
function harvest(uint256 pid, address to) external { require(!nonReentrant, "genericFarmV2::nonReentrant - try again"); nonReentrant = true; PoolInfo memory pool = updatePool(pid); UserInfo storage user = userInfo[pid][msg.sender]; int256 accumulatedRewardTokens = int256(user.amount.mul(pool.accRewardTokensPerShare) / ACC_TOKEN_PRECISION); uint256 _pendingRewardTokens = accumulatedRewardTokens.sub(user.rewardDebt).toUInt256(); // Effects user.rewardDebt = accumulatedRewardTokens; // Interactions if (_pendingRewardTokens > 0) { REWARD_TOKEN.safeTransfer(to, _pendingRewardTokens); } emit Harvest(msg.sender, pid, _pendingRewardTokens); nonReentrant = false; }
function harvest(uint256 pid, address to) external { require(!nonReentrant, "genericFarmV2::nonReentrant - try again"); nonReentrant = true; PoolInfo memory pool = updatePool(pid); UserInfo storage user = userInfo[pid][msg.sender]; int256 accumulatedRewardTokens = int256(user.amount.mul(pool.accRewardTokensPerShare) / ACC_TOKEN_PRECISION); uint256 _pendingRewardTokens = accumulatedRewardTokens.sub(user.rewardDebt).toUInt256(); // Effects user.rewardDebt = accumulatedRewardTokens; // Interactions if (_pendingRewardTokens > 0) { REWARD_TOKEN.safeTransfer(to, _pendingRewardTokens); } emit Harvest(msg.sender, pid, _pendingRewardTokens); nonReentrant = false; }
27,581
110
// Settles the lottery, the winners are calculated based onthe random number generated. The Admin fee is calculated andtransferred back to Admin `adminAddress`.
* Emits an {WinnersGenerated} event indicating that the winners for the lottery have been generated. * Emits {LotterySettled} event indicating that the winnings have been transferred to the Admin and the Lottery is closed. * * Requirements: * * - The random number has been generated * - The Lottery is in progress. */ function settleLottery() payable public { require( isRandomNumberGenerated, "Lottery Configuration still in progress. Please try in a short while" ); require( lotteryStatus == LotteryStatus.INPROGRESS, "The Lottery is not started or closed" ); for (uint256 i = 0; i < lotteryConfig.numOfWinners; i = i.add(1)) { uint256 winningIndex = randomResult.mod(lotteryConfig.playersLimit); uint256 counter = 0; while (winnerAddresses[winningIndex] != address(0)) { randomResult = getRandomNumberBlockchain(i, randomResult); winningIndex = randomResult.mod(lotteryConfig.playersLimit); counter = counter.add(1); if (counter == lotteryConfig.playersLimit) { while (winnerAddresses[winningIndex] != address(0)) { winningIndex = (winningIndex.add(1)).mod( lotteryConfig.playersLimit ); } counter = 0; } } winnerAddresses[winningIndex] = lotteryPlayers[winningIndex]; winnerIndexes.push(winningIndex); randomResult = getRandomNumberBlockchain(i, randomResult); } areWinnersGenerated = true; emit WinnersGenerated(winnerIndexes); adminFeesAmount = ( (totalLotteryPool.mul(lotteryConfig.adminFeePercentage)).div(100) ); rewardPoolAmount = (totalLotteryPool.sub(adminFeesAmount)).div( lotteryConfig.numOfWinners ); lotteryStatus = LotteryStatus.CLOSED; if(isOnlyETHAccepted) { (bool status, ) = payable(adminAddress).call{value: adminFeesAmount}(""); require(status, "Admin fees not transferred"); } else { buyToken.transfer(adminAddress, adminFeesAmount); } // collectRewards(); emit LotterySettled(); }
* Emits an {WinnersGenerated} event indicating that the winners for the lottery have been generated. * Emits {LotterySettled} event indicating that the winnings have been transferred to the Admin and the Lottery is closed. * * Requirements: * * - The random number has been generated * - The Lottery is in progress. */ function settleLottery() payable public { require( isRandomNumberGenerated, "Lottery Configuration still in progress. Please try in a short while" ); require( lotteryStatus == LotteryStatus.INPROGRESS, "The Lottery is not started or closed" ); for (uint256 i = 0; i < lotteryConfig.numOfWinners; i = i.add(1)) { uint256 winningIndex = randomResult.mod(lotteryConfig.playersLimit); uint256 counter = 0; while (winnerAddresses[winningIndex] != address(0)) { randomResult = getRandomNumberBlockchain(i, randomResult); winningIndex = randomResult.mod(lotteryConfig.playersLimit); counter = counter.add(1); if (counter == lotteryConfig.playersLimit) { while (winnerAddresses[winningIndex] != address(0)) { winningIndex = (winningIndex.add(1)).mod( lotteryConfig.playersLimit ); } counter = 0; } } winnerAddresses[winningIndex] = lotteryPlayers[winningIndex]; winnerIndexes.push(winningIndex); randomResult = getRandomNumberBlockchain(i, randomResult); } areWinnersGenerated = true; emit WinnersGenerated(winnerIndexes); adminFeesAmount = ( (totalLotteryPool.mul(lotteryConfig.adminFeePercentage)).div(100) ); rewardPoolAmount = (totalLotteryPool.sub(adminFeesAmount)).div( lotteryConfig.numOfWinners ); lotteryStatus = LotteryStatus.CLOSED; if(isOnlyETHAccepted) { (bool status, ) = payable(adminAddress).call{value: adminFeesAmount}(""); require(status, "Admin fees not transferred"); } else { buyToken.transfer(adminAddress, adminFeesAmount); } // collectRewards(); emit LotterySettled(); }
37,034
72
// Batch query of asset liabilities for a user user user address to query /
function getLiabilities(address user)
function getLiabilities(address user)
62,834
58
// log the bet being placed successfully
emit Placed(vrfInputHash, player, playerNonce, amount, packedBet.toUint(), humanReadable.toString());
emit Placed(vrfInputHash, player, playerNonce, amount, packedBet.toUint(), humanReadable.toString());
17,884
21
// Allows the trader to return the position/loan token to increase their escrowed balance/This should be used by the trader if they've withdraw an overcollateralized loan/If depositTokenAddress is not the correct token, it will be traded to the correct token using the oracle./loanOrderHash A unique hash representing the loan order/borrower The borrower whose loan to deposit position token to (for margin trades, this has to equal the sender)/depositTokenAddress The address of the position token being returned/depositAmount The amount of position token to deposit./ return True on success
function depositPositionForBorrower( bytes32 loanOrderHash, address borrower, address depositTokenAddress, uint256 depositAmount) external nonReentrant tracksGas returns (bool)
function depositPositionForBorrower( bytes32 loanOrderHash, address borrower, address depositTokenAddress, uint256 depositAmount) external nonReentrant tracksGas returns (bool)
12,312
122
// Initialize the contract _stakedToken: staked token address _rewardToken: reward token address _rewardPerBlock: reward per block (in rewardToken) _startBlock: start block _endBlock: end block _poolLimitPerUser: pool limit per user in stakedToken (if any, else 0) _depositFee: deposit fee _withdrawFee: withdraw fee _lockPeriod: lock period _feeAddress: fee address _admin: admin address with ownership /
function initialize( IERC20 _stakedToken, IERC20 _rewardToken, uint256 _rewardPerBlock, uint256 _startBlock, uint256 _endBlock, uint256 _poolLimitPerUser, uint16 _depositFee, uint16 _withdrawFee, uint256 _lockPeriod,
function initialize( IERC20 _stakedToken, IERC20 _rewardToken, uint256 _rewardPerBlock, uint256 _startBlock, uint256 _endBlock, uint256 _poolLimitPerUser, uint16 _depositFee, uint16 _withdrawFee, uint256 _lockPeriod,
77,489
81
// adds `_amt` collateral to `vaultOwner` and returns the new balance of the vault vaultOwner the index of the vault amt the amount of collateral to add /
function _addCollateral(address payable vaultOwner, uint256 amt) internal notExpired returns (uint256)
function _addCollateral(address payable vaultOwner, uint256 amt) internal notExpired returns (uint256)
46,381
7
// list of all the treasuries deployed
address[] private treasuries;
address[] private treasuries;
37,385
46
// Sets/updates the converter for a given vault _vault The address of the vault _converter The address of the converter /
function setConverter( address _vault, address _converter ) external notHalted onlyStrategist
function setConverter( address _vault, address _converter ) external notHalted onlyStrategist
52,519
26
// Update the name of the token newName The new name for the token /
function _setName(string memory newName) internal { _name = newName; }
function _setName(string memory newName) internal { _name = newName; }
4,647
39
// Set L1 TransferRoot
_setTransferRoot(rootHash, totalAmount);
_setTransferRoot(rootHash, totalAmount);
50,550
50
// game over: display zero
if (now >= roundEndTime) { return 0;
if (now >= roundEndTime) { return 0;
25,560
104
// _controller:BvaultsBank _buyBackToken1Info[]: buyBackToken1, buyBackAddress1, buyBackToken1MidRouteAddress _buyBackToken2Info[]: buyBackToken2, buyBackAddress2, buyBackToken2MidRouteAddress
constructor( address _controller, bool _isCAKEStaking, bool _isAutoComp, address _farmContractAddress, uint256 _pid, address _wantAddress, address _earnedAddress, address _uniRouterAddress, address[] memory _buyBackToken1Info,
constructor( address _controller, bool _isCAKEStaking, bool _isAutoComp, address _farmContractAddress, uint256 _pid, address _wantAddress, address _earnedAddress, address _uniRouterAddress, address[] memory _buyBackToken1Info,
11,082
7
// Fixed at deployment time
struct DeploymentConfig { // Name of the NFT contract. string name; // Symbol of the NFT contract. string symbol; // The contract owner address. If you wish to own the contract, then set it as your wallet address. // This is also the wallet that can manage the contract on NFT marketplaces. Use `transferOwnership()` // to update the contract owner. address owner; // The maximum number of tokens that can be minted in this collection. uint256 maxSupply; // The number of free token mints reserved for the contract owner uint256 reservedSupply; /// The maximum number of tokens the user can mint per transaction. uint256 tokensPerMint; // Treasury address is the address where minting fees can be withdrawn to. // Use `withdrawFees()` to transfer the entire contract balance to the treasury address. address payable treasuryAddress; }
struct DeploymentConfig { // Name of the NFT contract. string name; // Symbol of the NFT contract. string symbol; // The contract owner address. If you wish to own the contract, then set it as your wallet address. // This is also the wallet that can manage the contract on NFT marketplaces. Use `transferOwnership()` // to update the contract owner. address owner; // The maximum number of tokens that can be minted in this collection. uint256 maxSupply; // The number of free token mints reserved for the contract owner uint256 reservedSupply; /// The maximum number of tokens the user can mint per transaction. uint256 tokensPerMint; // Treasury address is the address where minting fees can be withdrawn to. // Use `withdrawFees()` to transfer the entire contract balance to the treasury address. address payable treasuryAddress; }
37,811
122
// no ref purchase add the referral bonus back to the global dividends cake
_dividends = safeAdd(_dividends, _referralBonus); _fee = _dividends * magnitude;
_dividends = safeAdd(_dividends, _referralBonus); _fee = _dividends * magnitude;
18,690
99
// b = S_ + D / Ann
uint256 b = S_.add(_D.div(Ann)); uint256 prevY = 0; uint256 y = _D;
uint256 b = S_.add(_D.div(Ann)); uint256 prevY = 0; uint256 y = _D;
53,080
139
// Increment buffer length - 0x60 plus the original length
mstore(ptr, add(0x60, mload(ptr)))
mstore(ptr, add(0x60, mload(ptr)))
28,205
1
// Sale Information
bytes32 private _merkleRoot; uint64 public cost; uint8 public salePhase; uint8 public lastSalePhase; uint8 private constant _MAX_PER_TX = 10;
bytes32 private _merkleRoot; uint64 public cost; uint8 public salePhase; uint8 public lastSalePhase; uint8 private constant _MAX_PER_TX = 10;
19,957
58
// Set the length of the array the number that has been used. solium-disable-next-line security/no-inline-assembly
assembly { mstore(results, i) }
assembly { mstore(results, i) }
24,771
76
// manage public mint
mintSupply=totalSupply(); require(!paused, "Contract is paused"); require(_mintAmount > 0, "mint amount cant be 0"); require(_mintAmount <= maxMintAmount, "Cant mint over the max mint amount"); require(mintSupply + _mintAmount <= maxSupply, "Mint amount is too high there may not be enough left to mint that many"); for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(msg.sender, mintSupply + i); }
mintSupply=totalSupply(); require(!paused, "Contract is paused"); require(_mintAmount > 0, "mint amount cant be 0"); require(_mintAmount <= maxMintAmount, "Cant mint over the max mint amount"); require(mintSupply + _mintAmount <= maxSupply, "Mint amount is too high there may not be enough left to mint that many"); for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(msg.sender, mintSupply + i); }
58,834
110
// multiplier applied to rarity bounds when feeding horsey
uint8 public rarityMultiplier = 1;
uint8 public rarityMultiplier = 1;
30,588
1
// The DIN to buy a DIN.
uint256 public GENESIS_DIN = 1000000000; string public version = "0.0.1";
uint256 public GENESIS_DIN = 1000000000; string public version = "0.0.1";
20,562
171
// /
function revoke(address from, uint256 amount) public onlyRevoker returns (bool) { return _revoke(from, amount); }
function revoke(address from, uint256 amount) public onlyRevoker returns (bool) { return _revoke(from, amount); }
4,354
66
// Passing ERC20 token details to the constructor
ERC20("Reviewfy", "R5") { // Adding total supply in multiplication with desired decimal places <Total supply * (10 ** decimals)> uint totalSupply = 100000000 * (10**18); // Mint the supply to the address provided setInitialRewardAmount(10**18); _mint(msg.sender,totalSupply); }
ERC20("Reviewfy", "R5") { // Adding total supply in multiplication with desired decimal places <Total supply * (10 ** decimals)> uint totalSupply = 100000000 * (10**18); // Mint the supply to the address provided setInitialRewardAmount(10**18); _mint(msg.sender,totalSupply); }
29,567
101
// Calculates the claimable amounts for token and lp stake from normal and super rewards _account user addressreturn token - claimable reward amount for token stakereturn lp - claimable reward amount for lp stake /
function claimable(address _account) external view returns (uint256 token, uint256 lp) { token = _earned(_account, false) + _earnedSuper(_account, false) - tokenStake[_account].rewards; lp = _earned(_account, true) + _earnedSuper(_account, true) - liquidityStake[_account].rewards; }
function claimable(address _account) external view returns (uint256 token, uint256 lp) { token = _earned(_account, false) + _earnedSuper(_account, false) - tokenStake[_account].rewards; lp = _earned(_account, true) + _earnedSuper(_account, true) - liquidityStake[_account].rewards; }
49,766
12
// Initialises the Module by setting publisher addresses, and reading all available system module information /
constructor(address _nexus) internal { require(_nexus != address(0), "Nexus is zero address"); nexus = INexus(_nexus); }
constructor(address _nexus) internal { require(_nexus != address(0), "Nexus is zero address"); nexus = INexus(_nexus); }
13,570
86
// Original amount for the pool
uint256 remamountToPoolOrg = feeamount.sub(feeamountToPool);
uint256 remamountToPoolOrg = feeamount.sub(feeamountToPool);
19,395
13
// Changes the `_rng` storage variable._rng The new value for the `RNGenerator` storage variable._rngLookahead The new value for the `rngLookahead` storage variable. /
function changeRandomNumberGenerator(RNG _rng, uint256 _rngLookahead) external onlyByGovernor { rng = _rng; rngLookahead = _rngLookahead; if (phase == Phase.generating) { rngRequestedBlock = block.number + rngLookahead; rng.requestRandomness(rngRequestedBlock); } }
function changeRandomNumberGenerator(RNG _rng, uint256 _rngLookahead) external onlyByGovernor { rng = _rng; rngLookahead = _rngLookahead; if (phase == Phase.generating) { rngRequestedBlock = block.number + rngLookahead; rng.requestRandomness(rngRequestedBlock); } }
22,510
24
// Sets the borrow cap of the reserve self The reserve configuration borrowCap The borrow cap /
{ require(borrowCap <= MAX_VALID_BORROW_CAP, Errors.RC_INVALID_BORROW_CAP); self.data = (self.data & BORROW_CAP_MASK) | (borrowCap << BORROW_CAP_START_BIT_POSITION); }
{ require(borrowCap <= MAX_VALID_BORROW_CAP, Errors.RC_INVALID_BORROW_CAP); self.data = (self.data & BORROW_CAP_MASK) | (borrowCap << BORROW_CAP_START_BIT_POSITION); }
9,897
108
// return the total number of deposits this _staker has made /
function getNumberOfDeposits(address _staker) external view returns (uint256)
function getNumberOfDeposits(address _staker) external view returns (uint256)
79,349
16
// position ID is the ERC 1155 token ID
positionIds, amounts, "" ); emit PositionSplit(msg.sender, collateralToken, parentCollectionId, conditionId, partition, amount);
positionIds, amounts, "" ); emit PositionSplit(msg.sender, collateralToken, parentCollectionId, conditionId, partition, amount);
23,773
71
// we save the stake amount of a donor at the end of each claim,so rewardPeriods[_index - 1].donorStakeAmounts[_donorAddress] is the amount staked by the donor at his last claim
_lastDonorStakeAmount = rewardPeriods[_index - 1].donorStakeAmounts[_donorAddress]; while (_index <= _lastPeriodNumber) { if (_currentRewardPeriod.startBlock > 0) {
_lastDonorStakeAmount = rewardPeriods[_index - 1].donorStakeAmounts[_donorAddress]; while (_index <= _lastPeriodNumber) { if (_currentRewardPeriod.startBlock > 0) {
20,350
107
// 如果累计债务 > 最大债务
if (accumulatedDebt > maxDebt) {
if (accumulatedDebt > maxDebt) {
42,980
37
// Retrieves the identifier from action _action The actionreturn The action type /
function actionType(bytes29 _action) internal pure returns (uint8) { return uint8(_action.indexUint(0, 1)); }
function actionType(bytes29 _action) internal pure returns (uint8) { return uint8(_action.indexUint(0, 1)); }
33,519
8
// Places `addr` in the first empty position if it isn't in the queue /
function enqueue(address _addr) external { for(uint8 i = 0; i<free; i++) { if(_addr == queue[i]) return; } if(free < size) { queue[free] = _addr; pushTime[_addr] = now; free++; } }
function enqueue(address _addr) external { for(uint8 i = 0; i<free; i++) { if(_addr == queue[i]) return; } if(free < size) { queue[free] = _addr; pushTime[_addr] = now; free++; } }
33,383
3
// the address of the Vault that the strategy belongs to
function vault() external view returns (address);
function vault() external view returns (address);
33,833
176
// Only smart contracts will be affected by this modifier
modifier defense() { require( (msg.sender == tx.origin) || // If it is a normal user and not smart contract, // then the requirement will pass !IController(controller()).greyList(msg.sender), // If it is a smart contract, then "Vault: This smart contract has not been grey listed" // make sure that it is not on our greyList. ); _; }
modifier defense() { require( (msg.sender == tx.origin) || // If it is a normal user and not smart contract, // then the requirement will pass !IController(controller()).greyList(msg.sender), // If it is a smart contract, then "Vault: This smart contract has not been grey listed" // make sure that it is not on our greyList. ); _; }
10,234
61
// _Available since v3.1._ /
interface IERC1155Receiver is IERC165 { /** @dev Handles the receipt of a single ERC1155 token type. This function is called at the end of a `safeTransferFrom` after the balance has been updated. To accept the transfer, this must return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` (i.e. 0xf23a6e61, or its own function selector). @param operator The address which initiated the transfer (i.e. msg.sender) @param from The address which previously owned the token @param id The ID of the token being transferred @param value The amount of tokens being transferred @param data Additional data with no specified format @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns(bytes4); /** @dev Handles the receipt of a multiple ERC1155 token types. This function is called at the end of a `safeBatchTransferFrom` after the balances have been updated. To accept the transfer(s), this must return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` (i.e. 0xbc197c81, or its own function selector). @param operator The address which initiated the batch transfer (i.e. msg.sender) @param from The address which previously owned the token @param ids An array containing ids of each token being transferred (order and length must match values array) @param values An array containing amounts of each token being transferred (order and length must match ids array) @param data Additional data with no specified format @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns(bytes4); }
interface IERC1155Receiver is IERC165 { /** @dev Handles the receipt of a single ERC1155 token type. This function is called at the end of a `safeTransferFrom` after the balance has been updated. To accept the transfer, this must return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` (i.e. 0xf23a6e61, or its own function selector). @param operator The address which initiated the transfer (i.e. msg.sender) @param from The address which previously owned the token @param id The ID of the token being transferred @param value The amount of tokens being transferred @param data Additional data with no specified format @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns(bytes4); /** @dev Handles the receipt of a multiple ERC1155 token types. This function is called at the end of a `safeBatchTransferFrom` after the balances have been updated. To accept the transfer(s), this must return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` (i.e. 0xbc197c81, or its own function selector). @param operator The address which initiated the batch transfer (i.e. msg.sender) @param from The address which previously owned the token @param ids An array containing ids of each token being transferred (order and length must match values array) @param values An array containing amounts of each token being transferred (order and length must match ids array) @param data Additional data with no specified format @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns(bytes4); }
12,485
33
// to update the owner parameterscode is the associated codeval is value to be set /
function updateAddressParameters(bytes8 code, address payable val) public { require(ms.checkIsAuthToGoverned(msg.sender)); if (code == "PUMPAD") { _changePumpAddress(val); } }
function updateAddressParameters(bytes8 code, address payable val) public { require(ms.checkIsAuthToGoverned(msg.sender)); if (code == "PUMPAD") { _changePumpAddress(val); } }
51,029
13
// lib/tinlake-math/src/math.sol Copyright (C) 2018 Rain <rainbreak@riseup.net>/ pragma solidity >=0.5.15; /
contract Math { uint256 constant ONE = 10 ** 27; function safeAdd(uint x, uint y) public pure returns (uint z) { require((z = x + y) >= x, "safe-add-failed"); } function safeSub(uint x, uint y) public pure returns (uint z) { require((z = x - y) <= x, "safe-sub-failed"); } function safeMul(uint x, uint y) public pure returns (uint z) { require(y == 0 || (z = x * y) / y == x, "safe-mul-failed"); } function safeDiv(uint x, uint y) public pure returns (uint z) { z = x / y; } function rmul(uint x, uint y) public pure returns (uint z) { z = safeMul(x, y) / ONE; } function rdiv(uint x, uint y) public pure returns (uint z) { require(y > 0, "division by zero"); z = safeAdd(safeMul(x, ONE), y / 2) / y; } function rdivup(uint x, uint y) internal pure returns (uint z) { require(y > 0, "division by zero"); // always rounds up z = safeAdd(safeMul(x, ONE), safeSub(y, 1)) / y; } }
contract Math { uint256 constant ONE = 10 ** 27; function safeAdd(uint x, uint y) public pure returns (uint z) { require((z = x + y) >= x, "safe-add-failed"); } function safeSub(uint x, uint y) public pure returns (uint z) { require((z = x - y) <= x, "safe-sub-failed"); } function safeMul(uint x, uint y) public pure returns (uint z) { require(y == 0 || (z = x * y) / y == x, "safe-mul-failed"); } function safeDiv(uint x, uint y) public pure returns (uint z) { z = x / y; } function rmul(uint x, uint y) public pure returns (uint z) { z = safeMul(x, y) / ONE; } function rdiv(uint x, uint y) public pure returns (uint z) { require(y > 0, "division by zero"); z = safeAdd(safeMul(x, ONE), y / 2) / y; } function rdivup(uint x, uint y) internal pure returns (uint z) { require(y > 0, "division by zero"); // always rounds up z = safeAdd(safeMul(x, ONE), safeSub(y, 1)) / y; } }
10,321
124
// The amount of time to vote on a proposal
function votingPeriod() external view returns (uint256) { return settings.votingPeriod; }
function votingPeriod() external view returns (uint256) { return settings.votingPeriod; }
17,989
190
// Allows users to access the token's symbol/
function symbol() external pure returns (string memory) { return "TRB"; }
function symbol() external pure returns (string memory) { return "TRB"; }
26,086
15
// Events // Modifiers /
modifier onlylockdropContractCreator() { require(msg.sender == lockdropContractCreator, "Sender must be lockdrop contract creator"); _; }
modifier onlylockdropContractCreator() { require(msg.sender == lockdropContractCreator, "Sender must be lockdrop contract creator"); _; }
20,891
272
// DM Gargamel in Discord that you're standing right behind him. /
function setRevealTimestamp(uint256 revealTimeStamp) public onlyOwner { REVEAL_TIMESTAMP = revealTimeStamp; }
function setRevealTimestamp(uint256 revealTimeStamp) public onlyOwner { REVEAL_TIMESTAMP = revealTimeStamp; }
30,212
40
// Various utilities useful for uint256. /
library UInt256Lib { uint256 private constant MAX_INT256 = ~(uint256(1) << 255); /** * @dev Safely converts a uint256 to an int256. */ function toInt256Safe(uint256 a) internal pure returns (int256) { require(a <= MAX_INT256); return int256(a); } }
library UInt256Lib { uint256 private constant MAX_INT256 = ~(uint256(1) << 255); /** * @dev Safely converts a uint256 to an int256. */ function toInt256Safe(uint256 a) internal pure returns (int256) { require(a <= MAX_INT256); return int256(a); } }
9,431
39
// gas optimizationcredit squeebo_nft /
abstract contract ERC721EnumerableLite is ERC721B, IERC721Batch, IERC721Enumerable { mapping(address => uint) internal _balances; function isOwnerOf( address account, uint[] calldata tokenIds ) external view virtual override returns( bool ){ for(uint i; i < tokenIds.length; ++i ){ if( _owners[ tokenIds[i] ] != account ) return false; } return true; } function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721B) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } function tokenOfOwnerByIndex(address owner, uint index) public view override returns (uint tokenId) { uint count; for( uint i; i < _owners.length; ++i ){ if( owner == _owners[i] ){ if( count == index ) return i; else ++count; } } revert("ERC721Enumerable: owner index out of bounds"); } function tokenByIndex(uint index) external view virtual override returns (uint) { require(index < totalSupply(), "ERC721Enumerable: global index out of bounds"); return index; } function totalSupply() public view virtual override( ERC721B, IERC721Enumerable ) returns (uint) { return _owners.length - (_offset + _burned); } function transferBatch( address from, address to, uint[] calldata tokenIds, bytes calldata data ) external override{ for(uint i; i < tokenIds.length; ++i ){ safeTransferFrom( from, to, tokenIds[i], data ); } } function walletOfOwner( address account ) external view virtual override returns( uint[] memory ){ uint quantity = balanceOf( account ); uint[] memory wallet = new uint[]( quantity ); for( uint i; i < quantity; ++i ){ wallet[i] = tokenOfOwnerByIndex( account, i ); } return wallet; } }
abstract contract ERC721EnumerableLite is ERC721B, IERC721Batch, IERC721Enumerable { mapping(address => uint) internal _balances; function isOwnerOf( address account, uint[] calldata tokenIds ) external view virtual override returns( bool ){ for(uint i; i < tokenIds.length; ++i ){ if( _owners[ tokenIds[i] ] != account ) return false; } return true; } function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721B) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } function tokenOfOwnerByIndex(address owner, uint index) public view override returns (uint tokenId) { uint count; for( uint i; i < _owners.length; ++i ){ if( owner == _owners[i] ){ if( count == index ) return i; else ++count; } } revert("ERC721Enumerable: owner index out of bounds"); } function tokenByIndex(uint index) external view virtual override returns (uint) { require(index < totalSupply(), "ERC721Enumerable: global index out of bounds"); return index; } function totalSupply() public view virtual override( ERC721B, IERC721Enumerable ) returns (uint) { return _owners.length - (_offset + _burned); } function transferBatch( address from, address to, uint[] calldata tokenIds, bytes calldata data ) external override{ for(uint i; i < tokenIds.length; ++i ){ safeTransferFrom( from, to, tokenIds[i], data ); } } function walletOfOwner( address account ) external view virtual override returns( uint[] memory ){ uint quantity = balanceOf( account ); uint[] memory wallet = new uint[]( quantity ); for( uint i; i < quantity; ++i ){ wallet[i] = tokenOfOwnerByIndex( account, i ); } return wallet; } }
75,167
329
// No overflow check are needed for the amount since it's never casted to `int` and Solidity 0.8.0 automatically handles overflows
col.token.safeTransferFrom(msg.sender, address(poolManager), amount);
col.token.safeTransferFrom(msg.sender, address(poolManager), amount);
44,290
54
// It is important to place this if because the recipient can call this function again as part of the receiving call before `transfer` returns .
if (transportDeposit[_id] - selectedProduct.lowestBid >= 0 && !selectedProduct.ended) { selectedProduct.lowestBidder.transfer(selectedProduct.lowestBid + selectedProduct.lowestBid); uint tax = chargeTax(selectedProduct.lowestBid, selectedProduct.beneficiary); uint sub = selectedProduct.lowestBid + tax; transportDeposit[_id] -= sub; }
if (transportDeposit[_id] - selectedProduct.lowestBid >= 0 && !selectedProduct.ended) { selectedProduct.lowestBidder.transfer(selectedProduct.lowestBid + selectedProduct.lowestBid); uint tax = chargeTax(selectedProduct.lowestBid, selectedProduct.beneficiary); uint sub = selectedProduct.lowestBid + tax; transportDeposit[_id] -= sub; }
40,952
69
// If we overflow on multiplication it should not revert tx, we will get lower fees
protocolShare = accruedInterest * protocolShareFee / SolvencyV2._PRECISION_DECIMALS; newProtocolFees = protocolFeesCached + protocolShare; if (newProtocolFees < protocolFeesCached) { protocolShare = type(uint256).max - protocolFeesCached; newProtocolFees = type(uint256).max; }
protocolShare = accruedInterest * protocolShareFee / SolvencyV2._PRECISION_DECIMALS; newProtocolFees = protocolFeesCached + protocolShare; if (newProtocolFees < protocolFeesCached) { protocolShare = type(uint256).max - protocolFeesCached; newProtocolFees = type(uint256).max; }
8,547
2
// Register a name, or change the owner of an existing registration. subnode The hash of the label to register. owner The address of the new owner. /
function register(bytes32 subnode, address owner) public only_owner(subnode) { engns.setSubnodeOwner(rootNode, subnode, owner); }
function register(bytes32 subnode, address owner) public only_owner(subnode) { engns.setSubnodeOwner(rootNode, subnode, owner); }
20,243