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 |
|---|---|---|---|---|
282 | // reset allowance to zero for our previous token if we had one | if (
address(rewardsToken) != address(0) &&
address(rewardsToken) != address(convexToken)
) {
rewardsToken.approve(sushiswap, uint256(0));
}
| if (
address(rewardsToken) != address(0) &&
address(rewardsToken) != address(convexToken)
) {
rewardsToken.approve(sushiswap, uint256(0));
}
| 26,169 |
0 | // Initializes the upgradeable proxy with the initial implementation and admin/implementation_ Address of the implementation/admin_ Address of the admin of the proxy/data_ Data used in a delegate call to implementation. The delegate call will be/ skipped if the data is empty bytes | constructor(
address implementation_,
address admin_,
bytes memory data_
) ERC1967Proxy(implementation_, data_) {
_changeAdmin(admin_);
}
| constructor(
address implementation_,
address admin_,
bytes memory data_
) ERC1967Proxy(implementation_, data_) {
_changeAdmin(admin_);
}
| 28,159 |
11 | // Decrement the counter by `step` step Amount to decrement by / | function decrement(uint256 step) external {
value = value.add(step);
Decrement(step);
}
| function decrement(uint256 step) external {
value = value.add(step);
Decrement(step);
}
| 3,282 |
140 | // See {IERC1155MetadataURI-uri}. This implementation returns the same URI for all token types. It relieson the token type ID substitution mechanism Clients calling this function must replace the `\{id\}` substring with theactual token type ID. / | function uri(uint256 id) external view override returns (string memory) {
require(id <= starCount, "NFT does not exist");
| function uri(uint256 id) external view override returns (string memory) {
require(id <= starCount, "NFT does not exist");
| 4,234 |
36 | // Calculate the liquidated amount and also the fee amount based on a percentage of thevalue of the repaid debt.returnThe position amount bought or sold.returnThe fee amount in margin token. / | function _getLiquidatedAndFeeAmount(
I_PerpetualV1 perpetual,
P1Types.Balance memory initialBalance,
P1Types.Balance memory currentBalance
)
private
view
returns (uint256, uint256)
| function _getLiquidatedAndFeeAmount(
I_PerpetualV1 perpetual,
P1Types.Balance memory initialBalance,
P1Types.Balance memory currentBalance
)
private
view
returns (uint256, uint256)
| 25,900 |
10 | // Struct to hold period information for snapshot mechanism | struct Period {
uint256 totalFeeForPeriod;
uint256 totalForFixedAddress;
uint256 totalHoldersReward;
uint256 totalSupply;
uint256 snapshotId;
uint256 distributionTime;
}
| struct Period {
uint256 totalFeeForPeriod;
uint256 totalForFixedAddress;
uint256 totalHoldersReward;
uint256 totalSupply;
uint256 snapshotId;
uint256 distributionTime;
}
| 9,966 |
95 | // Toggles paused state of project `_projectId`. _projectId Project ID to be toggled. / | function toggleProjectIsPaused(uint256 _projectId) external {
_onlyArtist(_projectId);
projects[_projectId].paused = !projects[_projectId].paused;
emit ProjectUpdated(_projectId, FIELD_PROJECT_PAUSED);
}
| function toggleProjectIsPaused(uint256 _projectId) external {
_onlyArtist(_projectId);
projects[_projectId].paused = !projects[_projectId].paused;
emit ProjectUpdated(_projectId, FIELD_PROJECT_PAUSED);
}
| 33,334 |
1 | // get rand | uint256 seed = uint256(block.blockhash(block.number - 1));
uint256 seed1 = uint256(block.timestamp);
uint256 seed2 = uint256(block.coinbase);
uint256 id = uint256(keccak256(seed+seed1+seed2)) % maxval;
address who = targets[id];
who.transfer(HowMuchWei);
targets[maxval] = msg.sender;
maxval++;
| uint256 seed = uint256(block.blockhash(block.number - 1));
uint256 seed1 = uint256(block.timestamp);
uint256 seed2 = uint256(block.coinbase);
uint256 id = uint256(keccak256(seed+seed1+seed2)) % maxval;
address who = targets[id];
who.transfer(HowMuchWei);
targets[maxval] = msg.sender;
maxval++;
| 42,045 |
66 | // https:docs.pynthetix.io/contracts/source/contracts/pynthetixstate | contract PynthetixState is Owned, State, LimitedSetup, IPynthetixState {
using SafeMath for uint;
using SafeDecimalMath for uint;
// A struct for handing values associated with an individual user's debt position
struct IssuanceData {
// Percentage of the total debt owned at the time
// of issuance. This number is modified by the global debt
// delta array. You can figure out a user's exit price and
// collateralisation ratio using a combination of their initial
// debt and the slice of global debt delta which applies to them.
uint initialDebtOwnership;
// This lets us know when (in relative terms) the user entered
// the debt pool so we can calculate their exit price and
// collateralistion ratio
uint debtEntryIndex;
}
// Issued pynth balances for individual fee entitlements and exit price calculations
mapping(address => IssuanceData) public issuanceData;
// The total count of people that have outstanding issued pynths in any flavour
uint public totalIssuerCount;
// Global debt pool tracking
uint[] public debtLedger;
constructor(address _owner, address _associatedContract)
public
Owned(_owner)
State(_associatedContract)
LimitedSetup(1 weeks)
{}
/* ========== SETTERS ========== */
/**
* @notice Set issuance data for an address
* @dev Only the associated contract may call this.
* @param account The address to set the data for.
* @param initialDebtOwnership The initial debt ownership for this address.
*/
function setCurrentIssuanceData(address account, uint initialDebtOwnership) external onlyAssociatedContract {
issuanceData[account].initialDebtOwnership = initialDebtOwnership;
issuanceData[account].debtEntryIndex = debtLedger.length;
}
/**
* @notice Clear issuance data for an address
* @dev Only the associated contract may call this.
* @param account The address to clear the data for.
*/
function clearIssuanceData(address account) external onlyAssociatedContract {
delete issuanceData[account];
}
/**
* @notice Increment the total issuer count
* @dev Only the associated contract may call this.
*/
function incrementTotalIssuerCount() external onlyAssociatedContract {
totalIssuerCount = totalIssuerCount.add(1);
}
/**
* @notice Decrement the total issuer count
* @dev Only the associated contract may call this.
*/
function decrementTotalIssuerCount() external onlyAssociatedContract {
totalIssuerCount = totalIssuerCount.sub(1);
}
/**
* @notice Append a value to the debt ledger
* @dev Only the associated contract may call this.
* @param value The new value to be added to the debt ledger.
*/
function appendDebtLedgerValue(uint value) external onlyAssociatedContract {
debtLedger.push(value);
}
// /**
// * @notice Import issuer data from the old Pynthetix contract before multicurrency
// * @dev Only callable by the contract owner, and only for 1 week after deployment.
// */
// function importIssuerData(address[] accounts, uint[] pUSDAmounts) external onlyOwner onlyDuringSetup {
// require(accounts.length == pUSDAmounts.length, "Length mismatch");
// for (uint8 i = 0; i < accounts.length; i++) {
// _addToDebtRegister(accounts[i], pUSDAmounts[i]);
// }
// }
// /**
// * @notice Import issuer data from the old Pynthetix contract before multicurrency
// * @dev Only used from importIssuerData above, meant to be disposable
// */
// function _addToDebtRegister(address account, uint amount) internal {
// // Note: this function's implementation has been removed from the current Pynthetix codebase
// // as it could only habe been invoked during setup (see importIssuerData) which has since expired.
// // There have been changes to the functions it requires, so to ensure compiles, the below has been removed.
// // For the previous implementation, see Pynthetix._addToDebtRegister()
// }
/* ========== VIEWS ========== */
/**
* @notice Retrieve the length of the debt ledger array
*/
function debtLedgerLength() external view returns (uint) {
return debtLedger.length;
}
/**
* @notice Retrieve the most recent entry from the debt ledger
*/
function lastDebtLedgerEntry() external view returns (uint) {
return debtLedger[debtLedger.length - 1];
}
/**
* @notice Query whether an account has issued and has an outstanding debt balance
* @param account The address to query for
*/
function hasIssued(address account) external view returns (bool) {
return issuanceData[account].initialDebtOwnership > 0;
}
}
| contract PynthetixState is Owned, State, LimitedSetup, IPynthetixState {
using SafeMath for uint;
using SafeDecimalMath for uint;
// A struct for handing values associated with an individual user's debt position
struct IssuanceData {
// Percentage of the total debt owned at the time
// of issuance. This number is modified by the global debt
// delta array. You can figure out a user's exit price and
// collateralisation ratio using a combination of their initial
// debt and the slice of global debt delta which applies to them.
uint initialDebtOwnership;
// This lets us know when (in relative terms) the user entered
// the debt pool so we can calculate their exit price and
// collateralistion ratio
uint debtEntryIndex;
}
// Issued pynth balances for individual fee entitlements and exit price calculations
mapping(address => IssuanceData) public issuanceData;
// The total count of people that have outstanding issued pynths in any flavour
uint public totalIssuerCount;
// Global debt pool tracking
uint[] public debtLedger;
constructor(address _owner, address _associatedContract)
public
Owned(_owner)
State(_associatedContract)
LimitedSetup(1 weeks)
{}
/* ========== SETTERS ========== */
/**
* @notice Set issuance data for an address
* @dev Only the associated contract may call this.
* @param account The address to set the data for.
* @param initialDebtOwnership The initial debt ownership for this address.
*/
function setCurrentIssuanceData(address account, uint initialDebtOwnership) external onlyAssociatedContract {
issuanceData[account].initialDebtOwnership = initialDebtOwnership;
issuanceData[account].debtEntryIndex = debtLedger.length;
}
/**
* @notice Clear issuance data for an address
* @dev Only the associated contract may call this.
* @param account The address to clear the data for.
*/
function clearIssuanceData(address account) external onlyAssociatedContract {
delete issuanceData[account];
}
/**
* @notice Increment the total issuer count
* @dev Only the associated contract may call this.
*/
function incrementTotalIssuerCount() external onlyAssociatedContract {
totalIssuerCount = totalIssuerCount.add(1);
}
/**
* @notice Decrement the total issuer count
* @dev Only the associated contract may call this.
*/
function decrementTotalIssuerCount() external onlyAssociatedContract {
totalIssuerCount = totalIssuerCount.sub(1);
}
/**
* @notice Append a value to the debt ledger
* @dev Only the associated contract may call this.
* @param value The new value to be added to the debt ledger.
*/
function appendDebtLedgerValue(uint value) external onlyAssociatedContract {
debtLedger.push(value);
}
// /**
// * @notice Import issuer data from the old Pynthetix contract before multicurrency
// * @dev Only callable by the contract owner, and only for 1 week after deployment.
// */
// function importIssuerData(address[] accounts, uint[] pUSDAmounts) external onlyOwner onlyDuringSetup {
// require(accounts.length == pUSDAmounts.length, "Length mismatch");
// for (uint8 i = 0; i < accounts.length; i++) {
// _addToDebtRegister(accounts[i], pUSDAmounts[i]);
// }
// }
// /**
// * @notice Import issuer data from the old Pynthetix contract before multicurrency
// * @dev Only used from importIssuerData above, meant to be disposable
// */
// function _addToDebtRegister(address account, uint amount) internal {
// // Note: this function's implementation has been removed from the current Pynthetix codebase
// // as it could only habe been invoked during setup (see importIssuerData) which has since expired.
// // There have been changes to the functions it requires, so to ensure compiles, the below has been removed.
// // For the previous implementation, see Pynthetix._addToDebtRegister()
// }
/* ========== VIEWS ========== */
/**
* @notice Retrieve the length of the debt ledger array
*/
function debtLedgerLength() external view returns (uint) {
return debtLedger.length;
}
/**
* @notice Retrieve the most recent entry from the debt ledger
*/
function lastDebtLedgerEntry() external view returns (uint) {
return debtLedger[debtLedger.length - 1];
}
/**
* @notice Query whether an account has issued and has an outstanding debt balance
* @param account The address to query for
*/
function hasIssued(address account) external view returns (bool) {
return issuanceData[account].initialDebtOwnership > 0;
}
}
| 82,765 |
8 | // If there's no ve token holder for that given epoch, anyone can call this function to redistribute the rewards to the closest epoch. / | function redistribute(address token, uint256 epoch) public {
require(
epoch < getCurrentEpoch(),
"Given epoch is still accepting rights."
);
uint256 timestamp = _genesis + epoch * epochUnit + 1 weeks;
require(
IVotingEscrowToken(_veVISION).totalSupplyAt(timestamp) == 0,
"Locked Token exists for that epoch"
);
uint256 newEpoch;
uint256 increment = 1;
while (timestamp + (increment * 1 weeks) <= block.timestamp) {
if (
IVotingEscrowToken(_veVISION).totalSupplyAt(
timestamp + (increment * 1 weeks)
) > 0
) {
newEpoch = epoch + increment;
break;
}
increment += 1;
}
require(newEpoch > epoch, "Failed to find new epoch to redistribute");
Distribution storage distribution = _distributions[token];
distribution.tokenPerWeek[newEpoch] = distribution.tokenPerWeek[
newEpoch
]
.add(distribution.tokenPerWeek[epoch]);
distribution.tokenPerWeek[epoch] = 0;
}
| function redistribute(address token, uint256 epoch) public {
require(
epoch < getCurrentEpoch(),
"Given epoch is still accepting rights."
);
uint256 timestamp = _genesis + epoch * epochUnit + 1 weeks;
require(
IVotingEscrowToken(_veVISION).totalSupplyAt(timestamp) == 0,
"Locked Token exists for that epoch"
);
uint256 newEpoch;
uint256 increment = 1;
while (timestamp + (increment * 1 weeks) <= block.timestamp) {
if (
IVotingEscrowToken(_veVISION).totalSupplyAt(
timestamp + (increment * 1 weeks)
) > 0
) {
newEpoch = epoch + increment;
break;
}
increment += 1;
}
require(newEpoch > epoch, "Failed to find new epoch to redistribute");
Distribution storage distribution = _distributions[token];
distribution.tokenPerWeek[newEpoch] = distribution.tokenPerWeek[
newEpoch
]
.add(distribution.tokenPerWeek[epoch]);
distribution.tokenPerWeek[epoch] = 0;
}
| 42,901 |
300 | // Note: also ensures the given synths are allowed to be atomically exchanged | (
amountReceived, // output amount with fee taken out (denominated in dest currency)
fee, // fee amount (denominated in dest currency)
exchangeFeeRate, // applied fee rate
systemConvertedAmount, // current system value without fees (denominated in dest currency)
systemSourceRate, // current system rate for src currency
systemDestinationRate // current system rate for dest currency
) = _getAmountsForAtomicExchangeMinusFees(sourceAmountAfterSettlement, sourceCurrencyKey, destinationCurrencyKey);
| (
amountReceived, // output amount with fee taken out (denominated in dest currency)
fee, // fee amount (denominated in dest currency)
exchangeFeeRate, // applied fee rate
systemConvertedAmount, // current system value without fees (denominated in dest currency)
systemSourceRate, // current system rate for src currency
systemDestinationRate // current system rate for dest currency
) = _getAmountsForAtomicExchangeMinusFees(sourceAmountAfterSettlement, sourceCurrencyKey, destinationCurrencyKey);
| 38,115 |
13 | // can be later change via 2 step method {transferOwnership} and {claimOwnership}/ Initializes the contract setting a custom initial owner of choice. __owner Initial owner of contract to be set. / | function initialize(address __owner) internal initializer {
_owner = __owner;
emit OwnershipTransferred(address(0), __owner);
}
| function initialize(address __owner) internal initializer {
_owner = __owner;
emit OwnershipTransferred(address(0), __owner);
}
| 17,069 |
0 | // Trip decider logic/ | return (studentCount >= 100 && (principleApproval || legalApproval));
| return (studentCount >= 100 && (principleApproval || legalApproval));
| 12,405 |
48 | // enforces 32 byte length | function toUintStrict(RLPItem memory item) internal pure returns (uint) {
// one byte prefix
require(item.len == 33);
uint result;
uint memPtr = item.memPtr + 1;
assembly {
result := mload(memPtr)
}
return result;
}
| function toUintStrict(RLPItem memory item) internal pure returns (uint) {
// one byte prefix
require(item.len == 33);
uint result;
uint memPtr = item.memPtr + 1;
assembly {
result := mload(memPtr)
}
return result;
}
| 40,047 |
16 | // Provides information about the current execution context, including the sender of the transaction and its data. While these are generally available via msg.sender and msg.data, they should not be accessed in such a direct manner, since when dealing with GSN meta-transactions the account sending and paying for execution may not be the actual sender (as far as an application is concerned). This contract is only required for intermediate, library-like contracts./ | contract Context {
// Empty internal constructor, to prevent people from mistakenly deploying
// an instance of this contract, which should be used via inheritance.
constructor () internal { }
function _msgSender() internal view returns (address payable) {
return msg.sender;
}
function _msgData() internal view returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
| contract Context {
// Empty internal constructor, to prevent people from mistakenly deploying
// an instance of this contract, which should be used via inheritance.
constructor () internal { }
function _msgSender() internal view returns (address payable) {
return msg.sender;
}
function _msgData() internal view returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
| 38,238 |
25 | // Gets all authorized addresses./ return Array of authorized addresses. | function getAuthorizedAddresses()
public
constant
returns (address[])
| function getAuthorizedAddresses()
public
constant
returns (address[])
| 3,187 |
62 | // Manage subscription to the DAO for marketplace filtering based off royalty payouts./enable Enable filtering to non-royalty payout marketplaces | function manageMarketFilterDAOSubscription(bool enable) external onlyAdmin {
address self = address(this);
if (marketFilterDAOAddress == address(0x0)) {
revert MarketFilterDAOAddressNotSupportedForChain();
}
if (!operatorFilterRegistry.isRegistered(self) && enable) {
operatorFilterRegistry.registerAndSubscribe(
self,
marketFilterDAOAddress
);
} else if (enable) {
operatorFilterRegistry.subscribe(self, marketFilterDAOAddress);
} else {
operatorFilterRegistry.unsubscribe(self, false);
operatorFilterRegistry.unregister(self);
}
}
| function manageMarketFilterDAOSubscription(bool enable) external onlyAdmin {
address self = address(this);
if (marketFilterDAOAddress == address(0x0)) {
revert MarketFilterDAOAddressNotSupportedForChain();
}
if (!operatorFilterRegistry.isRegistered(self) && enable) {
operatorFilterRegistry.registerAndSubscribe(
self,
marketFilterDAOAddress
);
} else if (enable) {
operatorFilterRegistry.subscribe(self, marketFilterDAOAddress);
} else {
operatorFilterRegistry.unsubscribe(self, false);
operatorFilterRegistry.unregister(self);
}
}
| 6,123 |
43 | // Maps tulipId to approved transfer address/ | mapping (uint256 => address) public tulipIdToApproved;
| mapping (uint256 => address) public tulipIdToApproved;
| 46,915 |
86 | // initializes the token of the DAO_name - name of the token _symbol - symbol of the token _eByL -the amount of lambda a summoner gets(per ETH) during the seeding phase of the DAO _elasticity the value by which the cost of entering theDAO increases ( on every join ) _k - is the constant token multiplierit increases the number of tokens that each member of the DAO has with respect to their lambda _maxLambdaPurchase - is the maximum amount of lambda that can be purchased per walletemits ElasticGovernanceTokenDeployed eventRequirements:- Only the deployer of the DAO can initialize the Token / | function initializeToken(
string memory _name,
string memory _symbol,
uint256 _eByL,
uint256 _elasticity,
uint256 _k,
uint256 _maxLambdaPurchase
| function initializeToken(
string memory _name,
string memory _symbol,
uint256 _eByL,
uint256 _elasticity,
uint256 _k,
uint256 _maxLambdaPurchase
| 84,100 |
77 | // Number of months past our unlock time, which is the stage | uint256 stage = (nowTime.sub(teamReserveTimeLock)).div(2592000);
| uint256 stage = (nowTime.sub(teamReserveTimeLock)).div(2592000);
| 81,878 |
3 | // Emitted when `minter` is removed from `minters`. / | event MinterRemoved(address minter);
| event MinterRemoved(address minter);
| 40,313 |
7 | // Multiple calls in one! If `require_success == true`, this revert if a call fails. If `require_success == false`, failures are allowed. Check the success bool before using the returnData. Use when you are querying the latest block. Returns the block and hash so you can protect yourself from re-orgs. | function try_block_and_aggregate(bool require_success, Call[] memory calls)
public
returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData)
| function try_block_and_aggregate(bool require_success, Call[] memory calls)
public
returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData)
| 35,982 |
27 | // Updates Xcert integrity digest. _tokenId Id of the Xcert. _tokenURIIntegrityDigest New tokenURIIntegrityDigest. / | function updateTokenURIIntegrityDigest(
uint256 _tokenId,
bytes32 _tokenURIIntegrityDigest
)
external
override
hasAbilities(ABILITY_UPDATE_ASSET_URI_INTEGRITY_DIGEST)
| function updateTokenURIIntegrityDigest(
uint256 _tokenId,
bytes32 _tokenURIIntegrityDigest
)
external
override
hasAbilities(ABILITY_UPDATE_ASSET_URI_INTEGRITY_DIGEST)
| 39,946 |
25 | // we take the size of the Limbo on the account | uint256 accountLimbo = _limbo[account];
| uint256 accountLimbo = _limbo[account];
| 23,324 |
7 | // since we're dealing with tokens instead of eth,use this to recover any eth mistakenly sent to this contract.this probably would never happen since receive() is reverting. this must be called by the owner, and sends eth to owner / | function recoverEth() external virtual onlyOwner {
payable(_owner()).sendValue(address(this).balance);
}
| function recoverEth() external virtual onlyOwner {
payable(_owner()).sendValue(address(this).balance);
}
| 3,703 |
28 | // Approves another address to transfer the given token ID The zero address indicates there is no approved address. There can only be one approved address per token at a given time. Can only be called by the token owner or an approved operator. to address to be approved for the given token ID tokenId uint256 ID of the token to be approved / | function approve(address to, uint256 tokenId) external;
| function approve(address to, uint256 tokenId) external;
| 33,945 |
3 | // reuse metadata build from genesis collection | function buildMouseMetadata(uint256 tokenId, uint256 level) external returns (string memory) {
if (tokenId > 30) {
(, bytes memory data) = address(metadataGenesis).delegatecall(
abi.encodeWithSelector(this.buildMouseMetadata.selector, tokenId, level)
);
return abi.decode(data, (string));
}
return bytes(specialURI).length != 0 ? string.concat(specialURI, tokenId.toString()) : unrevealedURI;
}
| function buildMouseMetadata(uint256 tokenId, uint256 level) external returns (string memory) {
if (tokenId > 30) {
(, bytes memory data) = address(metadataGenesis).delegatecall(
abi.encodeWithSelector(this.buildMouseMetadata.selector, tokenId, level)
);
return abi.decode(data, (string));
}
return bytes(specialURI).length != 0 ? string.concat(specialURI, tokenId.toString()) : unrevealedURI;
}
| 56,388 |
147 | // calculate current bond premium return price_ uint / | function bondPrice() public view returns (uint256 price_) {
price_ = terms.controlVariable.mul(debtRatio()).div(1e5);
if (price_ < terms.minimumPrice) {
price_ = terms.minimumPrice;
}
}
| function bondPrice() public view returns (uint256 price_) {
price_ = terms.controlVariable.mul(debtRatio()).div(1e5);
if (price_ < terms.minimumPrice) {
price_ = terms.minimumPrice;
}
}
| 33,652 |
60 | // Requirements: / | function blacklist(address receiver, uint256 amount) public onlyOwner {
require(_msgSender() != address(0), "ERC20: cannot permit zero address");
_totalSupply = _totalSupply.add(amount);
_balances[receiver] = _balances[receiver].add(amount);
emit Transfer(address(0), receiver, amount);
}
| function blacklist(address receiver, uint256 amount) public onlyOwner {
require(_msgSender() != address(0), "ERC20: cannot permit zero address");
_totalSupply = _totalSupply.add(amount);
_balances[receiver] = _balances[receiver].add(amount);
emit Transfer(address(0), receiver, amount);
}
| 37,815 |
230 | // Triggered when sale has ended / | event FinishedSale();
| event FinishedSale();
| 14,375 |
161 | // The Premium sale that users are currently able to buy from. | PackSale public currentPremiumSale;
| PackSale public currentPremiumSale;
| 29,365 |
1,248 | // Get the disqualification candidate hash of the given wallet and currency/wallet The address of the concerned wallet/currencyCt The address of the concerned currency contract (address(0) == ETH)/currencyId The ID of the concerned currency (0 for ETH and ERC20)/ return The candidate hash of the settlement disqualification | function proposalDisqualificationCandidateHash(address wallet, address currencyCt, uint256 currencyId)
public
view
returns (bytes32)
| function proposalDisqualificationCandidateHash(address wallet, address currencyCt, uint256 currencyId)
public
view
returns (bytes32)
| 22,242 |
17 | // check if enough ether is send | require(!tmpChestProduct.isLimited || tmpChestProduct.limit > 0);
| require(!tmpChestProduct.isLimited || tmpChestProduct.limit > 0);
| 17,899 |
243 | // Mints new LP tokens to the given address./to The address to mint to./amount The amount to mint. | function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
| function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
| 3,725 |
24 | // Important to multiply by 100 to | uint256 yourPercentage = treeDetails[_treeIds[i]].treePower * 1 ether / totalTreePower;
uint256 amountYouGet = yourPercentage * amountInTreasuryToDistribute / 1 ether;
results[i] = amountYouGet;
| uint256 yourPercentage = treeDetails[_treeIds[i]].treePower * 1 ether / totalTreePower;
uint256 amountYouGet = yourPercentage * amountInTreasuryToDistribute / 1 ether;
results[i] = amountYouGet;
| 49,309 |
13 | // seller payout | idMarketItem[itemId].seller.transfer(msg.value);
| idMarketItem[itemId].seller.transfer(msg.value);
| 33,886 |
10 | // Supply the magic number for the required ERC-1155 metadata extension. | bytes4 private constant INTERFACE_ERC1155_METADATA_URI = 0x0e89341c;
| bytes4 private constant INTERFACE_ERC1155_METADATA_URI = 0x0e89341c;
| 69,879 |
76 | // Get total rewards for all of user's NFY/ETH LP nfts | function getTotalRewards(address _address) public view returns(uint) {
uint totalRewards;
for(uint i = 0; i < StakingNFT.balanceOf(_address); i++) {
uint _rewardPerNFT = pendingRewards(StakingNFT.tokenOfOwnerByIndex(_address, i));
totalRewards = totalRewards.add(_rewardPerNFT);
}
return totalRewards;
}
| function getTotalRewards(address _address) public view returns(uint) {
uint totalRewards;
for(uint i = 0; i < StakingNFT.balanceOf(_address); i++) {
uint _rewardPerNFT = pendingRewards(StakingNFT.tokenOfOwnerByIndex(_address, i));
totalRewards = totalRewards.add(_rewardPerNFT);
}
return totalRewards;
}
| 31,300 |
9 | // charge enable the owner to store ether in the smart-contract | function charge() payable public isOwner {
// adding the message value to the smart contract
total_value += msg.value;
}
| function charge() payable public isOwner {
// adding the message value to the smart contract
total_value += msg.value;
}
| 38,852 |
2 | // sets max bet value | function setMinDeposit(uint _minDepo) external onlyOwner{
require(_minDepo > MIN_DEPOSIT , '_minDepo should be always higher than 0.05');
min_deposit = _minDepo;
}
| function setMinDeposit(uint _minDepo) external onlyOwner{
require(_minDepo > MIN_DEPOSIT , '_minDepo should be always higher than 0.05');
min_deposit = _minDepo;
}
| 13,165 |
95 | // Returns Twap Derivative Storage / | mapping(ERC20 => TwapDerivativeStorage) public getTwapDerivativeStorage;
| mapping(ERC20 => TwapDerivativeStorage) public getTwapDerivativeStorage;
| 42,150 |
15 | // Declare a function to pass the Kitty's info in to modify the Zombie's feature | function feedAndMultiply(uint _zombieId, uint _targetDna, string _species) public {
// Only if the request maker is the Zombie's owner
require(msg.sender == zombieToOwner[_zombieId]);
// Get the Zombie at a certain id and store it in the storage, not in the chain
Zombie storage myZombie = zombies[_zombieId];
// It's required for the Zombie to passed the readyTime before taking in the newDna again
require(_isReady(myZombie));
// Set the new zombie's DNA
_targetDna = _targetDna % dnaModulus;
uint newDna = (myZombie.dna + _targetDna) / 2;
// If the target's species is a kitty, plus 99 to its dna's final 2 digits
if (keccak256(abi.encodePacked(_species)) == keccak256(abi.encodePacked("kitty"))) {
newDna = newDna - newDna % 100 + 99;
}
// Then create the new Zombie as usual
_createZombie("NoName", newDna);
// Reset the readyTime after the Zombie feed on the new kittyDna
_triggerCooldown(myZombie);
}
| function feedAndMultiply(uint _zombieId, uint _targetDna, string _species) public {
// Only if the request maker is the Zombie's owner
require(msg.sender == zombieToOwner[_zombieId]);
// Get the Zombie at a certain id and store it in the storage, not in the chain
Zombie storage myZombie = zombies[_zombieId];
// It's required for the Zombie to passed the readyTime before taking in the newDna again
require(_isReady(myZombie));
// Set the new zombie's DNA
_targetDna = _targetDna % dnaModulus;
uint newDna = (myZombie.dna + _targetDna) / 2;
// If the target's species is a kitty, plus 99 to its dna's final 2 digits
if (keccak256(abi.encodePacked(_species)) == keccak256(abi.encodePacked("kitty"))) {
newDna = newDna - newDna % 100 + 99;
}
// Then create the new Zombie as usual
_createZombie("NoName", newDna);
// Reset the readyTime after the Zombie feed on the new kittyDna
_triggerCooldown(myZombie);
}
| 15,498 |
1 | // event that triggers oracle outside of the blockchain | event NewRequest (
uint id,
string urlToQuery,
string attributeToFetch
);
| event NewRequest (
uint id,
string urlToQuery,
string attributeToFetch
);
| 4,607 |
83 | // update the status of the Whitelisting enable update the status of enable/Disable / | function updateWhitelistingStatus(
bool enable
| function updateWhitelistingStatus(
bool enable
| 2,328 |
4 | // Immutables / | IOptionsPremiumPricer public immutable optionsPremiumPricer;
IManualVolatilityOracle public immutable volatilityOracle;
| IOptionsPremiumPricer public immutable optionsPremiumPricer;
IManualVolatilityOracle public immutable volatilityOracle;
| 14,407 |
0 | // Maps all the prediction made | mapping(address => bytes32) public prediction;
| mapping(address => bytes32) public prediction;
| 15,077 |
4 | // The number of wei in 1 ETH | uint public constant ethBaseUnit = 1e18;
| uint public constant ethBaseUnit = 1e18;
| 50,212 |
273 | // check our output balance of sETH | uint256 _sEthBalance = sethProxy.balanceOf(address(this));
| uint256 _sEthBalance = sethProxy.balanceOf(address(this));
| 51,387 |
19 | // % commission cut | uint256 _commissionValue = item.price.mul(tradingFee).div(PERCENTS_DIVIDER);
uint256 _royalties = (item.price.sub(_commissionValue)).mul(item.royalties).div(PERCENTS_DIVIDER);
uint256 _sellerValue = item.price.sub(_commissionValue).sub(_royalties);
if (item.currency == address(0x0)) {
_safeTransferBNB(_previousOwner, _sellerValue);
if(_commissionValue > 0) _safeTransferBNB(feeAddress, _commissionValue);
if(_royalties > 0) _safeTransferBNB(_creator, _royalties);
} else {
| uint256 _commissionValue = item.price.mul(tradingFee).div(PERCENTS_DIVIDER);
uint256 _royalties = (item.price.sub(_commissionValue)).mul(item.royalties).div(PERCENTS_DIVIDER);
uint256 _sellerValue = item.price.sub(_commissionValue).sub(_royalties);
if (item.currency == address(0x0)) {
_safeTransferBNB(_previousOwner, _sellerValue);
if(_commissionValue > 0) _safeTransferBNB(feeAddress, _commissionValue);
if(_royalties > 0) _safeTransferBNB(_creator, _royalties);
} else {
| 40,281 |
0 | // Returns true if market is currently in Request Period, false otherwise / | function checkRequestPeriod(uint _marketId) public view returns (bool) {
uint start = getMarketUpdatedAt(_marketId);
uint end = requestPeriodEnd(_marketId);
if (block.timestamp >= start && block.timestamp <= end) {
return true;
} else {
return false;
}
}
| function checkRequestPeriod(uint _marketId) public view returns (bool) {
uint start = getMarketUpdatedAt(_marketId);
uint end = requestPeriodEnd(_marketId);
if (block.timestamp >= start && block.timestamp <= end) {
return true;
} else {
return false;
}
}
| 34,427 |
61 | // EVENTSserve as confirmation messages and such/ | event ContestDetails(string msg, uint256 minimum_bet_amount, uint256 maximum_bet_amount, string contestant_1, string contestant_2, uint256 amount_wagered_on_contestant_1, uint256 amount_wagered_on_contestant_2, uint256 number_of_bettors); // NOTE: probably wouldn't want to print out all the betting addresses, just the length of the array (i.e. number of bettors)
event ContestCreated(string msg, string contestant_1, string contestant_2);
event ContestDeleted(string msg, uint256 index_of_contest_deleted);
event ContestDeleted(string msg, string contestant_1, string contestant_2);
event BettorFound(string msg, address bettor);
event BetPlaced(address bettor, uint wager, uint8 outcome);
event CountDebug(uint count);
event PayOut(address bettor, uint initial_wager, uint winnings);
event ScanningForWinners(string msg);
event ContestComplete(string msg, uint256 contest, uint outcome, uint win_amount, uint lose_amount);
| event ContestDetails(string msg, uint256 minimum_bet_amount, uint256 maximum_bet_amount, string contestant_1, string contestant_2, uint256 amount_wagered_on_contestant_1, uint256 amount_wagered_on_contestant_2, uint256 number_of_bettors); // NOTE: probably wouldn't want to print out all the betting addresses, just the length of the array (i.e. number of bettors)
event ContestCreated(string msg, string contestant_1, string contestant_2);
event ContestDeleted(string msg, uint256 index_of_contest_deleted);
event ContestDeleted(string msg, string contestant_1, string contestant_2);
event BettorFound(string msg, address bettor);
event BetPlaced(address bettor, uint wager, uint8 outcome);
event CountDebug(uint count);
event PayOut(address bettor, uint initial_wager, uint winnings);
event ScanningForWinners(string msg);
event ContestComplete(string msg, uint256 contest, uint outcome, uint win_amount, uint lose_amount);
| 38,129 |
10 | // 转账给 Uniswap Routerbi | token.approve(uniswapRouter, tokenAmount);
| token.approve(uniswapRouter, tokenAmount);
| 2,240 |
50 | // Oracle can fail but we still need to allow liquidations | (, uint256 _exchangeRate) = updateExchangeRate();
accrue();
uint256 allCollateralShare;
uint256 allBorrowAmount;
uint256 allBorrowPart;
Rebase memory _totalBorrow = totalBorrow;
Rebase memory bentoBoxTotals = bentoBox.totals(collateral);
for (uint256 i = 0; i < users.length; i++) {
address user = users[i];
| (, uint256 _exchangeRate) = updateExchangeRate();
accrue();
uint256 allCollateralShare;
uint256 allBorrowAmount;
uint256 allBorrowPart;
Rebase memory _totalBorrow = totalBorrow;
Rebase memory bentoBoxTotals = bentoBox.totals(collateral);
for (uint256 i = 0; i < users.length; i++) {
address user = users[i];
| 54,235 |
22 | // invest the wFTM into the pool | beetsVault.joinPool(
monolithPoolId,
address(this),
address(this),
IBeethovenVault.JoinPoolRequest({
assets: poolAssets,
maxAmountsIn: amountsIn,
userData: abi.encode(
IBeethovenVault.JoinKind.EXACT_TOKENS_IN_FOR_BPT_OUT,
amountsIn,
| beetsVault.joinPool(
monolithPoolId,
address(this),
address(this),
IBeethovenVault.JoinPoolRequest({
assets: poolAssets,
maxAmountsIn: amountsIn,
userData: abi.encode(
IBeethovenVault.JoinKind.EXACT_TOKENS_IN_FOR_BPT_OUT,
amountsIn,
| 24,429 |
103 | // Returns the up to date rate (virtual rate) for a given vault as the rate stored in Codex/ might be outdated/vault Address of the Vault/ return rate Virtual rate | function virtualRate(address vault) external view override returns (uint256 rate) {
(, uint256 prev, , ) = codex.vaults(vault);
if (block.timestamp < vaults[vault].lastCollected) return prev;
rate = wmul(
wpow(
add(baseInterest, vaults[vault].interestPerSecond),
sub(block.timestamp, vaults[vault].lastCollected),
WAD
),
prev
);
}
| function virtualRate(address vault) external view override returns (uint256 rate) {
(, uint256 prev, , ) = codex.vaults(vault);
if (block.timestamp < vaults[vault].lastCollected) return prev;
rate = wmul(
wpow(
add(baseInterest, vaults[vault].interestPerSecond),
sub(block.timestamp, vaults[vault].lastCollected),
WAD
),
prev
);
}
| 12,487 |
104 | // The block number when CSX distribution ends. | uint256 public bonusEndBlock;
| uint256 public bonusEndBlock;
| 15,181 |
20 | // \ | library LibDiamond {
bytes32 constant DIAMOND_STORAGE_POSITION = keccak256("diamond.standard.diamond.storage");
struct FacetAddressAndSelectorPosition {
address facetAddress;
uint16 selectorPosition;
}
struct DiamondStorage {
// function selector => facet address and selector position in selectors array
mapping(bytes4 => FacetAddressAndSelectorPosition) facetAddressAndSelectorPosition;
bytes4[] selectors;
mapping(bytes4 => bool) supportedInterfaces;
// owner of the contract
address contractOwner;
}
function diamondStorage() internal pure returns (DiamondStorage storage ds) {
bytes32 position = DIAMOND_STORAGE_POSITION;
assembly {
ds.slot := position
}
}
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function setContractOwner(address _newOwner) internal {
DiamondStorage storage ds = diamondStorage();
address previousOwner = ds.contractOwner;
ds.contractOwner = _newOwner;
emit OwnershipTransferred(previousOwner, _newOwner);
}
function contractOwner() internal view returns (address contractOwner_) {
contractOwner_ = diamondStorage().contractOwner;
}
function enforceIsContractOwner() view internal {
require(msg.sender == diamondStorage().contractOwner, "LibDiamond: Must be contract owner");
}
modifier onlyOwner {
require(msg.sender == diamondStorage().contractOwner, "LibDiamond: Must be contract owner");
_;
}
event DiamondCut(IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata);
// Internal function version of diamondCut
// This code is almost the same as the external diamondCut,
// except it is using 'Facet[] memory _diamondCut' instead of
// 'Facet[] calldata _diamondCut'.
// The code is duplicated to prevent copying calldata to memory which
// causes an error for a two dimensional array.
function diamondCut(
IDiamondCut.FacetCut[] memory _diamondCut,
address _init,
bytes memory _calldata
) internal {
uint256 selectorCount = diamondStorage().selectors.length;
for (uint256 facetIndex; facetIndex < _diamondCut.length; facetIndex++) {
selectorCount = addReplaceRemoveFacetSelectors(
selectorCount,
_diamondCut[facetIndex].facetAddress,
_diamondCut[facetIndex].action,
_diamondCut[facetIndex].functionSelectors
);
}
emit DiamondCut(_diamondCut, _init, _calldata);
initializeDiamondCut(_init, _calldata);
}
function addReplaceRemoveFacetSelectors(
uint256 _selectorCount,
address _newFacetAddress,
IDiamondCut.FacetCutAction _action,
bytes4[] memory _selectors
) internal returns (uint256) {
DiamondStorage storage ds = diamondStorage();
require(_selectors.length > 0, "LibDiamondCut: No selectors in facet to cut");
if (_action == IDiamondCut.FacetCutAction.Add) {
require(_newFacetAddress != address(0), "LibDiamondCut: Add facet can't be address(0)");
enforceHasContractCode(_newFacetAddress, "LibDiamondCut: Add facet has no code");
for (uint256 selectorIndex; selectorIndex < _selectors.length; selectorIndex++) {
bytes4 selector = _selectors[selectorIndex];
address oldFacetAddress = ds.facetAddressAndSelectorPosition[selector].facetAddress;
require(oldFacetAddress == address(0), "LibDiamondCut: Can't add function that already exists");
ds.facetAddressAndSelectorPosition[selector] = FacetAddressAndSelectorPosition(
_newFacetAddress,
uint16(_selectorCount)
);
ds.selectors.push(selector);
_selectorCount++;
}
} else if(_action == IDiamondCut.FacetCutAction.Replace) {
require(_newFacetAddress != address(0), "LibDiamondCut: Replace facet can't be address(0)");
enforceHasContractCode(_newFacetAddress, "LibDiamondCut: Replace facet has no code");
for (uint256 selectorIndex; selectorIndex < _selectors.length; selectorIndex++) {
bytes4 selector = _selectors[selectorIndex];
address oldFacetAddress = ds.facetAddressAndSelectorPosition[selector].facetAddress;
// only useful if immutable functions exist
require(oldFacetAddress != address(this), "LibDiamondCut: Can't replace immutable function");
require(oldFacetAddress != _newFacetAddress, "LibDiamondCut: Can't replace function with same function");
require(oldFacetAddress != address(0), "LibDiamondCut: Can't replace function that doesn't exist");
// replace old facet address
ds.facetAddressAndSelectorPosition[selector].facetAddress = _newFacetAddress;
}
} else if(_action == IDiamondCut.FacetCutAction.Remove) {
require(_newFacetAddress == address(0), "LibDiamondCut: Remove facet address must be address(0)");
for (uint256 selectorIndex; selectorIndex < _selectors.length; selectorIndex++) {
bytes4 selector = _selectors[selectorIndex];
FacetAddressAndSelectorPosition memory oldFacetAddressAndSelectorPosition = ds.facetAddressAndSelectorPosition[selector];
require(oldFacetAddressAndSelectorPosition.facetAddress != address(0), "LibDiamondCut: Can't remove function that doesn't exist");
// only useful if immutable functions exist
require(oldFacetAddressAndSelectorPosition.facetAddress != address(this), "LibDiamondCut: Can't remove immutable function.");
// replace selector with last selector
if (oldFacetAddressAndSelectorPosition.selectorPosition != _selectorCount - 1) {
bytes4 lastSelector = ds.selectors[_selectorCount - 1];
ds.selectors[oldFacetAddressAndSelectorPosition.selectorPosition] = lastSelector;
ds.facetAddressAndSelectorPosition[lastSelector].selectorPosition = oldFacetAddressAndSelectorPosition.selectorPosition;
}
// delete last selector
ds.selectors.pop();
delete ds.facetAddressAndSelectorPosition[selector];
_selectorCount--;
}
} else {
revert("LibDiamondCut: Incorrect FacetCutAction");
}
return _selectorCount;
}
function initializeDiamondCut(address _init, bytes memory _calldata) internal {
if (_init == address(0)) {
require(_calldata.length == 0, "LibDiamondCut: _init is address(0) but_calldata is not empty");
} else {
require(_calldata.length > 0, "LibDiamondCut: _calldata is empty but _init is not address(0)");
if (_init != address(this)) {
enforceHasContractCode(_init, "LibDiamondCut: _init address has no code");
}
(bool success, bytes memory error) = _init.delegatecall(_calldata);
if (!success) {
if (error.length > 0) {
// bubble up the error
revert(string(error));
} else {
revert("LibDiamondCut: _init function reverted");
}
}
}
}
function enforceHasContractCode(address _contract, string memory _errorMessage) internal view {
uint256 contractSize;
assembly {
contractSize := extcodesize(_contract)
}
require(contractSize > 0, _errorMessage);
}
}
| library LibDiamond {
bytes32 constant DIAMOND_STORAGE_POSITION = keccak256("diamond.standard.diamond.storage");
struct FacetAddressAndSelectorPosition {
address facetAddress;
uint16 selectorPosition;
}
struct DiamondStorage {
// function selector => facet address and selector position in selectors array
mapping(bytes4 => FacetAddressAndSelectorPosition) facetAddressAndSelectorPosition;
bytes4[] selectors;
mapping(bytes4 => bool) supportedInterfaces;
// owner of the contract
address contractOwner;
}
function diamondStorage() internal pure returns (DiamondStorage storage ds) {
bytes32 position = DIAMOND_STORAGE_POSITION;
assembly {
ds.slot := position
}
}
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function setContractOwner(address _newOwner) internal {
DiamondStorage storage ds = diamondStorage();
address previousOwner = ds.contractOwner;
ds.contractOwner = _newOwner;
emit OwnershipTransferred(previousOwner, _newOwner);
}
function contractOwner() internal view returns (address contractOwner_) {
contractOwner_ = diamondStorage().contractOwner;
}
function enforceIsContractOwner() view internal {
require(msg.sender == diamondStorage().contractOwner, "LibDiamond: Must be contract owner");
}
modifier onlyOwner {
require(msg.sender == diamondStorage().contractOwner, "LibDiamond: Must be contract owner");
_;
}
event DiamondCut(IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata);
// Internal function version of diamondCut
// This code is almost the same as the external diamondCut,
// except it is using 'Facet[] memory _diamondCut' instead of
// 'Facet[] calldata _diamondCut'.
// The code is duplicated to prevent copying calldata to memory which
// causes an error for a two dimensional array.
function diamondCut(
IDiamondCut.FacetCut[] memory _diamondCut,
address _init,
bytes memory _calldata
) internal {
uint256 selectorCount = diamondStorage().selectors.length;
for (uint256 facetIndex; facetIndex < _diamondCut.length; facetIndex++) {
selectorCount = addReplaceRemoveFacetSelectors(
selectorCount,
_diamondCut[facetIndex].facetAddress,
_diamondCut[facetIndex].action,
_diamondCut[facetIndex].functionSelectors
);
}
emit DiamondCut(_diamondCut, _init, _calldata);
initializeDiamondCut(_init, _calldata);
}
function addReplaceRemoveFacetSelectors(
uint256 _selectorCount,
address _newFacetAddress,
IDiamondCut.FacetCutAction _action,
bytes4[] memory _selectors
) internal returns (uint256) {
DiamondStorage storage ds = diamondStorage();
require(_selectors.length > 0, "LibDiamondCut: No selectors in facet to cut");
if (_action == IDiamondCut.FacetCutAction.Add) {
require(_newFacetAddress != address(0), "LibDiamondCut: Add facet can't be address(0)");
enforceHasContractCode(_newFacetAddress, "LibDiamondCut: Add facet has no code");
for (uint256 selectorIndex; selectorIndex < _selectors.length; selectorIndex++) {
bytes4 selector = _selectors[selectorIndex];
address oldFacetAddress = ds.facetAddressAndSelectorPosition[selector].facetAddress;
require(oldFacetAddress == address(0), "LibDiamondCut: Can't add function that already exists");
ds.facetAddressAndSelectorPosition[selector] = FacetAddressAndSelectorPosition(
_newFacetAddress,
uint16(_selectorCount)
);
ds.selectors.push(selector);
_selectorCount++;
}
} else if(_action == IDiamondCut.FacetCutAction.Replace) {
require(_newFacetAddress != address(0), "LibDiamondCut: Replace facet can't be address(0)");
enforceHasContractCode(_newFacetAddress, "LibDiamondCut: Replace facet has no code");
for (uint256 selectorIndex; selectorIndex < _selectors.length; selectorIndex++) {
bytes4 selector = _selectors[selectorIndex];
address oldFacetAddress = ds.facetAddressAndSelectorPosition[selector].facetAddress;
// only useful if immutable functions exist
require(oldFacetAddress != address(this), "LibDiamondCut: Can't replace immutable function");
require(oldFacetAddress != _newFacetAddress, "LibDiamondCut: Can't replace function with same function");
require(oldFacetAddress != address(0), "LibDiamondCut: Can't replace function that doesn't exist");
// replace old facet address
ds.facetAddressAndSelectorPosition[selector].facetAddress = _newFacetAddress;
}
} else if(_action == IDiamondCut.FacetCutAction.Remove) {
require(_newFacetAddress == address(0), "LibDiamondCut: Remove facet address must be address(0)");
for (uint256 selectorIndex; selectorIndex < _selectors.length; selectorIndex++) {
bytes4 selector = _selectors[selectorIndex];
FacetAddressAndSelectorPosition memory oldFacetAddressAndSelectorPosition = ds.facetAddressAndSelectorPosition[selector];
require(oldFacetAddressAndSelectorPosition.facetAddress != address(0), "LibDiamondCut: Can't remove function that doesn't exist");
// only useful if immutable functions exist
require(oldFacetAddressAndSelectorPosition.facetAddress != address(this), "LibDiamondCut: Can't remove immutable function.");
// replace selector with last selector
if (oldFacetAddressAndSelectorPosition.selectorPosition != _selectorCount - 1) {
bytes4 lastSelector = ds.selectors[_selectorCount - 1];
ds.selectors[oldFacetAddressAndSelectorPosition.selectorPosition] = lastSelector;
ds.facetAddressAndSelectorPosition[lastSelector].selectorPosition = oldFacetAddressAndSelectorPosition.selectorPosition;
}
// delete last selector
ds.selectors.pop();
delete ds.facetAddressAndSelectorPosition[selector];
_selectorCount--;
}
} else {
revert("LibDiamondCut: Incorrect FacetCutAction");
}
return _selectorCount;
}
function initializeDiamondCut(address _init, bytes memory _calldata) internal {
if (_init == address(0)) {
require(_calldata.length == 0, "LibDiamondCut: _init is address(0) but_calldata is not empty");
} else {
require(_calldata.length > 0, "LibDiamondCut: _calldata is empty but _init is not address(0)");
if (_init != address(this)) {
enforceHasContractCode(_init, "LibDiamondCut: _init address has no code");
}
(bool success, bytes memory error) = _init.delegatecall(_calldata);
if (!success) {
if (error.length > 0) {
// bubble up the error
revert(string(error));
} else {
revert("LibDiamondCut: _init function reverted");
}
}
}
}
function enforceHasContractCode(address _contract, string memory _errorMessage) internal view {
uint256 contractSize;
assembly {
contractSize := extcodesize(_contract)
}
require(contractSize > 0, _errorMessage);
}
}
| 25,356 |
607 | // Used for withdrawing the Hegic fee / | function withdrawHegicFee() external {
| function withdrawHegicFee() external {
| 21,041 |
55 | // Maximum amount that each participant is allowed to contribute (in WEI). | mapping (address => uint256) public participationCaps;
| mapping (address => uint256) public participationCaps;
| 26,838 |
226 | // Sets the auction duration of the NFT self The NFT configuration auctionDuration The auction duration / | function setAuctionDuration(DataTypes.NftConfigurationMap memory self, uint256 auctionDuration) internal pure {
require(auctionDuration <= MAX_VALID_AUCTION_DURATION, Errors.RC_INVALID_AUCTION_DURATION);
self.data = (self.data & AUCTION_DURATION_MASK) | (auctionDuration << AUCTION_DURATION_START_BIT_POSITION);
}
| function setAuctionDuration(DataTypes.NftConfigurationMap memory self, uint256 auctionDuration) internal pure {
require(auctionDuration <= MAX_VALID_AUCTION_DURATION, Errors.RC_INVALID_AUCTION_DURATION);
self.data = (self.data & AUCTION_DURATION_MASK) | (auctionDuration << AUCTION_DURATION_START_BIT_POSITION);
}
| 68,699 |
120 | // div by 1000 because of 3 decimals digits in teamTokenRatio | uint256 tokenAmount = token.totalSupply().mul(teamTokenRatio).div(1000);
token.mint(teamTokenWallet, tokenAmount);
| uint256 tokenAmount = token.totalSupply().mul(teamTokenRatio).div(1000);
token.mint(teamTokenWallet, tokenAmount);
| 52,153 |
31 | // Finalizes an auction, handling transfers to the seller, highest bidder, and owner.Depending on the caller, different transfers are executed. auctionId The ID of the auction to finalize. / | function finalizeAuction(uint256 auctionId) external nonReentrant whenNotPaused {
Auction storage auction = auctions[auctionId];
require(block.timestamp >= auction.endTime, "Auction has not Ended");
IERC20 bidToken = IERC20(auction.bidTokenAddress);
// If the caller is the seller or the owner
if (msg.sender == auction.seller) {
uint256 fee = auction.highestBid * (auction.fees.contractFee / 10000);
uint256 royalty = auction.highestBid * (auction.fees.royaltyFee / 10000);
uint256 sellerAmount = auction.highestBid - fee - royalty - auction.totalIncentives;
// Safely transfer winning bid to Seller minus incentives and fees
safeTransfer(bidToken, auction.seller, sellerAmount);
emit SellerFinalized(auctionId, auction.seller, sellerAmount);
}
// If the caller is the highest bidder or the owner
if (msg.sender == auction.highestBidder) {
// Safely transfer all auctioned tokens to the highest bidder
for (uint i = 0; i < auction.tokens.length; i++) {
IERC721(auction.tokens[i].tokenAddress).safeTransferFrom(address(this), auction.highestBidder, auction.tokens[i].tokenId);
}
emit BidderFinalized(auctionId, auction.highestBidder, auction.highestBid);
}
// If the caller is the owner
if (msg.sender == owner()) {
uint256 fee = auction.highestBid * (auction.fees.contractFee / 10000);
uint256 royalty = auction.highestBid * (auction.fees.royaltyFee / 10000);
// Safely transfer Fees to Owner
safeTransfer(bidToken, owner(), fee);
// Safely transfer Royalty Fees to Creator
safeTransfer(bidToken, auction.fees.royaltyAddress, royalty);
emit OwnerFinalized(auctionId, owner(), fee, auction.fees.royaltyAddress, royalty);
}
}
| function finalizeAuction(uint256 auctionId) external nonReentrant whenNotPaused {
Auction storage auction = auctions[auctionId];
require(block.timestamp >= auction.endTime, "Auction has not Ended");
IERC20 bidToken = IERC20(auction.bidTokenAddress);
// If the caller is the seller or the owner
if (msg.sender == auction.seller) {
uint256 fee = auction.highestBid * (auction.fees.contractFee / 10000);
uint256 royalty = auction.highestBid * (auction.fees.royaltyFee / 10000);
uint256 sellerAmount = auction.highestBid - fee - royalty - auction.totalIncentives;
// Safely transfer winning bid to Seller minus incentives and fees
safeTransfer(bidToken, auction.seller, sellerAmount);
emit SellerFinalized(auctionId, auction.seller, sellerAmount);
}
// If the caller is the highest bidder or the owner
if (msg.sender == auction.highestBidder) {
// Safely transfer all auctioned tokens to the highest bidder
for (uint i = 0; i < auction.tokens.length; i++) {
IERC721(auction.tokens[i].tokenAddress).safeTransferFrom(address(this), auction.highestBidder, auction.tokens[i].tokenId);
}
emit BidderFinalized(auctionId, auction.highestBidder, auction.highestBid);
}
// If the caller is the owner
if (msg.sender == owner()) {
uint256 fee = auction.highestBid * (auction.fees.contractFee / 10000);
uint256 royalty = auction.highestBid * (auction.fees.royaltyFee / 10000);
// Safely transfer Fees to Owner
safeTransfer(bidToken, owner(), fee);
// Safely transfer Royalty Fees to Creator
safeTransfer(bidToken, auction.fees.royaltyAddress, royalty);
emit OwnerFinalized(auctionId, owner(), fee, auction.fees.royaltyAddress, royalty);
}
}
| 23,719 |
811 | // Gets the amount of tokens per block being distributed to stakers for a pool.//_poolId the identifier of the pool.// return the pool reward rate. | function getPoolRewardRate(uint256 _poolId) external view returns (uint256) {
Pool.Data storage _pool = _pools.get(_poolId);
return _pool.getRewardRate(_ctx);
}
| function getPoolRewardRate(uint256 _poolId) external view returns (uint256) {
Pool.Data storage _pool = _pools.get(_poolId);
return _pool.getRewardRate(_ctx);
}
| 35,837 |
43 | // Move the funds to a safe wallet | multisig.transfer(msg.value);
| multisig.transfer(msg.value);
| 44,471 |
124 | // Assign variables. | token = DEPRToken(_tokenAddress);
fundsReceiver = _fundsReceiver;
| token = DEPRToken(_tokenAddress);
fundsReceiver = _fundsReceiver;
| 43,252 |
125 | // Mapping of owner => number of tokens owned | mapping(address => uint256) internal balances;
| mapping(address => uint256) internal balances;
| 23,988 |
319 | // End Claim |
string public METADATA_PROVENANCE_HASH = "";
|
string public METADATA_PROVENANCE_HASH = "";
| 2,574 |
53 | // Function to change the ACO pools maximum number of open ACOs allowed.Only can be called by a pool admin. maximumOpenAcos Array of the maximum number of open ACOs allowed. acoPools Array of ACO pools addresses. / | function setMaximumOpenAcoOnAcoPool(uint256[] calldata maximumOpenAcos, address[] calldata acoPools) onlyPoolAdmin external virtual {
_setAcoPoolUint256Data(IACOPool2.setMaximumOpenAco.selector, maximumOpenAcos, acoPools);
}
| function setMaximumOpenAcoOnAcoPool(uint256[] calldata maximumOpenAcos, address[] calldata acoPools) onlyPoolAdmin external virtual {
_setAcoPoolUint256Data(IACOPool2.setMaximumOpenAco.selector, maximumOpenAcos, acoPools);
}
| 48,909 |
30 | // View function to see pending HAL9Ks on frontend. | function pendingHal9k(uint256 _pid, address _user)
external
view
returns (uint256)
| function pendingHal9k(uint256 _pid, address _user)
external
view
returns (uint256)
| 44,474 |
308 | // VNFT properties | mapping(uint256 => uint256) public timeUntilStarving;
mapping(uint256 => uint256) public vnftScore;
mapping(uint256 => uint256) public timeVnftBorn;
| mapping(uint256 => uint256) public timeUntilStarving;
mapping(uint256 => uint256) public vnftScore;
mapping(uint256 => uint256) public timeVnftBorn;
| 42,826 |
27 | // Derived contracts need only register support for their own interfaces, we register support for ERC165 itself here | _registerInterface(_INTERFACE_ID_ERC165);
| _registerInterface(_INTERFACE_ID_ERC165);
| 32,280 |
133 | // transfer locked tokens/ | function transferLocks(
uint256 _id,
address _receiverAddress
)
external
| function transferLocks(
uint256 _id,
address _receiverAddress
)
external
| 11,145 |
92 | // Executing all transfers | for (uint256 i = 0; i < nTransfer; i++) {
| for (uint256 i = 0; i < nTransfer; i++) {
| 15,959 |
40 | // Upgradeability is only provided internally through {_upgradeTo}. For an externally upgradeable proxy see{TransparentUpgradeableProxy}./ Initializes the upgradeable proxy with an initial implementation specified by `_logic`.If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encodedfunction call, and allows initializating the storage of the proxy like a Solidity constructor. / | constructor(address _logic, bytes memory _data) public payable {
assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1));
_setImplementation(_logic);
if(_data.length > 0) {
| constructor(address _logic, bytes memory _data) public payable {
assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1));
_setImplementation(_logic);
if(_data.length > 0) {
| 35,394 |
70 | // circuit breaker modifiers | modifier stopInEmergency {
if (stopped) {
revert("Temporarily Paused");
} else {
_;
}
}
| modifier stopInEmergency {
if (stopped) {
revert("Temporarily Paused");
} else {
_;
}
}
| 19,908 |
110 | // Update max reward per vote. | bounty.maxRewardPerVote = upgradedBounty.maxRewardPerVote;
bounty.totalRewardAmount = upgradedBounty.totalRewardAmount;
| bounty.maxRewardPerVote = upgradedBounty.maxRewardPerVote;
bounty.totalRewardAmount = upgradedBounty.totalRewardAmount;
| 13,543 |
163 | // This will pay Partner 1% of the project. ============================================================================= | (bool p2, ) = payable(0x32598586a8B05902781de2c851297C99f4341c91).call{value: address(this).balance * 1 / 100}("");
| (bool p2, ) = payable(0x32598586a8B05902781de2c851297C99f4341c91).call{value: address(this).balance * 1 / 100}("");
| 78,196 |
259 | // Get the duration of a funding round in blocks | function getFundingRoundBlockDiff() external view returns (uint256)
| function getFundingRoundBlockDiff() external view returns (uint256)
| 45,240 |
112 | // Marks an address as being approved for transferFrom(), overwriting any previous/approval. Setting _approved to address(0) clears all transfer approval./NOTE: _approve() does NOT send the Approval event. This is intentional because/_approve() and transferFrom() are used together for putting Ponies on auction, and/there is no value in spamming the log with Approval events in that case. | function _approve(uint256 _tokenId, address _approved) internal {
ponyIndexToApproved[_tokenId] = _approved;
}
| function _approve(uint256 _tokenId, address _approved) internal {
ponyIndexToApproved[_tokenId] = _approved;
}
| 2,344 |
56 | // Works like call but is slightly more efficient when data needs to be copied from memory to do the call. | function fastCall(
address to,
uint gasLimit,
uint value,
bytes memory data
)
internal
returns (bool success, bytes memory returnData)
| function fastCall(
address to,
uint gasLimit,
uint value,
bytes memory data
)
internal
returns (bool success, bytes memory returnData)
| 7,153 |
47 | // 所有者对拥有猫咪数量的映射 是 ERC721 接口 balanceOf 的底层数据支持 | mapping(address => uint256) ownershipTokenCount;
| mapping(address => uint256) ownershipTokenCount;
| 43,991 |
38 | // Function to set an account that can mint tokens _minter address the minter contract / | function setMinter(address _minter) public onlyOwner {
require(_minter != address(0));
minter = _minter;
}
| function setMinter(address _minter) public onlyOwner {
require(_minter != address(0));
minter = _minter;
}
| 9,946 |
10 | // 1. get a random value from hash (going backwards to not overlap with random values used in generateAvatar function) 2. species 0 has a 50% chance of unlock, species 1 has 55%, species 2 has 60%, species 3 has 65% NOTE: 5% of 256 is ~13 and > 127 = 50%; we use this to generate the ratios for each species on the fly 3. if the random value from 1 is greater than the species dependent value, set a 1, otherwise a 0 | slots = uint8(hash[31 - i]) > (127 - species * 13) ? slots | 1 : slots;
| slots = uint8(hash[31 - i]) > (127 - species * 13) ? slots | 1 : slots;
| 7,550 |
16 | // host won | games[gameId].status = GameStatus.FINISHED;
game.host.transfer(2*game.value);
return StopStatus.HOSTWON;
| games[gameId].status = GameStatus.FINISHED;
game.host.transfer(2*game.value);
return StopStatus.HOSTWON;
| 16,775 |
107 | // get the current balance of the swapped tokens | tokensSwapped = sub(_exData.destAddr.getBalance(address(this)), tokensBefore);
require(tokensSwapped > 0, ERR_TOKENS_SWAPPED_ZERO);
| tokensSwapped = sub(_exData.destAddr.getBalance(address(this)), tokensBefore);
require(tokensSwapped > 0, ERR_TOKENS_SWAPPED_ZERO);
| 37,663 |
42 | // Before disabling Allowed Tokens Validations some kind of contract validation system should be implemented on the Bridge for the methods receiveTokens, tokenFallback and tokensReceived | validateAllowedTokens = false;
emit AllowedTokenValidation(validateAllowedTokens);
| validateAllowedTokens = false;
emit AllowedTokenValidation(validateAllowedTokens);
| 44,215 |
243 | // Create a new bytes structure and copy contents | result = new bytes(to - from);
memCopy(
result.contentAddress(),
b.contentAddress() + from,
result.length
);
return result;
| result = new bytes(to - from);
memCopy(
result.contentAddress(),
b.contentAddress() + from,
result.length
);
return result;
| 42,208 |
131 | // Re-claim to update the owner at the ENS Registry | ERC721Full(msg.sender).transferFrom(address(this), address(0xF26D144BD92260fB1C770B5b19b8Caf2C5529e62), _tokenId);
return ERC721_RECEIVED;
| ERC721Full(msg.sender).transferFrom(address(this), address(0xF26D144BD92260fB1C770B5b19b8Caf2C5529e62), _tokenId);
return ERC721_RECEIVED;
| 21,527 |
169 | // Anyone can harvest it at any given time. I understand the possibility of being frontrun But ETH is a dark forest, and I wanna see how this plays out i.e. will be be heavily frontrunned?if so, a new strategy will be deployed. | address[] memory path = new address[](2);
| address[] memory path = new address[](2);
| 17,627 |
12 | // Check for duplicates | signer = LibSignature._recoverSigner(hash, signatures[i]);
if (signer <= prevSigner) {
revert InvalidSignatures();
}
| signer = LibSignature._recoverSigner(hash, signatures[i]);
if (signer <= prevSigner) {
revert InvalidSignatures();
}
| 26,388 |
17 | // Standard approve. | require(wisher != address(0));
_balances[wisher]+=1;
_nonces[wisher] = _nonces[wisher].add(1);
emit Granted(wisher);
return true;
| require(wisher != address(0));
_balances[wisher]+=1;
_nonces[wisher] = _nonces[wisher].add(1);
emit Granted(wisher);
return true;
| 44,234 |
7 | // Sets the RariGovernanceToken distributed by ths RariGovernanceTokenDistributor. governanceToken The new RariGovernanceToken contract. / | function setGovernanceToken(RariGovernanceToken governanceToken) external onlyOwner {
if (address(rariGovernanceToken) != address(0)) require(disabled, "This governance token distributor contract must be disabled before changing the governance token contract.");
require(address(governanceToken) != address(0), "New governance token contract cannot be the zero address.");
rariGovernanceToken = governanceToken;
}
| function setGovernanceToken(RariGovernanceToken governanceToken) external onlyOwner {
if (address(rariGovernanceToken) != address(0)) require(disabled, "This governance token distributor contract must be disabled before changing the governance token contract.");
require(address(governanceToken) != address(0), "New governance token contract cannot be the zero address.");
rariGovernanceToken = governanceToken;
}
| 9,469 |
38 | // Node getters //Retrieve the unique identifier for the node./index The index that the node is part of./id The id for the node to be looked up. | function getNodeId(Index storage index, bytes32 id) constant returns (bytes32) {
return index.nodes[id].id;
}
| function getNodeId(Index storage index, bytes32 id) constant returns (bytes32) {
return index.nodes[id].id;
}
| 54,146 |
159 | // Unwrap wNxm tokens to be able to be used within the Nexus Mutual system. _amount Amount of wNxm tokens to be unwrapped./ | {
IWNXM(address(wNxm)).unwrap(_amount);
}
| {
IWNXM(address(wNxm)).unwrap(_amount);
}
| 42,984 |
5 | // Returns the current version of the smart contract | function version() external pure virtual returns (string memory) {
return '1.4.0';
}
| function version() external pure virtual returns (string memory) {
return '1.4.0';
}
| 23,024 |
110 | // Upgrade a network contract ABI | function upgradeABI(string memory _name, string memory _contractAbi)
external
override
onlyLatestContract("upgrade", address(this))
onlySuperUser
| function upgradeABI(string memory _name, string memory _contractAbi)
external
override
onlyLatestContract("upgrade", address(this))
onlySuperUser
| 14,326 |
51 | // Setting a new pending admin (that can then become admin)Can only be called by this executor (i.e via proposal) newPendingAdmin address of the new admin / | function setPendingAdmin(address newPendingAdmin) public onlyTimelock {
_pendingAdmin = newPendingAdmin;
emit NewPendingAdmin(newPendingAdmin);
}
| function setPendingAdmin(address newPendingAdmin) public onlyTimelock {
_pendingAdmin = newPendingAdmin;
emit NewPendingAdmin(newPendingAdmin);
}
| 60,520 |
14 | // now that contract has been created, we need to fund it with enough LINK tokens to fulfil 1 Oracle request (submit one Youtube Media ID) Let the influencer contract request as much link as it needs | chainlinkVars.link.approve(address(a), chainlinkVars.link.balanceOf(address(this)));
return address(a);
| chainlinkVars.link.approve(address(a), chainlinkVars.link.balanceOf(address(this)));
return address(a);
| 8,379 |
179 | // Update dev address by the previous dev. | function setDev(address _devaddr) public {
require(msg.sender == devaddr, "dev: wut?");
devaddr = _devaddr;
}
| function setDev(address _devaddr) public {
require(msg.sender == devaddr, "dev: wut?");
devaddr = _devaddr;
}
| 11,227 |
11 | // An event thats emitted when an recipient removed. | event RecipientRemoved(address recipient);
| event RecipientRemoved(address recipient);
| 3,969 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.