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 |
|---|---|---|---|---|
7 | // Revert if the fee recipient is not already included. / | error FeeRecipientNotPresent();
| error FeeRecipientNotPresent();
| 12,693 |
152 | // Call setDynamicWeight for several tokens, can be called only by weightsStrategy address. _dynamicWeights Tokens dynamic weights configs. / | function setDynamicWeightListByStrategy(DynamicWeightInput[] memory _dynamicWeights) external onlyWeightsStrategy {
uint256 len = _dynamicWeights.length;
for (uint256 i = 0; i < len; i++) {
pool.setDynamicWeight(
_dynamicWeights[i].token,
_dynamicWeights[i].targetDenorm,
_dynamicWeights[i].fromTimestamp,
_dynamicWeights[i].targetTimestamp
);
}
}
| function setDynamicWeightListByStrategy(DynamicWeightInput[] memory _dynamicWeights) external onlyWeightsStrategy {
uint256 len = _dynamicWeights.length;
for (uint256 i = 0; i < len; i++) {
pool.setDynamicWeight(
_dynamicWeights[i].token,
_dynamicWeights[i].targetDenorm,
_dynamicWeights[i].fromTimestamp,
_dynamicWeights[i].targetTimestamp
);
}
}
| 18,097 |
36 | // pay the service fee for contract deployment | feeReceiver.transfer(msg.value);
| feeReceiver.transfer(msg.value);
| 19,585 |
23 | // Calls supportsInterface for all parent contracts /interfaceId The signature of the interface/ return bool True if `interfaceId` is supported | function supportsInterface(bytes4 interfaceId)
override(ERC721EnumerableUpgradeable, AccessControlUpgradeable)
public virtual view
returns (bool)
| function supportsInterface(bytes4 interfaceId)
override(ERC721EnumerableUpgradeable, AccessControlUpgradeable)
public virtual view
returns (bool)
| 28,680 |
34 | // 预测标题 | string title;
| string title;
| 4,358 |
12 | // A modifier that defines a protected reinitializer function that can be invoked at most once, and only if thecontract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can beused to initialize parent contracts. `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the originalinitialization step. This is essential to configure modules that are added through upgrades and that requireinitialization. Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist ina contract, executing them in the right order is up to the developer or operator. / | modifier reinitializer(uint8 version) {
bool isTopLevelCall = _setInitializedVersion(version);
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(version);
}
}
| modifier reinitializer(uint8 version) {
bool isTopLevelCall = _setInitializedVersion(version);
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(version);
}
}
| 33,673 |
84 | // IConstantFlowAgreementV1.decreaseFlowRateAllowanceWithPermissions implementation | function decreaseFlowRateAllowanceWithPermissions(
ISuperfluidToken token,
address flowOperator,
uint8 permissionsToRemove,
int96 subtractedFlowRateAllowance,
bytes calldata ctx
| function decreaseFlowRateAllowanceWithPermissions(
ISuperfluidToken token,
address flowOperator,
uint8 permissionsToRemove,
int96 subtractedFlowRateAllowance,
bytes calldata ctx
| 6,019 |
21 | // INTERNAL / | function _mintLand(address to, string memory topLeftLatLong, string memory bottomRightLatLong, string memory ipfsHash, string memory metadataURI, uint cardId) private returns (uint) {
require(_tokenIdTracker.current() < MAX_LANDS, "MAX_LANDS_REACHED");
string memory coordinatesString = string(abi.encodePacked(topLeftLatLong, "#", bottomRightLatLong));
require(_coordinatesExists[coordinatesString] != true, "COORDINATES_EXISTS");
uint newLandId = _tokenIdTracker.current();
Land memory newLand = Land({topLeftLatLong: topLeftLatLong, bottomRightLatLong: bottomRightLatLong, metadataURI: metadataURI});
_lands.push(newLand);
tokenIdToFirstOwner[newLandId] = to;
_mint(to, newLandId);
_tokenIdTracker.increment();
_coordinatesExists[coordinatesString] = true;
_hashes[ipfsHash] = 1;
emit Discovery(to, newLandId, tokenURI(newLandId), cardId);
return newLandId;
}
| function _mintLand(address to, string memory topLeftLatLong, string memory bottomRightLatLong, string memory ipfsHash, string memory metadataURI, uint cardId) private returns (uint) {
require(_tokenIdTracker.current() < MAX_LANDS, "MAX_LANDS_REACHED");
string memory coordinatesString = string(abi.encodePacked(topLeftLatLong, "#", bottomRightLatLong));
require(_coordinatesExists[coordinatesString] != true, "COORDINATES_EXISTS");
uint newLandId = _tokenIdTracker.current();
Land memory newLand = Land({topLeftLatLong: topLeftLatLong, bottomRightLatLong: bottomRightLatLong, metadataURI: metadataURI});
_lands.push(newLand);
tokenIdToFirstOwner[newLandId] = to;
_mint(to, newLandId);
_tokenIdTracker.increment();
_coordinatesExists[coordinatesString] = true;
_hashes[ipfsHash] = 1;
emit Discovery(to, newLandId, tokenURI(newLandId), cardId);
return newLandId;
}
| 31,714 |
27 | // Set auto liquidity to trigger collecting available fees and send to the treasury flag provide the boolean value / | function setAutoCollectFees(bool flag) external onlyOwner {
autoCollectFees = flag;
}
| function setAutoCollectFees(bool flag) external onlyOwner {
autoCollectFees = flag;
}
| 31,332 |
118 | // Calculate new multiplier | uint256 newMultiplier = (block.number <= adjustedEndBlock)
? (block.number - previousEndBlock)
: stakingPeriod[adjustedCurrentPhase].periodLengthInBlock;
| uint256 newMultiplier = (block.number <= adjustedEndBlock)
? (block.number - previousEndBlock)
: stakingPeriod[adjustedCurrentPhase].periodLengthInBlock;
| 37,838 |
22 | // Returns the token identifier for the `_index`th NFT assigned to `_owner`. Sort order isnot specified. It throws if `_index` >= `balanceOf(_owner)` or if `_owner` is the zero address,representing invalid NFTs. _owner An address where we are interested in NFTs owned by them. _index A counter less than `balanceOf(_owner)`.return Token id. / | function tokenOfOwnerByIndex( address _owner, uint256 _index ) external view returns (uint256);
| function tokenOfOwnerByIndex( address _owner, uint256 _index ) external view returns (uint256);
| 606 |
32 | // Checks a given address to determine whether it is populous address.sender The address to be checked. return bool returns true or false is the address corresponds to populous or not./ | function isPopulous(address sender) public view returns (bool) {
return sender == populous;
}
| function isPopulous(address sender) public view returns (bool) {
return sender == populous;
}
| 22,147 |
28 | // Function to determine whether to use old or new prices/ return Array of prices | function _priceSelector() internal returns (uint256[] memory) {
uint256[] memory prices;
// No price change:
if (_priceChangeTimestamp == 0) {
prices = _starterPackPrices;
} else {
// Price change delay has expired.
if (now > _priceChangeTimestamp + 1 hours) {
_priceChangeTimestamp = 0;
prices = _starterPackPrices;
} else {
// Price change has occured:
prices = _previousStarterPackPrices;
}
}
return prices;
}
| function _priceSelector() internal returns (uint256[] memory) {
uint256[] memory prices;
// No price change:
if (_priceChangeTimestamp == 0) {
prices = _starterPackPrices;
} else {
// Price change delay has expired.
if (now > _priceChangeTimestamp + 1 hours) {
_priceChangeTimestamp = 0;
prices = _starterPackPrices;
} else {
// Price change has occured:
prices = _previousStarterPackPrices;
}
}
return prices;
}
| 30,647 |
103 | // allocation 100000 means 0.1(10%), 1 meanss 0.000001(0.0001%), 1000000 means 1(100%) | function getUserAllocation(address _user) public view returns (uint256) {
return userInfo[_user].amount.mul(1e12).div(totalAmount).div(1e6);
}
| function getUserAllocation(address _user) public view returns (uint256) {
return userInfo[_user].amount.mul(1e12).div(totalAmount).div(1e6);
}
| 14,883 |
425 | // mint loaned tokens to the sender | if (payout > 0) {
share._loanStart = _currentDay();
share._loanedDays = loanDays;
share._interestRate = day._dayInterestRate;
share._isLoaned = true;
_emitLoanStart(
share,
payout
);
| if (payout > 0) {
share._loanStart = _currentDay();
share._loanedDays = loanDays;
share._interestRate = day._dayInterestRate;
share._isLoaned = true;
_emitLoanStart(
share,
payout
);
| 31,386 |
34 | // ERC223 Transfer to contract and invoke tokenFallback() method | function transferToContract( address to, uint value, bytes data ) private
returns (bool success)
| function transferToContract( address to, uint value, bytes data ) private
returns (bool success)
| 80,442 |
1 | // Merkle | bytes32 private saleMerkleRoot;
| bytes32 private saleMerkleRoot;
| 25,996 |
51 | // Larger modulos specify the right edge of half-open interval of winning bet outcomes. | require(betMask > 0 && betMask <= modulo, "High modulo range, betMask larger than modulo.");
rollUnder = betMask;
| require(betMask > 0 && betMask <= modulo, "High modulo range, betMask larger than modulo.");
rollUnder = betMask;
| 14,199 |
4 | // Mint amount and update internal balances | if (address(compToken) != address(0)) {
uint256 amount = compBalances[holder];
compBalances[holder] = 0;
compToken.mint(holder, amount);
}
| if (address(compToken) != address(0)) {
uint256 amount = compBalances[holder];
compBalances[holder] = 0;
compToken.mint(holder, amount);
}
| 20,730 |
3 | // The FRT TOKEN! | IFRTToken public FRT;
| IFRTToken public FRT;
| 17,031 |
3 | // MockLendingPoolCore contractAaveThis is a mock contract to test upgradeability of the AddressProvider / | contract MockLendingPoolCore is LendingPoolCore {
event ReserveUpdatedFromMock(uint256 indexed revision);
uint256 constant private CORE_REVISION = 0x5;
function getRevision() internal pure returns(uint256) {
return CORE_REVISION;
}
function initialize(LendingPoolAddressesProvider _addressesProvider) public initializer {
addressesProvider = _addressesProvider;
refreshConfigInternal();
}
function updateReserveInterestRatesAndTimestampInternal(address _reserve, uint256 _liquidityAdded, uint256 _liquidityTaken)
internal
{
super.updateReserveInterestRatesAndTimestampInternal(_reserve, _liquidityAdded, _liquidityTaken);
emit ReserveUpdatedFromMock(getRevision());
}
}
| contract MockLendingPoolCore is LendingPoolCore {
event ReserveUpdatedFromMock(uint256 indexed revision);
uint256 constant private CORE_REVISION = 0x5;
function getRevision() internal pure returns(uint256) {
return CORE_REVISION;
}
function initialize(LendingPoolAddressesProvider _addressesProvider) public initializer {
addressesProvider = _addressesProvider;
refreshConfigInternal();
}
function updateReserveInterestRatesAndTimestampInternal(address _reserve, uint256 _liquidityAdded, uint256 _liquidityTaken)
internal
{
super.updateReserveInterestRatesAndTimestampInternal(_reserve, _liquidityAdded, _liquidityTaken);
emit ReserveUpdatedFromMock(getRevision());
}
}
| 23,922 |
17 | // Swap Struct | struct swapStruct {
address dapp;
address typeStd;
uint256[] tokenId;
uint256[] blc;
bytes data;
}
| struct swapStruct {
address dapp;
address typeStd;
uint256[] tokenId;
uint256[] blc;
bytes data;
}
| 51,640 |
172 | // Block number when bonus ALPACA period ends. | uint256 public bonusEndBlock;
| uint256 public bonusEndBlock;
| 1,502 |
114 | // get reward claimable for previous epoch | previousEpoch.rewardsClaimed = previousEpoch.rewardsClaimed.add(previousEpochRewardsClaimable[user]);
uint256 reward = previousEpochRewardsClaimable[user];
previousEpochRewardsClaimable[user] = 0;
| previousEpoch.rewardsClaimed = previousEpoch.rewardsClaimed.add(previousEpochRewardsClaimable[user]);
uint256 reward = previousEpochRewardsClaimable[user];
previousEpochRewardsClaimable[user] = 0;
| 36,088 |
5 | // The constructor for the Staking Token. / | constructor() ERC20("Stake_Token", "STK") {
_mint(msg.sender, 10000 * decimal);
}
| constructor() ERC20("Stake_Token", "STK") {
_mint(msg.sender, 10000 * decimal);
}
| 47,399 |
4 | // Force updates in all collateral assets/ @custom:refresher | function refresh() external {
// It's a waste of gas to require notPaused because assets can be updated directly
for (uint256 i = 0; i < _erc20s.length(); i++) {
IAsset asset = assets[IERC20(_erc20s.at(i))];
if (asset.isCollateral()) ICollateral(address(asset)).refresh();
}
}
| function refresh() external {
// It's a waste of gas to require notPaused because assets can be updated directly
for (uint256 i = 0; i < _erc20s.length(); i++) {
IAsset asset = assets[IERC20(_erc20s.at(i))];
if (asset.isCollateral()) ICollateral(address(asset)).refresh();
}
}
| 10,245 |
288 | // {ERC721} token, including:This contract uses {AccessControl} to lock permissioned functions using the/Grants `DEFAULT_ADMIN_ROLE` to the account that deploys the contract. Token URIs will be autogenerated based on `baseURI` and their token IDs. See {ERC721-tokenURI}./ | constructor(string memory name, string memory symbol, string memory baseTokenURI, uint mintPrice, address admin) ERC721(name, symbol) {
_baseTokenURI = baseTokenURI;
_price = mintPrice;
_admin = admin;
_setupRole(DEFAULT_ADMIN_ROLE, admin);
}
| constructor(string memory name, string memory symbol, string memory baseTokenURI, uint mintPrice, address admin) ERC721(name, symbol) {
_baseTokenURI = baseTokenURI;
_price = mintPrice;
_admin = admin;
_setupRole(DEFAULT_ADMIN_ROLE, admin);
}
| 33,633 |
101 | // Emit the event | emit RegisterCreator(account, resultAssets[i]);
| emit RegisterCreator(account, resultAssets[i]);
| 69,005 |
80 | // Decode a `Witnet.CBOR` structure into a native `bool` value./_cborValue An instance of `Witnet.CBOR`./ return The value represented by the input, as a `bool` value. | function decodeBool(Witnet.CBOR memory _cborValue) public pure returns(bool) {
_cborValue.len = readLength(_cborValue.buffer, _cborValue.additionalInformation);
require(_cborValue.majorType == 7, "Tried to read a `bool` value from a `Witnet.CBOR` with majorType != 7");
if (_cborValue.len == 20) {
return false;
} else if (_cborValue.len == 21) {
return true;
} else {
revert("Tried to read `bool` from a `Witnet.CBOR` with len different than 20 or 21");
}
}
| function decodeBool(Witnet.CBOR memory _cborValue) public pure returns(bool) {
_cborValue.len = readLength(_cborValue.buffer, _cborValue.additionalInformation);
require(_cborValue.majorType == 7, "Tried to read a `bool` value from a `Witnet.CBOR` with majorType != 7");
if (_cborValue.len == 20) {
return false;
} else if (_cborValue.len == 21) {
return true;
} else {
revert("Tried to read `bool` from a `Witnet.CBOR` with len different than 20 or 21");
}
}
| 67,792 |
25 | // Officiant | string public officiant;
| string public officiant;
| 13,734 |
779 | // Populate whitelist | activeWhitelist = new address[](activeCount);
activeCount = 0;
for (uint256 i = 0; i < whitelistIndices.length; i++) {
address addr = whitelistIndices[i];
if (whitelist[addr] == Status.In) {
activeWhitelist[activeCount] = addr;
activeCount++;
}
| activeWhitelist = new address[](activeCount);
activeCount = 0;
for (uint256 i = 0; i < whitelistIndices.length; i++) {
address addr = whitelistIndices[i];
if (whitelist[addr] == Status.In) {
activeWhitelist[activeCount] = addr;
activeCount++;
}
| 12,249 |
18 | // 检验是否会发生溢出 | require(balanceOf[to] + tokens >= balanceOf[to]);
| require(balanceOf[to] + tokens >= balanceOf[to]);
| 19,442 |
340 | // Keep track of the total number of unique owners for this lock (both expired and valid). This may be larger than totalSupply | uint public numberOfOwners;
| uint public numberOfOwners;
| 18,240 |
52 | // logged on claim state transition indicating NEU reward available | event LogPlatformNeuReward(
address tokenOfferingOperator,
uint256 totalRewardNmkUlps,
uint256 platformRewardNmkUlps
);
| event LogPlatformNeuReward(
address tokenOfferingOperator,
uint256 totalRewardNmkUlps,
uint256 platformRewardNmkUlps
);
| 40,412 |
129 | // Record the transfer. | store.recordTransferForTier(_tier.id, _from, _to);
| store.recordTransferForTier(_tier.id, _from, _to);
| 30,608 |
0 | // Location – Represents a geographic coordinate with altitude. Latitude and longitude values are in degrees under the WGS 84 referenceframe. Altitude values are in meters. Two location types are providedint256 and string. The integer representation enables on chain computationwhere as the string representation provides future computational compatability. See IPlaceDrop.sol, IPlaceDrop.Place.Location Converting a location from a to integer uses GEO_RESOLUTION_INT denominator.37.73957402260721 encodes to 3773957402260721-122.41902666230027 encodes to -12241902666230027 hasAltitude – a boolean that indicates the validity of the altitude valueslatitudeInt – integer representing the latitude in degrees encoded withGEO_RESOLUTION_INTlongitudeInt – integer representing the longitude in degrees encoded withGEO_RESOLUTION_INTaltitudeInt – integer representing the | struct Location {
int256 latitudeInt;
int256 longitudeInt;
int256 altitudeInt;
bool hasAltitude;
string latitude;
string longitude;
string altitude;
}
| struct Location {
int256 latitudeInt;
int256 longitudeInt;
int256 altitudeInt;
bool hasAltitude;
string latitude;
string longitude;
string altitude;
}
| 43,494 |
6 | // Update fee recipient of tradingPool._tradingPoolThe address of the trading pool being updated _newFeeRecipientAddress of new fee recipient / | function setFeeRecipient(
| function setFeeRecipient(
| 19,005 |
20 | // 获取平均分 | function getAverageScore() public view returns(uint) {
require(State == RankingChainState.Settlement, "state error");
return averageScore;
}
| function getAverageScore() public view returns(uint) {
require(State == RankingChainState.Settlement, "state error");
return averageScore;
}
| 2,948 |
33 | // Reference to contract that tracks ownership | CutieCoreInterface public coreContract;
| CutieCoreInterface public coreContract;
| 39,383 |
1 | // this event shows the other signer and the operation hash that they signed specific batch transfer events are emitted in Batcher | event BatchTransacted(
address msgSender, // Address of the sender of the message initiating the transaction
address otherSigner, // Address of the signer (second signature) used to initiate the transaction
bytes32 operation // Operation hash (see Data Formats)
);
| event BatchTransacted(
address msgSender, // Address of the sender of the message initiating the transaction
address otherSigner, // Address of the signer (second signature) used to initiate the transaction
bytes32 operation // Operation hash (see Data Formats)
);
| 16,841 |
1 | // Withdraw wrBTC from the vault.to The address of the recipient. value The amount of wrBTC tokens to transfer. / | function vaultEtherWithdraw(address to, uint256 value) internal {
if (value != 0) {
IWrbtcERC20 _wrbtcToken = wrbtcToken;
uint256 balance = address(this).balance;
if (value > balance) {
_wrbtcToken.withdraw(value - balance);
}
Address.sendValue(to, value);
emit VaultWithdraw(address(_wrbtcToken), to, value);
}
}
| function vaultEtherWithdraw(address to, uint256 value) internal {
if (value != 0) {
IWrbtcERC20 _wrbtcToken = wrbtcToken;
uint256 balance = address(this).balance;
if (value > balance) {
_wrbtcToken.withdraw(value - balance);
}
Address.sendValue(to, value);
emit VaultWithdraw(address(_wrbtcToken), to, value);
}
}
| 12,209 |
13 | // get the token total supply | function totalSupply() constant returns (uint256 totalSupply) {
return _totalSupply;
}
| function totalSupply() constant returns (uint256 totalSupply) {
return _totalSupply;
}
| 39,466 |
239 | // Obtain the quantity which the next schedule entry will vest for a given user. / | {
uint index = getNextVestingIndex(account);
if (index == numVestingEntries(account)) {
return 0;
}
return getVestingQuantity(account, index);
}
| {
uint index = getNextVestingIndex(account);
if (index == numVestingEntries(account)) {
return 0;
}
return getVestingQuantity(account, index);
}
| 703 |
49 | // transfer token for a specified address with external data_to The address to transfer to._value The amount to be transferred._data The data to call tokenFallback function / | function transfer(address _to, uint256 _value, bytes _data) public whenNotPaused returns (bool) {
if (isContract(_to)) {
return transferToContract(msg.sender, _to, _value, _data);
} else {
return transferToAddress(msg.sender, _to, _value, _data);
}
}
| function transfer(address _to, uint256 _value, bytes _data) public whenNotPaused returns (bool) {
if (isContract(_to)) {
return transferToContract(msg.sender, _to, _value, _data);
} else {
return transferToAddress(msg.sender, _to, _value, _data);
}
}
| 82,340 |
297 | // 1. Operational checks for supply | uint256 nonCirculatingSupply = IMintableERC20(_x2y2Token).SUPPLY_CAP() -
IMintableERC20(_x2y2Token).totalSupply();
uint256 amountTokensToBeMinted;
for (uint256 i = 0; i < _numberPeriods; i++) {
amountTokensToBeMinted +=
(_rewardsPerBlockForStaking[i] * _periodLengthesInBlocks[i]) +
(_rewardsPerBlockForOthers[i] * _periodLengthesInBlocks[i]);
| uint256 nonCirculatingSupply = IMintableERC20(_x2y2Token).SUPPLY_CAP() -
IMintableERC20(_x2y2Token).totalSupply();
uint256 amountTokensToBeMinted;
for (uint256 i = 0; i < _numberPeriods; i++) {
amountTokensToBeMinted +=
(_rewardsPerBlockForStaking[i] * _periodLengthesInBlocks[i]) +
(_rewardsPerBlockForOthers[i] * _periodLengthesInBlocks[i]);
| 68,495 |
182 | // Withdraw all stake from BaseRewardPool, remove liquidity, get the reward out and convert one asset to another /token0Percentage Determine what percentage of token0 to return to user. Any number between 0 to 100 /minToken0AmountConverted The minimum amount of token0 received when removing liquidity /minToken1AmountConverted The minimum amount of token1 received when removing liquidity /minTokenAmountConverted The minimum amount of token0 or token1 received when converting reward token to either one of them | // function exitWithNative(uint256 token0Percentage, uint256 minToken0AmountConverted, uint256 minToken1AmountConverted, uint256 minTokenAmountConverted) external {
// revert("Not supported");
// }
| // function exitWithNative(uint256 token0Percentage, uint256 minToken0AmountConverted, uint256 minToken1AmountConverted, uint256 minTokenAmountConverted) external {
// revert("Not supported");
// }
| 6,885 |
1 | // Returns the version of this contract. / | function version() public pure returns (bytes4) {
// version 00.0.1
return "0001";
}
| function version() public pure returns (bytes4) {
// version 00.0.1
return "0001";
}
| 29,736 |
61 | // update global plantation list | plantation[plantationSize++] = gardenId;
| plantation[plantationSize++] = gardenId;
| 29,079 |
58 | // See {ERC777-constructor}. / | function __ERC777PresetFixedSupply_init(
string memory name,
string memory symbol,
address[] memory defaultOperators,
uint256 initialSupply,
address owner
) internal initializer {
__Context_init_unchained();
__ERC777_init_unchained(name, symbol, defaultOperators);
__ERC777PresetFixedSupply_init_unchained(name, symbol, defaultOperators, initialSupply, owner);
| function __ERC777PresetFixedSupply_init(
string memory name,
string memory symbol,
address[] memory defaultOperators,
uint256 initialSupply,
address owner
) internal initializer {
__Context_init_unchained();
__ERC777_init_unchained(name, symbol, defaultOperators);
__ERC777PresetFixedSupply_init_unchained(name, symbol, defaultOperators, initialSupply, owner);
| 36,757 |
151 | // Redeem mining reward The validation of this redeeming operation should be done by the caller, a registered sidechain contract Here we use cumulative mining reward to simplify the logic in sidechain code _receiver the receiver of the redeemed mining reward _cumulativeReward the latest cumulative mining reward / | function redeemMiningReward(address _receiver, uint256 _cumulativeReward)
| function redeemMiningReward(address _receiver, uint256 _cumulativeReward)
| 58,730 |
0 | // You can use this hash to verify the image file containing all the punks | string public imageHash = "ac39af4793119ee46bbff351d8cb6b5f23da60222126add4268e261199a2921b";
address owner;
string public standard = 'CryptoPunks';
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
| string public imageHash = "ac39af4793119ee46bbff351d8cb6b5f23da60222126add4268e261199a2921b";
address owner;
string public standard = 'CryptoPunks';
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
| 35,461 |
14 | // Document management functions | function set(string tableName, string key, bytes data) public isWriter(tableName) returns (bool) {
db[encode(tableName)][encode(key)] = data;
emit Write(msg.sender, tableName);
return true;
}
| function set(string tableName, string key, bytes data) public isWriter(tableName) returns (bool) {
db[encode(tableName)][encode(key)] = data;
emit Write(msg.sender, tableName);
return true;
}
| 22,046 |
58 | // Either TransferSingle or TransferBatch MUST emit when tokens are transferred, including zero amount transfers as well as minting or burningOperator MUST be msg.senderWhen minting/creating tokens, the `_from` field MUST be set to `0x0`When burning/destroying tokens, the `_to` field MUST be set to `0x0`The total amount transferred from address 0x0 minus the total amount transferred to 0x0 may be used by clients and exchanges to be added to the "circulating supply" for a given token IDTo broadcast the existence of a token ID with no initial balance, the contract SHOULD emit the TransferSingle event from `0x0` to `0x0`, with the token | event TransferSingle(address indexed _operator, address indexed _from, address indexed _to, uint256 _id, uint256 _amount);
| event TransferSingle(address indexed _operator, address indexed _from, address indexed _to, uint256 _id, uint256 _amount);
| 29,251 |
143 | // To be set by the "member" when verfied. All the needed checks (staking amount,...) have been done. The member is now wishing to run with the pool (go live). | memberStatus = MemberStatus.readytorun;
| memberStatus = MemberStatus.readytorun;
| 27,866 |
145 | // Returns EIP2612 Permit message hash. Used to construct EIP2612/ signature provided to `permit` function. | bytes32 public constant override PERMIT_TYPEHASH =
keccak256(
"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
);
| bytes32 public constant override PERMIT_TYPEHASH =
keccak256(
"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
);
| 22,501 |
28 | // An internal function to calculate the total claimable tokens at any given point _userAddresses address of the User _vestingIndex index number of the vesting type / |
function calculateClaimableVestTokens(
address _userAddresses,
uint8 _vestingIndex
)
public
view
checkVestingStatus(_userAddresses, _vestingIndex)
returns (uint256)
|
function calculateClaimableVestTokens(
address _userAddresses,
uint8 _vestingIndex
)
public
view
checkVestingStatus(_userAddresses, _vestingIndex)
returns (uint256)
| 77,645 |
122 | // allows contract owner to claim their mint | function ownerClaim() external onlyOwner {
require(now > ownerTimeLastMinted);
uint _timePassedSinceLastMint; // The amount of time passed since the owner claimed in seconds
uint _tokenMintCount; // The amount of new tokens to mint
bool _mintingSuccess; // The success of minting the new Scale tokens
// Calculate the number of seconds that have passed since the owner last took a claim
_timePassedSinceLastMint = now.sub(ownerTimeLastMinted);
assert(_timePassedSinceLastMint > 0);
// Determine the token mint amount, determined from the number of seconds passed and the ownerMintRate
_tokenMintCount = calculateMintTotal(_timePassedSinceLastMint, ownerMintRate);
// Mint the owner's tokens; this also increases totalSupply
_mintingSuccess = mint(msg.sender, _tokenMintCount);
require(_mintingSuccess);
// New minting was a success. Set last time minted to current block.timestamp (now)
ownerTimeLastMinted = now;
}
| function ownerClaim() external onlyOwner {
require(now > ownerTimeLastMinted);
uint _timePassedSinceLastMint; // The amount of time passed since the owner claimed in seconds
uint _tokenMintCount; // The amount of new tokens to mint
bool _mintingSuccess; // The success of minting the new Scale tokens
// Calculate the number of seconds that have passed since the owner last took a claim
_timePassedSinceLastMint = now.sub(ownerTimeLastMinted);
assert(_timePassedSinceLastMint > 0);
// Determine the token mint amount, determined from the number of seconds passed and the ownerMintRate
_tokenMintCount = calculateMintTotal(_timePassedSinceLastMint, ownerMintRate);
// Mint the owner's tokens; this also increases totalSupply
_mintingSuccess = mint(msg.sender, _tokenMintCount);
require(_mintingSuccess);
// New minting was a success. Set last time minted to current block.timestamp (now)
ownerTimeLastMinted = now;
}
| 32,635 |
17 | // list of all deposites | Deposit[] public deposits;
| Deposit[] public deposits;
| 22,614 |
150 | // in case rounding error, send all to final | token.transfer(
tokenPools[last],
totalTokens.mulBP(tokenPoolBPs[last])
);
| token.transfer(
tokenPools[last],
totalTokens.mulBP(tokenPoolBPs[last])
);
| 55,386 |
30 | // emitted whenever user's staked tokens are successfully unstaked and trasnferred back to the user | event ClaimedInterestTokens(address indexed _user, uint256 _amount);
| event ClaimedInterestTokens(address indexed _user, uint256 _amount);
| 20,848 |
28 | // updateStakeArray(_stakeId);totalStaked -= stakeAmount; | uint256 referrerAmount = ((stakeAmount - userStakeDetails.totalCompounded) * referralFee) / percentageDivisor;
uint256 unstakableAmount = userStakeDetails.stakeAmount - (userStakeDetails.totalClaimed + referrerAmount);
require(unstakableAmount > 0,"Cannot unstake, already claimed more than staked amount");
uint256 unstakeFeeAmount = (unstakableAmount * unstakeFee) / percentageDivisor;
uint256 devFeeAmount = unstakeFeeAmount / 2;
uint256 finalUnstakableAmount = unstakableAmount - unstakeFeeAmount;
return(totalStaked,userDetails.totalStakedBalance,stakeAmount,referrerAmount,unstakableAmount,unstakeFeeAmount,devFeeAmount,finalUnstakableAmount );
| uint256 referrerAmount = ((stakeAmount - userStakeDetails.totalCompounded) * referralFee) / percentageDivisor;
uint256 unstakableAmount = userStakeDetails.stakeAmount - (userStakeDetails.totalClaimed + referrerAmount);
require(unstakableAmount > 0,"Cannot unstake, already claimed more than staked amount");
uint256 unstakeFeeAmount = (unstakableAmount * unstakeFee) / percentageDivisor;
uint256 devFeeAmount = unstakeFeeAmount / 2;
uint256 finalUnstakableAmount = unstakableAmount - unstakeFeeAmount;
return(totalStaked,userDetails.totalStakedBalance,stakeAmount,referrerAmount,unstakableAmount,unstakeFeeAmount,devFeeAmount,finalUnstakableAmount );
| 24,305 |
22 | // get the username hash of the sender's account | bytes32 usernameHash = owners[msg.sender];
| bytes32 usernameHash = owners[msg.sender];
| 48,139 |
17 | // Complete sale if no more crew members available | if (scanCount == (endScanCount - 1)) {
_cancelSale();
unlockCitizens();
}
| if (scanCount == (endScanCount - 1)) {
_cancelSale();
unlockCitizens();
}
| 12,471 |
42 | // HEX Share Market/Sam Presnal - Staker/Sell shares priced at the original purchase rate/ plus the applied premium | contract ShareMarket is MinterReceiver {
IERC20 public immutable hexContract;
address public immutable minterContract;
/// @dev Share price is sharesBalance/heartsBalance
/// Both balances reduce on buyShares to maintain the price,
/// keep track of hearts owed to supplier, and determine
/// when the listing is no longer buyable
struct ShareListing {
uint72 sharesBalance;
uint72 heartsBalance;
}
mapping(uint40 => ShareListing) public shareListings;
/// @dev The values are initialized onSharesMinted and
/// onEarningsMinted respectively. Used to calculate personal
/// earnings for a listing sharesOwned/sharesTotal*heartsEarned
struct ShareEarnings {
uint72 sharesTotal;
uint72 heartsEarned;
}
mapping(uint40 => ShareEarnings) public shareEarnings;
/// @notice Maintains which addresses own shares of particular stakes
/// @dev heartsOwed is only set for the supplier to keep track of
/// repayment for creating the stake
struct ListingOwnership {
uint72 sharesOwned;
uint72 heartsOwed;
bool isSupplier;
}
//keccak(stakeId, address) => ListingOwnership
mapping(bytes32 => ListingOwnership) internal shareOwners;
struct ShareOrder {
uint40 stakeId;
uint256 sharesPurchased;
address shareReceiver;
}
event AddListing(
uint40 indexed stakeId,
address indexed supplier,
uint256 data0 //shares | hearts << 72
);
event AddEarnings(uint40 indexed stakeId, uint256 heartsEarned);
event BuyShares(
uint40 indexed stakeId,
address indexed owner,
uint256 data0, //sharesPurchased | sharesOwned << 72
uint256 data1 //sharesBalance | heartsBalance << 72
);
event ClaimEarnings(uint40 indexed stakeId, address indexed claimer, uint256 heartsClaimed);
event SupplierWithdraw(uint40 indexed stakeId, address indexed supplier, uint256 heartsWithdrawn);
uint256 private unlocked = 1;
modifier lock() {
require(unlocked == 1, "LOCKED");
unlocked = 0;
_;
unlocked = 1;
}
constructor(IERC20 _hex, address _minter) {
hexContract = _hex;
minterContract = _minter;
}
/// @inheritdoc MinterReceiver
function onSharesMinted(
uint40 stakeId,
address supplier,
uint72 stakedHearts,
uint72 stakeShares
) external override {
require(msg.sender == minterContract, "CALLER_NOT_MINTER");
//Seed pool with shares and hearts determining the rate
shareListings[stakeId] = ShareListing(stakeShares, stakedHearts);
//Store total shares to calculate user earnings for claiming
shareEarnings[stakeId].sharesTotal = stakeShares;
//Store how many hearts the supplier needs to be paid back
shareOwners[_hash(stakeId, supplier)] = ListingOwnership(0, stakedHearts, true);
emit AddListing(stakeId, supplier, uint256(uint72(stakeShares)) | (uint256(uint72(stakedHearts)) << 72));
}
/// @inheritdoc MinterReceiver
function onEarningsMinted(uint40 stakeId, uint72 heartsEarned) external override {
require(msg.sender == minterContract, "CALLER_NOT_MINTER");
//Hearts earned and total shares now stored in earnings
//for payout calculations
shareEarnings[stakeId].heartsEarned = heartsEarned;
emit AddEarnings(stakeId, heartsEarned);
}
/// @return Supplier hearts payable resulting from user purchases
function supplierHeartsPayable(uint40 stakeId, address supplier) external view returns (uint256) {
uint256 heartsOwed = shareOwners[_hash(stakeId, supplier)].heartsOwed;
if (heartsOwed == 0) return 0;
(uint256 heartsBalance, ) = listingBalances(stakeId);
return heartsOwed - heartsBalance;
}
/// @dev Used to calculate share price
/// @return hearts Balance of hearts remaining in the listing to be input
/// @return shares Balance of shares reamining in the listing to be sold
function listingBalances(uint40 stakeId) public view returns (uint256 hearts, uint256 shares) {
ShareListing memory listing = shareListings[stakeId];
hearts = listing.heartsBalance;
shares = listing.sharesBalance;
}
/// @dev Used to calculate personal earnings
/// @return heartsEarned Total hearts earned by the stake
/// @return sharesTotal Total shares originally on the market
function listingEarnings(uint40 stakeId) public view returns (uint256 heartsEarned, uint256 sharesTotal) {
ShareEarnings memory earnings = shareEarnings[stakeId];
heartsEarned = earnings.heartsEarned;
sharesTotal = earnings.sharesTotal;
}
/// @dev Shares owned is set to 0 when a user claims earnings
/// @return Current shares owned of a particular listing
function sharesOwned(uint40 stakeId, address owner) public view returns (uint256) {
return shareOwners[_hash(stakeId, owner)].sharesOwned;
}
/// @dev Hash together stakeId and address to form a key for
/// storage access
/// @return Listing address storage key
function _hash(uint40 stakeId, address addr) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(stakeId, addr));
}
/// @notice Allows user to purchase shares from multiple listings
/// @dev Lumps owed HEX into single transfer
function multiBuyShares(ShareOrder[] memory orders) external lock {
uint256 totalHeartsOwed;
for (uint256 i = 0; i < orders.length; i++) {
ShareOrder memory order = orders[i];
totalHeartsOwed += _buyShares(order.stakeId, order.shareReceiver, order.sharesPurchased);
}
hexContract.transferFrom(msg.sender, address(this), totalHeartsOwed);
}
/// @notice Allows user to purchase shares from a single listing
/// @param stakeId HEX stakeId to purchase shares from
/// @param shareReceiver The receiver of the shares being purchased
/// @param sharesPurchased The number of shares to purchase
function buyShares(
uint40 stakeId,
address shareReceiver,
uint256 sharesPurchased
) external lock {
uint256 heartsOwed = _buyShares(stakeId, shareReceiver, sharesPurchased);
hexContract.transferFrom(msg.sender, address(this), heartsOwed);
}
function _buyShares(
uint40 stakeId,
address shareReceiver,
uint256 sharesPurchased
) internal returns (uint256 heartsOwed) {
require(sharesPurchased != 0, "INSUFFICIENT_SHARES_PURCHASED");
(uint256 _heartsBalance, uint256 _sharesBalance) = listingBalances(stakeId);
require(sharesPurchased <= _sharesBalance, "INSUFFICIENT_SHARES_AVAILABLE");
//mulDivRoundingUp may result in 1 extra heart cost
//any shares purchased will always cost at least 1 heart
heartsOwed = FullMath.mulDivRoundingUp(sharesPurchased, _heartsBalance, _sharesBalance);
//Reduce hearts owed to remaining hearts balance if it exceeds it
//This can happen from extra 1 heart cost
if (heartsOwed >= _heartsBalance) {
heartsOwed = _heartsBalance;
sharesPurchased = _sharesBalance;
}
//Reduce both sides of the pool to maintain price
uint256 sharesBalance = _sharesBalance - sharesPurchased;
uint256 heartsBalance = _heartsBalance - heartsOwed;
shareListings[stakeId] = ShareListing(uint72(sharesBalance), uint72(heartsBalance));
//Add shares purchased to currently owned shares if any
bytes32 shareOwner = _hash(stakeId, shareReceiver);
uint256 newSharesOwned = shareOwners[shareOwner].sharesOwned + sharesPurchased;
shareOwners[shareOwner].sharesOwned = uint72(newSharesOwned);
emit BuyShares(
stakeId,
shareReceiver,
uint256(uint72(sharesPurchased)) | (uint256(uint72(newSharesOwned)) << 72),
uint256(uint72(sharesBalance)) | (uint256(uint72(heartsBalance)) << 72)
);
}
/// @notice Withdraw earnings as a supplier
/// @param stakeId HEX stakeId to withdraw earnings from
/// @dev Combines supplier withdraw from two sources
/// 1. Hearts paid for supplied shares by market participants
/// 2. Hearts earned from staking supplied shares (buyer fee %)
/// Note: If a listing has ended, assigns all leftover shares before withdraw
function supplierWithdraw(uint40 stakeId) external lock {
//Track total withdrawable
uint256 totalHeartsOwed = 0;
bytes32 supplier = _hash(stakeId, msg.sender);
require(shareOwners[supplier].isSupplier, "NOT_SUPPLIER");
//Check to see if heartsOwed for sold shares in listing
uint256 heartsOwed = uint256(shareOwners[supplier].heartsOwed);
(uint256 heartsBalance, uint256 sharesBalance) = listingBalances(stakeId);
//The delta between heartsOwed and heartsBalance is created
//by users buying shares from the pool and reducing heartsBalance
if (heartsOwed > heartsBalance) {
//Withdraw any hearts for shares sold
uint256 heartsPayable = heartsOwed - heartsBalance;
uint256 newHeartsOwed = heartsOwed - heartsPayable;
//Update hearts owed
shareOwners[supplier].heartsOwed = uint72(newHeartsOwed);
totalHeartsOwed = heartsPayable;
}
//Claim earnings including unsold shares only if the
//earnings have already been minted
(uint256 heartsEarned, ) = listingEarnings(stakeId);
if (heartsEarned != 0) {
uint256 supplierShares = shareOwners[supplier].sharesOwned;
//Check for unsold market shares
if (sharesBalance != 0) {
//Add unsold shares to supplier shares
supplierShares += sharesBalance;
//Update storage to reflect new shares
shareOwners[supplier].sharesOwned = uint72(supplierShares);
//Close buying from share listing
delete shareListings[stakeId];
//Remove supplier hearts owed
shareOwners[supplier].heartsOwed = 0;
emit BuyShares(
stakeId,
msg.sender,
uint256(uint72(sharesBalance)) | (uint256(supplierShares) << 72),
0
);
}
//Ensure supplier has shares (claim reverts otherwise)
if (supplierShares != 0) totalHeartsOwed += _claimEarnings(stakeId);
}
require(totalHeartsOwed != 0, "NO_HEARTS_OWED");
hexContract.transfer(msg.sender, totalHeartsOwed);
emit SupplierWithdraw(stakeId, msg.sender, totalHeartsOwed);
}
/// @notice Withdraw earnings as a market participant
/// @param stakeId HEX stakeId to withdraw earnings from
function claimEarnings(uint40 stakeId) external lock {
uint256 heartsEarned = _claimEarnings(stakeId);
require(heartsEarned != 0, "NO_HEARTS_EARNED");
hexContract.transfer(msg.sender, heartsEarned);
}
function _claimEarnings(uint40 stakeId) internal returns (uint256 heartsOwed) {
(uint256 heartsEarned, uint256 sharesTotal) = listingEarnings(stakeId);
require(sharesTotal != 0, "LISTING_NOT_FOUND");
require(heartsEarned != 0, "SHARES_NOT_MATURE");
bytes32 owner = _hash(stakeId, msg.sender);
uint256 ownedShares = shareOwners[owner].sharesOwned;
require(ownedShares != 0, "NO_SHARES_OWNED");
heartsOwed = FullMath.mulDiv(heartsEarned, ownedShares, sharesTotal);
shareOwners[owner].sharesOwned = 0;
emit ClaimEarnings(stakeId, msg.sender, heartsOwed);
}
}
| contract ShareMarket is MinterReceiver {
IERC20 public immutable hexContract;
address public immutable minterContract;
/// @dev Share price is sharesBalance/heartsBalance
/// Both balances reduce on buyShares to maintain the price,
/// keep track of hearts owed to supplier, and determine
/// when the listing is no longer buyable
struct ShareListing {
uint72 sharesBalance;
uint72 heartsBalance;
}
mapping(uint40 => ShareListing) public shareListings;
/// @dev The values are initialized onSharesMinted and
/// onEarningsMinted respectively. Used to calculate personal
/// earnings for a listing sharesOwned/sharesTotal*heartsEarned
struct ShareEarnings {
uint72 sharesTotal;
uint72 heartsEarned;
}
mapping(uint40 => ShareEarnings) public shareEarnings;
/// @notice Maintains which addresses own shares of particular stakes
/// @dev heartsOwed is only set for the supplier to keep track of
/// repayment for creating the stake
struct ListingOwnership {
uint72 sharesOwned;
uint72 heartsOwed;
bool isSupplier;
}
//keccak(stakeId, address) => ListingOwnership
mapping(bytes32 => ListingOwnership) internal shareOwners;
struct ShareOrder {
uint40 stakeId;
uint256 sharesPurchased;
address shareReceiver;
}
event AddListing(
uint40 indexed stakeId,
address indexed supplier,
uint256 data0 //shares | hearts << 72
);
event AddEarnings(uint40 indexed stakeId, uint256 heartsEarned);
event BuyShares(
uint40 indexed stakeId,
address indexed owner,
uint256 data0, //sharesPurchased | sharesOwned << 72
uint256 data1 //sharesBalance | heartsBalance << 72
);
event ClaimEarnings(uint40 indexed stakeId, address indexed claimer, uint256 heartsClaimed);
event SupplierWithdraw(uint40 indexed stakeId, address indexed supplier, uint256 heartsWithdrawn);
uint256 private unlocked = 1;
modifier lock() {
require(unlocked == 1, "LOCKED");
unlocked = 0;
_;
unlocked = 1;
}
constructor(IERC20 _hex, address _minter) {
hexContract = _hex;
minterContract = _minter;
}
/// @inheritdoc MinterReceiver
function onSharesMinted(
uint40 stakeId,
address supplier,
uint72 stakedHearts,
uint72 stakeShares
) external override {
require(msg.sender == minterContract, "CALLER_NOT_MINTER");
//Seed pool with shares and hearts determining the rate
shareListings[stakeId] = ShareListing(stakeShares, stakedHearts);
//Store total shares to calculate user earnings for claiming
shareEarnings[stakeId].sharesTotal = stakeShares;
//Store how many hearts the supplier needs to be paid back
shareOwners[_hash(stakeId, supplier)] = ListingOwnership(0, stakedHearts, true);
emit AddListing(stakeId, supplier, uint256(uint72(stakeShares)) | (uint256(uint72(stakedHearts)) << 72));
}
/// @inheritdoc MinterReceiver
function onEarningsMinted(uint40 stakeId, uint72 heartsEarned) external override {
require(msg.sender == minterContract, "CALLER_NOT_MINTER");
//Hearts earned and total shares now stored in earnings
//for payout calculations
shareEarnings[stakeId].heartsEarned = heartsEarned;
emit AddEarnings(stakeId, heartsEarned);
}
/// @return Supplier hearts payable resulting from user purchases
function supplierHeartsPayable(uint40 stakeId, address supplier) external view returns (uint256) {
uint256 heartsOwed = shareOwners[_hash(stakeId, supplier)].heartsOwed;
if (heartsOwed == 0) return 0;
(uint256 heartsBalance, ) = listingBalances(stakeId);
return heartsOwed - heartsBalance;
}
/// @dev Used to calculate share price
/// @return hearts Balance of hearts remaining in the listing to be input
/// @return shares Balance of shares reamining in the listing to be sold
function listingBalances(uint40 stakeId) public view returns (uint256 hearts, uint256 shares) {
ShareListing memory listing = shareListings[stakeId];
hearts = listing.heartsBalance;
shares = listing.sharesBalance;
}
/// @dev Used to calculate personal earnings
/// @return heartsEarned Total hearts earned by the stake
/// @return sharesTotal Total shares originally on the market
function listingEarnings(uint40 stakeId) public view returns (uint256 heartsEarned, uint256 sharesTotal) {
ShareEarnings memory earnings = shareEarnings[stakeId];
heartsEarned = earnings.heartsEarned;
sharesTotal = earnings.sharesTotal;
}
/// @dev Shares owned is set to 0 when a user claims earnings
/// @return Current shares owned of a particular listing
function sharesOwned(uint40 stakeId, address owner) public view returns (uint256) {
return shareOwners[_hash(stakeId, owner)].sharesOwned;
}
/// @dev Hash together stakeId and address to form a key for
/// storage access
/// @return Listing address storage key
function _hash(uint40 stakeId, address addr) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(stakeId, addr));
}
/// @notice Allows user to purchase shares from multiple listings
/// @dev Lumps owed HEX into single transfer
function multiBuyShares(ShareOrder[] memory orders) external lock {
uint256 totalHeartsOwed;
for (uint256 i = 0; i < orders.length; i++) {
ShareOrder memory order = orders[i];
totalHeartsOwed += _buyShares(order.stakeId, order.shareReceiver, order.sharesPurchased);
}
hexContract.transferFrom(msg.sender, address(this), totalHeartsOwed);
}
/// @notice Allows user to purchase shares from a single listing
/// @param stakeId HEX stakeId to purchase shares from
/// @param shareReceiver The receiver of the shares being purchased
/// @param sharesPurchased The number of shares to purchase
function buyShares(
uint40 stakeId,
address shareReceiver,
uint256 sharesPurchased
) external lock {
uint256 heartsOwed = _buyShares(stakeId, shareReceiver, sharesPurchased);
hexContract.transferFrom(msg.sender, address(this), heartsOwed);
}
function _buyShares(
uint40 stakeId,
address shareReceiver,
uint256 sharesPurchased
) internal returns (uint256 heartsOwed) {
require(sharesPurchased != 0, "INSUFFICIENT_SHARES_PURCHASED");
(uint256 _heartsBalance, uint256 _sharesBalance) = listingBalances(stakeId);
require(sharesPurchased <= _sharesBalance, "INSUFFICIENT_SHARES_AVAILABLE");
//mulDivRoundingUp may result in 1 extra heart cost
//any shares purchased will always cost at least 1 heart
heartsOwed = FullMath.mulDivRoundingUp(sharesPurchased, _heartsBalance, _sharesBalance);
//Reduce hearts owed to remaining hearts balance if it exceeds it
//This can happen from extra 1 heart cost
if (heartsOwed >= _heartsBalance) {
heartsOwed = _heartsBalance;
sharesPurchased = _sharesBalance;
}
//Reduce both sides of the pool to maintain price
uint256 sharesBalance = _sharesBalance - sharesPurchased;
uint256 heartsBalance = _heartsBalance - heartsOwed;
shareListings[stakeId] = ShareListing(uint72(sharesBalance), uint72(heartsBalance));
//Add shares purchased to currently owned shares if any
bytes32 shareOwner = _hash(stakeId, shareReceiver);
uint256 newSharesOwned = shareOwners[shareOwner].sharesOwned + sharesPurchased;
shareOwners[shareOwner].sharesOwned = uint72(newSharesOwned);
emit BuyShares(
stakeId,
shareReceiver,
uint256(uint72(sharesPurchased)) | (uint256(uint72(newSharesOwned)) << 72),
uint256(uint72(sharesBalance)) | (uint256(uint72(heartsBalance)) << 72)
);
}
/// @notice Withdraw earnings as a supplier
/// @param stakeId HEX stakeId to withdraw earnings from
/// @dev Combines supplier withdraw from two sources
/// 1. Hearts paid for supplied shares by market participants
/// 2. Hearts earned from staking supplied shares (buyer fee %)
/// Note: If a listing has ended, assigns all leftover shares before withdraw
function supplierWithdraw(uint40 stakeId) external lock {
//Track total withdrawable
uint256 totalHeartsOwed = 0;
bytes32 supplier = _hash(stakeId, msg.sender);
require(shareOwners[supplier].isSupplier, "NOT_SUPPLIER");
//Check to see if heartsOwed for sold shares in listing
uint256 heartsOwed = uint256(shareOwners[supplier].heartsOwed);
(uint256 heartsBalance, uint256 sharesBalance) = listingBalances(stakeId);
//The delta between heartsOwed and heartsBalance is created
//by users buying shares from the pool and reducing heartsBalance
if (heartsOwed > heartsBalance) {
//Withdraw any hearts for shares sold
uint256 heartsPayable = heartsOwed - heartsBalance;
uint256 newHeartsOwed = heartsOwed - heartsPayable;
//Update hearts owed
shareOwners[supplier].heartsOwed = uint72(newHeartsOwed);
totalHeartsOwed = heartsPayable;
}
//Claim earnings including unsold shares only if the
//earnings have already been minted
(uint256 heartsEarned, ) = listingEarnings(stakeId);
if (heartsEarned != 0) {
uint256 supplierShares = shareOwners[supplier].sharesOwned;
//Check for unsold market shares
if (sharesBalance != 0) {
//Add unsold shares to supplier shares
supplierShares += sharesBalance;
//Update storage to reflect new shares
shareOwners[supplier].sharesOwned = uint72(supplierShares);
//Close buying from share listing
delete shareListings[stakeId];
//Remove supplier hearts owed
shareOwners[supplier].heartsOwed = 0;
emit BuyShares(
stakeId,
msg.sender,
uint256(uint72(sharesBalance)) | (uint256(supplierShares) << 72),
0
);
}
//Ensure supplier has shares (claim reverts otherwise)
if (supplierShares != 0) totalHeartsOwed += _claimEarnings(stakeId);
}
require(totalHeartsOwed != 0, "NO_HEARTS_OWED");
hexContract.transfer(msg.sender, totalHeartsOwed);
emit SupplierWithdraw(stakeId, msg.sender, totalHeartsOwed);
}
/// @notice Withdraw earnings as a market participant
/// @param stakeId HEX stakeId to withdraw earnings from
function claimEarnings(uint40 stakeId) external lock {
uint256 heartsEarned = _claimEarnings(stakeId);
require(heartsEarned != 0, "NO_HEARTS_EARNED");
hexContract.transfer(msg.sender, heartsEarned);
}
function _claimEarnings(uint40 stakeId) internal returns (uint256 heartsOwed) {
(uint256 heartsEarned, uint256 sharesTotal) = listingEarnings(stakeId);
require(sharesTotal != 0, "LISTING_NOT_FOUND");
require(heartsEarned != 0, "SHARES_NOT_MATURE");
bytes32 owner = _hash(stakeId, msg.sender);
uint256 ownedShares = shareOwners[owner].sharesOwned;
require(ownedShares != 0, "NO_SHARES_OWNED");
heartsOwed = FullMath.mulDiv(heartsEarned, ownedShares, sharesTotal);
shareOwners[owner].sharesOwned = 0;
emit ClaimEarnings(stakeId, msg.sender, heartsOwed);
}
}
| 79,324 |
697 | // This function returns a 18 decimal fixed point number assetsPerShare decimals: 18 + main - wrapped _rateScaleFactor decimals: 18 - main + wrapped | uint256 rate = assetsPerShare.mul(_rateScaleFactor).divDown(FixedPoint.ONE);
return rate;
| uint256 rate = assetsPerShare.mul(_rateScaleFactor).divDown(FixedPoint.ONE);
return rate;
| 25,098 |
6 | // getTotalOffers / | function getTotalOffers() external view returns (uint256){
return totalOffers;
}
| function getTotalOffers() external view returns (uint256){
return totalOffers;
}
| 13,599 |
249 | // By storing the original value once again, a refund is triggered (see https:eips.ethereum.org/EIPS/eip-2200) | _status = _NOT_ENTERED;
| _status = _NOT_ENTERED;
| 8,906 |
0 | // Delegator claimable amounts | mapping(address => uint256) public claimables;
event Claimed(address delegator, uint256 amount);
event ClaimDeposit(address delegator, uint256 amount);
| mapping(address => uint256) public claimables;
event Claimed(address delegator, uint256 amount);
event ClaimDeposit(address delegator, uint256 amount);
| 32,260 |
249 | // set the new highest bid and bidder | emogramsOnAuction[_auctionId].highestBidder = payable(msg.sender);
emogramsOnAuction[_auctionId].highestBid = msg.value;
emit BidPlaced(_auctionId, emogramsOnAuction[_auctionId].tokenId, msg.sender, msg.value);
return _auctionId;
| emogramsOnAuction[_auctionId].highestBidder = payable(msg.sender);
emogramsOnAuction[_auctionId].highestBid = msg.value;
emit BidPlaced(_auctionId, emogramsOnAuction[_auctionId].tokenId, msg.sender, msg.value);
return _auctionId;
| 12,179 |
32 | // STATE MODIFYING FUNCTIONS // Swap two tokens using this pool tokenIndexFrom the token the user wants to swap from tokenIndexTo the token the user wants to swap to dx the amount of tokens the user wants to swap from minDy the min amount the user would like to receive, or revert. deadline latest timestamp to accept this transaction / | function swap(
uint8 tokenIndexFrom,
uint8 tokenIndexTo,
uint256 dx,
uint256 minDy,
uint256 deadline
)
external
nonReentrant
| function swap(
uint8 tokenIndexFrom,
uint8 tokenIndexTo,
uint256 dx,
uint256 minDy,
uint256 deadline
)
external
nonReentrant
| 34,204 |
13 | // Fallback function to allow the contract to receive Ether./This function has no function body, making it a default function for receiving Ether./ It is automatically called when Ether is transferred to the contract without any data. | receive() external payable {}
function transferNFTToChain(
uint64 destinationChainSelector,
address receiver,
NFTTransferData memory nftTransferData,
PayFeesIn payFeesIn
) external returns (bytes32 messageId) {
Client.EVM2AnyMessage memory message = Client.EVM2AnyMessage({
receiver: abi.encode(receiver),
data: abi.encodeWithSignature(
"receiveNFTFromChain(fromChainId,ownerAddress,tokenId,tokenUri,contractOriginChain)",
nftTransferData.fromChainId,
nftTransferData.ownerAddress,
nftTransferData.tokenId,
nftTransferData.tokenUri,
nftTransferData.contractOriginChain
),
tokenAmounts: new Client.EVMTokenAmount[](0),
extraArgs: "",
feeToken: payFeesIn == PayFeesIn.LINK
? address(linkToken)
: address(0)
});
uint256 fee = router.getFee(destinationChainSelector, message);
if (payFeesIn == PayFeesIn.LINK) {
if (fee > linkToken.balanceOf(address(this)))
revert NotEnoughBalance(
linkToken.balanceOf(address(this)),
fee
);
linkToken.approve(address(router), fee);
messageId = router.ccipSend(destinationChainSelector, message);
} else {
if (fee > address(0).balance)
revert NotEnoughBalance(address(0).balance, fee);
messageId = router.ccipSend{value: fee}(
destinationChainSelector,
message
);
}
emit NFTTransferred(
messageId,
destinationChainSelector,
receiver,
nftTransferData,
fee
);
return messageId;
}
| receive() external payable {}
function transferNFTToChain(
uint64 destinationChainSelector,
address receiver,
NFTTransferData memory nftTransferData,
PayFeesIn payFeesIn
) external returns (bytes32 messageId) {
Client.EVM2AnyMessage memory message = Client.EVM2AnyMessage({
receiver: abi.encode(receiver),
data: abi.encodeWithSignature(
"receiveNFTFromChain(fromChainId,ownerAddress,tokenId,tokenUri,contractOriginChain)",
nftTransferData.fromChainId,
nftTransferData.ownerAddress,
nftTransferData.tokenId,
nftTransferData.tokenUri,
nftTransferData.contractOriginChain
),
tokenAmounts: new Client.EVMTokenAmount[](0),
extraArgs: "",
feeToken: payFeesIn == PayFeesIn.LINK
? address(linkToken)
: address(0)
});
uint256 fee = router.getFee(destinationChainSelector, message);
if (payFeesIn == PayFeesIn.LINK) {
if (fee > linkToken.balanceOf(address(this)))
revert NotEnoughBalance(
linkToken.balanceOf(address(this)),
fee
);
linkToken.approve(address(router), fee);
messageId = router.ccipSend(destinationChainSelector, message);
} else {
if (fee > address(0).balance)
revert NotEnoughBalance(address(0).balance, fee);
messageId = router.ccipSend{value: fee}(
destinationChainSelector,
message
);
}
emit NFTTransferred(
messageId,
destinationChainSelector,
receiver,
nftTransferData,
fee
);
return messageId;
}
| 24,986 |
3 | // timestamp after which any portion of loan unpaid defaults | uint40 expiry;
| uint40 expiry;
| 38,095 |
488 | // Owned interface / | interface IOwned {
/**
* @dev returns the address of the current owner
*/
function owner() external view returns (address);
/**
* @dev allows transferring the contract ownership
*
* requirements:
*
* - the caller must be the owner of the contract
* - the new owner still needs to accept the transfer
*/
function transferOwnership(address ownerCandidate) external;
/**
* @dev used by a new owner to accept an ownership transfer
*/
function acceptOwnership() external;
}
| interface IOwned {
/**
* @dev returns the address of the current owner
*/
function owner() external view returns (address);
/**
* @dev allows transferring the contract ownership
*
* requirements:
*
* - the caller must be the owner of the contract
* - the new owner still needs to accept the transfer
*/
function transferOwnership(address ownerCandidate) external;
/**
* @dev used by a new owner to accept an ownership transfer
*/
function acceptOwnership() external;
}
| 65,112 |
101 | // If the signature is valid (and not malleable), return the signer address | address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
| address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
| 857 |
79 | // Sets the address of the ISwap-compatible router _router The address of the router / | function setRouter(address _router) external {
require(msg.sender == vaultManager.governance(), "!governance");
router = ISwap(_router);
IERC20(weth).safeApprove(address(_router), 0);
IERC20(weth).safeApprove(address(_router), type(uint256).max);
emit SetRouter(_router);
}
| function setRouter(address _router) external {
require(msg.sender == vaultManager.governance(), "!governance");
router = ISwap(_router);
IERC20(weth).safeApprove(address(_router), 0);
IERC20(weth).safeApprove(address(_router), type(uint256).max);
emit SetRouter(_router);
}
| 79,259 |
25 | // Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.Beware that changing an allowance with this method brings the risk that someone may use both the oldand the new allowance by unfortunate transaction ordering. One possible solution to mitigate thisrace condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: spender The address which will spend the funds. value The amount of tokens to be spent. / | function approve(address spender, uint256 value) public returns (bool) {
_approve(msg.sender, spender, value);
return true;
}
| function approve(address spender, uint256 value) public returns (bool) {
_approve(msg.sender, spender, value);
return true;
}
| 580 |
3 | // shares_ are scaled by 10,000 to prevent precision loss when including fees | constructor(
address payable _controlCenter,
address _trustedForwarder,
string memory _uri,
address[] memory payees,
uint256[] memory shares_
| constructor(
address payable _controlCenter,
address _trustedForwarder,
string memory _uri,
address[] memory payees,
uint256[] memory shares_
| 40,188 |
12 | // Function to create a new ACO token.It deploys a minimal proxy for the ACO token implementation address.underlying Address of the underlying asset (0x0 for Ethereum). strikeAsset Address of the strike asset (0x0 for Ethereum). isCall Whether the ACO token is the Call type. strikePrice The strike price with the strike asset precision. expiryTime The UNIX time for the ACO token expiration. maxExercisedAccounts The maximum number of accounts that can be exercised by transaction. / | function createAcoToken(
address underlying,
address strikeAsset,
bool isCall,
uint256 strikePrice,
uint256 expiryTime,
uint256 maxExercisedAccounts
| function createAcoToken(
address underlying,
address strikeAsset,
bool isCall,
uint256 strikePrice,
uint256 expiryTime,
uint256 maxExercisedAccounts
| 11,059 |
13 | // Set change status | function setChangeStatus(bool val) public onlyOwner {
require(change != val, "Already in this state");
require(addressToBeChanged != address(0) && addressToSend != address(0), "Change addresses cannot be zero");
change = val;
}
| function setChangeStatus(bool val) public onlyOwner {
require(change != val, "Already in this state");
require(addressToBeChanged != address(0) && addressToSend != address(0), "Change addresses cannot be zero");
change = val;
}
| 8,862 |
29 | // Returns the token URI / | function tokenURI(uint256 tokenId_) public view virtual override returns (string memory) {
// Check if the token exists using the _exists function
require(_exists(tokenId_), "Token does not exist");
// Return the base URI
return baseURI;
}
| function tokenURI(uint256 tokenId_) public view virtual override returns (string memory) {
// Check if the token exists using the _exists function
require(_exists(tokenId_), "Token does not exist");
// Return the base URI
return baseURI;
}
| 38,430 |
21 | // function setPositionMemberValueMul(address[] memory _account, uint[] memory _value) external; |
function getTotalAssert() external view returns (uint _ethNum, uint _USDNum, uint _WBTCNum);
function setTotalAssert(uint _ethNum, uint _USDNum, uint _WBTCNum) external;
|
function getTotalAssert() external view returns (uint _ethNum, uint _USDNum, uint _WBTCNum);
function setTotalAssert(uint _ethNum, uint _USDNum, uint _WBTCNum) external;
| 2,606 |
15 | // util function for slicing a bytes array and converting to bytes32/_bytes byte array to slice/_start start index of slice/given a byte array, convert a slice starting at specified index to bytes32 | function bytesToBytes32(bytes memory _bytes, uint256 _start) internal pure returns (bytes32) {
require(_bytes.length >= (_start + 32), "out of bounds when slicing to bytes32");
bytes32 tempBytes32;
assembly {
tempBytes32 := mload(add(add(_bytes, 0x20), _start))
}
return tempBytes32;
}
| function bytesToBytes32(bytes memory _bytes, uint256 _start) internal pure returns (bytes32) {
require(_bytes.length >= (_start + 32), "out of bounds when slicing to bytes32");
bytes32 tempBytes32;
assembly {
tempBytes32 := mload(add(add(_bytes, 0x20), _start))
}
return tempBytes32;
}
| 46,679 |
10 | // provides Zero (Empty) elements for a MiMC MerkleTree. Up to 32 levels | function zeros(uint256 i) public pure returns (bytes32) {
if (i == 0) return bytes32(0x2fe54c60d3acabf3343a35b6eba15db4821b340f76e741e2249685ed4899af6c);
else if (i == 1) return bytes32(0x256a6135777eee2fd26f54b8b7037a25439d5235caee224154186d2b8a52e31d);
else if (i == 2) return bytes32(0x1151949895e82ab19924de92c40a3d6f7bcb60d92b00504b8199613683f0c200);
else if (i == 3) return bytes32(0x20121ee811489ff8d61f09fb89e313f14959a0f28bb428a20dba6b0b068b3bdb);
else if (i == 4) return bytes32(0x0a89ca6ffa14cc462cfedb842c30ed221a50a3d6bf022a6a57dc82ab24c157c9);
else if (i == 5) return bytes32(0x24ca05c2b5cd42e890d6be94c68d0689f4f21c9cec9c0f13fe41d566dfb54959);
else if (i == 6) return bytes32(0x1ccb97c932565a92c60156bdba2d08f3bf1377464e025cee765679e604a7315c);
else if (i == 7) return bytes32(0x19156fbd7d1a8bf5cba8909367de1b624534ebab4f0f79e003bccdd1b182bdb4);
else if (i == 8) return bytes32(0x261af8c1f0912e465744641409f622d466c3920ac6e5ff37e36604cb11dfff80);
else if (i == 9) return bytes32(0x0058459724ff6ca5a1652fcbc3e82b93895cf08e975b19beab3f54c217d1c007);
else if (i == 10) return bytes32(0x1f04ef20dee48d39984d8eabe768a70eafa6310ad20849d4573c3c40c2ad1e30);
else if (i == 11) return bytes32(0x1bea3dec5dab51567ce7e200a30f7ba6d4276aeaa53e2686f962a46c66d511e5);
else if (i == 12) return bytes32(0x0ee0f941e2da4b9e31c3ca97a40d8fa9ce68d97c084177071b3cb46cd3372f0f);
else if (i == 13) return bytes32(0x1ca9503e8935884501bbaf20be14eb4c46b89772c97b96e3b2ebf3a36a948bbd);
else if (i == 14) return bytes32(0x133a80e30697cd55d8f7d4b0965b7be24057ba5dc3da898ee2187232446cb108);
else if (i == 15) return bytes32(0x13e6d8fc88839ed76e182c2a779af5b2c0da9dd18c90427a644f7e148a6253b6);
else if (i == 16) return bytes32(0x1eb16b057a477f4bc8f572ea6bee39561098f78f15bfb3699dcbb7bd8db61854);
else if (i == 17) return bytes32(0x0da2cb16a1ceaabf1c16b838f7a9e3f2a3a3088d9e0a6debaa748114620696ea);
else if (i == 18) return bytes32(0x24a3b3d822420b14b5d8cb6c28a574f01e98ea9e940551d2ebd75cee12649f9d);
else if (i == 19) return bytes32(0x198622acbd783d1b0d9064105b1fc8e4d8889de95c4c519b3f635809fe6afc05);
else if (i == 20) return bytes32(0x29d7ed391256ccc3ea596c86e933b89ff339d25ea8ddced975ae2fe30b5296d4);
else if (i == 21) return bytes32(0x19be59f2f0413ce78c0c3703a3a5451b1d7f39629fa33abd11548a76065b2967);
else if (i == 22) return bytes32(0x1ff3f61797e538b70e619310d33f2a063e7eb59104e112e95738da1254dc3453);
else if (i == 23) return bytes32(0x10c16ae9959cf8358980d9dd9616e48228737310a10e2b6b731c1a548f036c48);
else if (i == 24) return bytes32(0x0ba433a63174a90ac20992e75e3095496812b652685b5e1a2eae0b1bf4e8fcd1);
else if (i == 25) return bytes32(0x019ddb9df2bc98d987d0dfeca9d2b643deafab8f7036562e627c3667266a044c);
else if (i == 26) return bytes32(0x2d3c88b23175c5a5565db928414c66d1912b11acf974b2e644caaac04739ce99);
else if (i == 27) return bytes32(0x2eab55f6ae4e66e32c5189eed5c470840863445760f5ed7e7b69b2a62600f354);
else if (i == 28) return bytes32(0x002df37a2642621802383cf952bf4dd1f32e05433beeb1fd41031fb7eace979d);
else if (i == 29) return bytes32(0x104aeb41435db66c3e62feccc1d6f5d98d0a0ed75d1374db457cf462e3a1f427);
else if (i == 30) return bytes32(0x1f3c6fd858e9a7d4b0d1f38e256a09d81d5a5e3c963987e2d4b814cfab7c6ebb);
else if (i == 31) return bytes32(0x2c7a07d20dff79d01fecedc1134284a8d08436606c93693b67e333f671bf69cc);
else revert("Index out of bounds");
}
| function zeros(uint256 i) public pure returns (bytes32) {
if (i == 0) return bytes32(0x2fe54c60d3acabf3343a35b6eba15db4821b340f76e741e2249685ed4899af6c);
else if (i == 1) return bytes32(0x256a6135777eee2fd26f54b8b7037a25439d5235caee224154186d2b8a52e31d);
else if (i == 2) return bytes32(0x1151949895e82ab19924de92c40a3d6f7bcb60d92b00504b8199613683f0c200);
else if (i == 3) return bytes32(0x20121ee811489ff8d61f09fb89e313f14959a0f28bb428a20dba6b0b068b3bdb);
else if (i == 4) return bytes32(0x0a89ca6ffa14cc462cfedb842c30ed221a50a3d6bf022a6a57dc82ab24c157c9);
else if (i == 5) return bytes32(0x24ca05c2b5cd42e890d6be94c68d0689f4f21c9cec9c0f13fe41d566dfb54959);
else if (i == 6) return bytes32(0x1ccb97c932565a92c60156bdba2d08f3bf1377464e025cee765679e604a7315c);
else if (i == 7) return bytes32(0x19156fbd7d1a8bf5cba8909367de1b624534ebab4f0f79e003bccdd1b182bdb4);
else if (i == 8) return bytes32(0x261af8c1f0912e465744641409f622d466c3920ac6e5ff37e36604cb11dfff80);
else if (i == 9) return bytes32(0x0058459724ff6ca5a1652fcbc3e82b93895cf08e975b19beab3f54c217d1c007);
else if (i == 10) return bytes32(0x1f04ef20dee48d39984d8eabe768a70eafa6310ad20849d4573c3c40c2ad1e30);
else if (i == 11) return bytes32(0x1bea3dec5dab51567ce7e200a30f7ba6d4276aeaa53e2686f962a46c66d511e5);
else if (i == 12) return bytes32(0x0ee0f941e2da4b9e31c3ca97a40d8fa9ce68d97c084177071b3cb46cd3372f0f);
else if (i == 13) return bytes32(0x1ca9503e8935884501bbaf20be14eb4c46b89772c97b96e3b2ebf3a36a948bbd);
else if (i == 14) return bytes32(0x133a80e30697cd55d8f7d4b0965b7be24057ba5dc3da898ee2187232446cb108);
else if (i == 15) return bytes32(0x13e6d8fc88839ed76e182c2a779af5b2c0da9dd18c90427a644f7e148a6253b6);
else if (i == 16) return bytes32(0x1eb16b057a477f4bc8f572ea6bee39561098f78f15bfb3699dcbb7bd8db61854);
else if (i == 17) return bytes32(0x0da2cb16a1ceaabf1c16b838f7a9e3f2a3a3088d9e0a6debaa748114620696ea);
else if (i == 18) return bytes32(0x24a3b3d822420b14b5d8cb6c28a574f01e98ea9e940551d2ebd75cee12649f9d);
else if (i == 19) return bytes32(0x198622acbd783d1b0d9064105b1fc8e4d8889de95c4c519b3f635809fe6afc05);
else if (i == 20) return bytes32(0x29d7ed391256ccc3ea596c86e933b89ff339d25ea8ddced975ae2fe30b5296d4);
else if (i == 21) return bytes32(0x19be59f2f0413ce78c0c3703a3a5451b1d7f39629fa33abd11548a76065b2967);
else if (i == 22) return bytes32(0x1ff3f61797e538b70e619310d33f2a063e7eb59104e112e95738da1254dc3453);
else if (i == 23) return bytes32(0x10c16ae9959cf8358980d9dd9616e48228737310a10e2b6b731c1a548f036c48);
else if (i == 24) return bytes32(0x0ba433a63174a90ac20992e75e3095496812b652685b5e1a2eae0b1bf4e8fcd1);
else if (i == 25) return bytes32(0x019ddb9df2bc98d987d0dfeca9d2b643deafab8f7036562e627c3667266a044c);
else if (i == 26) return bytes32(0x2d3c88b23175c5a5565db928414c66d1912b11acf974b2e644caaac04739ce99);
else if (i == 27) return bytes32(0x2eab55f6ae4e66e32c5189eed5c470840863445760f5ed7e7b69b2a62600f354);
else if (i == 28) return bytes32(0x002df37a2642621802383cf952bf4dd1f32e05433beeb1fd41031fb7eace979d);
else if (i == 29) return bytes32(0x104aeb41435db66c3e62feccc1d6f5d98d0a0ed75d1374db457cf462e3a1f427);
else if (i == 30) return bytes32(0x1f3c6fd858e9a7d4b0d1f38e256a09d81d5a5e3c963987e2d4b814cfab7c6ebb);
else if (i == 31) return bytes32(0x2c7a07d20dff79d01fecedc1134284a8d08436606c93693b67e333f671bf69cc);
else revert("Index out of bounds");
}
| 37,866 |
132 | // Emitted when a ACO Pool default strategy address has been changed. previousDefaultStrategy Address of the previous ACO pool default strategy. newDefaultStrategy Address of the new ACO pool default strategy./ | event SetDefaultStrategy(address indexed previousDefaultStrategy, address indexed newDefaultStrategy);
| event SetDefaultStrategy(address indexed previousDefaultStrategy, address indexed newDefaultStrategy);
| 36,416 |
74 | // address payable public _teamWallet = 0x3B333A64f0bbc6875176356D0Ded07FE8ae3e0aF; | IUniswapV2Router01 public _unirouter = IUniswapV2Router01(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
address[] public _pair_TOKEN_weth;
address[] public _pair_weth_TOKEN;
address[] public _validbots;
| IUniswapV2Router01 public _unirouter = IUniswapV2Router01(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
address[] public _pair_TOKEN_weth;
address[] public _pair_weth_TOKEN;
address[] public _validbots;
| 21,855 |
93 | // Returns the ABI associated with an ENS node.Defined in EIP205. node The ENS node to query contentTypes A bitwise OR of the ABI formats accepted by the caller.return contentType The content type of the return valuereturn data The ABI data / | function ABI(bytes32 node, uint256 contentTypes) external view returns (uint256, bytes memory) {
mapping(uint256=>bytes) storage abiset = abis[node];
for (uint256 contentType = 1; contentType <= contentTypes; contentType <<= 1) {
if ((contentType & contentTypes) != 0 && abiset[contentType].length > 0) {
return (contentType, abiset[contentType]);
}
}
return (0, bytes(""));
}
| function ABI(bytes32 node, uint256 contentTypes) external view returns (uint256, bytes memory) {
mapping(uint256=>bytes) storage abiset = abis[node];
for (uint256 contentType = 1; contentType <= contentTypes; contentType <<= 1) {
if ((contentType & contentTypes) != 0 && abiset[contentType].length > 0) {
return (contentType, abiset[contentType]);
}
}
return (0, bytes(""));
}
| 18,808 |
1 | // Passenger data object | struct Passenger {
address passenger;
bytes32 flightKey;
bool isInsured;
uint256 insurancePurchased;
uint256 insuranceOwed;
}
| struct Passenger {
address passenger;
bytes32 flightKey;
bool isInsured;
uint256 insurancePurchased;
uint256 insuranceOwed;
}
| 46,623 |
59 | // Require that the owner is not zero | require(owner != address(0), "ERC20: invalid-address-0");
| require(owner != address(0), "ERC20: invalid-address-0");
| 54,448 |
12 | // Determines if the given feature is freely allowed to all users. feature The bytes32 id of the feature.return True if anyone is allowed to use the feature, false if per-user control is used. / | function getFeatureFlagAllowAll(bytes32 feature) external view returns (bool);
| function getFeatureFlagAllowAll(bytes32 feature) external view returns (bool);
| 26,270 |
41 | // check re-entrancy guard | require(entered == 1, "!reentrant");
entered = 0;
| require(entered == 1, "!reentrant");
entered = 0;
| 52,042 |
30 | // ether: | event EtherReceived(address indexed from, uint indexed value);
event TokensCreated(address indexed to, uint indexed value, uint indexed tokenPriceInWei);
uint public tokenPriceInWei = 500000000000000; // 0.0005 ETH
| event EtherReceived(address indexed from, uint indexed value);
event TokensCreated(address indexed to, uint indexed value, uint indexed tokenPriceInWei);
uint public tokenPriceInWei = 500000000000000; // 0.0005 ETH
| 11,672 |
69 | // track mints | uint256 public amountMinted;
bool public paused = true;
bool public revealed = false;
string public notRevealedUri;
| uint256 public amountMinted;
bool public paused = true;
bool public revealed = false;
string public notRevealedUri;
| 58,829 |
80 | // function that returns the amount of total Staked tokensfor a specific user stakeHolder, address of the user to checkreturn uint amount of the total deposited Tokens by the caller / | function amountStaked(address stakeHolder) external view returns (uint);
| function amountStaked(address stakeHolder) external view returns (uint);
| 32,043 |
65 | // emit FeePayed(msg.sender, amount.mul(MARKETING_FEE.add(PROJECT_FEE)).div(PERCENTS_DIVIDER)); |
User storage user = users[msg.sender];
if (user.referrer == address(0) && users[referrer].deposits.length > 0 && referrer != msg.sender) {
user.referrer = referrer;
}
|
User storage user = users[msg.sender];
if (user.referrer == address(0) && users[referrer].deposits.length > 0 && referrer != msg.sender) {
user.referrer = referrer;
}
| 49,798 |
8 | // default 99% of transfer sent to recipient | uint256 sendAmount = amount.sub(taxAmount);
require(amount == sendAmount.add(taxAmount), "RIVAL::transfer: Tax value invalid");
super._transfer(sender, reserveWallet, taxAmount);
super._transfer(sender, recipient, sendAmount);
_moveDelegates(_delegates[sender], _delegates[recipient], sendAmount);
_moveDelegates(_delegates[sender], _delegates[reserveWallet], taxAmount);
| uint256 sendAmount = amount.sub(taxAmount);
require(amount == sendAmount.add(taxAmount), "RIVAL::transfer: Tax value invalid");
super._transfer(sender, reserveWallet, taxAmount);
super._transfer(sender, recipient, sendAmount);
_moveDelegates(_delegates[sender], _delegates[recipient], sendAmount);
_moveDelegates(_delegates[sender], _delegates[reserveWallet], taxAmount);
| 18,710 |
46 | // Calculate x / y rounding towards zero, where x and y are unsigned 256-bitinteger numbers.Revert on overflow or when y is zero.x unsigned 256-bit integer number y unsigned 256-bit integer numberreturn unsigned 64.64-bit fixed point number / | function divuu (uint256 x, uint256 y) private pure returns (uint128) {
unchecked {
require (y != 0);
uint256 result;
if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
result = (x << 64) / y;
else {
uint256 msb = 192;
uint256 xc = x >> 192;
if (xc >= 0x100000000) { xc >>= 32; msb += 32; }
if (xc >= 0x10000) { xc >>= 16; msb += 16; }
if (xc >= 0x100) { xc >>= 8; msb += 8; }
if (xc >= 0x10) { xc >>= 4; msb += 4; }
if (xc >= 0x4) { xc >>= 2; msb += 2; }
if (xc >= 0x2) msb += 1; // No need to shift xc anymore
result = (x << 255 - msb) / ((y - 1 >> msb - 191) + 1);
require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
uint256 hi = result * (y >> 128);
uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
uint256 xh = x >> 192;
uint256 xl = x << 64;
if (xl < lo) xh -= 1;
xl -= lo; // We rely on overflow behavior here
lo = hi << 128;
if (xl < lo) xh -= 1;
xl -= lo; // We rely on overflow behavior here
assert (xh == hi >> 128);
result += xl / y;
}
require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
return uint128 (result);
}
}
| function divuu (uint256 x, uint256 y) private pure returns (uint128) {
unchecked {
require (y != 0);
uint256 result;
if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
result = (x << 64) / y;
else {
uint256 msb = 192;
uint256 xc = x >> 192;
if (xc >= 0x100000000) { xc >>= 32; msb += 32; }
if (xc >= 0x10000) { xc >>= 16; msb += 16; }
if (xc >= 0x100) { xc >>= 8; msb += 8; }
if (xc >= 0x10) { xc >>= 4; msb += 4; }
if (xc >= 0x4) { xc >>= 2; msb += 2; }
if (xc >= 0x2) msb += 1; // No need to shift xc anymore
result = (x << 255 - msb) / ((y - 1 >> msb - 191) + 1);
require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
uint256 hi = result * (y >> 128);
uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
uint256 xh = x >> 192;
uint256 xl = x << 64;
if (xl < lo) xh -= 1;
xl -= lo; // We rely on overflow behavior here
lo = hi << 128;
if (xl < lo) xh -= 1;
xl -= lo; // We rely on overflow behavior here
assert (xh == hi >> 128);
result += xl / y;
}
require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
return uint128 (result);
}
}
| 26,586 |
112 | // constants | uint256 public constant BONUS_DECIMALS = 18;
uint256 public constant INITIAL_SHARES_PER_TOKEN = 10**6;
uint256 public constant MAX_ACTIVE_FUNDINGS = 16;
| uint256 public constant BONUS_DECIMALS = 18;
uint256 public constant INITIAL_SHARES_PER_TOKEN = 10**6;
uint256 public constant MAX_ACTIVE_FUNDINGS = 16;
| 853 |
73 | // set up our tx event data and determine if player is new or not F3Ddatasets.EventReturns memory _eventData_; _eventData_ = determinePID(_eventData_); | determinePID(_pAddr);
| determinePID(_pAddr);
| 39,761 |
8 | // Call Exchange function. Reentrancy guard is lazy-evaluated, so this should succeed. | (bool success,) = address(exchange).call(callData);
require(success);
return true;
| (bool success,) = address(exchange).call(callData);
require(success);
return true;
| 31,701 |
23 | // team classification flagfor defining the lock period/ |
uint constant tokensLock = 1;
uint constant tokensNoLock = 2;
uint public lockUntil = 1535846399; // 01-Sep-2018 23:59:59 GMT
|
uint constant tokensLock = 1;
uint constant tokensNoLock = 2;
uint public lockUntil = 1535846399; // 01-Sep-2018 23:59:59 GMT
| 39,473 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.