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 |
|---|---|---|---|---|
189 | // Returns the downcasted int136 from int256, reverting onoverflow (when the input is less than smallest int136 orgreater than largest int136). Counterpart to Solidity's `int136` operator. Requirements: - input must fit into 136 bits _Available since v4.7._ / | function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
require(downcasted == value, "SafeCast: value doesn't fit in 136 bits");
}
| function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
require(downcasted == value, "SafeCast: value doesn't fit in 136 bits");
}
| 14,464 |
54 | // function getpreSignTradeHash(address tokenGet,uint amountGet,address tokenGive,uint amountGive,uint expires,uint nonce, address _from)public view returns (bytes32) | // {
// return keccak256(abi.encodePacked(_from, tokenGet, amountGet, tokenGive, amountGive, expires, nonce));
// }
| // {
// return keccak256(abi.encodePacked(_from, tokenGet, amountGet, tokenGive, amountGive, expires, nonce));
// }
| 53,642 |
135 | // Thismay be different from totalDisbursed depending on number of eligible accounts. The primary use of this attribute is more of a flag to indicate the medium prize is disbursed fully. | mediumPrizeTotal = 0;
emit MediumPrizeReceivedAddresses(eligibleAddresses, mediumPrize);
return true;
| mediumPrizeTotal = 0;
emit MediumPrizeReceivedAddresses(eligibleAddresses, mediumPrize);
return true;
| 60,477 |
118 | // Reduce from owner liquidity | if (liquidityDetailsOwner._highRisk >= _poolBalances[_highRiskUsers[i]][false].mul(300).div(1000)) {
liquidityDetailsOwner._highRisk -= _poolBalances[_highRiskUsers[i]][false].mul(300).div(1000);
| if (liquidityDetailsOwner._highRisk >= _poolBalances[_highRiskUsers[i]][false].mul(300).div(1000)) {
liquidityDetailsOwner._highRisk -= _poolBalances[_highRiskUsers[i]][false].mul(300).div(1000);
| 30,209 |
428 | // Contract initializer. _logic address of the initial implementation. _admin Address of the proxy administrator. _data Data to send as msg.data to the implementation to initializethe proxied contract.It should include the signature and the parameters of the function to becalled, as described inhtmlfunction-selector-and-argument-encoding.This parameter is optional, if no data is given the initialization calltoproxied contract will be skipped. / | function initialize(
address _logic,
address _admin,
bytes memory _data
| function initialize(
address _logic,
address _admin,
bytes memory _data
| 9,737 |
33 | // calculate available refunds | uint256 availableRefund = nftBalance * _currency.balanceOf(address(this)) / projectLifetimeContribution[currencyId];
| uint256 availableRefund = nftBalance * _currency.balanceOf(address(this)) / projectLifetimeContribution[currencyId];
| 12,695 |
133 | // Safe tknv transfer function, just in case if rounding error causes pool to not have enough $TKNV | function safeTKNVTransfer(address _to, uint256 _amount) internal {
uint256 tknvBal = tknv.balanceOf(address(this));
if (_amount > tknvBal) {
tknv.transfer(_to, tknvBal);
} else {
tknv.transfer(_to, _amount);
}
}
| function safeTKNVTransfer(address _to, uint256 _amount) internal {
uint256 tknvBal = tknv.balanceOf(address(this));
if (_amount > tknvBal) {
tknv.transfer(_to, tknvBal);
} else {
tknv.transfer(_to, _amount);
}
}
| 8,047 |
30 | // PPDEX address | address public PPDEX;
| address public PPDEX;
| 45,102 |
3 | // Mint shiny Hegexoption, Chef only _to Beneficiary / | function mintHegexoption(address _to) public onlyOwner returns (uint256)
| function mintHegexoption(address _to) public onlyOwner returns (uint256)
| 80,615 |
4 | // Initialize totalRewards and totalPoints with small non-zero values | totalRewards = 1 wei; // 1 wei
totalPoints = 1;
| totalRewards = 1 wei; // 1 wei
totalPoints = 1;
| 6,945 |
4 | // ifwhitelist, set groupId = 0 | if(sk.isWhite){
sk.groupId = bytes32(0x00);
}
| if(sk.isWhite){
sk.groupId = bytes32(0x00);
}
| 30,070 |
295 | // We sum from large to small iteration so that we can have higher powers in later terms | for (int216 iteration = maxIterations - 1; iteration >= 0; iteration--) {
accumulator = REAL_ONE - mul(div(mul(realArg, realArg), toReal((2 * iteration + 2) * (2 * iteration + 3))), accumulator);
| for (int216 iteration = maxIterations - 1; iteration >= 0; iteration--) {
accumulator = REAL_ONE - mul(div(mul(realArg, realArg), toReal((2 * iteration + 2) * (2 * iteration + 3))), accumulator);
| 37,151 |
121 | // The 40 bit is flag to distinguish prints - 1 for print | uint256 constant SEED_MASK = uint40(~0);
uint256 constant PRINTS_FLAG_BIT = 1 << 39;
| uint256 constant SEED_MASK = uint40(~0);
uint256 constant PRINTS_FLAG_BIT = 1 << 39;
| 20,344 |
11 | // advance the value by the current collateral balance tokens on the account token scanned | if (0 < collateralBalance[_account][collateralTokens[i]]) {
value = value.add(tokenValue(collateralTokens[i], collateralBalance[_account][collateralTokens[i]]));
}
| if (0 < collateralBalance[_account][collateralTokens[i]]) {
value = value.add(tokenValue(collateralTokens[i], collateralBalance[_account][collateralTokens[i]]));
}
| 44,819 |
65 | // Extra bits for length codes 257..285 | uint8[29] memory lext =
[
0,
0,
0,
0,
0,
0,
0,
0,
| uint8[29] memory lext =
[
0,
0,
0,
0,
0,
0,
0,
0,
| 1,948 |
20 | // Collects tax./tokenId_ ID of token to collect tax for./Strictly envoked by modifier but can be called publically. | function collectTax(uint256 tokenId_) public {
uint256 valuation = valuationOf(tokenId_);
// There's no tax to be collected on an unvalued token.
if (valuation == 0) return;
// If valuation > 0, contract has not foreclosed.
uint256 owed = _taxOwed(tokenId_);
// Owed will be 0 when the token is owned by its beneficiary.
// i.e. no tax is owed.
if (owed == 0) return;
// If foreclosure should have occured in the past, last collection time will be
// backdated to when the tax was last paid for.
if (foreclosed(tokenId_)) {
_setLastCollectionTime(tokenId_, _backdatedForeclosureTime(tokenId_));
// Set remaining deposit to be collected.
owed = depositOf(tokenId_);
} else {
_setLastCollectionTime(tokenId_, block.timestamp);
}
// Normal collection
_setDeposit(tokenId_, depositOf(tokenId_) - owed);
taxationCollected[tokenId_] += owed;
_setTaxCollectedSinceLastTransfer(
tokenId_,
taxCollectedSinceLastTransferOf(tokenId_) + owed
);
emit LogCollection(tokenId_, owed);
/// Remit taxation to beneficiary.
_remit(beneficiaryOf(tokenId_), owed, RemittanceTriggers.TaxCollection);
_forecloseIfNecessary(tokenId_);
}
| function collectTax(uint256 tokenId_) public {
uint256 valuation = valuationOf(tokenId_);
// There's no tax to be collected on an unvalued token.
if (valuation == 0) return;
// If valuation > 0, contract has not foreclosed.
uint256 owed = _taxOwed(tokenId_);
// Owed will be 0 when the token is owned by its beneficiary.
// i.e. no tax is owed.
if (owed == 0) return;
// If foreclosure should have occured in the past, last collection time will be
// backdated to when the tax was last paid for.
if (foreclosed(tokenId_)) {
_setLastCollectionTime(tokenId_, _backdatedForeclosureTime(tokenId_));
// Set remaining deposit to be collected.
owed = depositOf(tokenId_);
} else {
_setLastCollectionTime(tokenId_, block.timestamp);
}
// Normal collection
_setDeposit(tokenId_, depositOf(tokenId_) - owed);
taxationCollected[tokenId_] += owed;
_setTaxCollectedSinceLastTransfer(
tokenId_,
taxCollectedSinceLastTransferOf(tokenId_) + owed
);
emit LogCollection(tokenId_, owed);
/// Remit taxation to beneficiary.
_remit(beneficiaryOf(tokenId_), owed, RemittanceTriggers.TaxCollection);
_forecloseIfNecessary(tokenId_);
}
| 20,028 |
59 | // Calculates exchange amount for DAI to token.amountDAI Amount of DAI, in base units / | function calculateAmountForDAI(uint256 amountDAI) public view returns (uint256) {
return Rationals.rmul(amountDAI, daiRate);
}
| function calculateAmountForDAI(uint256 amountDAI) public view returns (uint256) {
return Rationals.rmul(amountDAI, daiRate);
}
| 60,050 |
85 | // Get the full Merkle root and set _MERKLE_ROOT_ in storage. | MerkleRoot memory fullMerkleRoot = MerkleRoot({
merkleRoot: merkleRoot,
ipfsCid: ipfsCid
});
| MerkleRoot memory fullMerkleRoot = MerkleRoot({
merkleRoot: merkleRoot,
ipfsCid: ipfsCid
});
| 43,506 |
147 | // The token TOKEN! | Token public token;
| Token public token;
| 21,730 |
433 | // Max length in bytes of ancillary data that can be appended to a price request. As of December 2020, the current Ethereum gas limit is 12.5 million. This requestPrice function's gas primarily comes from computing a Keccak-256 hash in _encodePriceRequest and writing a new PriceRequest to storage. We have empirically determined an ancillary data limit of 8192 bytes that keeps this function well within the gas limit at ~8 million gas. To learn more about the gas limit and EVM opcode costs go here: - https:etherscan.io/chart/gaslimit - https:github.com/djrtwo/evm-opcode-gas-costs | uint256 public constant ancillaryBytesLimit = 8192;
bytes32 public snapshotMessageHash = ECDSA.toEthSignedMessageHash(keccak256(bytes("Sign For Snapshot")));
| uint256 public constant ancillaryBytesLimit = 8192;
bytes32 public snapshotMessageHash = ECDSA.toEthSignedMessageHash(keccak256(bytes("Sign For Snapshot")));
| 9,967 |
3 | // solium-disable-next-line security/no-assign-params | function uint2str(uint _i) internal pure returns (string memory) {
if (_i == 0) {
return "0";
}
uint j = _i;
uint len;
while (j != 0) {
len++;
j /= 10;
}
bytes memory bstr = new bytes(len);
uint k = len - 1;
while (_i != 0) {
bstr[k--] = byte(uint8(48 + _i % 10));
_i /= 10;
}
return string(bstr);
}
| function uint2str(uint _i) internal pure returns (string memory) {
if (_i == 0) {
return "0";
}
uint j = _i;
uint len;
while (j != 0) {
len++;
j /= 10;
}
bytes memory bstr = new bytes(len);
uint k = len - 1;
while (_i != 0) {
bstr[k--] = byte(uint8(48 + _i % 10));
_i /= 10;
}
return string(bstr);
}
| 16,843 |
102 | // solhint-disable-next-line max-line-length | require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
| require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
| 1,432 |
67 | // verifies that the gas price is lower than the universal limit | modifier validGasPrice() {
assert(tx.gasprice <= gasPrice);
_;
}
| modifier validGasPrice() {
assert(tx.gasprice <= gasPrice);
_;
}
| 30,981 |
25 | // Asserts are used to use static analysis to find bugs in your code. They should never fail | assert(balanceOf[_from].add(balanceOf[_to]) == previousBalances);
| assert(balanceOf[_from].add(balanceOf[_to]) == previousBalances);
| 24,353 |
7 | // store addresses that are automatic market maker pairs. Transfers to these addresses could be subject to a maximum transfer amount | mapping(address => bool) public automatedMarketMakerPairs;
| mapping(address => bool) public automatedMarketMakerPairs;
| 12,562 |
106 | // Add a value to a set. O(1). Returns true if the value was added to the set, that is if it was notalready present. / | function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
| function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
| 2,171 |
7 | // VIEWS//This view returns minimum valid deposit/ return Minimum valid deposit of ETH | function get_deposit_minimum() public override view returns(uint256){
return minimum_deposit;
}
| function get_deposit_minimum() public override view returns(uint256){
return minimum_deposit;
}
| 6,428 |
148 | // Map to allow the share holders to withdraw board meeting fees | mapping (address => uint) public pendingFeesWithdrawals;
| mapping (address => uint) public pendingFeesWithdrawals;
| 42,695 |
15 | // Deposit all rHEGIC to the redemption contract. Once this is executed,no new deposit will be accepted, and users will not be able to claim rHEGIC refund. / | function provideToGTS() external onlyOwner {
rHEGIC.approve(address(GTS), totalDeposited);
GTS.provide(totalDeposited);
allowDeposit = false;
allowClaimRefund = false;
}
| function provideToGTS() external onlyOwner {
rHEGIC.approve(address(GTS), totalDeposited);
GTS.provide(totalDeposited);
allowDeposit = false;
allowClaimRefund = false;
}
| 36,994 |
0 | // Minimal Aave V2 LendingPool interface | interface ILendingPool {
/**
* @dev Deposits an `amount` of underlying asset into the reserve, receiving in return overlying aTokens.
* - E.g. User deposits 100 USDC and gets in return 100 aUSDC
* @param asset The address of the underlying asset to deposit
* @param amount The amount to be deposited
* @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user
* wants to receive them on his own wallet, or a different address if the beneficiary of aTokens
* is a different wallet
* @param referralCode Code used to register the integrator originating the operation, for potential rewards.
* 0 if the action is executed directly by the user, without any middle-man
**/
function deposit(
address asset,
uint256 amount,
address onBehalfOf,
uint16 referralCode
) external;
/**
* @dev Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned
* E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC
* @param asset The address of the underlying asset to withdraw
* @param amount The underlying amount to be withdrawn
* - Send the value type(uint256).max in order to withdraw the whole aToken balance
* @param to Address that will receive the underlying, same as msg.sender if the user
* wants to receive it on his own wallet, or a different address if the beneficiary is a
* different wallet
* @return The final amount withdrawn
**/
function withdraw(
address asset,
uint256 amount,
address to
) external returns (uint256);
}
| interface ILendingPool {
/**
* @dev Deposits an `amount` of underlying asset into the reserve, receiving in return overlying aTokens.
* - E.g. User deposits 100 USDC and gets in return 100 aUSDC
* @param asset The address of the underlying asset to deposit
* @param amount The amount to be deposited
* @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user
* wants to receive them on his own wallet, or a different address if the beneficiary of aTokens
* is a different wallet
* @param referralCode Code used to register the integrator originating the operation, for potential rewards.
* 0 if the action is executed directly by the user, without any middle-man
**/
function deposit(
address asset,
uint256 amount,
address onBehalfOf,
uint16 referralCode
) external;
/**
* @dev Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned
* E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC
* @param asset The address of the underlying asset to withdraw
* @param amount The underlying amount to be withdrawn
* - Send the value type(uint256).max in order to withdraw the whole aToken balance
* @param to Address that will receive the underlying, same as msg.sender if the user
* wants to receive it on his own wallet, or a different address if the beneficiary is a
* different wallet
* @return The final amount withdrawn
**/
function withdraw(
address asset,
uint256 amount,
address to
) external returns (uint256);
}
| 5,890 |
265 | // Redeem mAsset for one or more bAssets / | {
require(_recipient != address(0), "Must be a valid recipient");
uint256 bAssetCount = _bAssetQuantities.length;
require(bAssetCount > 0 && bAssetCount == _bAssets.length, "Input array mismatch");
// Prepare relevant data
RedeemProps memory props = basketManager.prepareRedeemBassets(_bAssets);
if(!props.isValid) return 0;
Cache memory cache = _getCacheDetails();
// Validate redemption
(bool redemptionValid, string memory reason, bool applyFee) =
forgeValidator.validateRedemption(false, cache.vaultBalanceSum, props.allBassets, props.indexes, _bAssetQuantities);
require(redemptionValid, reason);
uint256 mAssetQuantity = 0;
// Calc total redeemed mAsset quantity
for(uint256 i = 0; i < bAssetCount; i++){
uint256 bAssetQuantity = _bAssetQuantities[i];
if(bAssetQuantity > 0){
// Calc equivalent mAsset amount
uint256 ratioedBasset = bAssetQuantity.mulRatioTruncateCeil(props.bAssets[i].ratio);
mAssetQuantity = mAssetQuantity.add(ratioedBasset);
}
}
require(mAssetQuantity > 0, "Must redeem some bAssets");
// Redemption has fee? Fetch the rate
uint256 fee = applyFee ? swapFee : 0;
// Apply fees, burn mAsset and return bAsset to recipient
_settleRedemption(
RedemptionSettlement({
recipient: _recipient,
mAssetQuantity: mAssetQuantity,
bAssetQuantities: _bAssetQuantities,
indices: props.indexes,
integrators: props.integrators,
feeRate: fee,
bAssets: props.bAssets,
cache: cache
})
);
emit Redeemed(msg.sender, _recipient, mAssetQuantity, _bAssets, _bAssetQuantities);
return mAssetQuantity;
}
| {
require(_recipient != address(0), "Must be a valid recipient");
uint256 bAssetCount = _bAssetQuantities.length;
require(bAssetCount > 0 && bAssetCount == _bAssets.length, "Input array mismatch");
// Prepare relevant data
RedeemProps memory props = basketManager.prepareRedeemBassets(_bAssets);
if(!props.isValid) return 0;
Cache memory cache = _getCacheDetails();
// Validate redemption
(bool redemptionValid, string memory reason, bool applyFee) =
forgeValidator.validateRedemption(false, cache.vaultBalanceSum, props.allBassets, props.indexes, _bAssetQuantities);
require(redemptionValid, reason);
uint256 mAssetQuantity = 0;
// Calc total redeemed mAsset quantity
for(uint256 i = 0; i < bAssetCount; i++){
uint256 bAssetQuantity = _bAssetQuantities[i];
if(bAssetQuantity > 0){
// Calc equivalent mAsset amount
uint256 ratioedBasset = bAssetQuantity.mulRatioTruncateCeil(props.bAssets[i].ratio);
mAssetQuantity = mAssetQuantity.add(ratioedBasset);
}
}
require(mAssetQuantity > 0, "Must redeem some bAssets");
// Redemption has fee? Fetch the rate
uint256 fee = applyFee ? swapFee : 0;
// Apply fees, burn mAsset and return bAsset to recipient
_settleRedemption(
RedemptionSettlement({
recipient: _recipient,
mAssetQuantity: mAssetQuantity,
bAssetQuantities: _bAssetQuantities,
indices: props.indexes,
integrators: props.integrators,
feeRate: fee,
bAssets: props.bAssets,
cache: cache
})
);
emit Redeemed(msg.sender, _recipient, mAssetQuantity, _bAssets, _bAssetQuantities);
return mAssetQuantity;
}
| 38,043 |
188 | // Returns hash of a message that can be signed by owners./message Message that should be hashed/ return Message hash. | function getMessageHash(bytes memory message) public view returns (bytes32) {
return getMessageHashForSafe(GnosisSafe(payable(msg.sender)), message);
}
| function getMessageHash(bytes memory message) public view returns (bytes32) {
return getMessageHashForSafe(GnosisSafe(payable(msg.sender)), message);
}
| 30,337 |
6 | // Returns number of token burned. / | function _burned() internal view returns (uint256 burned){
uint256 startBucket = _startTokenId() >> 8;
uint256 lastBucket = (_nextTokenId() >> 8) + 1;
for(uint256 i=startBucket; i < lastBucket; i++) {
uint256 bucket = _burnedToken.getBucket(i);
burned += _popcount(bucket);
}
}
| function _burned() internal view returns (uint256 burned){
uint256 startBucket = _startTokenId() >> 8;
uint256 lastBucket = (_nextTokenId() >> 8) + 1;
for(uint256 i=startBucket; i < lastBucket; i++) {
uint256 bucket = _burnedToken.getBucket(i);
burned += _popcount(bucket);
}
}
| 31,002 |
7 | // Getter function to find out the pending owner address The pending address is 0 when there is no transfer of owner in progressreturn pendingOwner The pending owner address, if any / | function pendingOwner() external view returns (address);
| function pendingOwner() external view returns (address);
| 30,466 |
3 | // called after deployment | function initialize(address _rewardAddr, address _configContractAddr, address _ballotFactoryAddr, address _stakingAddr) external onlyOwner {
require(_rewardAddr != address(0) && _configContractAddr != address(0) && _ballotFactoryAddr != address(0) && _stakingAddr != address(0), 'TomiGovernance: INPUT_ADDRESS_IS_ZERO');
stakingAddr = _stakingAddr;
rewardAddr = _rewardAddr;
configAddr = _configContractAddr;
ballotFactoryAddr = _ballotFactoryAddr;
lockTime = getConfigValue(ConfigNames.UNSTAKE_DURATION);
}
| function initialize(address _rewardAddr, address _configContractAddr, address _ballotFactoryAddr, address _stakingAddr) external onlyOwner {
require(_rewardAddr != address(0) && _configContractAddr != address(0) && _ballotFactoryAddr != address(0) && _stakingAddr != address(0), 'TomiGovernance: INPUT_ADDRESS_IS_ZERO');
stakingAddr = _stakingAddr;
rewardAddr = _rewardAddr;
configAddr = _configContractAddr;
ballotFactoryAddr = _ballotFactoryAddr;
lockTime = getConfigValue(ConfigNames.UNSTAKE_DURATION);
}
| 16,512 |
338 | // 指定pool的资产数量/poolIndex 池子索引号/ return 以本币计价的池子资产数量 | function assetsOfPool(uint poolIndex) external view returns(uint);
| function assetsOfPool(uint poolIndex) external view returns(uint);
| 35,492 |
36 | // verify bet amount range. | uint256 value = uint256(amount);
require(_safeTypeConversion(value, amount), "Not safe type conversion");
require(value >= minBet && value <= maxBet, "Bet amount is out of range.");
uint256 lockValue = value.mul(LOCK_RATIO).div(THIS_DIVISOR);
require(lockValue <= balanceOf(gambler).sub(lockedOf(gambler)), "Balance is not enough for locked.");
| uint256 value = uint256(amount);
require(_safeTypeConversion(value, amount), "Not safe type conversion");
require(value >= minBet && value <= maxBet, "Bet amount is out of range.");
uint256 lockValue = value.mul(LOCK_RATIO).div(THIS_DIVISOR);
require(lockValue <= balanceOf(gambler).sub(lockedOf(gambler)), "Balance is not enough for locked.");
| 49,404 |
61 | // Add int value to set at dictionary[key]. O(1). _key The bytes32 key. _value The int value.return bool true if succeeded (no conflicts). / | function addIntForKey(bytes32 _key, int256 _value) public returns (bool) {
return dictionary.addIntForKey(_key, _value);
}
| function addIntForKey(bytes32 _key, int256 _value) public returns (bool) {
return dictionary.addIntForKey(_key, _value);
}
| 26,391 |
47 | // Pay the Team Growth Bonus... Note the direct enroller never gets these for their first two membership positions (even on renewals) -- and they can't be collected from the first line of enrollership either -- | if(isTeamGrowthQualified(enroller, _currentID) && (getSecondMemberID(enroller) != _currentID))
{
(success, ) = enroller.call{value: pp4}("");
| if(isTeamGrowthQualified(enroller, _currentID) && (getSecondMemberID(enroller) != _currentID))
{
(success, ) = enroller.call{value: pp4}("");
| 41,513 |
123 | // Engine will consider inventory and team size in zone (17k) | return engine.modifyReward(
fb,
editions[editionIndex].modifyReward(reward, tokenId),
governance.getAccount(ownerContext),
context
);
| return engine.modifyReward(
fb,
editions[editionIndex].modifyReward(reward, tokenId),
governance.getAccount(ownerContext),
context
);
| 69,687 |
27 | // Storiqa pre-sale contract | contract STQPreSale is Ownable, ReentrancyGuard {
using SafeMath for uint256;
event FundTransfer(address backer, uint amount, bool isContribution);
function STQPreSale(address token, address funds) {
require(address(0) != address(token) && address(0) != address(funds));
m_token = STQToken(token);
m_funds = funds;
}
// PUBLIC interface: payments
// fallback function as a shortcut
function() payable {
require(0 == msg.data.length);
buy(); // only internal call here!
}
/// @notice ICO participation
/// @return number of STQ tokens bought (with all decimal symbols)
function buy()
public
payable
nonReentrant
returns (uint)
{
address investor = msg.sender;
uint256 payment = msg.value;
require(payment >= c_MinInvestment);
require(now < 1507766400);
// issue tokens
uint stq = payment.mul(c_STQperETH);
m_token.mint(investor, stq);
// record payment
m_funds.transfer(payment);
FundTransfer(investor, payment, true);
return stq;
}
/// @notice Tests ownership of the current caller.
/// @return true if it's an owner
// It's advisable to call it by new owner to make sure that the same erroneous address is not copy-pasted to
// addOwner/changeOwner and to isOwner.
function amIOwner() external constant onlyOwner returns (bool) {
return true;
}
// FIELDS
/// @notice starting exchange rate of STQ
uint public constant c_STQperETH = 150000;
/// @notice minimum investment
uint public constant c_MinInvestment = 10 finney;
/// @dev contract responsible for token accounting
STQToken public m_token;
/// @dev address responsible for investments accounting
address public m_funds;
}
| contract STQPreSale is Ownable, ReentrancyGuard {
using SafeMath for uint256;
event FundTransfer(address backer, uint amount, bool isContribution);
function STQPreSale(address token, address funds) {
require(address(0) != address(token) && address(0) != address(funds));
m_token = STQToken(token);
m_funds = funds;
}
// PUBLIC interface: payments
// fallback function as a shortcut
function() payable {
require(0 == msg.data.length);
buy(); // only internal call here!
}
/// @notice ICO participation
/// @return number of STQ tokens bought (with all decimal symbols)
function buy()
public
payable
nonReentrant
returns (uint)
{
address investor = msg.sender;
uint256 payment = msg.value;
require(payment >= c_MinInvestment);
require(now < 1507766400);
// issue tokens
uint stq = payment.mul(c_STQperETH);
m_token.mint(investor, stq);
// record payment
m_funds.transfer(payment);
FundTransfer(investor, payment, true);
return stq;
}
/// @notice Tests ownership of the current caller.
/// @return true if it's an owner
// It's advisable to call it by new owner to make sure that the same erroneous address is not copy-pasted to
// addOwner/changeOwner and to isOwner.
function amIOwner() external constant onlyOwner returns (bool) {
return true;
}
// FIELDS
/// @notice starting exchange rate of STQ
uint public constant c_STQperETH = 150000;
/// @notice minimum investment
uint public constant c_MinInvestment = 10 finney;
/// @dev contract responsible for token accounting
STQToken public m_token;
/// @dev address responsible for investments accounting
address public m_funds;
}
| 19,876 |
43 | // Getting number stats, access: ANY/ return _maxCapacities is a max liquidity of the pool/ return _buyPolicyCapacity is becuase to follow the same function in policy book/ return _totalSTBLLiquidity is PolicyBook's liquidity/ return _totalLeveragedLiquidity is becuase to follow the same function in policy book/ return _stakedSTBL is how much stable coin are staked on this PolicyBook/ return _annualProfitYields is its APY/ return _annualInsuranceCost is becuase to follow the same function in policy book/ return_bmiXRatio is multiplied by 1018. To get STBL representation | function numberStats()
external
view
override
returns (
uint256 _maxCapacities,
uint256 _buyPolicyCapacity,
uint256 _totalSTBLLiquidity,
uint256 _totalLeveragedLiquidity,
uint256 _stakedSTBL,
| function numberStats()
external
view
override
returns (
uint256 _maxCapacities,
uint256 _buyPolicyCapacity,
uint256 _totalSTBLLiquidity,
uint256 _totalLeveragedLiquidity,
uint256 _stakedSTBL,
| 7,403 |
11 | // computes the nearest integer to a given quotient without overflowing or underflowing. / | function roundDiv(uint256 n, uint256 d) internal pure returns (uint256) {
return n / d + (n % d) / (d - d / 2);
}
| function roundDiv(uint256 n, uint256 d) internal pure returns (uint256) {
return n / d + (n % d) / (d - d / 2);
}
| 12,222 |
92 | // PostKYCCrowdsale/Sicos et al. | contract PostKYCCrowdsale is Crowdsale, Ownable {
struct Investment {
bool isVerified; // wether or not the investor passed the KYC process
uint totalWeiInvested; // total invested wei regardless of verification state
// amount of token an unverified investor bought. should be zero for verified investors
uint pendingTokenAmount;
}
// total amount of wei held by unverified investors should never be larger than this.balance
uint public pendingWeiAmount = 0;
// maps investor addresses to investment information
mapping(address => Investment) public investments;
/// @dev Log entry on investor verified
/// @param investor the investor's Ethereum address
event InvestorVerified(address investor);
/// @dev Log entry on tokens delivered
/// @param investor the investor's Ethereum address
/// @param amount token amount delivered
event TokensDelivered(address investor, uint amount);
/// @dev Log entry on investment withdrawn
/// @param investor the investor's Ethereum address
/// @param value the wei amount withdrawn
event InvestmentWithdrawn(address investor, uint value);
/// @dev Verify investors
/// @param _investors list of investors' Ethereum addresses
function verifyInvestors(address[] _investors) public onlyOwner {
for (uint i = 0; i < _investors.length; ++i) {
address investor = _investors[i];
Investment storage investment = investments[investor];
if (!investment.isVerified) {
investment.isVerified = true;
emit InvestorVerified(investor);
uint pendingTokenAmount = investment.pendingTokenAmount;
// now we issue tokens to the verfied investor
if (pendingTokenAmount > 0) {
investment.pendingTokenAmount = 0;
_forwardFunds(investment.totalWeiInvested);
_deliverTokens(investor, pendingTokenAmount);
emit TokensDelivered(investor, pendingTokenAmount);
}
}
}
}
/// @dev Withdraw investment
/// @dev Investors that are not verified can withdraw their funds
function withdrawInvestment() public {
Investment storage investment = investments[msg.sender];
require(!investment.isVerified);
uint totalWeiInvested = investment.totalWeiInvested;
require(totalWeiInvested > 0);
investment.totalWeiInvested = 0;
investment.pendingTokenAmount = 0;
pendingWeiAmount = pendingWeiAmount.sub(totalWeiInvested);
msg.sender.transfer(totalWeiInvested);
emit InvestmentWithdrawn(msg.sender, totalWeiInvested);
assert(pendingWeiAmount <= address(this).balance);
}
/// @dev Prevalidate purchase
/// @param _beneficiary the investor's Ethereum address
/// @param _weiAmount the wei amount invested
function _preValidatePurchase(address _beneficiary, uint _weiAmount) internal {
// We only want the msg.sender to buy tokens
require(_beneficiary == msg.sender);
super._preValidatePurchase(_beneficiary, _weiAmount);
}
/// @dev Process purchase
/// @param _tokenAmount the token amount purchased
function _processPurchase(address, uint _tokenAmount) internal {
Investment storage investment = investments[msg.sender];
investment.totalWeiInvested = investment.totalWeiInvested.add(msg.value);
if (investment.isVerified) {
// If the investor's KYC is already verified we issue the tokens imediatly
_deliverTokens(msg.sender, _tokenAmount);
emit TokensDelivered(msg.sender, _tokenAmount);
} else {
// If the investor's KYC is not verified we store the pending token amount
investment.pendingTokenAmount = investment.pendingTokenAmount.add(_tokenAmount);
pendingWeiAmount = pendingWeiAmount.add(msg.value);
}
}
/// @dev Forward funds
function _forwardFunds() internal {
// Ensure the investor was verified, i.e. his purchased tokens were delivered,
// before forwarding funds.
if (investments[msg.sender].isVerified) {
super._forwardFunds();
}
}
/// @dev Forward funds
/// @param _weiAmount the amount to be transfered
function _forwardFunds(uint _weiAmount) internal {
pendingWeiAmount = pendingWeiAmount.sub(_weiAmount);
wallet.transfer(_weiAmount);
}
/// @dev Postvalidate purchase
/// @param _weiAmount the amount invested
function _postValidatePurchase(address, uint _weiAmount) internal {
super._postValidatePurchase(msg.sender, _weiAmount);
// checking invariant
assert(pendingWeiAmount <= address(this).balance);
}
}
| contract PostKYCCrowdsale is Crowdsale, Ownable {
struct Investment {
bool isVerified; // wether or not the investor passed the KYC process
uint totalWeiInvested; // total invested wei regardless of verification state
// amount of token an unverified investor bought. should be zero for verified investors
uint pendingTokenAmount;
}
// total amount of wei held by unverified investors should never be larger than this.balance
uint public pendingWeiAmount = 0;
// maps investor addresses to investment information
mapping(address => Investment) public investments;
/// @dev Log entry on investor verified
/// @param investor the investor's Ethereum address
event InvestorVerified(address investor);
/// @dev Log entry on tokens delivered
/// @param investor the investor's Ethereum address
/// @param amount token amount delivered
event TokensDelivered(address investor, uint amount);
/// @dev Log entry on investment withdrawn
/// @param investor the investor's Ethereum address
/// @param value the wei amount withdrawn
event InvestmentWithdrawn(address investor, uint value);
/// @dev Verify investors
/// @param _investors list of investors' Ethereum addresses
function verifyInvestors(address[] _investors) public onlyOwner {
for (uint i = 0; i < _investors.length; ++i) {
address investor = _investors[i];
Investment storage investment = investments[investor];
if (!investment.isVerified) {
investment.isVerified = true;
emit InvestorVerified(investor);
uint pendingTokenAmount = investment.pendingTokenAmount;
// now we issue tokens to the verfied investor
if (pendingTokenAmount > 0) {
investment.pendingTokenAmount = 0;
_forwardFunds(investment.totalWeiInvested);
_deliverTokens(investor, pendingTokenAmount);
emit TokensDelivered(investor, pendingTokenAmount);
}
}
}
}
/// @dev Withdraw investment
/// @dev Investors that are not verified can withdraw their funds
function withdrawInvestment() public {
Investment storage investment = investments[msg.sender];
require(!investment.isVerified);
uint totalWeiInvested = investment.totalWeiInvested;
require(totalWeiInvested > 0);
investment.totalWeiInvested = 0;
investment.pendingTokenAmount = 0;
pendingWeiAmount = pendingWeiAmount.sub(totalWeiInvested);
msg.sender.transfer(totalWeiInvested);
emit InvestmentWithdrawn(msg.sender, totalWeiInvested);
assert(pendingWeiAmount <= address(this).balance);
}
/// @dev Prevalidate purchase
/// @param _beneficiary the investor's Ethereum address
/// @param _weiAmount the wei amount invested
function _preValidatePurchase(address _beneficiary, uint _weiAmount) internal {
// We only want the msg.sender to buy tokens
require(_beneficiary == msg.sender);
super._preValidatePurchase(_beneficiary, _weiAmount);
}
/// @dev Process purchase
/// @param _tokenAmount the token amount purchased
function _processPurchase(address, uint _tokenAmount) internal {
Investment storage investment = investments[msg.sender];
investment.totalWeiInvested = investment.totalWeiInvested.add(msg.value);
if (investment.isVerified) {
// If the investor's KYC is already verified we issue the tokens imediatly
_deliverTokens(msg.sender, _tokenAmount);
emit TokensDelivered(msg.sender, _tokenAmount);
} else {
// If the investor's KYC is not verified we store the pending token amount
investment.pendingTokenAmount = investment.pendingTokenAmount.add(_tokenAmount);
pendingWeiAmount = pendingWeiAmount.add(msg.value);
}
}
/// @dev Forward funds
function _forwardFunds() internal {
// Ensure the investor was verified, i.e. his purchased tokens were delivered,
// before forwarding funds.
if (investments[msg.sender].isVerified) {
super._forwardFunds();
}
}
/// @dev Forward funds
/// @param _weiAmount the amount to be transfered
function _forwardFunds(uint _weiAmount) internal {
pendingWeiAmount = pendingWeiAmount.sub(_weiAmount);
wallet.transfer(_weiAmount);
}
/// @dev Postvalidate purchase
/// @param _weiAmount the amount invested
function _postValidatePurchase(address, uint _weiAmount) internal {
super._postValidatePurchase(msg.sender, _weiAmount);
// checking invariant
assert(pendingWeiAmount <= address(this).balance);
}
}
| 44,325 |
40 | // incentive to redo auction | uint256 _tip = tip;
uint256 _chip = chip;
uint256 coin;
if (_tip > 0 || _chip > 0) {
uint256 _chost = chost;
if (tab >= _chost && mul(lot, feedPrice) >= _chost) {
coin = add(_tip, wmul(tab, _chip));
vat.suck(vow, kpr, coin);
}
| uint256 _tip = tip;
uint256 _chip = chip;
uint256 coin;
if (_tip > 0 || _chip > 0) {
uint256 _chost = chost;
if (tab >= _chost && mul(lot, feedPrice) >= _chost) {
coin = add(_tip, wmul(tab, _chip));
vat.suck(vow, kpr, coin);
}
| 46,760 |
46 | // Sets the maximum number of committee members/governance function called only by the functional manager/when reducing the number of members, the bottom ones are removed from the committee/_maxCommitteeSize is the maximum number of committee members | function setMaxCommitteeSize(uint8 _maxCommitteeSize) external /* onlyFunctionalManager */;
| function setMaxCommitteeSize(uint8 _maxCommitteeSize) external /* onlyFunctionalManager */;
| 18,650 |
138 | // Require the staker has locked for withdraw(currentStatus ==2) and that 7 days havepassed by since they locked for withdraw | require(now - (now % 86400) - stakes.withdrawDate >= 7 days, "7 days didn't pass");
require(stakes.currentStatus !=3 , "Miner is under dispute");
TellorTransfer.doTransfer(self,msg.sender,address(0),stakes.withdrawAmount);
if (TellorTransfer.balanceOf(self,msg.sender) == 0){
stakes.currentStatus =0 ;
self.uintVars[keccak256("stakerCount")] -= 1;
self.uintVars[keccak256("uniqueStakers")] -= 1;
}
| require(now - (now % 86400) - stakes.withdrawDate >= 7 days, "7 days didn't pass");
require(stakes.currentStatus !=3 , "Miner is under dispute");
TellorTransfer.doTransfer(self,msg.sender,address(0),stakes.withdrawAmount);
if (TellorTransfer.balanceOf(self,msg.sender) == 0){
stakes.currentStatus =0 ;
self.uintVars[keccak256("stakerCount")] -= 1;
self.uintVars[keccak256("uniqueStakers")] -= 1;
}
| 24,226 |
5 | // Declare a set state variable | EnumerableSet.AddressSet private blacklist;
| EnumerableSet.AddressSet private blacklist;
| 35,370 |
8 | // Returns the length of the array of values | function getValuesLength(AddressData storage self)
| function getValuesLength(AddressData storage self)
| 19,462 |
9 | // Set. | if (_value < self.threshold){// SortionSumDrawTree -> SortitionSumSetTree
| if (_value < self.threshold){// SortionSumDrawTree -> SortitionSumSetTree
| 16,786 |
171 | // Perform low-level call and set return values using result. | (bool ok, bytes memory returnData) = calls[i].to.call.value(
uint256(calls[i].value)
)(calls[i].data);
| (bool ok, bytes memory returnData) = calls[i].to.call.value(
uint256(calls[i].value)
)(calls[i].data);
| 7,927 |
241 | // 2.2. Withdraw from the cache, if any | if (cache > 0) {
oldIntegration.withdrawRaw(address(this), bAsset, cache);
}
| if (cache > 0) {
oldIntegration.withdrawRaw(address(this), bAsset, cache);
}
| 50,716 |
143 | // https:etherscan.io/address/0xA38fCa8c6Bf9BdA52E76EB78f08CaA3BE7c5A970 | address internal constant ONE_INCH_V_TOKEN = 0xA38fCa8c6Bf9BdA52E76EB78f08CaA3BE7c5A970;
| address internal constant ONE_INCH_V_TOKEN = 0xA38fCa8c6Bf9BdA52E76EB78f08CaA3BE7c5A970;
| 15,835 |
17 | // for Emergency/Hard stop of the sale | function emergencyStop() external onlyOwner _contractUp() _saleNotEnded() {
saleEnded = true;
emit SaleStopped(msg.sender, block.timestamp);
}
| function emergencyStop() external onlyOwner _contractUp() _saleNotEnded() {
saleEnded = true;
emit SaleStopped(msg.sender, block.timestamp);
}
| 49,368 |
1 | // A mapping from the organization (Avatar) address to the saved data of the organization: | mapping(address=>mapping(bytes32=>VoteProposal)) public organizationsProposals;
| mapping(address=>mapping(bytes32=>VoteProposal)) public organizationsProposals;
| 40,139 |
88 | // A mapping from dividend card indices to the price of the dividend card. |
mapping (uint => uint) private divCardIndexToPrice;
mapping (address => bool) internal administrators;
address public creator;
bool public onSale;
|
mapping (uint => uint) private divCardIndexToPrice;
mapping (address => bool) internal administrators;
address public creator;
bool public onSale;
| 32,338 |
253 | // Returns a slice containing the entire string. self The string to make a slice from.return A newly allocated slice containing the entire string. / | function toSlice(string memory self) internal pure returns (slice memory) {
uint ptr;
assembly {
ptr := add(self, 0x20)
}
return slice(bytes(self).length, ptr);
}
| function toSlice(string memory self) internal pure returns (slice memory) {
uint ptr;
assembly {
ptr := add(self, 0x20)
}
return slice(bytes(self).length, ptr);
}
| 3,401 |
24 | // Add in the ETH specific prefix | bytes memory prefix = "\x19Ethereum Signed Message:\n32";
bytes32 prefixedHash = keccak256(abi.encodePacked(prefix, totalHash));
| bytes memory prefix = "\x19Ethereum Signed Message:\n32";
bytes32 prefixedHash = keccak256(abi.encodePacked(prefix, totalHash));
| 4,927 |
27 | // Function that is called when a user or another contract wants to transfer funds using custom fallback._to address to which the tokens are transfered._value uint256 amount of tokens to be transfered._data bytes data along token transaction._fallback string name of the custom fallback function to be called after transaction./ | function transfer(address _to, uint256 _value, bytes _data, string _fallback) public returns (bool _success) {
if (isContract(_to)) {
if (balanceOf(msg.sender) < _value)
revert();
balances[msg.sender] = balanceOf(msg.sender).sub(_value);
balances[_to] = balanceOf(_to).add(_value);
// Calls the custom fallback function.
// Will fail if not implemented, reverting transaction.
assert(_to.call.value(0)(bytes4(keccak256(_fallback)), msg.sender, _value, _data));
Transfer(msg.sender, _to, _value, _data);
return true;
} else {
return transferToAddress(_to, _value, _data);
}
}
| function transfer(address _to, uint256 _value, bytes _data, string _fallback) public returns (bool _success) {
if (isContract(_to)) {
if (balanceOf(msg.sender) < _value)
revert();
balances[msg.sender] = balanceOf(msg.sender).sub(_value);
balances[_to] = balanceOf(_to).add(_value);
// Calls the custom fallback function.
// Will fail if not implemented, reverting transaction.
assert(_to.call.value(0)(bytes4(keccak256(_fallback)), msg.sender, _value, _data));
Transfer(msg.sender, _to, _value, _data);
return true;
} else {
return transferToAddress(_to, _value, _data);
}
}
| 401 |
42 | // Internal function that caries out voting logic voter The voter that is casting their vote proposalId The id of the proposal to vote on support The support value for the vote. 0=against, 1=for, 2=abstainreturn The number of votes cast / | function castVoteInternal(
address voter,
uint256 proposalId,
uint8 support
| function castVoteInternal(
address voter,
uint256 proposalId,
uint8 support
| 34,911 |
101 | // Mapping from owner address to mapping of operator addresses. | mapping(address => mapping(address => bool)) internal ownerToOperators;
| mapping(address => mapping(address => bool)) internal ownerToOperators;
| 72,106 |
54 | // withdraw all outstanding dividends first | if(myDividends(true) > 0) withdraw();
| if(myDividends(true) > 0) withdraw();
| 14,279 |
10 | // create second listing | uint generatedId2 = market.createListingInStore(
200,
"Leather Coat",
"Mint condition",
"",
address(this)
);
Assert.equal(generatedId2, 2, "The second listing should have id = 2");
| uint generatedId2 = market.createListingInStore(
200,
"Leather Coat",
"Mint condition",
"",
address(this)
);
Assert.equal(generatedId2, 2, "The second listing should have id = 2");
| 49,503 |
17 | // where is idToName,or no need | mapping(string => uint32) public nameToId;
mapping(uint32 => state) private Oss;
mapping(uint32 => address) public manager;
mapping(address => uint32) public times;
mapping(uint32 => bool) public isIssue;
mapping(address => string[]) public daosOf;
address public owner;
| mapping(string => uint32) public nameToId;
mapping(uint32 => state) private Oss;
mapping(uint32 => address) public manager;
mapping(address => uint32) public times;
mapping(uint32 => bool) public isIssue;
mapping(address => string[]) public daosOf;
address public owner;
| 15,243 |
165 | // Note: while the call succeeded, the action may still have "failed". | emit CallSuccess(
actionID,
!externalOk, // If another call failed this will have been rolled back
nonce,
currentCall.to,
uint256(currentCall.value),
currentCall.data,
callResults[i].returnData
);
| emit CallSuccess(
actionID,
!externalOk, // If another call failed this will have been rolled back
nonce,
currentCall.to,
uint256(currentCall.value),
currentCall.data,
callResults[i].returnData
);
| 7,922 |
8 | // Success `Jade` generation eventid Token idto Recepient addressmetadata Encoded metadata/ | event GenerateJadeSuccess(uint256 indexed id, address indexed to, uint40 metadata);
| event GenerateJadeSuccess(uint256 indexed id, address indexed to, uint40 metadata);
| 31,923 |
72 | // Subtract 20 from byte array length. | let newLen := sub(mload(b), 20)
mstore(b, newLen)
| let newLen := sub(mload(b), 20)
mstore(b, newLen)
| 37,518 |
183 | // For the trustee to allow or disallow payments made to the Bakt | function acceptPayments(bool _accepting)
public
canEnter
onlyTrustee
returns (bool)
| function acceptPayments(bool _accepting)
public
canEnter
onlyTrustee
returns (bool)
| 45,735 |
29 | // Reconstruct data using information from previous orders | if (i > 0) {
OrderState memory prevOrder = orders[i - 1];
order.wallet = address(uint(prevOrder.wallet) ^ uint(order.wallet));
order.authAddr = address(uint(prevOrder.authAddr) ^ uint(order.authAddr));
order.ringR = prevOrder.ringR ^ order.ringR;
order.ringS = prevOrder.ringS ^ order.ringS;
order.ringV = prevOrder.ringV ^ order.ringV;
}
| if (i > 0) {
OrderState memory prevOrder = orders[i - 1];
order.wallet = address(uint(prevOrder.wallet) ^ uint(order.wallet));
order.authAddr = address(uint(prevOrder.authAddr) ^ uint(order.authAddr));
order.ringR = prevOrder.ringR ^ order.ringR;
order.ringS = prevOrder.ringS ^ order.ringS;
order.ringV = prevOrder.ringV ^ order.ringV;
}
| 15,846 |
2 | // Returns true if loan is currently in Settlement Period, false otherwise / | function checkSettlementPeriod() public view returns (bool) {
uint start = loanPeriodEnd();
uint end = settlementPeriodEnd();
if (block.timestamp >= start && block.timestamp <= end) {
return true;
} else {
return false;
}
}
| function checkSettlementPeriod() public view returns (bool) {
uint start = loanPeriodEnd();
uint end = settlementPeriodEnd();
if (block.timestamp >= start && block.timestamp <= end) {
return true;
} else {
return false;
}
}
| 25,941 |
84 | // Abort if not in Operational Normal state. |
require(migrationAgent == 0);
require(msg.sender == migrationMaster);
migrationAgent = _agent;
|
require(migrationAgent == 0);
require(msg.sender == migrationMaster);
migrationAgent = _agent;
| 35,659 |
53 | // https:github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.mdapprove there is and attack, see: https:github.com/CORIONplatform/solidity/issues/6, https:drive.google.com/file/d/0ByMtMw2hul0EN3NCaVFHSFdxRzA/view but this function is required by ERC-20 | function approve(address _spender, uint256 _value) public returns (bool){
require(_value >= 0);
allowance[msg.sender][_spender] = _value;
// event
emit Approval(msg.sender, _spender, _value);
return true;
}
| function approve(address _spender, uint256 _value) public returns (bool){
require(_value >= 0);
allowance[msg.sender][_spender] = _value;
// event
emit Approval(msg.sender, _spender, _value);
return true;
}
| 49,025 |
46 | // Validate star parameters / | function isValidGid(uint8 gid) internal view returns(bool) {
return gid > 0 && gid <= gidMax;
}
| function isValidGid(uint8 gid) internal view returns(bool) {
return gid > 0 && gid <= gidMax;
}
| 8,216 |
0 | // TODO Passing bytes32 is more efficient than strings | using Set for Set.Data;
| using Set for Set.Data;
| 52,238 |
7 | // Refurnish stock of book | function addBook(bytes10 _isbn, uint16 _newQty) external onlyOwner isRegistered(_isbn) {
require(_newQty > store[_isbn].stock, "New quantity cannot be lower than actual stock");
store[_isbn].stock = _newQty;
}
| function addBook(bytes10 _isbn, uint16 _newQty) external onlyOwner isRegistered(_isbn) {
require(_newQty > store[_isbn].stock, "New quantity cannot be lower than actual stock");
store[_isbn].stock = _newQty;
}
| 26,463 |
192 | // Get ether price based on current token supply | function getCurrentPrice() public pure returns (uint64) {
return 40_000_000_000_000_000;
}
| function getCurrentPrice() public pure returns (uint64) {
return 40_000_000_000_000_000;
}
| 5,783 |
226 | // At this point `low` is the exclusive upper bound. We will return the inclusive upper bound. | if (low > 0 && array[low - 1] == element) {
return low - 1;
} else {
| if (low > 0 && array[low - 1] == element) {
return low - 1;
} else {
| 2,945 |
0 | // Marks the following ERC165 interface(s) as supported: ERC20Burnable. | constructor() {
ERC20Storage.initERC20Burnable();
}
| constructor() {
ERC20Storage.initERC20Burnable();
}
| 22,548 |
27 | // Function for Testator to check inThrows if `msg.sender` has no Legacy registered / | function checkIn() public {
if (legacies[msg.sender].length == 0) revert NoLegacyRegistered();
uint256 prevCheckIn = executionDay[msg.sender];
executionDay[msg.sender] = getDay(block.timestamp - 1 days);
uint256 len = executionList[prevCheckIn].length;
if (len > 0) {
// Remove testator from previous checkIn's list
if (executionList[prevCheckIn][len - 1] == msg.sender) {
// Remove the last item for it is msg.sender
executionList[prevCheckIn].pop();
} else {
// msg.sender is not the last item, so we search it and replace with the last item
for (uint256 i = 0; i < len - 1; i++) {
if (executionList[prevCheckIn][i] == msg.sender) {
executionList[prevCheckIn][i] = executionList[
prevCheckIn
][len - 1];
break;
}
}
executionList[prevCheckIn].pop();
}
}
// Add testator to new checkIn's list
executionList[executionDay[msg.sender]].push(msg.sender);
// emit an event upon successful checkin
emit NewExecutionDay(
block.timestamp,
msg.sender,
executionDay[msg.sender]
);
}
| function checkIn() public {
if (legacies[msg.sender].length == 0) revert NoLegacyRegistered();
uint256 prevCheckIn = executionDay[msg.sender];
executionDay[msg.sender] = getDay(block.timestamp - 1 days);
uint256 len = executionList[prevCheckIn].length;
if (len > 0) {
// Remove testator from previous checkIn's list
if (executionList[prevCheckIn][len - 1] == msg.sender) {
// Remove the last item for it is msg.sender
executionList[prevCheckIn].pop();
} else {
// msg.sender is not the last item, so we search it and replace with the last item
for (uint256 i = 0; i < len - 1; i++) {
if (executionList[prevCheckIn][i] == msg.sender) {
executionList[prevCheckIn][i] = executionList[
prevCheckIn
][len - 1];
break;
}
}
executionList[prevCheckIn].pop();
}
}
// Add testator to new checkIn's list
executionList[executionDay[msg.sender]].push(msg.sender);
// emit an event upon successful checkin
emit NewExecutionDay(
block.timestamp,
msg.sender,
executionDay[msg.sender]
);
}
| 27,651 |
84 | // First 32 bytes are the padded length of data, so exclude that | let dataAddress := add(data, 32)
result := call(
sub(gas(), 34710),
destination,
0, // transfer value in wei
dataAddress,
mload(data), // Size of the input, in bytes. Stored in position 0 of the array.
outputAddress,
0 // Output is ignored, therefore the output size is zero
| let dataAddress := add(data, 32)
result := call(
sub(gas(), 34710),
destination,
0, // transfer value in wei
dataAddress,
mload(data), // Size of the input, in bytes. Stored in position 0 of the array.
outputAddress,
0 // Output is ignored, therefore the output size is zero
| 2,639 |
26 | // --- Internal --- |
function _buy(
ILooksRareV2.MakerOrder calldata makerAsk,
bytes calldata makerSignature,
ILooksRareV2.MerkleTree calldata merkleTree,
address receiver,
bool revertIfIncomplete,
uint256 value
|
function _buy(
ILooksRareV2.MakerOrder calldata makerAsk,
bytes calldata makerSignature,
ILooksRareV2.MerkleTree calldata merkleTree,
address receiver,
bool revertIfIncomplete,
uint256 value
| 22,115 |
14 | // first time commit of new strategy | require(_strategyInfo.pendingUncommitAmount == 0, "new strategy pendingUncommitAmount must be zero");
address strategyAddr = _registry.strategyIndexToAddress(_transition.strategyId);
address assetAddr = IStrategy(strategyAddr).getAssetAddress();
_strategyInfo.assetId = _registry.assetAddressToIndex(assetAddr);
| require(_strategyInfo.pendingUncommitAmount == 0, "new strategy pendingUncommitAmount must be zero");
address strategyAddr = _registry.strategyIndexToAddress(_transition.strategyId);
address assetAddr = IStrategy(strategyAddr).getAssetAddress();
_strategyInfo.assetId = _registry.assetAddressToIndex(assetAddr);
| 9,654 |
147 | // Cory tokens created per block. | uint256 public CoryPerBlock;
| uint256 public CoryPerBlock;
| 3,335 |
50 | // rooms[matchInfo.roomId].lastBettingTime = block.timestamp; | unlockRoomReverse_IyMI(matchInfo.roomId);
gameBets[matchInfo.matchId][gameType].add(betSlipId);
emit BetPlaced(
matchInfo,
bettorAddress,
betSlipId
| unlockRoomReverse_IyMI(matchInfo.roomId);
gameBets[matchInfo.matchId][gameType].add(betSlipId);
emit BetPlaced(
matchInfo,
bettorAddress,
betSlipId
| 32,442 |
108 | // View functions to respect old interface / | function rewardToken() public view returns(address) {
return rewardTokens[0];
}
| function rewardToken() public view returns(address) {
return rewardTokens[0];
}
| 32,077 |
149 | // min amount out = sellAmountpriceFloor / 1e18 e.g. 1e18100e6 / 1e18 = 100e6 e.g. 30e8100e6 / 1e8 = 3000e6 e.g. 30e18100e18 / 1e18 = 3000e18 | uint256 sellTokenDec = IBasicToken(sellToken).decimals();
uint256 minOut = sellAmount.mul(minReturn[_integration]).div(10 ** sellTokenDec);
require(minOut > 0, "Must have some price floor");
uniswap.swapExactTokensForTokens(
sellAmount,
minOut,
uniswapPath,
address(this),
block.timestamp.add(1800)
);
| uint256 sellTokenDec = IBasicToken(sellToken).decimals();
uint256 minOut = sellAmount.mul(minReturn[_integration]).div(10 ** sellTokenDec);
require(minOut > 0, "Must have some price floor");
uniswap.swapExactTokensForTokens(
sellAmount,
minOut,
uniswapPath,
address(this),
block.timestamp.add(1800)
);
| 53,560 |
17 | // Emitted when the allowance of a `spender` for an `owner` is set bya call to {approve}. `value` is the new allowance. / | event Approval(address indexed owner, address indexed spender, uint256 value);
| event Approval(address indexed owner, address indexed spender, uint256 value);
| 1,271 |
228 | // increases the total borrows at a stable rate on a specific reserve and updates the average stable rate consequently_reserve the reserve object_amount the amount to add to the total borrows stable_rate the rate at which the amount has been borrowed/ | ) internal {
uint256 previousTotalBorrowStable = _reserve.totalBorrowsStable;
//updating reserve borrows stable
_reserve.totalBorrowsStable = _reserve.totalBorrowsStable.add(_amount);
//update the average stable rate
//weighted average of all the borrows
uint256 weightedLastBorrow = _amount.wadToRay().rayMul(_rate);
uint256 weightedPreviousTotalBorrows = previousTotalBorrowStable.wadToRay().rayMul(
_reserve.currentAverageStableBorrowRate
);
_reserve.currentAverageStableBorrowRate = weightedLastBorrow
.add(weightedPreviousTotalBorrows)
.rayDiv(_reserve.totalBorrowsStable.wadToRay());
}
| ) internal {
uint256 previousTotalBorrowStable = _reserve.totalBorrowsStable;
//updating reserve borrows stable
_reserve.totalBorrowsStable = _reserve.totalBorrowsStable.add(_amount);
//update the average stable rate
//weighted average of all the borrows
uint256 weightedLastBorrow = _amount.wadToRay().rayMul(_rate);
uint256 weightedPreviousTotalBorrows = previousTotalBorrowStable.wadToRay().rayMul(
_reserve.currentAverageStableBorrowRate
);
_reserve.currentAverageStableBorrowRate = weightedLastBorrow
.add(weightedPreviousTotalBorrows)
.rayDiv(_reserve.totalBorrowsStable.wadToRay());
}
| 9,073 |
7 | // Calculates the binary exponent of x using the binary fraction method./Uses 128.128-bit fixed-point numbers - it is the most efficient way./x The exponent as an unsigned 128.128-bit fixed-point number./ return result The result as an unsigned 60x18 decimal fixed-point number. | function exp2(uint256 x) internal pure returns (uint256 result) {
unchecked {
// Start from 0.5 in the 128.128-bit fixed-point format. We need to use uint256 because the intermediary
// may get very close to 2^256, which doesn't fit in int256.
result = 0x80000000000000000000000000000000;
// Multiply the result by root(2, 2^-i) when the bit at position i is 1. None of the intermediary results overflows
// because the initial result is 2^127 and all magic factors are less than 2^129.
if (x & 0x80000000000000000000000000000000 > 0) result = (result * 0x16A09E667F3BCC908B2FB1366EA957D3E) >> 128;
if (x & 0x40000000000000000000000000000000 > 0) result = (result * 0x1306FE0A31B7152DE8D5A46305C85EDED) >> 128;
if (x & 0x20000000000000000000000000000000 > 0) result = (result * 0x1172B83C7D517ADCDF7C8C50EB14A7920) >> 128;
if (x & 0x10000000000000000000000000000000 > 0) result = (result * 0x10B5586CF9890F6298B92B71842A98364) >> 128;
if (x & 0x8000000000000000000000000000000 > 0) result = (result * 0x1059B0D31585743AE7C548EB68CA417FE) >> 128;
if (x & 0x4000000000000000000000000000000 > 0) result = (result * 0x102C9A3E778060EE6F7CACA4F7A29BDE9) >> 128;
if (x & 0x2000000000000000000000000000000 > 0) result = (result * 0x10163DA9FB33356D84A66AE336DCDFA40) >> 128;
if (x & 0x1000000000000000000000000000000 > 0) result = (result * 0x100B1AFA5ABCBED6129AB13EC11DC9544) >> 128;
if (x & 0x800000000000000000000000000000 > 0) result = (result * 0x10058C86DA1C09EA1FF19D294CF2F679C) >> 128;
if (x & 0x400000000000000000000000000000 > 0) result = (result * 0x1002C605E2E8CEC506D21BFC89A23A011) >> 128;
if (x & 0x200000000000000000000000000000 > 0) result = (result * 0x100162F3904051FA128BCA9C55C31E5E0) >> 128;
if (x & 0x100000000000000000000000000000 > 0) result = (result * 0x1000B175EFFDC76BA38E31671CA939726) >> 128;
if (x & 0x80000000000000000000000000000 > 0) result = (result * 0x100058BA01FB9F96D6CACD4B180917C3E) >> 128;
if (x & 0x40000000000000000000000000000 > 0) result = (result * 0x10002C5CC37DA9491D0985C348C68E7B4) >> 128;
if (x & 0x20000000000000000000000000000 > 0) result = (result * 0x1000162E525EE054754457D5995292027) >> 128;
if (x & 0x10000000000000000000000000000 > 0) result = (result * 0x10000B17255775C040618BF4A4ADE83FD) >> 128;
if (x & 0x8000000000000000000000000000 > 0) result = (result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAC) >> 128;
if (x & 0x4000000000000000000000000000 > 0) result = (result * 0x100002C5C89D5EC6CA4D7C8ACC017B7CA) >> 128;
if (x & 0x2000000000000000000000000000 > 0) result = (result * 0x10000162E43F4F831060E02D839A9D16D) >> 128;
if (x & 0x1000000000000000000000000000 > 0) result = (result * 0x100000B1721BCFC99D9F890EA06911763) >> 128;
if (x & 0x800000000000000000000000000 > 0) result = (result * 0x10000058B90CF1E6D97F9CA14DBCC1629) >> 128;
if (x & 0x400000000000000000000000000 > 0) result = (result * 0x1000002C5C863B73F016468F6BAC5CA2C) >> 128;
if (x & 0x200000000000000000000000000 > 0) result = (result * 0x100000162E430E5A18F6119E3C02282A6) >> 128;
if (x & 0x100000000000000000000000000 > 0) result = (result * 0x1000000B1721835514B86E6D96EFD1BFF) >> 128;
if (x & 0x80000000000000000000000000 > 0) result = (result * 0x100000058B90C0B48C6BE5DF846C5B2F0) >> 128;
if (x & 0x40000000000000000000000000 > 0) result = (result * 0x10000002C5C8601CC6B9E94213C72737B) >> 128;
if (x & 0x20000000000000000000000000 > 0) result = (result * 0x1000000162E42FFF037DF38AA2B219F07) >> 128;
if (x & 0x10000000000000000000000000 > 0) result = (result * 0x10000000B17217FBA9C739AA5819F44FA) >> 128;
if (x & 0x8000000000000000000000000 > 0) result = (result * 0x1000000058B90BFCDEE5ACD3C1CEDC824) >> 128;
if (x & 0x4000000000000000000000000 > 0) result = (result * 0x100000002C5C85FE31F35A6A30DA1BE51) >> 128;
if (x & 0x2000000000000000000000000 > 0) result = (result * 0x10000000162E42FF0999CE3541B9FFFD0) >> 128;
if (x & 0x1000000000000000000000000 > 0) result = (result * 0x100000000B17217F80F4EF5AADDA45554) >> 128;
if (x & 0x800000000000000000000000 > 0) result = (result * 0x10000000058B90BFBF8479BD5A81B51AE) >> 128;
if (x & 0x400000000000000000000000 > 0) result = (result * 0x1000000002C5C85FDF84BD62AE30A74CD) >> 128;
if (x & 0x200000000000000000000000 > 0) result = (result * 0x100000000162E42FEFB2FED257559BDAA) >> 128;
if (x & 0x100000000000000000000000 > 0) result = (result * 0x1000000000B17217F7D5A7716BBA4A9AF) >> 128;
if (x & 0x80000000000000000000000 > 0) result = (result * 0x100000000058B90BFBE9DDBAC5E109CCF) >> 128;
if (x & 0x40000000000000000000000 > 0) result = (result * 0x10000000002C5C85FDF4B15DE6F17EB0E) >> 128;
if (x & 0x20000000000000000000000 > 0) result = (result * 0x1000000000162E42FEFA494F1478FDE05) >> 128;
if (x & 0x10000000000000000000000 > 0) result = (result * 0x10000000000B17217F7D20CF927C8E94D) >> 128;
if (x & 0x8000000000000000000000 > 0) result = (result * 0x1000000000058B90BFBE8F71CB4E4B33E) >> 128;
if (x & 0x4000000000000000000000 > 0) result = (result * 0x100000000002C5C85FDF477B662B26946) >> 128;
if (x & 0x2000000000000000000000 > 0) result = (result * 0x10000000000162E42FEFA3AE53369388D) >> 128;
if (x & 0x1000000000000000000000 > 0) result = (result * 0x100000000000B17217F7D1D351A389D41) >> 128;
if (x & 0x800000000000000000000 > 0) result = (result * 0x10000000000058B90BFBE8E8B2D3D4EDF) >> 128;
if (x & 0x400000000000000000000 > 0) result = (result * 0x1000000000002C5C85FDF4741BEA6E77F) >> 128;
if (x & 0x200000000000000000000 > 0) result = (result * 0x100000000000162E42FEFA39FE95583C3) >> 128;
if (x & 0x100000000000000000000 > 0) result = (result * 0x1000000000000B17217F7D1CFB72B45E3) >> 128;
if (x & 0x80000000000000000000 > 0) result = (result * 0x100000000000058B90BFBE8E7CC35C3F2) >> 128;
if (x & 0x40000000000000000000 > 0) result = (result * 0x10000000000002C5C85FDF473E242EA39) >> 128;
if (x & 0x20000000000000000000 > 0) result = (result * 0x1000000000000162E42FEFA39F02B772C) >> 128;
if (x & 0x10000000000000000000 > 0) result = (result * 0x10000000000000B17217F7D1CF7D83C1A) >> 128;
if (x & 0x8000000000000000000 > 0) result = (result * 0x1000000000000058B90BFBE8E7BDCBE2E) >> 128;
if (x & 0x4000000000000000000 > 0) result = (result * 0x100000000000002C5C85FDF473DEA871F) >> 128;
if (x & 0x2000000000000000000 > 0) result = (result * 0x10000000000000162E42FEFA39EF44D92) >> 128;
if (x & 0x1000000000000000000 > 0) result = (result * 0x100000000000000B17217F7D1CF79E949) >> 128;
if (x & 0x800000000000000000 > 0) result = (result * 0x10000000000000058B90BFBE8E7BCE545) >> 128;
if (x & 0x400000000000000000 > 0) result = (result * 0x1000000000000002C5C85FDF473DE6ECA) >> 128;
if (x & 0x200000000000000000 > 0) result = (result * 0x100000000000000162E42FEFA39EF366F) >> 128;
if (x & 0x100000000000000000 > 0) result = (result * 0x1000000000000000B17217F7D1CF79AFA) >> 128;
if (x & 0x80000000000000000 > 0) result = (result * 0x100000000000000058B90BFBE8E7BCD6E) >> 128;
if (x & 0x40000000000000000 > 0) result = (result * 0x10000000000000002C5C85FDF473DE6B3) >> 128;
if (x & 0x20000000000000000 > 0) result = (result * 0x1000000000000000162E42FEFA39EF359) >> 128;
if (x & 0x10000000000000000 > 0) result = (result * 0x10000000000000000B17217F7D1CF79AC) >> 128;
// Multiply the result by the integer part 2^n + 1. We have to shift by one bit extra because we have already divided
// by two when we set the result equal to 0.5 above.
result = result << ((x >> 128) + 1);
// Convert the result to the signed 60.18-decimal fixed-point format.
result = PRBMathCommon.mulDiv(result, 1e18, 2**128);
}
}
| function exp2(uint256 x) internal pure returns (uint256 result) {
unchecked {
// Start from 0.5 in the 128.128-bit fixed-point format. We need to use uint256 because the intermediary
// may get very close to 2^256, which doesn't fit in int256.
result = 0x80000000000000000000000000000000;
// Multiply the result by root(2, 2^-i) when the bit at position i is 1. None of the intermediary results overflows
// because the initial result is 2^127 and all magic factors are less than 2^129.
if (x & 0x80000000000000000000000000000000 > 0) result = (result * 0x16A09E667F3BCC908B2FB1366EA957D3E) >> 128;
if (x & 0x40000000000000000000000000000000 > 0) result = (result * 0x1306FE0A31B7152DE8D5A46305C85EDED) >> 128;
if (x & 0x20000000000000000000000000000000 > 0) result = (result * 0x1172B83C7D517ADCDF7C8C50EB14A7920) >> 128;
if (x & 0x10000000000000000000000000000000 > 0) result = (result * 0x10B5586CF9890F6298B92B71842A98364) >> 128;
if (x & 0x8000000000000000000000000000000 > 0) result = (result * 0x1059B0D31585743AE7C548EB68CA417FE) >> 128;
if (x & 0x4000000000000000000000000000000 > 0) result = (result * 0x102C9A3E778060EE6F7CACA4F7A29BDE9) >> 128;
if (x & 0x2000000000000000000000000000000 > 0) result = (result * 0x10163DA9FB33356D84A66AE336DCDFA40) >> 128;
if (x & 0x1000000000000000000000000000000 > 0) result = (result * 0x100B1AFA5ABCBED6129AB13EC11DC9544) >> 128;
if (x & 0x800000000000000000000000000000 > 0) result = (result * 0x10058C86DA1C09EA1FF19D294CF2F679C) >> 128;
if (x & 0x400000000000000000000000000000 > 0) result = (result * 0x1002C605E2E8CEC506D21BFC89A23A011) >> 128;
if (x & 0x200000000000000000000000000000 > 0) result = (result * 0x100162F3904051FA128BCA9C55C31E5E0) >> 128;
if (x & 0x100000000000000000000000000000 > 0) result = (result * 0x1000B175EFFDC76BA38E31671CA939726) >> 128;
if (x & 0x80000000000000000000000000000 > 0) result = (result * 0x100058BA01FB9F96D6CACD4B180917C3E) >> 128;
if (x & 0x40000000000000000000000000000 > 0) result = (result * 0x10002C5CC37DA9491D0985C348C68E7B4) >> 128;
if (x & 0x20000000000000000000000000000 > 0) result = (result * 0x1000162E525EE054754457D5995292027) >> 128;
if (x & 0x10000000000000000000000000000 > 0) result = (result * 0x10000B17255775C040618BF4A4ADE83FD) >> 128;
if (x & 0x8000000000000000000000000000 > 0) result = (result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAC) >> 128;
if (x & 0x4000000000000000000000000000 > 0) result = (result * 0x100002C5C89D5EC6CA4D7C8ACC017B7CA) >> 128;
if (x & 0x2000000000000000000000000000 > 0) result = (result * 0x10000162E43F4F831060E02D839A9D16D) >> 128;
if (x & 0x1000000000000000000000000000 > 0) result = (result * 0x100000B1721BCFC99D9F890EA06911763) >> 128;
if (x & 0x800000000000000000000000000 > 0) result = (result * 0x10000058B90CF1E6D97F9CA14DBCC1629) >> 128;
if (x & 0x400000000000000000000000000 > 0) result = (result * 0x1000002C5C863B73F016468F6BAC5CA2C) >> 128;
if (x & 0x200000000000000000000000000 > 0) result = (result * 0x100000162E430E5A18F6119E3C02282A6) >> 128;
if (x & 0x100000000000000000000000000 > 0) result = (result * 0x1000000B1721835514B86E6D96EFD1BFF) >> 128;
if (x & 0x80000000000000000000000000 > 0) result = (result * 0x100000058B90C0B48C6BE5DF846C5B2F0) >> 128;
if (x & 0x40000000000000000000000000 > 0) result = (result * 0x10000002C5C8601CC6B9E94213C72737B) >> 128;
if (x & 0x20000000000000000000000000 > 0) result = (result * 0x1000000162E42FFF037DF38AA2B219F07) >> 128;
if (x & 0x10000000000000000000000000 > 0) result = (result * 0x10000000B17217FBA9C739AA5819F44FA) >> 128;
if (x & 0x8000000000000000000000000 > 0) result = (result * 0x1000000058B90BFCDEE5ACD3C1CEDC824) >> 128;
if (x & 0x4000000000000000000000000 > 0) result = (result * 0x100000002C5C85FE31F35A6A30DA1BE51) >> 128;
if (x & 0x2000000000000000000000000 > 0) result = (result * 0x10000000162E42FF0999CE3541B9FFFD0) >> 128;
if (x & 0x1000000000000000000000000 > 0) result = (result * 0x100000000B17217F80F4EF5AADDA45554) >> 128;
if (x & 0x800000000000000000000000 > 0) result = (result * 0x10000000058B90BFBF8479BD5A81B51AE) >> 128;
if (x & 0x400000000000000000000000 > 0) result = (result * 0x1000000002C5C85FDF84BD62AE30A74CD) >> 128;
if (x & 0x200000000000000000000000 > 0) result = (result * 0x100000000162E42FEFB2FED257559BDAA) >> 128;
if (x & 0x100000000000000000000000 > 0) result = (result * 0x1000000000B17217F7D5A7716BBA4A9AF) >> 128;
if (x & 0x80000000000000000000000 > 0) result = (result * 0x100000000058B90BFBE9DDBAC5E109CCF) >> 128;
if (x & 0x40000000000000000000000 > 0) result = (result * 0x10000000002C5C85FDF4B15DE6F17EB0E) >> 128;
if (x & 0x20000000000000000000000 > 0) result = (result * 0x1000000000162E42FEFA494F1478FDE05) >> 128;
if (x & 0x10000000000000000000000 > 0) result = (result * 0x10000000000B17217F7D20CF927C8E94D) >> 128;
if (x & 0x8000000000000000000000 > 0) result = (result * 0x1000000000058B90BFBE8F71CB4E4B33E) >> 128;
if (x & 0x4000000000000000000000 > 0) result = (result * 0x100000000002C5C85FDF477B662B26946) >> 128;
if (x & 0x2000000000000000000000 > 0) result = (result * 0x10000000000162E42FEFA3AE53369388D) >> 128;
if (x & 0x1000000000000000000000 > 0) result = (result * 0x100000000000B17217F7D1D351A389D41) >> 128;
if (x & 0x800000000000000000000 > 0) result = (result * 0x10000000000058B90BFBE8E8B2D3D4EDF) >> 128;
if (x & 0x400000000000000000000 > 0) result = (result * 0x1000000000002C5C85FDF4741BEA6E77F) >> 128;
if (x & 0x200000000000000000000 > 0) result = (result * 0x100000000000162E42FEFA39FE95583C3) >> 128;
if (x & 0x100000000000000000000 > 0) result = (result * 0x1000000000000B17217F7D1CFB72B45E3) >> 128;
if (x & 0x80000000000000000000 > 0) result = (result * 0x100000000000058B90BFBE8E7CC35C3F2) >> 128;
if (x & 0x40000000000000000000 > 0) result = (result * 0x10000000000002C5C85FDF473E242EA39) >> 128;
if (x & 0x20000000000000000000 > 0) result = (result * 0x1000000000000162E42FEFA39F02B772C) >> 128;
if (x & 0x10000000000000000000 > 0) result = (result * 0x10000000000000B17217F7D1CF7D83C1A) >> 128;
if (x & 0x8000000000000000000 > 0) result = (result * 0x1000000000000058B90BFBE8E7BDCBE2E) >> 128;
if (x & 0x4000000000000000000 > 0) result = (result * 0x100000000000002C5C85FDF473DEA871F) >> 128;
if (x & 0x2000000000000000000 > 0) result = (result * 0x10000000000000162E42FEFA39EF44D92) >> 128;
if (x & 0x1000000000000000000 > 0) result = (result * 0x100000000000000B17217F7D1CF79E949) >> 128;
if (x & 0x800000000000000000 > 0) result = (result * 0x10000000000000058B90BFBE8E7BCE545) >> 128;
if (x & 0x400000000000000000 > 0) result = (result * 0x1000000000000002C5C85FDF473DE6ECA) >> 128;
if (x & 0x200000000000000000 > 0) result = (result * 0x100000000000000162E42FEFA39EF366F) >> 128;
if (x & 0x100000000000000000 > 0) result = (result * 0x1000000000000000B17217F7D1CF79AFA) >> 128;
if (x & 0x80000000000000000 > 0) result = (result * 0x100000000000000058B90BFBE8E7BCD6E) >> 128;
if (x & 0x40000000000000000 > 0) result = (result * 0x10000000000000002C5C85FDF473DE6B3) >> 128;
if (x & 0x20000000000000000 > 0) result = (result * 0x1000000000000000162E42FEFA39EF359) >> 128;
if (x & 0x10000000000000000 > 0) result = (result * 0x10000000000000000B17217F7D1CF79AC) >> 128;
// Multiply the result by the integer part 2^n + 1. We have to shift by one bit extra because we have already divided
// by two when we set the result equal to 0.5 above.
result = result << ((x >> 128) + 1);
// Convert the result to the signed 60.18-decimal fixed-point format.
result = PRBMathCommon.mulDiv(result, 1e18, 2**128);
}
}
| 51,301 |
161 | // set controller address/make new controllerrequire input address is not a controllerexecute any time in sc state / | function setController(address _controller)
public
onlyEscrow
| function setController(address _controller)
public
onlyEscrow
| 17,194 |
309 | // ===== Metadata URI ===== | function _baseURI() internal view override(ERC721A) returns (string memory) {
return baseTokenURI;
}
| function _baseURI() internal view override(ERC721A) returns (string memory) {
return baseTokenURI;
}
| 14,433 |
3 | // Adds new evidence delegate address to `isDelegate` mapping. / | function addEvidenceDelegate(address delegate) public onlyOwner {
isDelegate[delegate] = true;
emit EvidenceDelegateAdded(delegate);
}
| function addEvidenceDelegate(address delegate) public onlyOwner {
isDelegate[delegate] = true;
emit EvidenceDelegateAdded(delegate);
}
| 38,138 |
56 | // Internal function to calculate treasury and stakers rewards. Calculates treasury and stakers rewards by getting their percentages and multiplying with the current set reward amount. rewardreward amount. feeTypeSWAP or PENALTY type fee type declaration.returntreasuryReward.returnstakersReward. / | function _calculateRewardsAllocation(
uint256 reward,
FeeTypes feeType
| function _calculateRewardsAllocation(
uint256 reward,
FeeTypes feeType
| 36,209 |
8 | // Runs all the necessary approval functions required for a list of ERC20 tokens._tokensAddresses of the tokens which need approval _spender Address of the spender which will be approved to spend token. (Must be a whitlisted issuance module) / | function approveTokens(IERC20[] calldata _tokens, address _spender) external {
for (uint256 i = 0; i < _tokens.length; i++) {
approveToken(_tokens[i], _spender);
}
}
| function approveTokens(IERC20[] calldata _tokens, address _spender) external {
for (uint256 i = 0; i < _tokens.length; i++) {
approveToken(_tokens[i], _spender);
}
}
| 17,168 |
11 | // Returns the current withdrawalTime. / | function getWithdrawalTime() external view returns (uint256) {
return _withdrawalTime;
}
| function getWithdrawalTime() external view returns (uint256) {
return _withdrawalTime;
}
| 29,572 |
185 | // change base extension (.json) | function setBaseExtension(string memory _newBaseExtension)
public
onlyOwner
| function setBaseExtension(string memory _newBaseExtension)
public
onlyOwner
| 31,512 |
29 | // calculate the amount of tokens to transfer for the given eth | uint256 tokenAmount = getTokensPerEth(msg.value);
require(IToken(tokenAddress).transfer(msg.sender, tokenAmount), "Insufficient balance of presale contract!");
usersInvestments[msg.sender] = usersInvestments[msg.sender].add(msg.value);
| uint256 tokenAmount = getTokensPerEth(msg.value);
require(IToken(tokenAddress).transfer(msg.sender, tokenAmount), "Insufficient balance of presale contract!");
usersInvestments[msg.sender] = usersInvestments[msg.sender].add(msg.value);
| 39,144 |
10 | // pass any number as input, the function doSomething() below will be called | hackMe.doSomething(1);
| hackMe.doSomething(1);
| 31,883 |
18 | // Delete all of your Glofile bio translations Deletes all of the bio translations. / | function deleteAllBioTranslations() {
Glofile glofile = glofiles[msg.sender];
// Delete the actual mappings in case a client accesses without checking
// language key.
for (uint i = 0; i < glofile.bioLanguages.length; i++) {
delete glofile.bioTranslations[glofile.bioLanguages[i]];
}
delete glofile.bioLanguages;
Update(msg.sender);
}
| function deleteAllBioTranslations() {
Glofile glofile = glofiles[msg.sender];
// Delete the actual mappings in case a client accesses without checking
// language key.
for (uint i = 0; i < glofile.bioLanguages.length; i++) {
delete glofile.bioTranslations[glofile.bioLanguages[i]];
}
delete glofile.bioLanguages;
Update(msg.sender);
}
| 10,401 |
31 | // verifies that a value is greater than zero | modifier greaterThanZero(uint256 _value) {
_greaterThanZero(_value);
_;
}
| modifier greaterThanZero(uint256 _value) {
_greaterThanZero(_value);
_;
}
| 11,660 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.