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 |
|---|---|---|---|---|
16 | // firstUnstakeRequest is stored at unstakeRequests[0].next | uint public lastUnstakeRequestId;
uint public processedToStakerIndex; // we processed the action up this staker
bool public isContractStakeCalculated; // flag to indicate whether staked amount is up to date or not
| uint public lastUnstakeRequestId;
uint public processedToStakerIndex; // we processed the action up this staker
bool public isContractStakeCalculated; // flag to indicate whether staked amount is up to date or not
| 21,500 |
30 | // Returns the amount of `token` that the `user` has currently staked / | function balanceOf(address user, address token) external view returns (uint256) {
return balances[user][token];
}
| function balanceOf(address user, address token) external view returns (uint256) {
return balances[user][token];
}
| 43,746 |
208 | // increases the pool's liquidity and mints new shares in the pool to the caller note that prior to version 28, you should use 'fund' instead_reserveTokens address of each reserve token_reserveAmountsamount of each reserve token_minReturn token minimum return-amount return amount of pool tokens issued/ | function addLiquidity(IERC20Token[] memory _reserveTokens, uint256[] memory _reserveAmounts, uint256 _minReturn)
public
payable
protected
active
returns (uint256)
| function addLiquidity(IERC20Token[] memory _reserveTokens, uint256[] memory _reserveAmounts, uint256 _minReturn)
public
payable
protected
active
returns (uint256)
| 39,272 |
105 | // uint256 stateOfCharge = no1s1TechLogs[no1s1TechLogs.length-1].batterystateofcharge; | uint256 batteryLevel = uint256(no1s1BatteryLevel);
uint256 time = no1s1TechLogs[no1s1TechLogs.length-1].time;
uint256 duration;
if (batteryLevel == 0){
duration = FULL_DURATION;}
| uint256 batteryLevel = uint256(no1s1BatteryLevel);
uint256 time = no1s1TechLogs[no1s1TechLogs.length-1].time;
uint256 duration;
if (batteryLevel == 0){
duration = FULL_DURATION;}
| 17,901 |
152 | // start of constructor and destructor | constructor () public {
require (contract_created == false);
contract_created = true;
contract_address = address(this);
admin = msg.sender;
}
| constructor () public {
require (contract_created == false);
contract_created = true;
contract_address = address(this);
admin = msg.sender;
}
| 6,505 |
200 | // Sets base URI for all tokens, only able to be called by contract owner | function setBaseURI(string memory baseURI_) external onlyOwner {
_baseURIExtended = baseURI_;
}
| function setBaseURI(string memory baseURI_) external onlyOwner {
_baseURIExtended = baseURI_;
}
| 7,122 |
54 | // Reward bonus percentage, must be > 0% | uint256 rewardBonusPercentage;
| uint256 rewardBonusPercentage;
| 28,634 |
2 | // split hrp and compare with the bytes hrp stored | bytes memory _hrpBytesLocal = _addressBytesLocal.slice(
0,
hrpBytes_.length
);
if (!_hrpBytesLocal.equal(hrpBytes_)) return false;
| bytes memory _hrpBytesLocal = _addressBytesLocal.slice(
0,
hrpBytes_.length
);
if (!_hrpBytesLocal.equal(hrpBytes_)) return false;
| 15,356 |
44 | // Allows for a request which was created on another contract to be fulfilledon this contract oracleAddress The address of the oracle contract that will fulfill the request requestId The request ID used for the response / | function addChainlinkExternalRequest(
address oracleAddress,
bytes32 requestId
)
internal
notPendingRequest(requestId)
| function addChainlinkExternalRequest(
address oracleAddress,
bytes32 requestId
)
internal
notPendingRequest(requestId)
| 14,597 |
13 | // Call the sweepDust function on the DustSweeper contract | dustSweeper.sweepDust{value: msg.value}(makers, tokenAddresses, packet);
| dustSweeper.sweepDust{value: msg.value}(makers, tokenAddresses, packet);
| 29,591 |
8 | // The address of the Nouns tokens | INounsTokenForkLike public nouns;
| INounsTokenForkLike public nouns;
| 34,878 |
8 | // Change authorization for _address /_address Address whose permission is to be changed/_authorization Authority to be changed | function toggleAuthorization(address _address, bytes32 _authorization) public ifAuthorized(msg.sender, APHRODITE) {
/// Prevent inadvertent self locking out, cannot change own authority
require(_address != msg.sender);
/// No need for lower level authorization to linger
if (_authorization == APHRODITE && !authorized[_address][APHRODITE]) {
authorized[_address][CUPID] = false;
}
authorized[_address][_authorization] = !authorized[_address][_authorization];
}
| function toggleAuthorization(address _address, bytes32 _authorization) public ifAuthorized(msg.sender, APHRODITE) {
/// Prevent inadvertent self locking out, cannot change own authority
require(_address != msg.sender);
/// No need for lower level authorization to linger
if (_authorization == APHRODITE && !authorized[_address][APHRODITE]) {
authorized[_address][CUPID] = false;
}
authorized[_address][_authorization] = !authorized[_address][_authorization];
}
| 13,712 |
13 | // transfer float in | IERC20 float = IERC20(floatAddress);
float.transferFrom(msg.sender, address(this), floatIn);
| IERC20 float = IERC20(floatAddress);
float.transferFrom(msg.sender, address(this), floatIn);
| 26,498 |
19 | // See {IERC165-supportsInterface}. Requirements: - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`). / | function _registerInterface(bytes4 interfaceId) internal virtual {
require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
_supportedInterfaces[interfaceId] = true;
}
| function _registerInterface(bytes4 interfaceId) internal virtual {
require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
_supportedInterfaces[interfaceId] = true;
}
| 5,164 |
165 | // Called by the Prize-Strategy to transfer out external ERC20 tokens/Used to transfer out tokens held by the Prize Pool.Could be liquidated, or anything./to The address of the winner that receives the award/externalToken The address of the external asset token being awarded/amount The amount of external assets to be awarded | function transferExternalERC20(
address to,
address externalToken,
uint256 amount
) external;
| function transferExternalERC20(
address to,
address externalToken,
uint256 amount
) external;
| 49,732 |
39 | // epochId not initialized and epoch 0 not initialized => there was never any action on this pool | if (!epochIsInitialized(tokenAddress, erc1155TokenId, 0)) {
return 0;
}
| if (!epochIsInitialized(tokenAddress, erc1155TokenId, 0)) {
return 0;
}
| 9,045 |
20 | // Returns the downcasted uint96 from uint256, reverting on overflow (when the input is greater than largest uint96). Counterpart to Solidity's `uint96` operator. Requirements: - input must fit into 96 bits _Available since v4.2._/ | function toUint96(uint256 value) internal pure returns (uint96) {
require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits");
return uint96(value);
}
| function toUint96(uint256 value) internal pure returns (uint96) {
require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits");
return uint96(value);
}
| 26,676 |
4 | // Transfers `amount` of native token to `to`. | function safeTransferNativeToken(address to, uint256 value) internal {
// solhint-disable avoid-low-level-calls
// slither-disable-next-line low-level-calls
(bool success, ) = to.call{ value: value }("");
require(success, "Native token transfer failed");
}
| function safeTransferNativeToken(address to, uint256 value) internal {
// solhint-disable avoid-low-level-calls
// slither-disable-next-line low-level-calls
(bool success, ) = to.call{ value: value }("");
require(success, "Native token transfer failed");
}
| 24,476 |
77 | // Returns asset's unit price accounting for different asset types and takes into account the context in which that price exists - - mint or redeem. Note: since we are returning the price of the unit and not the one of theasset (see comment above how 1 rETH exchanges for 1.2 units) we needto make the Oracle price adjustment as well since we are pricing theunits and not the assets. The price also snaps to a "full unit price" in case a mint or redeemaction would be unfavourable to the protocol./ | function _toUnitPrice(address _asset, bool isMint)
internal
view
returns (uint256 price)
| function _toUnitPrice(address _asset, bool isMint)
internal
view
returns (uint256 price)
| 15,419 |
311 | // a variable to load `extcodesize` to | uint256 size = 0;
| uint256 size = 0;
| 24,894 |
25 | // deposit token into the contract Be sure to Approve the contract to move your erc20 token token The address of deposited token amount The amount of token to deposit / | function depositToken(address token, uint256 amount) external {
require(amount > 0);
require(tokenAddress2Id[token] != 0);
addUser(msg.sender);
require(ERC20(token).transferFrom(msg.sender, this, amount));
balances[token][msg.sender] = balances[token][msg.sender].add(amount);
Deposit(
token,
msg.sender,
amount,
balances[token][msg.sender]
);
}
| function depositToken(address token, uint256 amount) external {
require(amount > 0);
require(tokenAddress2Id[token] != 0);
addUser(msg.sender);
require(ERC20(token).transferFrom(msg.sender, this, amount));
balances[token][msg.sender] = balances[token][msg.sender].add(amount);
Deposit(
token,
msg.sender,
amount,
balances[token][msg.sender]
);
}
| 42,040 |
20 | // Sets the allowance afforded to the given spender bythe message sender. / | function approve (address spender, uint256 value)
external override returns (bool)
| function approve (address spender, uint256 value)
external override returns (bool)
| 58,114 |
83 | // update SAFU address and SAFE_FEE to pools | function updateSafu(address[] calldata pools) external onlyCore {
require(pools.length > 0 && pools.length <= 30, "ERR_BATCH_COUNT");
for (uint8 i = 0; i < pools.length; i++) {
require(Address.isContract(pools[i]), "ERR_NOT_CONTRACT");
IXPool pool = IXPool(pools[i]);
pool.updateSafu(safu, SAFU_FEE);
}
}
| function updateSafu(address[] calldata pools) external onlyCore {
require(pools.length > 0 && pools.length <= 30, "ERR_BATCH_COUNT");
for (uint8 i = 0; i < pools.length; i++) {
require(Address.isContract(pools[i]), "ERR_NOT_CONTRACT");
IXPool pool = IXPool(pools[i]);
pool.updateSafu(safu, SAFU_FEE);
}
}
| 33,955 |
44 | // CHECKS | healBoss(); // Try and heal boss first
require(msg.value >= price + developmentFee, "PRICE_NOT_MET");
require(_characterIndex < defaultCharacters.length, "CHARACTER_NON_EXISTANT");
| healBoss(); // Try and heal boss first
require(msg.value >= price + developmentFee, "PRICE_NOT_MET");
require(_characterIndex < defaultCharacters.length, "CHARACTER_NON_EXISTANT");
| 14,089 |
77 | // 26 IN DATA / SET DATA / GET DATA / STRING / PUBLIC / ONLY OWNER / CONSTANT |
string inPI_edit_26 = " une première phrase " ;
|
string inPI_edit_26 = " une première phrase " ;
| 35,666 |
31 | // Set success to whether the call reverted, if not we check it either returned exactly 1 (can't just be non-zero data), or had no return data. | or(eq(mload(0x00), 1), iszero(returndatasize())),
call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20)
)
) {
| or(eq(mload(0x00), 1), iszero(returndatasize())),
call(gas(), token, 0, 0x1c, 0x64, 0x00, 0x20)
)
) {
| 24,375 |
28 | // require(success, _getRevertMsg(returnData)); |
emit ExecuteTransaction(txHash, target, value, signature, data, eta);
return callData;
|
emit ExecuteTransaction(txHash, target, value, signature, data, eta);
return callData;
| 24,402 |
190 | // Set the migrator contract. Can only be called by the owner. | function setMigrator(IMigratorChef _migrator) public onlyOwner {
migrator = _migrator;
}
| function setMigrator(IMigratorChef _migrator) public onlyOwner {
migrator = _migrator;
}
| 10,770 |
137 | // Veto an existing, pending proposal. / | function vetoProposal()
external
onlySignatory()
minimumSignatories()
latestProposalPending()
| function vetoProposal()
external
onlySignatory()
minimumSignatories()
latestProposalPending()
| 12,705 |
68 | // set launching phase | function Phase (uint256 phase) public override returns (bool){
if (phase == 1)
{
require(now>=phase1Start);
assert(ISigmoidTokens(SASH_contract).setPhase(1));
assert(ISigmoidBank(bank_contract).setPhase(1));
return(true);
}
if (phase == 2)
{
require(now>=phase2Start);
assert(ISigmoidTokens(SASH_contract).setPhase(2));
assert(ISigmoidBank(bank_contract).setPhase(2));
return(true);
}
if (phase == 3)
{
require(now>=phase3Start);
assert(ISigmoidTokens(SASH_contract).setPhase(3));
assert(ISigmoidBank(bank_contract).setPhase(3));
return(true);
}
if (phase == 4)
{
require(now>=phase4Start);
assert(ISigmoidTokens(SASH_contract).setPhase(4));
assert(ISigmoidBank(bank_contract).setPhase(4));
return(true);
}
return(false);
}
| function Phase (uint256 phase) public override returns (bool){
if (phase == 1)
{
require(now>=phase1Start);
assert(ISigmoidTokens(SASH_contract).setPhase(1));
assert(ISigmoidBank(bank_contract).setPhase(1));
return(true);
}
if (phase == 2)
{
require(now>=phase2Start);
assert(ISigmoidTokens(SASH_contract).setPhase(2));
assert(ISigmoidBank(bank_contract).setPhase(2));
return(true);
}
if (phase == 3)
{
require(now>=phase3Start);
assert(ISigmoidTokens(SASH_contract).setPhase(3));
assert(ISigmoidBank(bank_contract).setPhase(3));
return(true);
}
if (phase == 4)
{
require(now>=phase4Start);
assert(ISigmoidTokens(SASH_contract).setPhase(4));
assert(ISigmoidBank(bank_contract).setPhase(4));
return(true);
}
return(false);
}
| 8,937 |
61 | // структура описывающая интервалы битв | struct FightInterval {
uint fightsInterval;
uint startsFrom;
uint fightsCount; //число уже завершенных битв до этого интервала
uint betsPeriod;
uint applicationPeriod;
uint fightPeriod;
}
| struct FightInterval {
uint fightsInterval;
uint startsFrom;
uint fightsCount; //число уже завершенных битв до этого интервала
uint betsPeriod;
uint applicationPeriod;
uint fightPeriod;
}
| 31,706 |
30 | // Accept a given trade (+ potentially escrow tokens). index Index of the trade to be accepted. / | function acceptTrade(uint256 index) external payable {
_acceptTrade(index, msg.sender, msg.value);
}
| function acceptTrade(uint256 index) external payable {
_acceptTrade(index, msg.sender, msg.value);
}
| 29,318 |
1 | // Allocate GRT tokens for the purpose of serving queries of a subgraph deploymentAn allocation is created in the allocate() function and consumed in claim() / | struct Allocation {
address indexer;
bytes32 subgraphDeploymentID;
uint256 tokens; // Tokens allocated to a SubgraphDeployment
uint256 createdAtEpoch; // Epoch when it was created
uint256 closedAtEpoch; // Epoch when it was closed
uint256 collectedFees; // Collected fees for the allocation
uint256 effectiveAllocation; // Effective allocation when closed
uint256 accRewardsPerAllocatedToken; // Snapshot used for reward calc
| struct Allocation {
address indexer;
bytes32 subgraphDeploymentID;
uint256 tokens; // Tokens allocated to a SubgraphDeployment
uint256 createdAtEpoch; // Epoch when it was created
uint256 closedAtEpoch; // Epoch when it was closed
uint256 collectedFees; // Collected fees for the allocation
uint256 effectiveAllocation; // Effective allocation when closed
uint256 accRewardsPerAllocatedToken; // Snapshot used for reward calc
| 22,188 |
112 | // Fixed period of sale: 16 weeks from now set as sales period (changeable) |
constructor(
VictorToken _token_,
address _wallet
)
public
|
constructor(
VictorToken _token_,
address _wallet
)
public
| 45,166 |
104 | // Members / data setup | uint256 _undividedDividends = SafeMath.mul(_incomingtokens, entryFee_) / 100;
uint256 _amountOfTokens = SafeMath.sub(_incomingtokens, _undividedDividends);
| uint256 _undividedDividends = SafeMath.mul(_incomingtokens, entryFee_) / 100;
uint256 _amountOfTokens = SafeMath.sub(_incomingtokens, _undividedDividends);
| 7,692 |
55 | // Used to get the most revent vault for the token using the registry.return An instance of a VaultAPI / | function bestVault() public virtual view returns (VaultAPI) {
return VaultAPI(registry.latestVault(address(token)));
}
| function bestVault() public virtual view returns (VaultAPI) {
return VaultAPI(registry.latestVault(address(token)));
}
| 53,028 |
3 | // Cannot query the balance for the zero address. / | error BalanceQueryForZeroAddress();
| error BalanceQueryForZeroAddress();
| 309 |
199 | // Set early-access granting or revocation for the addresses. eg. ["0x12345"] / | function setEarlyAccessGrants(
address[] calldata addresses,
bool hasAccess
)
external
onlyOwner
| function setEarlyAccessGrants(
address[] calldata addresses,
bool hasAccess
)
external
onlyOwner
| 59,653 |
975 | // Checks if msg.sender is allowed to create proposal under given category/ | modifier isAllowed(uint _categoryId) {
require(allowedToCreateProposal(_categoryId), "Not allowed");
_;
}
| modifier isAllowed(uint _categoryId) {
require(allowedToCreateProposal(_categoryId), "Not allowed");
_;
}
| 33,732 |
17 | // count up? | if (_data.length > 0) {
(bytes memory encryptedURI, bytes32 provenanceHash) = abi.decode(_data, (bytes, bytes32));
if (encryptedURI.length != 0 && provenanceHash != "") {
_setEncryptedData(nextTokenIdToLazyMint + _quantity, _data);
}
| if (_data.length > 0) {
(bytes memory encryptedURI, bytes32 provenanceHash) = abi.decode(_data, (bytes, bytes32));
if (encryptedURI.length != 0 && provenanceHash != "") {
_setEncryptedData(nextTokenIdToLazyMint + _quantity, _data);
}
| 30,130 |
208 | // See {IERC721Enumerable-totalSupply}. / | function totalSupply() public view virtual override returns (uint256) {
return _allTokens.length;
}
| function totalSupply() public view virtual override returns (uint256) {
return _allTokens.length;
}
| 320 |
269 | // fetch how much approvals left for an operator | bool approvedOperator = approvedOperators[_from][operator];
| bool approvedOperator = approvedOperators[_from][operator];
| 32,439 |
29 | // Sale period. | uint256 public startDate;
uint256 public endDate;
| uint256 public startDate;
uint256 public endDate;
| 30,043 |
229 | // The total remaining vested balance, for verifying the actual havven balance of this contract against. | uint public totalVestedBalance;
| uint public totalVestedBalance;
| 25,668 |
12 | // Time by which the curve must be hatched. | uint256 public hatchDeadline;
| uint256 public hatchDeadline;
| 33,615 |
353 | // Calculate denominator for row 0: x - z. | let denominator := add(shiftedEvalPoint, mload(add(expmodsAndPoints, 0x2a0)))
mstore(productsPtr, partialProduct)
mstore(valuesPtr, denominator)
partialProduct := mulmod(partialProduct, denominator, PRIME)
| let denominator := add(shiftedEvalPoint, mload(add(expmodsAndPoints, 0x2a0)))
mstore(productsPtr, partialProduct)
mstore(valuesPtr, denominator)
partialProduct := mulmod(partialProduct, denominator, PRIME)
| 47,216 |
545 | // Set the amount of BRID+ distributed per block birdRate_ The amount of BRID+ wei per block to distribute / | function _setBirdPlusRate(uint birdRate_) public {
require(adminOrInitializing(), "only admin can change bird rate");
uint oldRate = birdRate;
birdRate = birdRate_;
emit NewBirdPlusRate(oldRate, birdRate_);
refreshBirdPlusSpeedsInternal();
}
| function _setBirdPlusRate(uint birdRate_) public {
require(adminOrInitializing(), "only admin can change bird rate");
uint oldRate = birdRate;
birdRate = birdRate_;
emit NewBirdPlusRate(oldRate, birdRate_);
refreshBirdPlusSpeedsInternal();
}
| 46,925 |
39 | // Returns whether the contract has been registered with the registry. If it is registered, it is an authorized participant in the UMA system. contractAddress address of the contract.return bool indicates whether the contract is registered. / | function isContractRegistered(address contractAddress) external view returns (bool);
| function isContractRegistered(address contractAddress) external view returns (bool);
| 11,860 |
9 | // calculate output | uint output = pair.getReserveReturn(address(sourceToken), address(targetToken), input);
| uint output = pair.getReserveReturn(address(sourceToken), address(targetToken), input);
| 13,549 |
1 | // Initial guess: 1.0 | uint xNew = one;
uint iter = 0;
while (iter < _maxIts) {
uint x = xNew;
uint t0 = x ** (_n - 1);
if (x * t0 > a0) {
xNew = x - (x - a0 / t0) / _n;
} else {
| uint xNew = one;
uint iter = 0;
while (iter < _maxIts) {
uint x = xNew;
uint t0 = x ** (_n - 1);
if (x * t0 > a0) {
xNew = x - (x - a0 / t0) / _n;
} else {
| 52,976 |
230 | // We invoke doTransferOut for the borrower and the borrowAmount. Note: The gToken must handle variations between ERC-20 and ETH underlying. On success, the gToken borrowAmount less of cash. doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred. / |
uint fee = 0;
uint borrowAmountMinusFee = 0;
(vars.mathErr, fee) = mulUInt(borrowAmount, borrowFee);
if (vars.mathErr != MathError.NO_ERROR) {
return failOpaque(Error.MATH_ERROR, FailureInfo.BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED, uint(vars.mathErr));
}
|
uint fee = 0;
uint borrowAmountMinusFee = 0;
(vars.mathErr, fee) = mulUInt(borrowAmount, borrowFee);
if (vars.mathErr != MathError.NO_ERROR) {
return failOpaque(Error.MATH_ERROR, FailureInfo.BORROW_NEW_ACCOUNT_BORROW_BALANCE_CALCULATION_FAILED, uint(vars.mathErr));
}
| 77,543 |
2 | // Calculates the current borrow interest rate per blockcash The total amount of cash the market hasborrows The total amount of borrows the market has outstandingreserves The total amnount of reserves the market has return The borrow rate per block (as a percentage, and scaled by 1e18)/ |
function getBorrowRate(uint cash, uint borrows, uint reserves) external view returns (uint);
|
function getBorrowRate(uint cash, uint borrows, uint reserves) external view returns (uint);
| 1,221 |
1 | // Sets the factoryAddress variable found in BaseScheduler contract. | factoryAddress = _factoryAddress;
| factoryAddress = _factoryAddress;
| 15,653 |
51 | // Get latest recorded price from oracleIf it falls below allowed buffer or has not updated, it would be invalid / | function _getPriceFromOracle() internal returns (int256) {
uint256 leastAllowedTimestamp = block.timestamp.add(oracleUpdateAllowance);
(uint80 roundId, int256 price, , uint256 timestamp, ) = oracle.latestRoundData();
require(timestamp <= leastAllowedTimestamp, "Oracle update exceeded max timestamp allowance");
require(roundId > oracleLatestRoundId, "Oracle update roundId must be larger than oracleLatestRoundId");
oracleLatestRoundId = uint256(roundId);
return price;
}
| function _getPriceFromOracle() internal returns (int256) {
uint256 leastAllowedTimestamp = block.timestamp.add(oracleUpdateAllowance);
(uint80 roundId, int256 price, , uint256 timestamp, ) = oracle.latestRoundData();
require(timestamp <= leastAllowedTimestamp, "Oracle update exceeded max timestamp allowance");
require(roundId > oracleLatestRoundId, "Oracle update roundId must be larger than oracleLatestRoundId");
oracleLatestRoundId = uint256(roundId);
return price;
}
| 10,605 |
179 | // The migrator contract. It has a lot of power. Can only be set through governance (owner). | IMigratorScientist public migrator;
| IMigratorScientist public migrator;
| 32,913 |
158 | // Converts a number to 18 decimal precision/If token decimal is bigger than 18, function reverts/_joinAddr Join address of the collateral/_amount Number to be converted | function convertTo18(address _joinAddr, uint256 _amount) internal view returns (uint256) {
return mul(_amount, 10 ** sub(18 , IJoin(_joinAddr).dec()));
}
| function convertTo18(address _joinAddr, uint256 _amount) internal view returns (uint256) {
return mul(_amount, 10 ** sub(18 , IJoin(_joinAddr).dec()));
}
| 25,699 |
198 | // token contract address => resourceID | mapping (address => bytes32) public _tokenContractAddressToResourceID;
| mapping (address => bytes32) public _tokenContractAddressToResourceID;
| 57,891 |
2 | // Get the BLS public key associated with an address (revert if there isn't one) | function getPublicKey(address addr) external view returns (uint, uint, uint, uint);
| function getPublicKey(address addr) external view returns (uint, uint, uint, uint);
| 12,122 |
179 | // Mapping from token address to price channel. tokenAddress=>PriceChannel | mapping(address=>PriceChannel) _channels;
| mapping(address=>PriceChannel) _channels;
| 37,300 |
52 | // Show balance tokens | function getTokenBalance() view public returns (uint256) {
return token.balanceOf(address(this));
}
| function getTokenBalance() view public returns (uint256) {
return token.balanceOf(address(this));
}
| 55,758 |
31 | // Retrieves the total earnings of a video. Retrieve the total earnings of the specified video. videoId_ The ID of the video.return The total earnings of the video. / | function getVideoTotalEarning(
string memory videoId_
| function getVideoTotalEarning(
string memory videoId_
| 32,114 |
187 | // let event know how much was won | _eventData_.compressedData += _prize * 1000000000000000000000000000000000;
| _eventData_.compressedData += _prize * 1000000000000000000000000000000000;
| 29,583 |
25 | // Set allowance for other address Allows `_spender` to spend no more than `_value` tokens in your behalf_spender The address authorized to spend_value the max amount they can spend/ | function approve(address _spender, uint256 _value) public returns (bool success) {
require(!safeguard);
allowance[msg.sender][_spender] = _value;
return true;
}
| function approve(address _spender, uint256 _value) public returns (bool success) {
require(!safeguard);
allowance[msg.sender][_spender] = _value;
return true;
}
| 15,650 |
150 | // for any rooms that oraclize fails to return the money to can use this to return ante to owners | require (_roomID != bytes32(0)); //make sure address is not null
require (rooms[_roomID].winner == address(0)); //make sure that the sum cannot be double spent
rooms[_roomID].player1.transfer(ante);
rooms[_roomID].player2.transfer(ante);
rooms[_roomID].status = "failed";
if (rooms[_roomID].privateroomid != bytes32(0) ) {
private_rooms[rooms[_roomID].privateroomid].status ="failed";
}
| require (_roomID != bytes32(0)); //make sure address is not null
require (rooms[_roomID].winner == address(0)); //make sure that the sum cannot be double spent
rooms[_roomID].player1.transfer(ante);
rooms[_roomID].player2.transfer(ante);
rooms[_roomID].status = "failed";
if (rooms[_roomID].privateroomid != bytes32(0) ) {
private_rooms[rooms[_roomID].privateroomid].status ="failed";
}
| 40,411 |
8 | // quote the share value for an amount of tokens without unstaking user address of user amount number of tokens to claim with data additional datareturn address of staking accountreturn number of shares that the claim amount is worth / | function claim(
| function claim(
| 11,740 |
24 | // Return registration status of user/_user Wallet address of user | function getRegistrationStatus(address _user) public view returns (bool) {
return users[_user].registered;
}
| function getRegistrationStatus(address _user) public view returns (bool) {
return users[_user].registered;
}
| 36,517 |
9 | // add all reserve tokens | for (uint i = 0; i < reserveTokenCount; i++)
addConvertibleToken(converterRegistryData, _converter.connectorTokens(i), token);
| for (uint i = 0; i < reserveTokenCount; i++)
addConvertibleToken(converterRegistryData, _converter.connectorTokens(i), token);
| 2,173 |
28 | // Returns the integer division of two unsigned integers, reverting with custom message ondivision by zero. The result is rounded towards zero. CAUTION: This function is deprecated because it requires allocating memory for the error | * message unnecessarily. For custom revert reasons use {tryDiv}.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a / b;
}
| * message unnecessarily. For custom revert reasons use {tryDiv}.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a / b;
}
| 2,103 |
233 | // If the period expired, renew it | function retroCatchUp() internal {
// Failsafe check
require(block.timestamp > periodFinish, "Period has not expired yet!");
// Ensure the provided reward amount is not more than the balance in the contract.
// This keeps the reward rate in the right range, preventing overflows due to
// very high values of rewardRate in the earned and rewardsPerToken functions;
// Reward + leftover must be less than 2^256 / 10^18 to avoid overflow.
uint256 num_periods_elapsed = uint256(
block.timestamp.sub(periodFinish)
) / rewardsDuration; // Floor division to the nearest period
// Make sure there are enough tokens to renew the reward period
for (uint256 i = 0; i < rewardTokens.length; i++) {
require(
rewardRates[i].mul(rewardsDuration).mul(
num_periods_elapsed + 1
) <= IERC20(rewardTokens[i]).balanceOf(address(this)),
string(
abi.encodePacked(
"Not enough reward tokens available: ",
rewardTokens[i]
)
)
);
}
// uint256 old_lastUpdateTime = lastUpdateTime;
// uint256 new_lastUpdateTime = block.timestamp;
// lastUpdateTime = periodFinish;
periodFinish = periodFinish.add(
(num_periods_elapsed.add(1)).mul(rewardsDuration)
);
_updateStoredRewardsAndTime();
emit RewardsPeriodRenewed(address(stakingToken));
}
| function retroCatchUp() internal {
// Failsafe check
require(block.timestamp > periodFinish, "Period has not expired yet!");
// Ensure the provided reward amount is not more than the balance in the contract.
// This keeps the reward rate in the right range, preventing overflows due to
// very high values of rewardRate in the earned and rewardsPerToken functions;
// Reward + leftover must be less than 2^256 / 10^18 to avoid overflow.
uint256 num_periods_elapsed = uint256(
block.timestamp.sub(periodFinish)
) / rewardsDuration; // Floor division to the nearest period
// Make sure there are enough tokens to renew the reward period
for (uint256 i = 0; i < rewardTokens.length; i++) {
require(
rewardRates[i].mul(rewardsDuration).mul(
num_periods_elapsed + 1
) <= IERC20(rewardTokens[i]).balanceOf(address(this)),
string(
abi.encodePacked(
"Not enough reward tokens available: ",
rewardTokens[i]
)
)
);
}
// uint256 old_lastUpdateTime = lastUpdateTime;
// uint256 new_lastUpdateTime = block.timestamp;
// lastUpdateTime = periodFinish;
periodFinish = periodFinish.add(
(num_periods_elapsed.add(1)).mul(rewardsDuration)
);
_updateStoredRewardsAndTime();
emit RewardsPeriodRenewed(address(stakingToken));
}
| 15,175 |
11 | // 125 million in wei | totalSupply = 125000000000000000000000000;
balances[msg.sender] = balances[msg.sender].add(totalSupply);
tokenTransfersFrozen = true;
tokenMintingEnabled = false;
contractLaunched = false;
| totalSupply = 125000000000000000000000000;
balances[msg.sender] = balances[msg.sender].add(totalSupply);
tokenTransfersFrozen = true;
tokenMintingEnabled = false;
contractLaunched = false;
| 33,527 |
150 | // Ops | Address.sendValue(_feeAddrWallet3, amount.mul(opsRatio).div(divisorRatioNoRF));
| Address.sendValue(_feeAddrWallet3, amount.mul(opsRatio).div(divisorRatioNoRF));
| 22,404 |
33 | // transfer end | return;
| return;
| 7,320 |
3 | // Sets the `implementer` contract as ``account``'s implementer for`interfaceHash`. `account` being the zero address is an alias for the caller's address.The zero address can also be used in `implementer` to remove an old one. See {interfaceHash} to learn how these are created. Emits an {InterfaceImplementerSet} event. Requirements: - the caller must be the current manager for `account`.- `interfaceHash` must not be an {IERC165} interface id (i.e. it must notend in 28 zeroes).- `implementer` must implement {IERC1820Implementer} and return true whenqueried for support, unless `implementer` is the caller. See{IERC1820Implementer-canImplementInterfaceForAddress}. / | function setInterfaceImplementer(
address account,
bytes32 _interfaceHash,
address implementer
) external;
| function setInterfaceImplementer(
address account,
bytes32 _interfaceHash,
address implementer
) external;
| 22,658 |
66 | // load price of token into memory | uint256 pricePerTokenInWei = _projectConfig.pricePerTokenInWei;
require(
msg.value >= pricePerTokenInWei,
"Must send minimum value to mint!"
);
| uint256 pricePerTokenInWei = _projectConfig.pricePerTokenInWei;
require(
msg.value >= pricePerTokenInWei,
"Must send minimum value to mint!"
);
| 26,793 |
292 | // Used for changing the hedging pool addressthat will be accumulating the hedging premiums paidas a share of the total premium redirected to this address. value The address for receiving hedging premiums / | {
require(value != address(0));
hedgePool = value;
}
| {
require(value != address(0));
hedgePool = value;
}
| 10,816 |
557 | // For a transfer both accounts must be owned by msg.sender | if (action.actionType == Actions.ActionType.Transfer) {
address owner2 = accounts[action.otherAccountId].owner;
Require.that(
owner2 == msg.sender,
FILE,
"Sender must be secondary account",
owner2
);
}
| if (action.actionType == Actions.ActionType.Transfer) {
address owner2 = accounts[action.otherAccountId].owner;
Require.that(
owner2 == msg.sender,
FILE,
"Sender must be secondary account",
owner2
);
}
| 15,747 |
36 | // Allows the social trader to make a trade on an active position/Allow manual trading of an active position with an array of custom operations/_timestamp UNIX value of when the position was opened/_operations memory array of TradeOperation that will be used to execute a trade | function executeTrade(uint256 _timestamp, TradeOperation[] memory _operations) external override onlyAdmin {
Position storage pos = positions[_timestamp];
_executeTradingOperation(_operations, pos);
}
| function executeTrade(uint256 _timestamp, TradeOperation[] memory _operations) external override onlyAdmin {
Position storage pos = positions[_timestamp];
_executeTradingOperation(_operations, pos);
}
| 34,634 |
38 | // Indicates whether a contract implements the `ERC1155TokenReceiver` functions and so can accept ERC1155 token types.interfaceID The ERC-165 interface ID that is queried for support.s This function MUST return true if it implements the ERC1155TokenReceiver interface and ERC-165 interface. This function MUST NOT consume more than 5,000 gas.return Wheter ERC-165 or ERC1155TokenReceiver interfaces are supported. / | function supportsInterface(bytes4 interfaceID) external view returns (bool);
| function supportsInterface(bytes4 interfaceID) external view returns (bool);
| 2,599 |
40 | // forgive all remaining debt when removing a strategy | uint256 remainingDebt = strategies[_strategy].debt;
if (remainingDebt > 0) totalDebt -= remainingDebt;
| uint256 remainingDebt = strategies[_strategy].debt;
if (remainingDebt > 0) totalDebt -= remainingDebt;
| 6,251 |
114 | // to recieve ETH from uniswapV2Router when swaping | receive() external payable {}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tCharity) = _getTValues(tAmount, _taxFee, _charityFee);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tCharity);
}
| receive() external payable {}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tCharity) = _getTValues(tAmount, _taxFee, _charityFee);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tCharity);
}
| 2,958 |
155 | // Returns the address of a member at a given index | function memberAt(uint256 _index) internal view returns (address) {
Storage storage gs = governanceStorage();
return gs.membersSet.at(_index);
}
| function memberAt(uint256 _index) internal view returns (address) {
Storage storage gs = governanceStorage();
return gs.membersSet.at(_index);
}
| 65,405 |
26 | // Override the renounce ownership inherited by zeppelin ownable | function renounceOwnership() public override onlyOwner {}
}
| function renounceOwnership() public override onlyOwner {}
}
| 19,351 |
19 | // perform static call | bool success;
uint256 returnSize;
uint256 returnValue;
assembly {
success := staticcall(30000, account, add(encodedParams, 0x20), mload(encodedParams), 0x00, 0x20)
returnSize := returndatasize()
returnValue := mload(0x00)
}
| bool success;
uint256 returnSize;
uint256 returnValue;
assembly {
success := staticcall(30000, account, add(encodedParams, 0x20), mload(encodedParams), 0x00, 0x20)
returnSize := returndatasize()
returnValue := mload(0x00)
}
| 13,783 |
119 | // External // Public //claim interests generated by POSController | function claimTokens(address _owner) public {
doClaim(_owner, claims[_owner]);
}
| function claimTokens(address _owner) public {
doClaim(_owner, claims[_owner]);
}
| 37,688 |
739 | // Helper method to return all the subscribed CDPs | function getSubscribers() public view returns (CdpHolder[] memory) {
return subscribers;
}
| function getSubscribers() public view returns (CdpHolder[] memory) {
return subscribers;
}
| 57,919 |
7 | // Triggered when the Humanity Cash address is updated_oldHumanityCashAddress Old address _newHumanityCashAddress New address / | event HumanityCashUpdated(
| event HumanityCashUpdated(
| 21,170 |
172 | // factory type | FactoryType factoryType;
| FactoryType factoryType;
| 53,727 |
29 | // Contracts that should be able to recover tokens or ethers Ilan Doron This allows to recover any tokens or Ethers received in a contract.This will prevent any accidental loss of tokens. / | contract Withdrawable is PermissionGroups {
event TokenWithdraw(ERC20 token, uint amount, address sendTo);
/**
* @dev Withdraw all ERC20 compatible tokens
* @param token ERC20 The address of the token contract
*/
function withdrawToken(ERC20 token, uint amount, address sendTo) external onlyAdmin {
require(token.transfer(sendTo, amount));
TokenWithdraw(token, amount, sendTo);
}
event EtherWithdraw(uint amount, address sendTo);
/**
* @dev Withdraw Ethers
*/
function withdrawEther(uint amount, address sendTo) external onlyAdmin {
sendTo.transfer(amount);
EtherWithdraw(amount, sendTo);
}
}
| contract Withdrawable is PermissionGroups {
event TokenWithdraw(ERC20 token, uint amount, address sendTo);
/**
* @dev Withdraw all ERC20 compatible tokens
* @param token ERC20 The address of the token contract
*/
function withdrawToken(ERC20 token, uint amount, address sendTo) external onlyAdmin {
require(token.transfer(sendTo, amount));
TokenWithdraw(token, amount, sendTo);
}
event EtherWithdraw(uint amount, address sendTo);
/**
* @dev Withdraw Ethers
*/
function withdrawEther(uint amount, address sendTo) external onlyAdmin {
sendTo.transfer(amount);
EtherWithdraw(amount, sendTo);
}
}
| 51,144 |
126 | // Equals to bytes4(keccak256("unfreezeWithoutDelay(address)")) | bytes4 internal constant UNFREEZE_WITHOUT_DELAY = 0x69521650;
| bytes4 internal constant UNFREEZE_WITHOUT_DELAY = 0x69521650;
| 37,482 |
188 | // return The max borrowing spread. | function MAX_BORROWING_SPREAD() external view returns (uint256);
| function MAX_BORROWING_SPREAD() external view returns (uint256);
| 17,757 |
26 | // Stores the total count of assets managed by this registry / | uint256 internal _count;
| uint256 internal _count;
| 33,174 |
49 | // Optional mapping for token names | mapping(uint256 => string) internal _tokenNames;
bytes4 internal constant _INTERFACE_ID_ERC721_METADATA = 0xbc7bebe8;
| mapping(uint256 => string) internal _tokenNames;
bytes4 internal constant _INTERFACE_ID_ERC721_METADATA = 0xbc7bebe8;
| 11,231 |
227 | // Encode integer in big endian binary form with no leading zeroes. TODO: This should be optimized with assembly to save gas costs. _x The integer to encode.return RLP encoded bytes. / | function toBinary(uint _x) private pure returns (bytes memory) {
bytes memory b = new bytes(32);
assembly {
mstore(add(b, 32), _x)
}
uint i;
for (i = 0; i < 32; i++) {
if (b[i] != 0) {
break;
}
}
bytes memory res = new bytes(32 - i);
for (uint j = 0; j < res.length; j++) {
res[j] = b[i++];
}
return res;
}
| function toBinary(uint _x) private pure returns (bytes memory) {
bytes memory b = new bytes(32);
assembly {
mstore(add(b, 32), _x)
}
uint i;
for (i = 0; i < 32; i++) {
if (b[i] != 0) {
break;
}
}
bytes memory res = new bytes(32 - i);
for (uint j = 0; j < res.length; j++) {
res[j] = b[i++];
}
return res;
}
| 29,191 |
128 | // https:docs.synthetix.io/contracts/source/interfaces/isystemstatus | interface ISystemStatus {
struct Status {
bool canSuspend;
bool canResume;
}
struct Suspension {
bool suspended;
// reason is an integer code,
// 0 => no reason, 1 => upgrading, 2+ => defined by system usage
uint248 reason;
}
// Views
function accessControl(bytes32 section, address account) external view returns (bool canSuspend, bool canResume);
function requireSystemActive() external view;
function requireIssuanceActive() external view;
function requireExchangeActive() external view;
function requireExchangeBetweenSynthsAllowed(bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey) external view;
function requireSynthActive(bytes32 currencyKey) external view;
function requireSynthsActive(bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey) external view;
function systemSuspension() external view returns (bool suspended, uint248 reason);
function issuanceSuspension() external view returns (bool suspended, uint248 reason);
function exchangeSuspension() external view returns (bool suspended, uint248 reason);
function synthExchangeSuspension(bytes32 currencyKey) external view returns (bool suspended, uint248 reason);
function synthSuspension(bytes32 currencyKey) external view returns (bool suspended, uint248 reason);
function getSynthExchangeSuspensions(bytes32[] calldata synths)
external
view
returns (bool[] memory exchangeSuspensions, uint256[] memory reasons);
function getSynthSuspensions(bytes32[] calldata synths)
external
view
returns (bool[] memory suspensions, uint256[] memory reasons);
// Restricted functions
function suspendSynth(bytes32 currencyKey, uint256 reason) external;
function updateAccessControl(
bytes32 section,
address account,
bool canSuspend,
bool canResume
) external;
}
| interface ISystemStatus {
struct Status {
bool canSuspend;
bool canResume;
}
struct Suspension {
bool suspended;
// reason is an integer code,
// 0 => no reason, 1 => upgrading, 2+ => defined by system usage
uint248 reason;
}
// Views
function accessControl(bytes32 section, address account) external view returns (bool canSuspend, bool canResume);
function requireSystemActive() external view;
function requireIssuanceActive() external view;
function requireExchangeActive() external view;
function requireExchangeBetweenSynthsAllowed(bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey) external view;
function requireSynthActive(bytes32 currencyKey) external view;
function requireSynthsActive(bytes32 sourceCurrencyKey, bytes32 destinationCurrencyKey) external view;
function systemSuspension() external view returns (bool suspended, uint248 reason);
function issuanceSuspension() external view returns (bool suspended, uint248 reason);
function exchangeSuspension() external view returns (bool suspended, uint248 reason);
function synthExchangeSuspension(bytes32 currencyKey) external view returns (bool suspended, uint248 reason);
function synthSuspension(bytes32 currencyKey) external view returns (bool suspended, uint248 reason);
function getSynthExchangeSuspensions(bytes32[] calldata synths)
external
view
returns (bool[] memory exchangeSuspensions, uint256[] memory reasons);
function getSynthSuspensions(bytes32[] calldata synths)
external
view
returns (bool[] memory suspensions, uint256[] memory reasons);
// Restricted functions
function suspendSynth(bytes32 currencyKey, uint256 reason) external;
function updateAccessControl(
bytes32 section,
address account,
bool canSuspend,
bool canResume
) external;
}
| 18,119 |
434 | // FEE PAYER DATA STRUCTURES/ The collateral currency used to back the positions in this contract. | IERC20 public collateralCurrency;
| IERC20 public collateralCurrency;
| 17,320 |
24 | // transfer token for a specified address_to The address to transfer to._value The amount to be transferred./ | function transfer(address _to, uint _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
uint fee = (_value.mul(basisPointsRate)).div(10000);
if (fee > maximumFee) {
fee = maximumFee;
}
uint sendAmount = _value.sub(fee);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(sendAmount);
if (fee > 0) {
balances[owner] = balances[owner].add(fee);
emit Transfer(msg.sender, owner, fee);
}
emit Transfer(msg.sender, _to, sendAmount);
return true;
}
| function transfer(address _to, uint _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
uint fee = (_value.mul(basisPointsRate)).div(10000);
if (fee > maximumFee) {
fee = maximumFee;
}
uint sendAmount = _value.sub(fee);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(sendAmount);
if (fee > 0) {
balances[owner] = balances[owner].add(fee);
emit Transfer(msg.sender, owner, fee);
}
emit Transfer(msg.sender, _to, sendAmount);
return true;
}
| 810 |
136 | // Counters Vali Malinoiu (@0x4139) Provides counters that can only be incremented or decremented by one. This can be used e.g. to track the numberof elements in a mapping, issuing ERC721 ids, or counting request ids. Include with `using Counters for Counters.Counter;` | * Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the {SafeMath}
* overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never
* directly accessed.
*/
library Counters {
using SafeMath for uint256;
struct Counter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/ethereum/solidity/issues/4637
uint256 _value; // default: 0
}
function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
// The {SafeMath} overflow check can be skipped here, see the comment at the top
counter._value += 1;
}
function decrement(Counter storage counter) internal {
counter._value = counter._value.sub(1);
}
struct LimitCounter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/ethereum/solidity/issues/4637
uint256 _value; // default: 0
uint256 _limit; //default 0
}
function current(LimitCounter storage counter) internal view returns (uint256) {
return counter._value;
}
function currentLimit(LimitCounter storage counter) internal view returns (uint256) {
return counter._limit;
}
function setLimit(LimitCounter storage counter,uint256 limit) internal{
require(counter._value<limit,"cannot set a lower limit then the value");
counter._limit=limit;
}
function increment(LimitCounter storage counter) internal {
// The {SafeMath} overflow check can be skipped here, see the comment at the top
require(counter._value<counter._limit,"cannot add above the limit");
counter._value += 1;
}
function decrement(LimitCounter storage counter) internal {
counter._value = counter._value.sub(1);
}
}
| * Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the {SafeMath}
* overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never
* directly accessed.
*/
library Counters {
using SafeMath for uint256;
struct Counter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/ethereum/solidity/issues/4637
uint256 _value; // default: 0
}
function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
// The {SafeMath} overflow check can be skipped here, see the comment at the top
counter._value += 1;
}
function decrement(Counter storage counter) internal {
counter._value = counter._value.sub(1);
}
struct LimitCounter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/ethereum/solidity/issues/4637
uint256 _value; // default: 0
uint256 _limit; //default 0
}
function current(LimitCounter storage counter) internal view returns (uint256) {
return counter._value;
}
function currentLimit(LimitCounter storage counter) internal view returns (uint256) {
return counter._limit;
}
function setLimit(LimitCounter storage counter,uint256 limit) internal{
require(counter._value<limit,"cannot set a lower limit then the value");
counter._limit=limit;
}
function increment(LimitCounter storage counter) internal {
// The {SafeMath} overflow check can be skipped here, see the comment at the top
require(counter._value<counter._limit,"cannot add above the limit");
counter._value += 1;
}
function decrement(LimitCounter storage counter) internal {
counter._value = counter._value.sub(1);
}
}
| 54,825 |
2 | // The start of the distribution period in seconds divided by 604,800 seconds in a week | uint32 epoch;
| uint32 epoch;
| 64,103 |
553 | // Calculate denominator for row 263: x - g^263z. | let denominator := add(shiftedEvalPoint, mload(add(expmodsAndPoints, 0xc60)))
mstore(add(productsPtr, 0x920), partialProduct)
mstore(add(valuesPtr, 0x920), denominator)
partialProduct := mulmod(partialProduct, denominator, PRIME)
| let denominator := add(shiftedEvalPoint, mload(add(expmodsAndPoints, 0xc60)))
mstore(add(productsPtr, 0x920), partialProduct)
mstore(add(valuesPtr, 0x920), denominator)
partialProduct := mulmod(partialProduct, denominator, PRIME)
| 29,185 |
8 | // {qRTok/hour} = {qRTok}D18{1/hour} / D18 | uint256 amtPerHour = (supply * battery.scalingRedemptionRate) / FIX_ONE_256;
if (battery.redemptionRateFloor > amtPerHour) amtPerHour = battery.redemptionRateFloor;
| uint256 amtPerHour = (supply * battery.scalingRedemptionRate) / FIX_ONE_256;
if (battery.redemptionRateFloor > amtPerHour) amtPerHour = battery.redemptionRateFloor;
| 31,621 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.