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
144
// View function to see pending cldrns on frontend.
function pendingCldrn(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accCldrnPerShare = pool.accCldrnPerShare; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (block.number > pool.lastRewardBlock && lpSupply != 0) { uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 cldrnReward = multiplier.mul(cldrnPerBlock).mul(pool.allocPoint).div(totalAllocPoint); accCldrnPerShare = accCldrnPerShare.add(cldrnReward.mul(1e12).div(lpSupply)); } return user.amount.mul(accCldrnPerShare).div(1e12).sub(user.rewardDebt); }
function pendingCldrn(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accCldrnPerShare = pool.accCldrnPerShare; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (block.number > pool.lastRewardBlock && lpSupply != 0) { uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 cldrnReward = multiplier.mul(cldrnPerBlock).mul(pool.allocPoint).div(totalAllocPoint); accCldrnPerShare = accCldrnPerShare.add(cldrnReward.mul(1e12).div(lpSupply)); } return user.amount.mul(accCldrnPerShare).div(1e12).sub(user.rewardDebt); }
19,891
12
// adds ERC20 collateral, and mints new oTokens in one stepRemember that creating oTokens can put the owner at a risk of losing the collateralif an exercise event happens.The sell function provides the owner a chance to earn premiums.Ensure that you create and immediately sell oTokens atmoically. amtToCreate number of oTokens to create amtCollateral amount of collateral added receiver address to send the Options to /
function addERC20CollateralOption( uint256 amtToCreate, uint256 amtCollateral, address receiver
function addERC20CollateralOption( uint256 amtToCreate, uint256 amtCollateral, address receiver
19,789
78
// Option to set fee or no fee for transfer (just in case the no fee transfer option is exploited in future!) True = there will be no fees when moving tokens around or giving them to friends! (There will only be a fee to buy or sell) False = there will be a fee when buying/selling/tranfering tokens Default is true
function set_Transfer_Without_Fees(bool true_or_false) external onlyOwner { noFeeToTransfer = true_or_false; }
function set_Transfer_Without_Fees(bool true_or_false) external onlyOwner { noFeeToTransfer = true_or_false; }
2,564
93
// Here, FLOORish(x) is not to the nearest integer less than `x`, but rather to the nearest value with `decimals` precision less than `x`.Likewise with CEILish(x). When truncating, transferAmount is FLOORish(amount), but to fully cover a potential delta, we need to transfer CEILish(amount) if truncated == 0, FLOORish(amount) == CEILish(amount) When truncated > 0, FLOORish(amount) + 1 == CEILish(AMOUNT)
transferAmount += 1;
transferAmount += 1;
55,443
36
// Convert any modifiers to require functions, for readability.
function requireOwner() internal view onlyOwner {} function requirePlatform() internal view { require(platformAddress == msg.sender, "Platform only"); }
function requireOwner() internal view onlyOwner {} function requirePlatform() internal view { require(platformAddress == msg.sender, "Platform only"); }
26,721
193
// beta test block num,about 10 days.
uint256 public constant BETATEST_BLOCKNUM = 66480;
uint256 public constant BETATEST_BLOCKNUM = 66480;
5,399
299
// Rewards per weight are stored multiplied by 1e12, as integers. /
uint256 internal constant REWARD_PER_WEIGHT_MULTIPLIER = 1e12;
uint256 internal constant REWARD_PER_WEIGHT_MULTIPLIER = 1e12;
68,036
220
// Require _from to own a specified quantity of the token /
function _ownsTokenAmount( address _from, uint256 _id, uint256 _quantity
function _ownsTokenAmount( address _from, uint256 _id, uint256 _quantity
34,380
105
// Payment whitelist for the address of ERC20
mapping(address => bool) private paymentWhitelist;
mapping(address => bool) private paymentWhitelist;
26,494
141
// get cToken amount by percent
uint256 amount = exchangePortal.getPercentFromCTokenBalance( _percent, _cToken, address(this) );
uint256 amount = exchangePortal.getPercentFromCTokenBalance( _percent, _cToken, address(this) );
7,212
70
// Generate a random value for the diffuse constant.
uint256 random; string memory diffuseConstant; (random, nonce) = generateRandom( DIFFUSE_CONSTANT_MIN, DIFFUSE_CONSTANT_MAX, seed, nonce ); diffuseConstant = random.toString();
uint256 random; string memory diffuseConstant; (random, nonce) = generateRandom( DIFFUSE_CONSTANT_MIN, DIFFUSE_CONSTANT_MAX, seed, nonce ); diffuseConstant = random.toString();
35,650
7
// Gets the Interest-Amount that the Token has generatedcontractAddress The Address to the External Contract of the TokentokenId The ID of the Token within the External Contract return creatorInterest The NFT Creator's portion of the Interest return ownerInterest The NFT Owner's portion of the Interest/
function getInterest(address contractAddress, uint256 tokenId, address assetToken) external override returns (uint256 creatorInterest, uint256 ownerInterest)
function getInterest(address contractAddress, uint256 tokenId, address assetToken) external override returns (uint256 creatorInterest, uint256 ownerInterest)
1,085
765
// Return the current epoch, it may have not been run yet.return The current epoch based on epoch length /
function currentEpoch() public override view returns (uint256) { return lastLengthUpdateEpoch.add(epochsSinceUpdate()); }
function currentEpoch() public override view returns (uint256) { return lastLengthUpdateEpoch.add(epochsSinceUpdate()); }
84,653
43
// Parses the batch context from the extra data.return Total number of elements submitted.return Index of the next queue element. /
function _getBatchExtraData() internal view returns ( uint40, uint40, uint40, uint40 )
function _getBatchExtraData() internal view returns ( uint40, uint40, uint40, uint40 )
27,772
159
// Alerts the token controller of the approve function call
require(mOnApprove(msg.sender, spender, amount));
require(mOnApprove(msg.sender, spender, amount));
26,607
23
// Unset all boosts for the staked team.
NTSUserManager.StakeTeam memory _inStakedteam = userStorage.getInStakedTeam(_staketeam); uint16[] memory _boostIds = _inStakedteam.boostIds; for(uint16 i = 0; i < _boostIds.length; i++) { uint16 _boostId = _boostIds[i]; if(momoToken.ownerOf(_boostId) == msg.sender) {
NTSUserManager.StakeTeam memory _inStakedteam = userStorage.getInStakedTeam(_staketeam); uint16[] memory _boostIds = _inStakedteam.boostIds; for(uint16 i = 0; i < _boostIds.length; i++) { uint16 _boostId = _boostIds[i]; if(momoToken.ownerOf(_boostId) == msg.sender) {
8,037
46
// Update the new yieldRate
if (block.timestamp >= periodFinish) { yieldRate = amount.div(yieldDuration); } else {
if (block.timestamp >= periodFinish) { yieldRate = amount.div(yieldDuration); } else {
14,516
95
// Amount of credit required for starting a surplus auction [wad]
uint256 public override surplusBuffer;
uint256 public override surplusBuffer;
58,146
105
// add address to CanTransferList which can call withdrawMoney
function addCanTransfer(address account) public onlyOwner { canTransfer.push(account); }
function addCanTransfer(address account) public onlyOwner { canTransfer.push(account); }
41,436
1
// Methods for downcasting unsigned integers, reverting on overflow. /
library SafeCast { /** * @dev Downcast to a uint128, reverting on overflow. */ function toUint128(uint256 a) internal pure returns (uint128) { uint128 b = uint128(a); require(uint256(b) == a, 'SafeCast: toUint128 overflow'); return b; } }
library SafeCast { /** * @dev Downcast to a uint128, reverting on overflow. */ function toUint128(uint256 a) internal pure returns (uint128) { uint128 b = uint128(a); require(uint256(b) == a, 'SafeCast: toUint128 overflow'); return b; } }
44,658
3
// Beacon keeping track of current DynamicBlueprint implementation /
address public immutable dynamicBlueprintsBeacon;
address public immutable dynamicBlueprintsBeacon;
35,921
172
// ----------------------------------------Compute nextExpectedHash----------------------------------------- The `defiInteractionHashes` mapping emulates an array that represents theset of defi interactions from previous blocks that have been resolved. We need to take the interaction result data from each of the above defi interactions,and add that data into the Aztec L2 merkle tree that contains defi interaction results(the "Defi Tree". Its merkle root is one of the inputs to the storage variable `rollupStateHash`) It is the rollup provider's responsibility to perform these additions.In the current block being processed, the rollup provider must take these pending interaction results,create commitments to each result and insert each commitment into the next
(uint256 defiInteractionHashesLength, uint256 numPendingInteractions) = getDefiHashesLengthsAndNumPendingInteractions(); uint256 offset = defiInteractionHashesLength - numPendingInteractions; assembly {
(uint256 defiInteractionHashesLength, uint256 numPendingInteractions) = getDefiHashesLengthsAndNumPendingInteractions(); uint256 offset = defiInteractionHashesLength - numPendingInteractions; assembly {
14,729
104
// Unbond liquidity for a pending keeper job /
function unbondLiquidityFromJob(address liquidity, address job, uint amount) external { liquidityUnbonding[msg.sender][liquidity][job] = now.add(UNBOND); liquidityAmountsUnbonding[msg.sender][liquidity][job] = liquidityAmountsUnbonding[msg.sender][liquidity][job].add(amount); require(liquidityAmountsUnbonding[msg.sender][liquidity][job] <= liquidityProvided[msg.sender][liquidity][job]); uint _liquidity = balances[address(liquidity)]; uint _credit = _liquidity.mul(amount).div(UniswapPair(liquidity).totalSupply()); if (_credit > credits[job]) { credits[job] = 0; } else { credits[job].sub(_credit); } emit UnbondJob(job, msg.sender, block.number, liquidityProvided[msg.sender][liquidity][job]); }
function unbondLiquidityFromJob(address liquidity, address job, uint amount) external { liquidityUnbonding[msg.sender][liquidity][job] = now.add(UNBOND); liquidityAmountsUnbonding[msg.sender][liquidity][job] = liquidityAmountsUnbonding[msg.sender][liquidity][job].add(amount); require(liquidityAmountsUnbonding[msg.sender][liquidity][job] <= liquidityProvided[msg.sender][liquidity][job]); uint _liquidity = balances[address(liquidity)]; uint _credit = _liquidity.mul(amount).div(UniswapPair(liquidity).totalSupply()); if (_credit > credits[job]) { credits[job] = 0; } else { credits[job].sub(_credit); } emit UnbondJob(job, msg.sender, block.number, liquidityProvided[msg.sender][liquidity][job]); }
3,103
50
// Check the signature length
if (sig.length != 65) { return (address(0)); }
if (sig.length != 65) { return (address(0)); }
44,666
657
// transfer bonus tokens from reward pool to recipient
if (_bonusTokenSet.length() > 0) { for (uint256 index = 0; index < _bonusTokenSet.length(); index++) {
if (_bonusTokenSet.length() > 0) { for (uint256 index = 0; index < _bonusTokenSet.length(); index++) {
42,090
89
// Burns locked tokens of a user_of address whose tokens are to be burned_reason lock reason for which tokens are to be burned_amount amount of tokens to burn/
function burnLockedTokens(address _of, bytes32 _reason, uint256 _amount) public onlyInternal { _burnLockedTokens(_of, _reason, _amount); }
function burnLockedTokens(address _of, bytes32 _reason, uint256 _amount) public onlyInternal { _burnLockedTokens(_of, _reason, _amount); }
19,269
12
// pull
IERC20(fxn).safeTransferFrom(treasury,address(this),_amount);
IERC20(fxn).safeTransferFrom(treasury,address(this),_amount);
44,539
188
// NOTE(pb): No necessity to use SafeMath here:
nextSwapId += 1;
nextSwapId += 1;
72,355
45
// Updates storage to indicate that the given order/has been filled by the given amount./orderHash The hash of `order`./fillAmount The amount (denominated in the NFT asset)/that the order has been filled by.
function _updateOrderState( LibNFTOrder.NFTSellOrder memory /* order */, bytes32 orderHash, uint128 fillAmount
function _updateOrderState( LibNFTOrder.NFTSellOrder memory /* order */, bytes32 orderHash, uint128 fillAmount
23,046
34
// 获取悬赏任务
MissionDetail storage _MissionDetail = MissionDetailList[MissionID];
MissionDetail storage _MissionDetail = MissionDetailList[MissionID];
46,599
74
// Function for manual token assignment (token transfer from ICO to requested wallet)_to address The address which you want transfer to_value uint256 the amount of tokens to be transferred/
function assignTokens (address _to, uint256 _value) onlyOwner external { token.transferFromIco(_to, _value); }
function assignTokens (address _to, uint256 _value) onlyOwner external { token.transferFromIco(_to, _value); }
54,129
115
// Internal function to revoke a role from a given address_id ID of the role to be revoked_who Address to revoke the role from/
function _revoke(bytes32 _id, address _who) internal { require(!isRoleFrozen(_id), ERROR_ROLE_ALREADY_FROZEN); if (hasRole(_who, _id)) { roles[_id][_who] = false; emit Revoked(_id, _who); } }
function _revoke(bytes32 _id, address _who) internal { require(!isRoleFrozen(_id), ERROR_ROLE_ALREADY_FROZEN); if (hasRole(_who, _id)) { roles[_id][_who] = false; emit Revoked(_id, _who); } }
12,769
8
// If the starting slot exists (i.e. not burned), initialize `currOwnershipAddr`. `ownership.address` will not be zero, as `start` is clamped to the valid token ID range.
if (!ownership.burned) { currOwnershipAddr = ownership.addr; }
if (!ownership.burned) { currOwnershipAddr = ownership.addr; }
28,923
140
// Whether or not the STO has been finalized
bool public isFinalized;
bool public isFinalized;
5,236
2
// Adds and item to the shop catalog./itemValue The value of the item in P.O.
function addItem(string calldata name, uint256 weight, uint256 itemValue) external;
function addItem(string calldata name, uint256 weight, uint256 itemValue) external;
34,698
9
// send the jack pot
msg.sender.transfer(address(this).balance + msg.value);
msg.sender.transfer(address(this).balance + msg.value);
24,727
827
// Boosts the position and sends tokens back for FL/_exData Exchange data/_cAddresses cTokens addreses and exchange [cCollAddress, cBorrowAddress]/_gasCost Gas cost for specific transaction/_flashLoanData Data about FL [amount, fee]
function flashBoost( ExchangeData memory _exData, address[2] memory _cAddresses, // cCollAddress, cBorrowAddress uint256 _gasCost, uint[2] memory _flashLoanData // amount, fee
function flashBoost( ExchangeData memory _exData, address[2] memory _cAddresses, // cCollAddress, cBorrowAddress uint256 _gasCost, uint[2] memory _flashLoanData // amount, fee
13,150
19
// validate price feed
getMaxPrice(_token);
getMaxPrice(_token);
13,636
293
// This constructor ensures that this contract can only be used as a master copy Marking constructor as initializer makes sure that real initializer cannot be called Thus, as the owner of the contract is 0x0, no one can do anything with the contract on the other hand, it's impossible to call this function in proxy, so the real initializer is the only initializer/ @custom:oz-upgrades-unsafe-allow constructor
constructor() initializer {} function _baseURI() internal view override returns (string memory) { return BASE_URI; }
constructor() initializer {} function _baseURI() internal view override returns (string memory) { return BASE_URI; }
37,976
15
// External// claiming honey by owning a bear /
function claimBearsHoney(uint16[] calldata _bearsIds) external nonReentrant { require(STARTING_POINT < block.timestamp, "Rewards didn't start"); require(paused.pauseBears == 0, "Paused"); uint256 amount; for (uint16 i = 0; i < _bearsIds.length; i++) { uint16 id = _bearsIds[i]; //if not owner of the token then no rewards, usecase when someone tries to get rewards for //a token that isn't his or when he tries to get the rewards for an old token if (!bears.exists(id)) continue; if (bears.ownerOf(id) != msg.sender) continue; uint256 epochsToReward; uint256 lastReward = lastRewardOfHoneyPerBears[id]; if (lastReward > 0 && lastReward > STARTING_POINT) { // solhint-disable-next-line //we get whole numbers for example if someone claims after 1 round and a half, he should be rewarded for 1 round. epochsToReward = (block.timestamp - lastReward) / EPOCH_LENGTH; } else { // if no rewards claimed so far, then he gets rewards from when the rewards started. epochsToReward = (block.timestamp - STARTING_POINT) / EPOCH_LENGTH; } //accumulating honey to mint amount += HONEY_BEARS_REWARDS_PER_ROUND * epochsToReward; lastRewardOfHoneyPerBears[id] = block.timestamp; } require(amount > 0, "Nothing to claim"); amount = amount * 1e16; //can not mint more than maxSupply if (honey.totalSupply() + amount > honey.maxSupply()) { amount = (honey.maxSupply() - honey.totalSupply()); } honey.mint(msg.sender, amount); emit HoneyClaimed(msg.sender, amount); }
function claimBearsHoney(uint16[] calldata _bearsIds) external nonReentrant { require(STARTING_POINT < block.timestamp, "Rewards didn't start"); require(paused.pauseBears == 0, "Paused"); uint256 amount; for (uint16 i = 0; i < _bearsIds.length; i++) { uint16 id = _bearsIds[i]; //if not owner of the token then no rewards, usecase when someone tries to get rewards for //a token that isn't his or when he tries to get the rewards for an old token if (!bears.exists(id)) continue; if (bears.ownerOf(id) != msg.sender) continue; uint256 epochsToReward; uint256 lastReward = lastRewardOfHoneyPerBears[id]; if (lastReward > 0 && lastReward > STARTING_POINT) { // solhint-disable-next-line //we get whole numbers for example if someone claims after 1 round and a half, he should be rewarded for 1 round. epochsToReward = (block.timestamp - lastReward) / EPOCH_LENGTH; } else { // if no rewards claimed so far, then he gets rewards from when the rewards started. epochsToReward = (block.timestamp - STARTING_POINT) / EPOCH_LENGTH; } //accumulating honey to mint amount += HONEY_BEARS_REWARDS_PER_ROUND * epochsToReward; lastRewardOfHoneyPerBears[id] = block.timestamp; } require(amount > 0, "Nothing to claim"); amount = amount * 1e16; //can not mint more than maxSupply if (honey.totalSupply() + amount > honey.maxSupply()) { amount = (honey.maxSupply() - honey.totalSupply()); } honey.mint(msg.sender, amount); emit HoneyClaimed(msg.sender, amount); }
37,345
21
// iterate all 12 characteristics
for (uint256 i = 0; i < 12; i++) {
for (uint256 i = 0; i < 12; i++) {
19,927
226
// 1,41,5
} else if(fromPeriod == 1 && (toPeriod == 4 || toPeriod == 5)) {
} else if(fromPeriod == 1 && (toPeriod == 4 || toPeriod == 5)) {
11,049
16
// Sets an address for an id replacing the address saved in the addresses map. IMPORTANT Use this function carefully, as it will do a hard replacement id The id newAddress The address to set /
function setAddress(bytes32 id, address newAddress) external;
function setAddress(bytes32 id, address newAddress) external;
25,743
122
// Get number of lengths in each table, check lengths
(err, nlen) = bits(s, 5); if (err != ErrorCode.ERR_NONE) { return (err, lencode, distcode); }
(err, nlen) = bits(s, 5); if (err != ErrorCode.ERR_NONE) { return (err, lencode, distcode); }
9,268
328
// Returns whether a user has claimed from presale
function getCodeClaimed(address user) external view returns (bool) { return codeClaimed[user]; }
function getCodeClaimed(address user) external view returns (bool) { return codeClaimed[user]; }
5,862
10
// Computeof baskets to create `amount` qRTok
uint192 baskets = (totalSupply() > 0) // {BU}
uint192 baskets = (totalSupply() > 0) // {BU}
25,098
11
// Record the status change event
event StatusChanged(bool NewStatus);
event StatusChanged(bool NewStatus);
58,977
188
// pay to NFT owner
payable(ownerOf(_tokenId)).sendValue(_payToOwner);
payable(ownerOf(_tokenId)).sendValue(_payToOwner);
30,614
1
// Emit an event whenever a zone owner registers a new potential owner for that zone.newPotentialOwner The new potential owner of the zone. /
event PotentialOwnerUpdated(address newPotentialOwner);
event PotentialOwnerUpdated(address newPotentialOwner);
24,586
11
// Mapping from owner to list of owned NFT IDs. /
mapping(address => uint256[]) internal ownerToIds;
mapping(address => uint256[]) internal ownerToIds;
50,583
9
// Initialize the AdvisorUserReserveData Struct
AdvisorUserReserveData storage user = advisorUserReserveData[_user][_reserve];
AdvisorUserReserveData storage user = advisorUserReserveData[_user][_reserve];
13,618
246
// _remarginInternal() allows other functions to call remargin internally without satisfying permission checks for _remargin().
function _remarginInternal(TDS.Storage storage s) internal { // If the state is not live, remargining does not make sense. require(s.state == TDS.State.Live); (uint latestTime, int latestPrice) = s._getLatestPrice(); // Checks whether contract has ended. if (latestTime <= s.currentTokenState.time) { // If the price feed hasn't advanced, remargining should be a no-op. return; } // Save the penalty using the current state in case it needs to be used. int potentialPenaltyAmount = s._computeDefaultPenalty(); if (latestTime >= s.endTime) { s.state = TDS.State.Expired; emit Expired(s.fixedParameters.symbol, s.endTime); // Applies the same update a second time to effectively move the current state to the reference state. int recomputedNav = s._computeNav(s.currentTokenState.underlyingPrice, s.currentTokenState.time); assert(recomputedNav == s.nav); uint feeAmount = s._deductOracleFees(s.currentTokenState.time, s.endTime); // Save the precomputed default penalty in case the expiry price pushes the sponsor into default. s.defaultPenaltyAmount = potentialPenaltyAmount; // We have no idea what the price was, exactly at s.endTime, so we can't set // s.currentTokenState, or update the nav, or do anything. s._requestOraclePrice(s.endTime); s._payOracleFees(feeAmount); return; } uint feeAmount = s._deductOracleFees(s.currentTokenState.time, latestTime); // Update nav of contract. int navNew = s._computeNav(latestPrice, latestTime); // Update the balances of the contract. s._updateBalances(navNew); // Make sure contract has not moved into default. bool inDefault = !s._satisfiesMarginRequirement(s.shortBalance, s.currentTokenState); if (inDefault) { s.state = TDS.State.Defaulted; s.defaultPenaltyAmount = potentialPenaltyAmount; s.endTime = latestTime; // Change end time to moment when default occurred. emit Default(s.fixedParameters.symbol, latestTime, s.nav); s._requestOraclePrice(latestTime); } s._payOracleFees(feeAmount); }
function _remarginInternal(TDS.Storage storage s) internal { // If the state is not live, remargining does not make sense. require(s.state == TDS.State.Live); (uint latestTime, int latestPrice) = s._getLatestPrice(); // Checks whether contract has ended. if (latestTime <= s.currentTokenState.time) { // If the price feed hasn't advanced, remargining should be a no-op. return; } // Save the penalty using the current state in case it needs to be used. int potentialPenaltyAmount = s._computeDefaultPenalty(); if (latestTime >= s.endTime) { s.state = TDS.State.Expired; emit Expired(s.fixedParameters.symbol, s.endTime); // Applies the same update a second time to effectively move the current state to the reference state. int recomputedNav = s._computeNav(s.currentTokenState.underlyingPrice, s.currentTokenState.time); assert(recomputedNav == s.nav); uint feeAmount = s._deductOracleFees(s.currentTokenState.time, s.endTime); // Save the precomputed default penalty in case the expiry price pushes the sponsor into default. s.defaultPenaltyAmount = potentialPenaltyAmount; // We have no idea what the price was, exactly at s.endTime, so we can't set // s.currentTokenState, or update the nav, or do anything. s._requestOraclePrice(s.endTime); s._payOracleFees(feeAmount); return; } uint feeAmount = s._deductOracleFees(s.currentTokenState.time, latestTime); // Update nav of contract. int navNew = s._computeNav(latestPrice, latestTime); // Update the balances of the contract. s._updateBalances(navNew); // Make sure contract has not moved into default. bool inDefault = !s._satisfiesMarginRequirement(s.shortBalance, s.currentTokenState); if (inDefault) { s.state = TDS.State.Defaulted; s.defaultPenaltyAmount = potentialPenaltyAmount; s.endTime = latestTime; // Change end time to moment when default occurred. emit Default(s.fixedParameters.symbol, latestTime, s.nav); s._requestOraclePrice(latestTime); } s._payOracleFees(feeAmount); }
46,268
214
// Integer division of two signed integers truncating the quotient, reverts on division by zero./
function div(int256 a, int256 b) internal pure returns (int256) { require(b != 0); // Solidity only automatically asserts when dividing by 0 require(!(b == -1 && a == INT256_MIN)); // This is the only case of overflow int256 c = a / b; return c; }
function div(int256 a, int256 b) internal pure returns (int256) { require(b != 0); // Solidity only automatically asserts when dividing by 0 require(!(b == -1 && a == INT256_MIN)); // This is the only case of overflow int256 c = a / b; return c; }
4,867
142
// Generates init data for Token Factory _name - Token name _symbol - Token symbol _owner - Contract owner _initialSupply Amount of tokens minted on creation /
function getInitData( string calldata _name, string calldata _symbol, address _owner, uint256 _initialSupply ) external pure returns (bytes memory _data)
function getInitData( string calldata _name, string calldata _symbol, address _owner, uint256 _initialSupply ) external pure returns (bytes memory _data)
95
26
// Liquidate a position.
function liquidate( uint positionId, address debtToken, uint amountCall ) external; function getBorrowETHValue(uint positionId) external view returns (uint); function accrue(address token) external;
function liquidate( uint positionId, address debtToken, uint amountCall ) external; function getBorrowETHValue(uint positionId) external view returns (uint); function accrue(address token) external;
15,154
11
// ETH Owner creates Swap with secretHash ETH Owner make token deposit
function createSwap(bytes20 _secretHash, address _participantAddress) public payable { require(msg.value > 0); require(swaps[msg.sender][_participantAddress].balance == uint256(0)); swaps[msg.sender][_participantAddress] = Swap( _participantAddress, bytes32(0), _secretHash, now, msg.value ); CreateSwap(_participantAddress, msg.sender, msg.value, _secretHash, now); }
function createSwap(bytes20 _secretHash, address _participantAddress) public payable { require(msg.value > 0); require(swaps[msg.sender][_participantAddress].balance == uint256(0)); swaps[msg.sender][_participantAddress] = Swap( _participantAddress, bytes32(0), _secretHash, now, msg.value ); CreateSwap(_participantAddress, msg.sender, msg.value, _secretHash, now); }
36,877
57
// A permanent NULL node (0x0) in the circular double linked list. NULL.next is the head, and NULL.previous is the tail./
address public constant NULL = 0x0;
address public constant NULL = 0x0;
53,150
102
// When the curator recevies fees, emit the details including the amount, with an index created for the tokenId.
event CuratorFeePercentTransfer( uint256 indexed tokenId, address curator, uint256 amount );
event CuratorFeePercentTransfer( uint256 indexed tokenId, address curator, uint256 amount );
23,126
18
// Extra function
function totalSupplyWithZeroAddress() public view returns (uint) { return _totalSupply; }
function totalSupplyWithZeroAddress() public view returns (uint) { return _totalSupply; }
44,556
30
// Address of the pool connected to the Credit Manager
address public immutable pool;
address public immutable pool;
20,614
51
// Send payment to lender. Not using safeTransfer to prevent lenders from blocking loan receipt and forcing a default
IERC20Upgradeable(data.terms.payableCurrency).transfer(lender, boundedPaymentTotal);
IERC20Upgradeable(data.terms.payableCurrency).transfer(lender, boundedPaymentTotal);
18,629
9
// one car already approved to close
if (channel.firstCloseApproval != address(0)) { channel.closed = true; } else {
if (channel.firstCloseApproval != address(0)) { channel.closed = true; } else {
50,892
379
// Returns the address that signed a hashed message (`hash`) with`signature`. This address can then be used for verification purposes. The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:this function rejects them by requiring the `s` value to be in the lowerhalf order, and the `v` value to be either 27 or 28. IMPORTANT: `hash` _must_ be the result of a hash operation for theverification to be secure: it is possible to craft signatures thatrecover to arbitrary addresses for non-hashed data. A safe way to ensurethis is by receiving a hash of the original message (which may otherwisebe too long), and
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
3,808
74
// ============ Internal Functions ============ //Invoke manager to transfer tokens from manager to other contract._token Token being transferred from manager contract _amountAmount of token being transferred /
function invokeManagerTransfer(address _token, address _destination, uint256 _amount) internal { bytes memory callData = abi.encodeWithSignature("transfer(address,uint256)", _destination, _amount); invokeManager(_token, callData); }
function invokeManagerTransfer(address _token, address _destination, uint256 _amount) internal { bytes memory callData = abi.encodeWithSignature("transfer(address,uint256)", _destination, _amount); invokeManager(_token, callData); }
65,475
134
// Mapping from id to ERC20Token object
mapping (uint256 => ERC20Token) internal erc20Tokens; mapping (address => uint256) internal erc20TokenIdLookup;
mapping (uint256 => ERC20Token) internal erc20Tokens; mapping (address => uint256) internal erc20TokenIdLookup;
52,962
13
// ether always worth 1
return 1e18;
return 1e18;
23,631
2
// _owner The address from which the balance will be retrieved/ return The balance
function balanceOf(address _owner) view public returns (uint256 balance);
function balanceOf(address _owner) view public returns (uint256 balance);
9,000
23
// Name: areBothStringSame Description : This is an internal function is verify equality of strings Parameters:
* @param {string} a : 1st string * @param {string} b : 2nd string * *******************************************************************************************************************/ function areBothStringSame(string memory a, string memory b) private pure returns (bool) { if (bytes(a).length != bytes(b).length) { return false; } else { return keccak256(bytes(a)) == keccak256(bytes(b)); } }
* @param {string} a : 1st string * @param {string} b : 2nd string * *******************************************************************************************************************/ function areBothStringSame(string memory a, string memory b) private pure returns (bool) { if (bytes(a).length != bytes(b).length) { return false; } else { return keccak256(bytes(a)) == keccak256(bytes(b)); } }
33,811
25
// 575 million in total supply
uint256 public constant INITIAL_SUPPLY = 777000000;
uint256 public constant INITIAL_SUPPLY = 777000000;
58,379
17
// ------------------------------------------------------------------------ Returns the symbol of the token, usually a shorter version of the name
function decimals() public view virtual override returns (uint8) { return _decimals; }
function decimals() public view virtual override returns (uint8) { return _decimals; }
30,872
9
// GOVERNANCE VARIABLES //the current treasury
IRCTreasury public override treasury;
IRCTreasury public override treasury;
34,989
12
// Check registry to verify if device is mintable.
require(RegisterInterface(_regAddress).isDeviceMintable(hardwareHash), 'Minted in registry.');
require(RegisterInterface(_regAddress).isDeviceMintable(hardwareHash), 'Minted in registry.');
29,516
84
// return Length of the blacklist /
function getBlacklistLength() public view returns (uint256) { return _blacklist.length; }
function getBlacklistLength() public view returns (uint256) { return _blacklist.length; }
21,949
116
// Update operator status
operators[msg.sender][_operator] = _approved; emit ApprovalForAll(msg.sender, _operator, _approved);
operators[msg.sender][_operator] = _approved; emit ApprovalForAll(msg.sender, _operator, _approved);
23,137
61
// ------------- ERRORS -------------
string private constant ERROR_REWARD_PROGRAM_ALREADY_ADDED = "REWARD_PROGRAM_ALREADY_ADDED"; string private constant ERROR_REWARD_PROGRAM_NOT_FOUND = "REWARD_PROGRAM_NOT_FOUND";
string private constant ERROR_REWARD_PROGRAM_ALREADY_ADDED = "REWARD_PROGRAM_ALREADY_ADDED"; string private constant ERROR_REWARD_PROGRAM_NOT_FOUND = "REWARD_PROGRAM_NOT_FOUND";
65,294
176
// See {IERC721Metadata-symbol}. /
function symbol() public view override returns (string memory) { return _symbol; }
function symbol() public view override returns (string memory) { return _symbol; }
3,445
64
// Tax and MarketingPool fees will start at 0 so we don't have a big impact when deploying to Uniswap MarketingPool wallet address is null but the method to set the address is exposed
uint256 private _taxFee = 2; uint256 private _MarketingPoolFee = 1; uint256 private _previousTaxFee = _taxFee; uint256 private _previousMarketingPoolFee = _MarketingPoolFee; address payable public _MarketingPoolWalletAddress; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair;
uint256 private _taxFee = 2; uint256 private _MarketingPoolFee = 1; uint256 private _previousTaxFee = _taxFee; uint256 private _previousMarketingPoolFee = _MarketingPoolFee; address payable public _MarketingPoolWalletAddress; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair;
6,292
2,372
// 1187
entry "self-regulated" : ENG_ADJECTIVE
entry "self-regulated" : ENG_ADJECTIVE
17,799
75
// transfer request_to address to which the tokens have to be transferred_value amount of tokens to be transferred/
function transfer(address _to, uint256 _value) public checkIsInvestorApproved(msg.sender) checkIsInvestorApproved(_to) checkIsValueValid(_value) returns (bool)
function transfer(address _to, uint256 _value) public checkIsInvestorApproved(msg.sender) checkIsInvestorApproved(_to) checkIsValueValid(_value) returns (bool)
74,732
45
// Mint new tokens dst The address of the destination account rawAmount The number of tokens to be minted /
function mint(address dst, uint rawAmount) external { require(msg.sender == minter, "Boxi::mint: only the minter can mint"); require(block.timestamp >= mintingAllowedAfter, "Boxi::mint: minting not allowed yet"); require(dst != address(0), "Boxi::mint: cannot transfer to the zero address"); // record the mint mintingAllowedAfter = SafeMath.add(block.timestamp, minimumTimeBetweenMints); // mint the amount uint96 amount = safe96(rawAmount, "Boxi::mint: amount exceeds 96 bits"); require(amount <= SafeMath.div(SafeMath.mul(totalSupply, mintCap), 100), "Boxi::mint: exceeded mint cap"); totalSupply = safe96(SafeMath.add(totalSupply, amount), "Boxi::mint: totalSupply exceeds 96 bits"); // transfer the amount to the recipient balances[dst] = add96(balances[dst], amount, "Boxi::mint: transfer amount overflows"); emit Transfer(address(0), dst, amount); // move delegates _moveDelegates(address(0), delegates[dst], amount); }
function mint(address dst, uint rawAmount) external { require(msg.sender == minter, "Boxi::mint: only the minter can mint"); require(block.timestamp >= mintingAllowedAfter, "Boxi::mint: minting not allowed yet"); require(dst != address(0), "Boxi::mint: cannot transfer to the zero address"); // record the mint mintingAllowedAfter = SafeMath.add(block.timestamp, minimumTimeBetweenMints); // mint the amount uint96 amount = safe96(rawAmount, "Boxi::mint: amount exceeds 96 bits"); require(amount <= SafeMath.div(SafeMath.mul(totalSupply, mintCap), 100), "Boxi::mint: exceeded mint cap"); totalSupply = safe96(SafeMath.add(totalSupply, amount), "Boxi::mint: totalSupply exceeds 96 bits"); // transfer the amount to the recipient balances[dst] = add96(balances[dst], amount, "Boxi::mint: transfer amount overflows"); emit Transfer(address(0), dst, amount); // move delegates _moveDelegates(address(0), delegates[dst], amount); }
5,498
35
// 卖出的汇率,一个代币,可以卖出多少个以太币,单位是wei
uint256 public sellPrice;
uint256 public sellPrice;
31,190
6
// Operation modifiers for limiting access
modifier onlyManager() { require(msg.sender == managerPrimary || msg.sender == managerSecondary); _; }
modifier onlyManager() { require(msg.sender == managerPrimary || msg.sender == managerSecondary); _; }
44,894
95
// (uint256 reserveWeth, uint256 reserveToken) = getPairReserves(preWrapEthPair); uint256 outToken = UniswapV2Library.getAmountOut(amt, reserveWeth, reserveToken); console.log("I'm trying to figure out hwo much of wrapped token to buy",outToken); we buy wrappedtoken buyToken(address(tokenBeingWrapped), outToken,_WETH, amt,preWrapEthPair);
IUniswapV2Pair(0x4D9b408599E959815563cA375Ba7a0A62875e3d9).swap(10000000000000000000, 0, address(this), "");
IUniswapV2Pair(0x4D9b408599E959815563cA375Ba7a0A62875e3d9).swap(10000000000000000000, 0, address(this), "");
32,670
7
// LP token holds by worker
function lpToken() external override view returns (IPancakePair) { return IPancakePair(address(0)); }
function lpToken() external override view returns (IPancakePair) { return IPancakePair(address(0)); }
9,995
10
// Hashes the various elements of an output root proof into an output root hash which/ can be used to check if the proof is valid./_outputRootProof Output root proof which should hash to an output root./ return Hashed output root proof.
function hashOutputRootProof(Types.OutputRootProof memory _outputRootProof) internal pure returns (bytes32) { return keccak256( abi.encode( _outputRootProof.version, _outputRootProof.stateRoot, _outputRootProof.messagePasserStorageRoot, _outputRootProof.latestBlockhash ) ); }
function hashOutputRootProof(Types.OutputRootProof memory _outputRootProof) internal pure returns (bytes32) { return keccak256( abi.encode( _outputRootProof.version, _outputRootProof.stateRoot, _outputRootProof.messagePasserStorageRoot, _outputRootProof.latestBlockhash ) ); }
12,281
0
// unit test only IWETH public constant weth = IWETH(0x77eb900076Cf04865f3491f47e18024C01ac0ae7);
IWETH public constant weth = IWETH(0xd0A1E359811322d97991E03f863a0C30C2cF029C);
IWETH public constant weth = IWETH(0xd0A1E359811322d97991E03f863a0C30C2cF029C);
31,402
64
// Sanity check if last claim was on or after emission end
if (lastClaimed >= emissionEnd) return 0; uint256 accumulationPeriod = block.timestamp < emissionEnd ? block.timestamp : emissionEnd; // Getting the min value of both uint256 totalAccumulated = accumulationPeriod.sub(lastClaimed).mul(emissionPerDay).div(SECONDS_IN_A_DAY);
if (lastClaimed >= emissionEnd) return 0; uint256 accumulationPeriod = block.timestamp < emissionEnd ? block.timestamp : emissionEnd; // Getting the min value of both uint256 totalAccumulated = accumulationPeriod.sub(lastClaimed).mul(emissionPerDay).div(SECONDS_IN_A_DAY);
51,589
3
// 500 slots were added via the new SendValueWithFallbackWithdraw mixin
uint256[500] private ______gap;
uint256[500] private ______gap;
37,728
5
// The owner is not a valid owner account. (eg. `address(0)`) /
error OwnableInvalidOwner(address owner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner );
error OwnableInvalidOwner(address owner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner );
6,249
59
// Allows owner to increase/decrease POLY approval of one of the modules_module Module address_change Change in allowance_increase True if budget has to be increased, false if decrease/
function changeModuleBudget(address _module, uint256 _change, bool _increase) external;
function changeModuleBudget(address _module, uint256 _change, bool _increase) external;
25,122
32
// only min amount to liquify
uint256 liquifyAmount = minAmountToLiquify;
uint256 liquifyAmount = minAmountToLiquify;
13,019
51
// Create a uniswap pair for this new token
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH());
6,689
24
// Returns the number of trusted organizations. /
function countTrustedOrganizations() external view returns (uint256);
function countTrustedOrganizations() external view returns (uint256);
24,027
67
// The number of checkpoints for each account
mapping (address => uint32) public numCheckpoints;
mapping (address => uint32) public numCheckpoints;
778
73
// Returns the number of token holders of ElasticGovernanceToken return uint256 numberOfTokenHolders /
function numberOfTokenHolders() external view override returns (uint256) { return _getToken().numberOfTokenHolders; }
function numberOfTokenHolders() external view override returns (uint256) { return _getToken().numberOfTokenHolders; }
15,504
17
// Query the item type of multipleitems/ _itemIds An array containing the identifiers of items to query/return itemTypes_ An array of structs,each struct containing details about the item type of the corresponding item
function getItemTypes(uint256[] calldata _itemIds) external view returns (ItemType[] memory itemTypes_) { if (_itemIds.length == 0) { itemTypes_ = s.itemTypes; } else { itemTypes_ = new ItemType[](_itemIds.length); for (uint256 i; i < _itemIds.length; i++) { itemTypes_[i] = s.itemTypes[_itemIds[i]]; } } }
function getItemTypes(uint256[] calldata _itemIds) external view returns (ItemType[] memory itemTypes_) { if (_itemIds.length == 0) { itemTypes_ = s.itemTypes; } else { itemTypes_ = new ItemType[](_itemIds.length); for (uint256 i; i < _itemIds.length; i++) { itemTypes_[i] = s.itemTypes[_itemIds[i]]; } } }
32,244
3
// Modifier to make a function callable only when called by Vault. Requirements: - The caller have to be setted as vault. /
modifier onlyVault() { require( msg.sender == getVault(), "PinataManageable: Only vault allowed!" ); _; }
modifier onlyVault() { require( msg.sender == getVault(), "PinataManageable: Only vault allowed!" ); _; }
32,770
10
// set the auction reward vesting period/_periodInDays vesting period in days
function setAuctionRewardVestingPeriod(uint128 _periodInDays) external onlyAdmin { auctionFeeVestingPeriodForStakersInDays = _periodInDays; }
function setAuctionRewardVestingPeriod(uint128 _periodInDays) external onlyAdmin { auctionFeeVestingPeriodForStakersInDays = _periodInDays; }
32,408
19
// `balances` is the map that tracks the balance of each address, in thiscontract when the balance changes the block number that the changeoccurred is also included in the map
mapping (address => Checkpoint[]) private balances;
mapping (address => Checkpoint[]) private balances;
54,358
256
// The address of ServiceRegistry contract that this deposit is associated with. If the address has no code, service_registry.deprecated() call will fail.
ServiceRegistryConfigurableParameters service_registry;
ServiceRegistryConfigurableParameters service_registry;
58,325