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 |
|---|---|---|---|---|
45 | // daily winners' award | mapping(uint => mapping(address => uint)) winnerDailyParticipantInfos;
| mapping(uint => mapping(address => uint)) winnerDailyParticipantInfos;
| 3,338 |
15 | // Constructor function _name Token name _symbol Token symbol _price Token price _unitsPerTransaction Purchasable token amounts per transaction _maxSupply Maximum number of mintable tokens _defaultTokenURI Deafult token uri _prizeTokenURI Prize token uri _baseURI Base token uri _startingTime Start time to purchase NFT / | constructor(
string memory _name,
string memory _symbol,
uint256 _price,
uint256 _unitsPerTransaction,
uint256 _maxSupply,
string memory _defaultTokenURI,
string memory _prizeTokenURI,
string memory _baseURI,
uint256 _startingTime
| constructor(
string memory _name,
string memory _symbol,
uint256 _price,
uint256 _unitsPerTransaction,
uint256 _maxSupply,
string memory _defaultTokenURI,
string memory _prizeTokenURI,
string memory _baseURI,
uint256 _startingTime
| 19,589 |
26 | // Creates a lock for the provided _beneficiary with the provided amountThe creation can be peformed only if:- the sender is the address of the crowdsale;- the _beneficiary and _tokenHolder are valid addresses;- the _amount is greater than 0 and was appoved by the _tokenHolder prior to the transaction.The investors will have a lock with a lock period of 6 months. _beneficiary Address that will own the lock. _amount the amount of the locked tokens. _start when the lock should start. _tokenHolder the account that approved the amount for this contract. / | function createInvestorTokenTimeLock(
address _beneficiary,
uint256 _amount,
uint256 _start,
address _tokenHolder
) external onlyCrowdsale returns (bool)
| function createInvestorTokenTimeLock(
address _beneficiary,
uint256 _amount,
uint256 _start,
address _tokenHolder
) external onlyCrowdsale returns (bool)
| 66,417 |
47 | // Pocket the money | if(!wallet.send(msg.value)) throw;
| if(!wallet.send(msg.value)) throw;
| 51,345 |
4 | // User Begin | struct User {
address _eth;
uint _startTime;
uint _pledgeCycle;
uint _curBTC;
//uint _btcVal;
string _btc;
bool _bReceive;
//bool _Receive;
bool _bExist;
}
| struct User {
address _eth;
uint _startTime;
uint _pledgeCycle;
uint _curBTC;
//uint _btcVal;
string _btc;
bool _bReceive;
//bool _Receive;
bool _bExist;
}
| 40,115 |
33 | // See {IERC20-approve}. Requirements: - `spender` cannot be the zero address. / | function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
| function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
| 10,064 |
19 | // _______ ______ // \ \/ / (_)| |__(_) |_ _| ___| |______ _//\ \/\/ /| || / /| | | |/ _ \ | / / / -_)| ' \ // \_/\_/_|_|_ |_\_\ _|_|_ _|_|_ \___/ |_\_\ \___||_||_|// _|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""| //"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'//wikitoken.org /Wiki Token ERC 721 contract. / | contract Token is ERC721Enumerable, JuiceboxProject {
/// Minted page ids in order, used for pagination and for getting all of the tokens belonging to an address.
uint256[] private _mintedWikipediaPageIds;
/// Base URI that WikiToken IDs will be concatenated to.
string public baseURI;
/// True if Juice is enblaed, false otherwise. This is useful for local testing.
/// https://juicebox.money
bool private _isJuiceEnabled;
/// The minimum price required to mint a WikiToken.
uint256 public constant MIN_MINT_PRICE = 10000000000000000; // 0.01 ETH.
/// Wiki Token constructor.
///
/// @param _baseURI Base URI that will be applied to all tokens.
/// @param isJuiceEnabled True if juice is enabled, false otherwise.
/// @param _projectID Juicebox project ID.
/// @param _terminalDirectory Terminal Directory, required by Juice.
constructor(
string memory _baseURI,
bool isJuiceEnabled,
uint256 _projectID,
ITerminalDirectory _terminalDirectory
) JuiceboxProject(_projectID, _terminalDirectory) ERC721("WikiToken", "WIKI") {
baseURI = _baseURI;
_isJuiceEnabled = isJuiceEnabled;
}
/// Sets the base URI for all tokens.
///
/// @param _baseURI Base URI that will be set.
function setBaseURI(string memory _baseURI) public onlyOwner {
baseURI = _baseURI;
}
/// Returns the URI for a given token.
///
/// @param tokenId ID of the token in question.
function tokenURI(uint256 tokenId) public view override returns (string memory) {
require(_exists(tokenId), "WikiToken::tokenURI:: TOKEN_DOES_NOT_EXIST");
return
bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, Strings.toString(tokenId))) : "";
}
/// Mints a Wiki Token with a Wikipedia page ID.
///
/// @param wikipediaPageId Wikipedia page that will be minted as a token.
function mintWikipediaPage(uint256 wikipediaPageId) external payable {
require(
msg.value >= MIN_MINT_PRICE,
"WikiToken::mintWikipediaPage:: MIN_ETHER_NOT_SENT"
);
/// Route fee to WikiTokenDAO Juicebox treasury if Juice is enabled.
if (_isJuiceEnabled) {
_takeFee(
msg.value,
msg.sender,
string(abi.encodePacked("Minted WikiToken for Page ID ", wikipediaPageId)),
false // _preferUnstakedTickets
);
}
_mint(msg.sender, wikipediaPageId);
_mintedWikipediaPageIds.push(wikipediaPageId);
}
/// Checks if the token for a corresponding Wikipedia page has been minted.
///
/// @param pageId ID of token in question.
/// @return True if minted, false otherwise.
function isPageMinted(uint256 pageId) public view returns (bool) {
return _exists(pageId);
}
/// Fetches tokens belonging to a specific address via pagination.
///
/// NOTE: Logic for tokensOfAddress() and discover() is not shared because different APIs are
/// required for fetching tokens generally and fetching tokens belonging to a particular address.
///
/// @param owner Address of the owner tokens should be fetched for.
/// @param cursor Index paginated results should start at.
/// @param howMany How many results should be returned.
/// @param ascending True if results should be returned in ascending order.
function tokensOfAddress(
address owner,
uint256 cursor,
uint256 howMany,
bool ascending
)
external
view
returns (
uint256[] memory result,
bool reachedEnd,
uint256 newCursor
)
{
uint256 tokenCount = balanceOf(owner);
require(
tokenCount > 0,
"WikiToken::tokensOfAddress:: OWNER_HAS_NO_TOKENS"
);
require(
cursor >= 0 && cursor < tokenCount,
"WikiToken::tokensOfAddress:: CURSOR_OUT_OF_BOUNDS"
);
/// Determine cursor position depending on length and
uint256 cursor_ = cursor;
uint256 length = Math.min(howMany, tokenCount - cursor);
uint256 cursorInternal = ascending ? cursor : tokenCount - 1 - cursor;
/// Allocate space for the resulting array and push paginated items.
result = new uint256[](length);
for (uint256 i = 0; i < length; i++) {
result[i] = tokenOfOwnerByIndex(owner, cursorInternal);
if (ascending) {
cursorInternal++;
} else {
cursorInternal--;
}
cursor_++;
}
return (result, cursor_ == tokenCount, cursor_);
}
/// Fetches tokens belonging to any address via pagination.
///
/// @param cursor Index paginated results should start at.
/// @param howMany How many results should be returned.
/// @param ascending True if results should be returned in ascending order.
function discover(
uint256 cursor,
uint256 howMany,
bool ascending
)
external
view
returns (
uint256[] memory result,
bool reachedEnd,
uint256 newCursor
)
{
require(
_mintedWikipediaPageIds.length > 0,
"WikiToken::discover:: NO_TOKENS_MINTED"
);
require(
cursor >= 0 && cursor < _mintedWikipediaPageIds.length,
"WikiToken::discover:: CURSOR_OUT_OF_BOUNDS"
);
/// Determine cursor position depending on length and
uint256 cursor_ = cursor;
uint256 length = Math.min(howMany, _mintedWikipediaPageIds.length - cursor);
uint256 cursorInternal = ascending ? cursor : _mintedWikipediaPageIds.length - 1 - cursor;
/// Allocate space for the resulting array and push paginated items.
result = new uint256[](length);
for (uint256 i = 0; i < length; i++) {
result[i] = _mintedWikipediaPageIds[cursorInternal];
if (ascending) {
cursorInternal++;
} else {
cursorInternal--;
}
cursor_++;
}
return (result, cursor_ == _mintedWikipediaPageIds.length, cursor_);
}
}
| contract Token is ERC721Enumerable, JuiceboxProject {
/// Minted page ids in order, used for pagination and for getting all of the tokens belonging to an address.
uint256[] private _mintedWikipediaPageIds;
/// Base URI that WikiToken IDs will be concatenated to.
string public baseURI;
/// True if Juice is enblaed, false otherwise. This is useful for local testing.
/// https://juicebox.money
bool private _isJuiceEnabled;
/// The minimum price required to mint a WikiToken.
uint256 public constant MIN_MINT_PRICE = 10000000000000000; // 0.01 ETH.
/// Wiki Token constructor.
///
/// @param _baseURI Base URI that will be applied to all tokens.
/// @param isJuiceEnabled True if juice is enabled, false otherwise.
/// @param _projectID Juicebox project ID.
/// @param _terminalDirectory Terminal Directory, required by Juice.
constructor(
string memory _baseURI,
bool isJuiceEnabled,
uint256 _projectID,
ITerminalDirectory _terminalDirectory
) JuiceboxProject(_projectID, _terminalDirectory) ERC721("WikiToken", "WIKI") {
baseURI = _baseURI;
_isJuiceEnabled = isJuiceEnabled;
}
/// Sets the base URI for all tokens.
///
/// @param _baseURI Base URI that will be set.
function setBaseURI(string memory _baseURI) public onlyOwner {
baseURI = _baseURI;
}
/// Returns the URI for a given token.
///
/// @param tokenId ID of the token in question.
function tokenURI(uint256 tokenId) public view override returns (string memory) {
require(_exists(tokenId), "WikiToken::tokenURI:: TOKEN_DOES_NOT_EXIST");
return
bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, Strings.toString(tokenId))) : "";
}
/// Mints a Wiki Token with a Wikipedia page ID.
///
/// @param wikipediaPageId Wikipedia page that will be minted as a token.
function mintWikipediaPage(uint256 wikipediaPageId) external payable {
require(
msg.value >= MIN_MINT_PRICE,
"WikiToken::mintWikipediaPage:: MIN_ETHER_NOT_SENT"
);
/// Route fee to WikiTokenDAO Juicebox treasury if Juice is enabled.
if (_isJuiceEnabled) {
_takeFee(
msg.value,
msg.sender,
string(abi.encodePacked("Minted WikiToken for Page ID ", wikipediaPageId)),
false // _preferUnstakedTickets
);
}
_mint(msg.sender, wikipediaPageId);
_mintedWikipediaPageIds.push(wikipediaPageId);
}
/// Checks if the token for a corresponding Wikipedia page has been minted.
///
/// @param pageId ID of token in question.
/// @return True if minted, false otherwise.
function isPageMinted(uint256 pageId) public view returns (bool) {
return _exists(pageId);
}
/// Fetches tokens belonging to a specific address via pagination.
///
/// NOTE: Logic for tokensOfAddress() and discover() is not shared because different APIs are
/// required for fetching tokens generally and fetching tokens belonging to a particular address.
///
/// @param owner Address of the owner tokens should be fetched for.
/// @param cursor Index paginated results should start at.
/// @param howMany How many results should be returned.
/// @param ascending True if results should be returned in ascending order.
function tokensOfAddress(
address owner,
uint256 cursor,
uint256 howMany,
bool ascending
)
external
view
returns (
uint256[] memory result,
bool reachedEnd,
uint256 newCursor
)
{
uint256 tokenCount = balanceOf(owner);
require(
tokenCount > 0,
"WikiToken::tokensOfAddress:: OWNER_HAS_NO_TOKENS"
);
require(
cursor >= 0 && cursor < tokenCount,
"WikiToken::tokensOfAddress:: CURSOR_OUT_OF_BOUNDS"
);
/// Determine cursor position depending on length and
uint256 cursor_ = cursor;
uint256 length = Math.min(howMany, tokenCount - cursor);
uint256 cursorInternal = ascending ? cursor : tokenCount - 1 - cursor;
/// Allocate space for the resulting array and push paginated items.
result = new uint256[](length);
for (uint256 i = 0; i < length; i++) {
result[i] = tokenOfOwnerByIndex(owner, cursorInternal);
if (ascending) {
cursorInternal++;
} else {
cursorInternal--;
}
cursor_++;
}
return (result, cursor_ == tokenCount, cursor_);
}
/// Fetches tokens belonging to any address via pagination.
///
/// @param cursor Index paginated results should start at.
/// @param howMany How many results should be returned.
/// @param ascending True if results should be returned in ascending order.
function discover(
uint256 cursor,
uint256 howMany,
bool ascending
)
external
view
returns (
uint256[] memory result,
bool reachedEnd,
uint256 newCursor
)
{
require(
_mintedWikipediaPageIds.length > 0,
"WikiToken::discover:: NO_TOKENS_MINTED"
);
require(
cursor >= 0 && cursor < _mintedWikipediaPageIds.length,
"WikiToken::discover:: CURSOR_OUT_OF_BOUNDS"
);
/// Determine cursor position depending on length and
uint256 cursor_ = cursor;
uint256 length = Math.min(howMany, _mintedWikipediaPageIds.length - cursor);
uint256 cursorInternal = ascending ? cursor : _mintedWikipediaPageIds.length - 1 - cursor;
/// Allocate space for the resulting array and push paginated items.
result = new uint256[](length);
for (uint256 i = 0; i < length; i++) {
result[i] = _mintedWikipediaPageIds[cursorInternal];
if (ascending) {
cursorInternal++;
} else {
cursorInternal--;
}
cursor_++;
}
return (result, cursor_ == _mintedWikipediaPageIds.length, cursor_);
}
}
| 43,283 |
42 | // mapping that keeps track of if a user is staking normal nft | mapping (address => bool) isStakingNormalNFT;
| mapping (address => bool) isStakingNormalNFT;
| 16,224 |
2 | // Deposit LP tokens to MCV2 for SUSHI allocation./pid The index of the pool. See `poolInfo`./amount LP token amount to deposit./to The receiver of `amount` deposit benefit. | function deposit(
uint256 pid,
uint256 amount,
address to
) external;
| function deposit(
uint256 pid,
uint256 amount,
address to
) external;
| 53,431 |
18 | // Deposit staked tokens and collect reward tokens (if any) _amount: amount to deposit (in stakedToken) / | function deposit(uint256 _amount) external nonReentrant {
UserInfo storage user = userInfo[msg.sender];
_updatePool();
if (user.amount > 0) {
uint256 pendingToken1 = user
.amount
.mul(mapOfAccTokenPerShare[TOKEN1])
.div(mapOfPrecisionFactor[TOKEN1])
.sub(user.rewardDebt1);
if (pendingToken1 > 0) {
_safeTokenTransfer(
mapOfRewardTokens[TOKEN1],
msg.sender,
pendingToken1
);
}
uint256 pendingToken2 = user
.amount
.mul(mapOfAccTokenPerShare[TOKEN2])
.div(mapOfPrecisionFactor[TOKEN2])
.sub(user.rewardDebt2);
if (pendingToken2 > 0) {
_safeTokenTransfer(
mapOfRewardTokens[TOKEN2],
msg.sender,
pendingToken2
);
}
}
if (_amount > 0) {
user.amount = user.amount.add(_amount);
stakedToken.safeTransferFrom(
address(msg.sender),
address(this),
_amount
);
user.firstDeposit = user.firstDeposit == 0
? block.timestamp
: user.firstDeposit;
}
user.rewardDebt1 = user
.amount
.mul(mapOfAccTokenPerShare[TOKEN1])
.div(mapOfPrecisionFactor[TOKEN1]);
user.rewardDebt2 = user
.amount
.mul(mapOfAccTokenPerShare[TOKEN2])
.div(mapOfPrecisionFactor[TOKEN2]);
emit Deposit(msg.sender, _amount);
}
| function deposit(uint256 _amount) external nonReentrant {
UserInfo storage user = userInfo[msg.sender];
_updatePool();
if (user.amount > 0) {
uint256 pendingToken1 = user
.amount
.mul(mapOfAccTokenPerShare[TOKEN1])
.div(mapOfPrecisionFactor[TOKEN1])
.sub(user.rewardDebt1);
if (pendingToken1 > 0) {
_safeTokenTransfer(
mapOfRewardTokens[TOKEN1],
msg.sender,
pendingToken1
);
}
uint256 pendingToken2 = user
.amount
.mul(mapOfAccTokenPerShare[TOKEN2])
.div(mapOfPrecisionFactor[TOKEN2])
.sub(user.rewardDebt2);
if (pendingToken2 > 0) {
_safeTokenTransfer(
mapOfRewardTokens[TOKEN2],
msg.sender,
pendingToken2
);
}
}
if (_amount > 0) {
user.amount = user.amount.add(_amount);
stakedToken.safeTransferFrom(
address(msg.sender),
address(this),
_amount
);
user.firstDeposit = user.firstDeposit == 0
? block.timestamp
: user.firstDeposit;
}
user.rewardDebt1 = user
.amount
.mul(mapOfAccTokenPerShare[TOKEN1])
.div(mapOfPrecisionFactor[TOKEN1]);
user.rewardDebt2 = user
.amount
.mul(mapOfAccTokenPerShare[TOKEN2])
.div(mapOfPrecisionFactor[TOKEN2]);
emit Deposit(msg.sender, _amount);
}
| 51,527 |
32 | // Divide wei between 3 and 6 matrixes | uint cost3 = msg.value / 2;
uint cost6 = msg.value - cost3;
| uint cost3 = msg.value / 2;
uint cost6 = msg.value - cost3;
| 21,688 |
32 | // 20: processed, but tx still open[ FINAL STATES >= 50 ]50: processed, costing done, tx settled60: rejected or error-ed, costing done, tx settled |
bool isxIPFS; // true: IPFS-augmented call (xIPFS); false: on-chain call
|
bool isxIPFS; // true: IPFS-augmented call (xIPFS); false: on-chain call
| 1,158 |
8 | // Set the computational speed limit for the chain | function setSpeedLimit(uint64 limit) external;
| function setSpeedLimit(uint64 limit) external;
| 16,635 |
11 | // newStartPrice The new start price | event NewStartPrice( uint128 newStartPrice );
| event NewStartPrice( uint128 newStartPrice );
| 21,217 |
372 | // round 18 | ark(i, q, 16894591341213863947423904025624185991098788054337051624251730868231322135455);
sbox_partial(i, q);
mix(i, q);
| ark(i, q, 16894591341213863947423904025624185991098788054337051624251730868231322135455);
sbox_partial(i, q);
mix(i, q);
| 51,198 |
92 | // Data part taken out for building of contracts that receive delegate calls | contract ERC20Data {
/// @notice owner > balance mapping.
mapping(address => uint256) public balanceOf;
/// @notice owner > spender > allowance mapping.
mapping(address => mapping(address => uint256)) public allowance;
/// @notice owner > nonce mapping. Used in `permit`.
mapping(address => uint256) public nonces;
}
| contract ERC20Data {
/// @notice owner > balance mapping.
mapping(address => uint256) public balanceOf;
/// @notice owner > spender > allowance mapping.
mapping(address => mapping(address => uint256)) public allowance;
/// @notice owner > nonce mapping. Used in `permit`.
mapping(address => uint256) public nonces;
}
| 6,249 |
270 | // if vault is partially liquidated (amount of short otoken is still greater than zero) make sure remaining collateral amount is greater than dust amount | if (vault.shortAmounts[0].sub(_args.amount) > 0) {
require(vault.collateralAmounts[0].sub(collateralToSell) >= collateralDust, "C34");
}
| if (vault.shortAmounts[0].sub(_args.amount) > 0) {
require(vault.collateralAmounts[0].sub(collateralToSell) >= collateralDust, "C34");
}
| 9,593 |
224 | // override base uri. It will be combined with token ID | function _baseURI() internal view override returns (string memory) {
return _baseURL;
}
| function _baseURI() internal view override returns (string memory) {
return _baseURL;
}
| 11,464 |
51 | // OperableCore The Operable contract enable the restrictions of operations to a set of operatorsCyril Lapinte - <cyril.lapinte@openfiz.com> Error messagesOC01: Sender is not a system operatorOC02: Sender is not a core operatorOC03: Sender is not a proxy operatorOC04: AllPrivileges is a reserved role / | contract OperableCore is Core, OperableStorage {
constructor() public {
operators[msg.sender].coreRole = ALL_PRIVILEGES;
operators[msg.sender].proxyRoles[ALL_PROXIES] = ALL_PRIVILEGES;
}
/**
* @dev onlySysOp modifier
* @dev for safety reason, core owner
* @dev can always define roles and assign or revoke operatos
*/
modifier onlySysOp() {
require(msg.sender == owner || hasCorePrivilege(msg.sender, msg.sig), "OC01");
_;
}
/**
* @dev onlyCoreOp modifier
*/
modifier onlyCoreOp() {
require(hasCorePrivilege(msg.sender, msg.sig), "OC02");
_;
}
/**
* @dev onlyProxyOp modifier
*/
modifier onlyProxyOp(address _proxy) {
require(hasProxyPrivilege(msg.sender, _proxy, msg.sig), "OC03");
_;
}
/**
* @dev defineRoles
* @param _role operator role
* @param _privileges as 4 bytes of the method
*/
function defineRole(bytes32 _role, bytes4[] memory _privileges)
public onlySysOp returns (bool)
{
require(_role != ALL_PRIVILEGES, "OC04");
delete roles[_role];
for (uint256 i=0; i < _privileges.length; i++) {
roles[_role].privileges[_privileges[i]] = true;
}
emit RoleDefined(_role);
return true;
}
/**
* @dev assignOperators
* @param _role operator role. May be a role not defined yet.
* @param _operators addresses
*/
function assignOperators(bytes32 _role, address[] memory _operators)
public onlySysOp returns (bool)
{
for (uint256 i=0; i < _operators.length; i++) {
operators[_operators[i]].coreRole = _role;
emit OperatorAssigned(_role, _operators[i]);
}
return true;
}
/**
* @dev assignProxyOperators
* @param _role operator role. May be a role not defined yet.
* @param _operators addresses
*/
function assignProxyOperators(
address _proxy, bytes32 _role, address[] memory _operators)
public onlySysOp returns (bool)
{
for (uint256 i=0; i < _operators.length; i++) {
operators[_operators[i]].proxyRoles[_proxy] = _role;
emit ProxyOperatorAssigned(_proxy, _role, _operators[i]);
}
return true;
}
/**
* @dev removeOperator
* @param _operators addresses
*/
function revokeOperators(address[] memory _operators)
public onlySysOp returns (bool)
{
for (uint256 i=0; i < _operators.length; i++) {
delete operators[_operators[i]];
emit OperatorRevoked(_operators[i]);
}
return true;
}
event RoleDefined(bytes32 role);
event OperatorAssigned(bytes32 role, address operator);
event ProxyOperatorAssigned(address proxy, bytes32 role, address operator);
event OperatorRevoked(address operator);
}
| contract OperableCore is Core, OperableStorage {
constructor() public {
operators[msg.sender].coreRole = ALL_PRIVILEGES;
operators[msg.sender].proxyRoles[ALL_PROXIES] = ALL_PRIVILEGES;
}
/**
* @dev onlySysOp modifier
* @dev for safety reason, core owner
* @dev can always define roles and assign or revoke operatos
*/
modifier onlySysOp() {
require(msg.sender == owner || hasCorePrivilege(msg.sender, msg.sig), "OC01");
_;
}
/**
* @dev onlyCoreOp modifier
*/
modifier onlyCoreOp() {
require(hasCorePrivilege(msg.sender, msg.sig), "OC02");
_;
}
/**
* @dev onlyProxyOp modifier
*/
modifier onlyProxyOp(address _proxy) {
require(hasProxyPrivilege(msg.sender, _proxy, msg.sig), "OC03");
_;
}
/**
* @dev defineRoles
* @param _role operator role
* @param _privileges as 4 bytes of the method
*/
function defineRole(bytes32 _role, bytes4[] memory _privileges)
public onlySysOp returns (bool)
{
require(_role != ALL_PRIVILEGES, "OC04");
delete roles[_role];
for (uint256 i=0; i < _privileges.length; i++) {
roles[_role].privileges[_privileges[i]] = true;
}
emit RoleDefined(_role);
return true;
}
/**
* @dev assignOperators
* @param _role operator role. May be a role not defined yet.
* @param _operators addresses
*/
function assignOperators(bytes32 _role, address[] memory _operators)
public onlySysOp returns (bool)
{
for (uint256 i=0; i < _operators.length; i++) {
operators[_operators[i]].coreRole = _role;
emit OperatorAssigned(_role, _operators[i]);
}
return true;
}
/**
* @dev assignProxyOperators
* @param _role operator role. May be a role not defined yet.
* @param _operators addresses
*/
function assignProxyOperators(
address _proxy, bytes32 _role, address[] memory _operators)
public onlySysOp returns (bool)
{
for (uint256 i=0; i < _operators.length; i++) {
operators[_operators[i]].proxyRoles[_proxy] = _role;
emit ProxyOperatorAssigned(_proxy, _role, _operators[i]);
}
return true;
}
/**
* @dev removeOperator
* @param _operators addresses
*/
function revokeOperators(address[] memory _operators)
public onlySysOp returns (bool)
{
for (uint256 i=0; i < _operators.length; i++) {
delete operators[_operators[i]];
emit OperatorRevoked(_operators[i]);
}
return true;
}
event RoleDefined(bytes32 role);
event OperatorAssigned(bytes32 role, address operator);
event ProxyOperatorAssigned(address proxy, bytes32 role, address operator);
event OperatorRevoked(address operator);
}
| 30,463 |
39 | // VIEW & PURE FUNCTIONS / | function _getAPrecise(Swap storage self) internal view returns (uint256) {
return AmplificationUtils._getAPrecise(self);
}
| function _getAPrecise(Swap storage self) internal view returns (uint256) {
return AmplificationUtils._getAPrecise(self);
}
| 45,136 |
7 | // Emitted after burn, notifies relays that transfer is happening/amount Amount of token burned/substrateRecipient Who should get tokens on substrate | event OutgoingReceipt(uint256 amount, bytes32 substrateRecipient);
| event OutgoingReceipt(uint256 amount, bytes32 substrateRecipient);
| 13,174 |
14 | // Check if the _pricePerToken needs to be overridden | if (_allowlistProof.pricePerToken > 0) {
_pricePerToken = _allowlistProof.pricePerToken;
}
| if (_allowlistProof.pricePerToken > 0) {
_pricePerToken = _allowlistProof.pricePerToken;
}
| 18,254 |
98 | // How much tokens we Swapped into | uint256 SwappedTokens = balanceOf(address(balancer));
uint256 rewardForCaller = SwappedTokens.mul(_rebalanceCallerFee).div(10**(_feeDecimal + 2));
uint256 amountToBurn = SwappedTokens.sub(rewardForCaller);
uint256 rate = _getReflectionRate();
_reflectionBalance[tx.origin] = _reflectionBalance[tx.origin].add(rewardForCaller.mul(rate));
_reflectionBalance[address(balancer)] = 0;
_burnFeeTotal = _burnFeeTotal.add(amountToBurn);
| uint256 SwappedTokens = balanceOf(address(balancer));
uint256 rewardForCaller = SwappedTokens.mul(_rebalanceCallerFee).div(10**(_feeDecimal + 2));
uint256 amountToBurn = SwappedTokens.sub(rewardForCaller);
uint256 rate = _getReflectionRate();
_reflectionBalance[tx.origin] = _reflectionBalance[tx.origin].add(rewardForCaller.mul(rate));
_reflectionBalance[address(balancer)] = 0;
_burnFeeTotal = _burnFeeTotal.add(amountToBurn);
| 28,642 |
71 | // usertx info | struct UserTx {
BaseTx baseTx;
uint tokenPairID;
uint value;
uint fee;
address userAccount; /// HTLC transaction sender address for the security check while user's revoke
}
| struct UserTx {
BaseTx baseTx;
uint tokenPairID;
uint value;
uint fee;
address userAccount; /// HTLC transaction sender address for the security check while user's revoke
}
| 36,129 |
39 | // Take DAI from the urn in case there is any in the Urn can be dealt with through migrate() after ES | function quit() public auth {
urn.quit();
}
| function quit() public auth {
urn.quit();
}
| 39,041 |
134 | // Before reward is minted, increment blockIssue in CerticolDAOVoC record | _vocRecords[msg.sender][target].blockIssue = _vocRecords[msg.sender][target].blockIssue.add(_posatRewardRequirement);
| _vocRecords[msg.sender][target].blockIssue = _vocRecords[msg.sender][target].blockIssue.add(_posatRewardRequirement);
| 51,489 |
67 | // Can be overridden to add finalization logic. The overriding functionshould call super.finalization() to ensure the chain of finalization isexecuted entirely. / | function finalization() internal {
}
| function finalization() internal {
}
| 25,759 |
144 | // Collects UNI tokens | IStakingRewards(rewards).getReward();
uint256 _uni = IERC20(uni).balanceOf(address(this));
if (_uni > 0) {
| IStakingRewards(rewards).getReward();
uint256 _uni = IERC20(uni).balanceOf(address(this));
if (_uni > 0) {
| 48,674 |
123 | // K值是固定常量,伪造amountIn没有意义 | if (src == NEST_TOKEN_ADDRESS && dest == DCU_TOKEN_ADDRESS) {
amountOut = _swap(NEST_TOKEN_ADDRESS, DCU_TOKEN_ADDRESS, to);
} else if (src == DCU_TOKEN_ADDRESS && dest == NEST_TOKEN_ADDRESS) {
| if (src == NEST_TOKEN_ADDRESS && dest == DCU_TOKEN_ADDRESS) {
amountOut = _swap(NEST_TOKEN_ADDRESS, DCU_TOKEN_ADDRESS, to);
} else if (src == DCU_TOKEN_ADDRESS && dest == NEST_TOKEN_ADDRESS) {
| 26,808 |
5 | // Maps each token id to a mapping that can enumerate all active quests within an adventure | mapping (uint256 => mapping (address => uint32[])) public activeQuestList;
| mapping (uint256 => mapping (address => uint32[])) public activeQuestList;
| 12,662 |
63 | // Shezmu | if (rewardInfo.pending > 0) {
IERC20(addressProvider.getShezmu()).safeTransfer(
_recipient,
rewardInfo.pending
);
delete rewardInfoOf[_depositId];
}
| if (rewardInfo.pending > 0) {
IERC20(addressProvider.getShezmu()).safeTransfer(
_recipient,
rewardInfo.pending
);
delete rewardInfoOf[_depositId];
}
| 7,108 |
1 | // RLP encodes a list of RLP encoded byte byte strings._in The list of RLP encoded byte strings. return The RLP encoded list of items in bytes. / | function writeList(bytes[] memory _in) internal pure returns (bytes memory) {
bytes memory list = _flatten(_in);
return abi.encodePacked(_writeLength(list.length, 192), list);
}
| function writeList(bytes[] memory _in) internal pure returns (bytes memory) {
bytes memory list = _flatten(_in);
return abi.encodePacked(_writeLength(list.length, 192), list);
}
| 19,624 |
4 | // nftPerAddressLimit: mint amount of token per address limittokenBalanceOf: token balance minted by input address / | uint256 public nftPerAddressLimit = 100;
| uint256 public nftPerAddressLimit = 100;
| 16,496 |
240 | // if `returnedFund` is negative, trader can't get anything back | if (returnedFund.toInt() > 0) {
settledValue = returnedFund.abs();
}
| if (returnedFund.toInt() > 0) {
settledValue = returnedFund.abs();
}
| 30,832 |
38 | // Performs a Solidity function call using a low level `call`. Aplain `call` is an unsafe replacement for a function call: use thisfunction instead. If `target` reverts with a revert reason, it is bubbled up by thisfunction (like regular Solidity function calls). Returns the raw returned data. To convert to the expected return value, Requirements: - `target` must be a contract.- calling `target` with `data` must not revert. _Available since v3.1._ / | function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
| function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
| 122 |
1 | // transfer ETH from the contract to the caller | function withdraw(uint256 amount) external {
msg.sender.transfer(amount);
}
| function withdraw(uint256 amount) external {
msg.sender.transfer(amount);
}
| 4,763 |
53 | // Mask of all 256 bits in packed address data except the 64 bits for `aux`. | uint256 private constant _BITMASK_AUX_COMPLEMENT = (1 << 192) - 1;
| uint256 private constant _BITMASK_AUX_COMPLEMENT = (1 << 192) - 1;
| 331 |
13 | // Decreases the amount of liquidity in a position and accounts it to the position/params tokenId The ID of the token for which liquidity is being decreased,/ amount The amount by which liquidity will be decreased,/ amount0Min The minimum amount of token0 that should be accounted for the burned liquidity,/ amount1Min The minimum amount of token1 that should be accounted for the burned liquidity,/ deadline The time by which the transaction must be included to effect the change/ return amount0 The amount of token0 accounted to the position's tokens owed/ return amount1 The amount of token1 accounted to the position's tokens | function decreaseLiquidity(DecreaseLiquidityParams calldata params) external payable returns (uint256 amount0, uint256 amount1);
| function decreaseLiquidity(DecreaseLiquidityParams calldata params) external payable returns (uint256 amount0, uint256 amount1);
| 18,965 |
379 | // 获得赎回了多少代币 | uint redeemBal = self.balance;
| uint redeemBal = self.balance;
| 30,127 |
21 | // randomWords looks like this uint256: 68187645017388103597074813724954069904348581739269924188458647203960383435815 |
console.log("Fulfilling random Words by RandomWordFunction");
string[] memory urisForTrend = currentMarketTrend == MarketTrend.BULL ? bullUrisIpfs : bearUrisIpfs;
uint256 idx = randomWords[0] % urisForTrend.length; // use modulo to choose a random index.
for (uint i = 0; i < _tokenIdCounter.current() ; i++) {
_setTokenURI(i, urisForTrend[idx]);
}
|
console.log("Fulfilling random Words by RandomWordFunction");
string[] memory urisForTrend = currentMarketTrend == MarketTrend.BULL ? bullUrisIpfs : bearUrisIpfs;
uint256 idx = randomWords[0] % urisForTrend.length; // use modulo to choose a random index.
for (uint i = 0; i < _tokenIdCounter.current() ; i++) {
_setTokenURI(i, urisForTrend[idx]);
}
| 12,458 |
57 | // solium-disable-next-line arg-overflow | safeTransferFrom(_from, _to, _tokenId, "");
| safeTransferFrom(_from, _to, _tokenId, "");
| 26,296 |
172 | // hash_t4f6p52 |
struct HashInputs4
|
struct HashInputs4
| 47,526 |
11 | // To change the approve amount you first have to reduce the addresses&39;s allowance to zero | if (_value != 0 && allowed[msg.sender][_spender] != 0) {
return false;
}
| if (_value != 0 && allowed[msg.sender][_spender] != 0) {
return false;
}
| 30,695 |
59 | // erc20TokenAddress the wrapped ERC20 Token address you want to know info aboutreturn objectId the id in the collection which correspondes to the given erc20TokenAddress / | function object(address erc20TokenAddress) external view returns (uint256 objectId);
| function object(address erc20TokenAddress) external view returns (uint256 objectId);
| 6,990 |
36 | // Set Chainlink Oracle's job id -> http get > uint256 job / | function setChainJobId(string memory _jobId) public onlyOwner{
JOBID = _jobId;
}
| function setChainJobId(string memory _jobId) public onlyOwner{
JOBID = _jobId;
}
| 34,071 |
3 | // solhint-disable-next-line var-name-mixedcase | bytes4 immutable private _MAX_SELECTOR = bytes4(uint32(IERC20.transferFrom.selector) + 10);
uint256 constant private _FROM_INDEX = 0;
uint256 constant private _TO_INDEX = 1;
uint256 constant private _AMOUNT_INDEX = 2;
mapping(bytes32 => uint256) private _remaining;
mapping(address => mapping(uint256 => uint256)) private _invalidator;
| bytes4 immutable private _MAX_SELECTOR = bytes4(uint32(IERC20.transferFrom.selector) + 10);
uint256 constant private _FROM_INDEX = 0;
uint256 constant private _TO_INDEX = 1;
uint256 constant private _AMOUNT_INDEX = 2;
mapping(bytes32 => uint256) private _remaining;
mapping(address => mapping(uint256 => uint256)) private _invalidator;
| 12,861 |
176 | // For refunds, the numerator is the negative of the bid case. | if (refund) {
(bidsPerPrice, _deposited) = (_deposited, bidsPerPrice);
}
| if (refund) {
(bidsPerPrice, _deposited) = (_deposited, bidsPerPrice);
}
| 36,893 |
224 | // assign reward for posting to creator | owner_pending_posts[memes[_id].owner].push(_id);
total_pending_rewards[memes[_id].owner] += posting.amount_owner;
post_rewards_status[_id] = 1;
| owner_pending_posts[memes[_id].owner].push(_id);
total_pending_rewards[memes[_id].owner] += posting.amount_owner;
post_rewards_status[_id] = 1;
| 36,397 |
158 | // See {IERC721Enumerable-totalSupply}. / | function totalSupply() public view virtual override returns (uint256) {
return _allTokens.length;
}
| function totalSupply() public view virtual override returns (uint256) {
return _allTokens.length;
}
| 5,654 |
156 | // Transfer any leftover dust back to the vault buffer. | uint256 dust = IERC20(_asset).balanceOf(address(this));
if (dust > 0) {
IERC20(_asset).safeTransfer(vaultAddress, dust);
}
| uint256 dust = IERC20(_asset).balanceOf(address(this));
if (dust > 0) {
IERC20(_asset).safeTransfer(vaultAddress, dust);
}
| 43,336 |
48 | // Get token info | TokenType listTokenType = getTokenType(_param.assetContract);
| TokenType listTokenType = getTokenType(_param.assetContract);
| 30,050 |
722 | // Now use Newton-Raphson itteration to improve the precision. We want to find the root of the equation: f(x) = x - 1 / d (where d = denominator) Newton-Rhapson itteration then is f(x)d - 1 / xx' = x -------- = x - ----------- = x(2 - dx) f'(x)1 / x^2 Thanks to Hensel's lifting lemma, this also works in modular arithmetic. Each itteration will double the number of correct bits. Counter-intuitively, this works from least significant bits upwards. | inv := mul(inv, sub(2, mul(denominator, inv))) // inverse mod 2^8
inv := mul(inv, sub(2, mul(denominator, inv))) // inverse mod 2^16
inv := mul(inv, sub(2, mul(denominator, inv))) // inverse mod 2^32
inv := mul(inv, sub(2, mul(denominator, inv))) // inverse mod 2^64
inv := mul(inv, sub(2, mul(denominator, inv))) // inverse mod 2^128
inv := mul(inv, sub(2, mul(denominator, inv))) // inverse mod 2^256
| inv := mul(inv, sub(2, mul(denominator, inv))) // inverse mod 2^8
inv := mul(inv, sub(2, mul(denominator, inv))) // inverse mod 2^16
inv := mul(inv, sub(2, mul(denominator, inv))) // inverse mod 2^32
inv := mul(inv, sub(2, mul(denominator, inv))) // inverse mod 2^64
inv := mul(inv, sub(2, mul(denominator, inv))) // inverse mod 2^128
inv := mul(inv, sub(2, mul(denominator, inv))) // inverse mod 2^256
| 71,639 |
4 | // In addition to the current interfaceId, also support previous version of the interfaceId that did not include the castVoteWithReasonAndParams() function as standard | return
interfaceId == type(IERC721ReceiverUpgradeable).interfaceId ||
interfaceId == type(IERC1155ReceiverUpgradeable).interfaceId ||
super.supportsInterface(interfaceId);
| return
interfaceId == type(IERC721ReceiverUpgradeable).interfaceId ||
interfaceId == type(IERC1155ReceiverUpgradeable).interfaceId ||
super.supportsInterface(interfaceId);
| 21,644 |
209 | // Hardcode the Manager's approval so that users don't have to waste gas approving | if (_msgSender() != address(staking))
require(
_isApprovedOrOwner(_msgSender(), tokenId),
"ERC721: transfer caller is not owner nor approved"
);
_transfer(from, to, tokenId);
| if (_msgSender() != address(staking))
require(
_isApprovedOrOwner(_msgSender(), tokenId),
"ERC721: transfer caller is not owner nor approved"
);
_transfer(from, to, tokenId);
| 42,920 |
13 | // Public Sale Mint / | function publicSaleMint(uint256 numberOfTokens) external payable whenNotPaused {
require(isMintingActive, "Public Sale minting is not active yet.");
require(numberOfTokens <= 20, "Too many requested");
require(CLAIMED_SUPPLY + numberOfTokens < TOTAL_SUPPLY, "Purchase would exceed max tokens");
require(msg.sender == tx.origin, "You are not a real person.");
require(MINTING_PRICE * numberOfTokens <= msg.value, "Ether value sent is not correct");
CLAIMED_SUPPLY += numberOfTokens;
for(uint i = 0; i < numberOfTokens; i++) {
safeMint(msg.sender);
}
}
| function publicSaleMint(uint256 numberOfTokens) external payable whenNotPaused {
require(isMintingActive, "Public Sale minting is not active yet.");
require(numberOfTokens <= 20, "Too many requested");
require(CLAIMED_SUPPLY + numberOfTokens < TOTAL_SUPPLY, "Purchase would exceed max tokens");
require(msg.sender == tx.origin, "You are not a real person.");
require(MINTING_PRICE * numberOfTokens <= msg.value, "Ether value sent is not correct");
CLAIMED_SUPPLY += numberOfTokens;
for(uint i = 0; i < numberOfTokens; i++) {
safeMint(msg.sender);
}
}
| 76,884 |
37 | // Emitted when the buy out is triggered on an auction. auctionId : The id of the auction this bid was for. buyer : The buyer who triggered the buyOut. buyOutAmount: The amount of the bid. / | event AuctionSellingAgreementBuyOutTriggered(
uint256 indexed auctionId,
address indexed buyer,
| event AuctionSellingAgreementBuyOutTriggered(
uint256 indexed auctionId,
address indexed buyer,
| 18,410 |
23 | // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of the merkle tree. | uint256 leavesLen = leaves.length;
uint256 totalHashes = proofFlags.length;
| uint256 leavesLen = leaves.length;
uint256 totalHashes = proofFlags.length;
| 6,835 |
165 | // Returns the number of tokens minted by `owner`. / | function _numberMinted(address owner) internal view returns (uint256) {
if (owner == address(0)) revert MintedQueryForZeroAddress();
return uint256(_addressData[owner].numberMinted);
}
| function _numberMinted(address owner) internal view returns (uint256) {
if (owner == address(0)) revert MintedQueryForZeroAddress();
return uint256(_addressData[owner].numberMinted);
}
| 6,652 |
6 | // Current amount of snails given to new players | uint256 public startingSnailAmount = STARTING_SNAIL;
| uint256 public startingSnailAmount = STARTING_SNAIL;
| 38,366 |
102 | // Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver recipient address The address which you want to transfer to amount uint256 The amount of tokens to be transferred data bytes Additional data with no specified format, sent in call to `recipient`return true unless throwing / | function transferAndCall(
address recipient,
uint256 amount,
bytes calldata data
) external returns (bool);
| function transferAndCall(
address recipient,
uint256 amount,
bytes calldata data
) external returns (bool);
| 11,763 |
159 | // Check that matron and sire are both owned by caller, or that the sire has given siring permission to caller (i.e. matron's owner). Will fail for _sireId = 0 | require(_isSiringPermitted(_sireId, _matronId));
| require(_isSiringPermitted(_sireId, _matronId));
| 14,624 |
0 | // Unofficial Turnstile interface/This interface is used as part of the csrCANTO related contracts/This minimal interface can be reused for contracts registration to the CSR | interface ICanto_Turnstile {
/// @notice Mints ownership NFT that allows the owner to collect fees earned by the smart contract.
/// `msg.sender` is assumed to be a smart contract that earns fees. Only smart contract itself
/// can register a fee receipient.
/// @param _recipient recipient of the ownership NFT
/// @return tokenId of the ownership NFT that collects fees
function register(address _recipient) external returns (uint256);
/// @notice Assigns smart contract to existing NFT. That NFT will collect fees generated by the smart contract.
/// Callable only by smart contract itself.
/// @param _tokenId tokenId which will collect fees
/// @return tokenId of the ownership NFT that collects fees
function assign(uint256 _tokenId) external returns (uint256);
/// @notice Returns tokenId that collects fees generated by the smart contract
/// @param _smartContract address of the smart contract
/// @return tokenId that collects fees generated by the smart contract
function getTokenId(address _smartContract) external view returns (uint256);
/// @notice Withdraws earned fees to `_recipient` address. Only callable by NFT owner.
/// @param _tokenId token Id
/// @param _recipient recipient of fees
/// @param _amount amount of fees to withdraw
/// @return amount of fees withdrawn
function withdraw(
uint256 _tokenId,
address _recipient,
uint256 _amount
) external returns (uint256);
/// @notice maps tokenId to fees earned
function balances(uint256 _tokenId) external view returns (uint256);
} | interface ICanto_Turnstile {
/// @notice Mints ownership NFT that allows the owner to collect fees earned by the smart contract.
/// `msg.sender` is assumed to be a smart contract that earns fees. Only smart contract itself
/// can register a fee receipient.
/// @param _recipient recipient of the ownership NFT
/// @return tokenId of the ownership NFT that collects fees
function register(address _recipient) external returns (uint256);
/// @notice Assigns smart contract to existing NFT. That NFT will collect fees generated by the smart contract.
/// Callable only by smart contract itself.
/// @param _tokenId tokenId which will collect fees
/// @return tokenId of the ownership NFT that collects fees
function assign(uint256 _tokenId) external returns (uint256);
/// @notice Returns tokenId that collects fees generated by the smart contract
/// @param _smartContract address of the smart contract
/// @return tokenId that collects fees generated by the smart contract
function getTokenId(address _smartContract) external view returns (uint256);
/// @notice Withdraws earned fees to `_recipient` address. Only callable by NFT owner.
/// @param _tokenId token Id
/// @param _recipient recipient of fees
/// @param _amount amount of fees to withdraw
/// @return amount of fees withdrawn
function withdraw(
uint256 _tokenId,
address _recipient,
uint256 _amount
) external returns (uint256);
/// @notice maps tokenId to fees earned
function balances(uint256 _tokenId) external view returns (uint256);
} | 15,556 |
38 | // Hardcode the Manager's approval so that users don't have to waste gas approving | if (_msgSender() != address(castle))
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
| if (_msgSender() != address(castle))
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
| 22,376 |
9 | // Max harvest interval: 14 days. | uint256 public constant MAXIMUM_HARVEST_INTERVAL = 14 days;
| uint256 public constant MAXIMUM_HARVEST_INTERVAL = 14 days;
| 9,734 |
26 | // check a vote isn't active | if (!proposal.onVote) {
require(
validateProposedContract(proposalType, proposalAddress) == true,
"The proposed contract did not operate as expected"
);
proposal.onVote = true; // put proposal on vote, no changes until vote is setteled or removed
proposal.proposalAddress = proposalAddress; // set new proposal for vote
proposal.proposalType = proposalType; // set type of proposal vote
proposal.proposalHeight = block.number; // set new proposal initial height
delete proposal.votes; // clear votes
| if (!proposal.onVote) {
require(
validateProposedContract(proposalType, proposalAddress) == true,
"The proposed contract did not operate as expected"
);
proposal.onVote = true; // put proposal on vote, no changes until vote is setteled or removed
proposal.proposalAddress = proposalAddress; // set new proposal for vote
proposal.proposalType = proposalType; // set type of proposal vote
proposal.proposalHeight = block.number; // set new proposal initial height
delete proposal.votes; // clear votes
| 12,945 |
340 | // Move the last value to the index where the value to delete is | set._values[toDeleteIndex] = lastvalue;
| set._values[toDeleteIndex] = lastvalue;
| 28,675 |
43 | // read 3 bytes | let input := mload(dataPtr)
| let input := mload(dataPtr)
| 15,394 |
63 | // Increase the GUNIV3DAIUSDC1-A Debt Ceiling - October 11, 2021https:vote.makerdao.com/polling/QmU6fTQx?network=mainnetpoll-detail | DssExecLib.setIlkAutoLineParameters("GUNIV3DAIUSDC1-A", 50 * MILLION, 10 * MILLION, 8 hours);
| DssExecLib.setIlkAutoLineParameters("GUNIV3DAIUSDC1-A", 50 * MILLION, 10 * MILLION, 8 hours);
| 12,186 |
16 | // Lifts the ban on transfers for given addresses/ | function restrict(address [] _restricted) external onlyAuthorized returns (bool) {
for (uint i = 0; i < _restricted.length; i++) {
blacklist[_restricted[i]] = true;
}
return true;
}
| function restrict(address [] _restricted) external onlyAuthorized returns (bool) {
for (uint i = 0; i < _restricted.length; i++) {
blacklist[_restricted[i]] = true;
}
return true;
}
| 44,981 |
180 | // return The associated Initial Reporter or a Dispute Crowdsourcer contract for the current tentative winning payout / | function getWinningReportingParticipant() public view returns (IReportingParticipant) {
return participants[participants.length-1];
}
| function getWinningReportingParticipant() public view returns (IReportingParticipant) {
return participants[participants.length-1];
}
| 4,355 |
19 | // ID for the Axon (ERC721 token ID) | uint256 axonId;
| uint256 axonId;
| 15,746 |
2 | // AErc20Interface Aegis / | contract AErc20Interface is AErc20Common {
function mint(uint _mintAmount) external returns (uint);
function redeem(uint _redeemTokens) external returns (uint);
function redeemUnderlying(uint _redeemAmount) external returns (uint);
function borrow(uint _borrowAmount) external returns (uint);
function repayBorrow(uint _repayAmount) external returns (uint);
function repayBorrowBehalf(address _borrower, uint _repayAmount) external returns (uint);
function _addReserves(uint addAmount) external returns (uint);
} | contract AErc20Interface is AErc20Common {
function mint(uint _mintAmount) external returns (uint);
function redeem(uint _redeemTokens) external returns (uint);
function redeemUnderlying(uint _redeemAmount) external returns (uint);
function borrow(uint _borrowAmount) external returns (uint);
function repayBorrow(uint _repayAmount) external returns (uint);
function repayBorrowBehalf(address _borrower, uint _repayAmount) external returns (uint);
function _addReserves(uint addAmount) external returns (uint);
} | 20,936 |
29 | // Buy insurance for a flight/ | function buy
(
address airline,
address passenger,
string flight,
uint256 amount,
uint256 payout
)
external
payable
| function buy
(
address airline,
address passenger,
string flight,
uint256 amount,
uint256 payout
)
external
payable
| 16,756 |
199 | // Event fired when a new digital media is created. No point in returning printIndex since its always zero when created. | event DigitalMediaCreateEvent(
uint256 id,
address creator,
uint32 totalSupply,
uint32 royalty,
bool immutableMedia,
string metadataPath);
event DigitalMediaReleaseCreateEvent(
uint256 id,
| event DigitalMediaCreateEvent(
uint256 id,
address creator,
uint32 totalSupply,
uint32 royalty,
bool immutableMedia,
string metadataPath);
event DigitalMediaReleaseCreateEvent(
uint256 id,
| 54,146 |
370 | // Returns the minimum price available | function _getWantTokenPrice() internal view returns (uint256) {
// Use price from spotter as base
uint256 minPrice = MakerDaiDelegateLib.getSpotPrice(ilk);
// Peek the OSM to get current price
try wantToUSDOSMProxy.read() returns (
uint256 current,
bool currentIsValid
) {
if (currentIsValid && current > 0) {
minPrice = Math.min(minPrice, current);
}
} catch {
// Ignore price peek()'d from OSM. Maybe we are no longer authorized.
}
// Peep the OSM to get future price
try wantToUSDOSMProxy.foresight() returns (
uint256 future,
bool futureIsValid
) {
if (futureIsValid && future > 0) {
minPrice = Math.min(minPrice, future);
}
} catch {
// Ignore price peep()'d from OSM. Maybe we are no longer authorized.
}
// If price is set to 0 then we hope no liquidations are taking place
// Emergency scenarios can be handled via manual debt repayment or by
// granting governance access to the CDP
require(minPrice > 0); // dev: invalid spot price
// par is crucial to this calculation as it defines the relationship between DAI and
// 1 unit of value in the price
return minPrice.mul(RAY).div(MakerDaiDelegateLib.getDaiPar());
}
| function _getWantTokenPrice() internal view returns (uint256) {
// Use price from spotter as base
uint256 minPrice = MakerDaiDelegateLib.getSpotPrice(ilk);
// Peek the OSM to get current price
try wantToUSDOSMProxy.read() returns (
uint256 current,
bool currentIsValid
) {
if (currentIsValid && current > 0) {
minPrice = Math.min(minPrice, current);
}
} catch {
// Ignore price peek()'d from OSM. Maybe we are no longer authorized.
}
// Peep the OSM to get future price
try wantToUSDOSMProxy.foresight() returns (
uint256 future,
bool futureIsValid
) {
if (futureIsValid && future > 0) {
minPrice = Math.min(minPrice, future);
}
} catch {
// Ignore price peep()'d from OSM. Maybe we are no longer authorized.
}
// If price is set to 0 then we hope no liquidations are taking place
// Emergency scenarios can be handled via manual debt repayment or by
// granting governance access to the CDP
require(minPrice > 0); // dev: invalid spot price
// par is crucial to this calculation as it defines the relationship between DAI and
// 1 unit of value in the price
return minPrice.mul(RAY).div(MakerDaiDelegateLib.getDaiPar());
}
| 3,435 |
78 | // Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier/ Address of lock flag variable./ Flag is placed at random memory location to not interfere with Storage contract. | uint constant private LOCK_FLAG_ADDRESS = 0x8e94fed44239eb2314ab7a406345e6c5a8f0ccedf3b600de3d004e672c33abf4; // keccak256("ReentrancyGuard") - 1;
function initializeReentrancyGuard () internal {
| uint constant private LOCK_FLAG_ADDRESS = 0x8e94fed44239eb2314ab7a406345e6c5a8f0ccedf3b600de3d004e672c33abf4; // keccak256("ReentrancyGuard") - 1;
function initializeReentrancyGuard () internal {
| 22,406 |
109 | // Get the current action state of an action by its `actionInfo` struct./actionInfo Data required to create an action./ return The current action state of the action. | function getActionState(ActionInfo calldata actionInfo) public view returns (ActionState) {
// We don't need an explicit check on the action ID to make sure it exists, because if the
// action does not exist, the expected payload hash from storage will be `bytes32(0)`, so
// bypassing this check by providing a non-existent actionId would require finding a collision
// to get a hash of zero.
Action storage action = actions[actionInfo.id];
_validateActionInfoHash(action.infoHash, actionInfo);
if (action.canceled) return ActionState.Canceled;
if (action.executed) return ActionState.Executed;
if (actionInfo.strategy.isActionActive(actionInfo)) return ActionState.Active;
if (!actionInfo.strategy.isActionApproved(actionInfo)) return ActionState.Failed;
if (action.minExecutionTime == 0) return ActionState.Approved;
if (actionInfo.strategy.isActionDisapproved(actionInfo)) return ActionState.Failed;
if (actionInfo.strategy.isActionExpired(actionInfo)) return ActionState.Expired;
return ActionState.Queued;
}
| function getActionState(ActionInfo calldata actionInfo) public view returns (ActionState) {
// We don't need an explicit check on the action ID to make sure it exists, because if the
// action does not exist, the expected payload hash from storage will be `bytes32(0)`, so
// bypassing this check by providing a non-existent actionId would require finding a collision
// to get a hash of zero.
Action storage action = actions[actionInfo.id];
_validateActionInfoHash(action.infoHash, actionInfo);
if (action.canceled) return ActionState.Canceled;
if (action.executed) return ActionState.Executed;
if (actionInfo.strategy.isActionActive(actionInfo)) return ActionState.Active;
if (!actionInfo.strategy.isActionApproved(actionInfo)) return ActionState.Failed;
if (action.minExecutionTime == 0) return ActionState.Approved;
if (actionInfo.strategy.isActionDisapproved(actionInfo)) return ActionState.Failed;
if (actionInfo.strategy.isActionExpired(actionInfo)) return ActionState.Expired;
return ActionState.Queued;
}
| 33,760 |
20 | // block when the match ended | uint256 endBlock;
| uint256 endBlock;
| 32,379 |
112 | // Add new token gauge | function addGauge(address _token) external onlyBenevolent {
require(gauges[_token] == address(0x0), "exists");
gauges[_token] = address(new GaugeV2(_token, governance));
_tokens.push(_token);
}
| function addGauge(address _token) external onlyBenevolent {
require(gauges[_token] == address(0x0), "exists");
gauges[_token] = address(new GaugeV2(_token, governance));
_tokens.push(_token);
}
| 630 |
22 | // The token which is already deployed to the network | ERC20Basic public token;
event AirDroppedTokens(uint256 addressCount);
event AirDrop(address indexed receiver, uint256 total);
| ERC20Basic public token;
event AirDroppedTokens(uint256 addressCount);
event AirDrop(address indexed receiver, uint256 total);
| 43,626 |
31 | // Hashes a commitment / | function hashCommitment(CommitmentPreimage memory _commitmentPreimage)
public
pure
returns (bytes32)
| function hashCommitment(CommitmentPreimage memory _commitmentPreimage)
public
pure
returns (bytes32)
| 17,290 |
19 | // query the available amount of LINK to withdraw by msg.sender / | function withdrawable() external view returns (uint256);
| function withdrawable() external view returns (uint256);
| 21,060 |
27 | // nftID ID of nft token / | function getNft(uint32 nftID) external override responsible view returns(Punk, address collector) {
return {flag: 64} (tokens[nftID], nftOwner[nftID]);
}
| function getNft(uint32 nftID) external override responsible view returns(Punk, address collector) {
return {flag: 64} (tokens[nftID], nftOwner[nftID]);
}
| 26,166 |
274 | // Check if `account` has operator role | require(hasRole(OPERATOR_ROLE, account), "StakePool#removeOperator: NO_OPERATOR_ROLE");
revokeRole(OPERATOR_ROLE, account);
| require(hasRole(OPERATOR_ROLE, account), "StakePool#removeOperator: NO_OPERATOR_ROLE");
revokeRole(OPERATOR_ROLE, account);
| 26,834 |
7 | // get user and balance | address a = dataAddress[__i(i, "tokenHolder")];
uint256 bal = dataUint256[__a(a, "tokenBalance")];
| address a = dataAddress[__i(i, "tokenHolder")];
uint256 bal = dataUint256[__a(a, "tokenBalance")];
| 47,060 |
98 | // Recipient is a module, governed by mStable governance / | {
rewardsDistributor = _rewardsDistributor;
}
| {
rewardsDistributor = _rewardsDistributor;
}
| 5,461 |
3 | // Store the mapping between the wearable NFT tokenId and the parent NFT tokenId | mapping(uint256 => uint256) public wearableTokenIdToParentTokenId;
| mapping(uint256 => uint256) public wearableTokenIdToParentTokenId;
| 2,813 |
7 | // Returns the time when the tokens are released in seconds since Unix epoch (i.e. Unix timestamp). / | function releaseTime() public view virtual returns (uint256) {
return _releaseTime;
}
| function releaseTime() public view virtual returns (uint256) {
return _releaseTime;
}
| 25,531 |
6 | // Addresses can set their name when composing jingles | function setAuthorName(string _name) public {
authors[msg.sender] = _name;
}
| function setAuthorName(string _name) public {
authors[msg.sender] = _name;
}
| 3,271 |
76 | // Withdraw available ethers into beneficiary account, serves as a safety, should never be needed / | function ownerSafeWithdrawal() external onlyOwner {
beneficiary.transfer(this.balance);
}
| function ownerSafeWithdrawal() external onlyOwner {
beneficiary.transfer(this.balance);
}
| 17,537 |
344 | // add unlent balance | total = total.add(_contractBalanceOf(token));
| total = total.add(_contractBalanceOf(token));
| 22,589 |
215 | // Starts at 0 and is set to the block at which the objection period ends when the objection period is initiated | uint64 objectionPeriodEndBlock;
| uint64 objectionPeriodEndBlock;
| 4,956 |
6 | // Burn address | address public constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD;
| address public constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD;
| 241 |
40 | // Mapping of index of component -> user address -> balance | mapping(uint => mapping(address => uint)) internal unredeemedBalances;
| mapping(uint => mapping(address => uint)) internal unredeemedBalances;
| 32,729 |
1 | // this runs when the contract is executed / | constructor() public {
// initialize the variables
}
| constructor() public {
// initialize the variables
}
| 46,239 |
33 | // Save the miner and value received | self.currentMiners[self.uintVars[keccak256("slotProgress")]].value = _value;
self.currentMiners[self.uintVars[keccak256("slotProgress")]].miner = msg.sender;
| self.currentMiners[self.uintVars[keccak256("slotProgress")]].value = _value;
self.currentMiners[self.uintVars[keccak256("slotProgress")]].miner = msg.sender;
| 11,785 |
4 | // mapping of users' address and their upline address,/ which means the value address that referred the key address./ user should be invited by unique upline address,/ and user can invite many other addresses. | mapping(address => address) public usersUpline;
| mapping(address => address) public usersUpline;
| 35,585 |
19 | // emit an event to announce the deal has been closed | emit DealClosed(_d);
| emit DealClosed(_d);
| 30,698 |
9 | // Note: this could be made external in a utility contract if addressCache was made public (used for deployment) | function isResolverCached(AddressResolver _resolver) external view returns (bool) {
if (resolver != _resolver) {
return false;
}
// otherwise, check everything
for (uint i = 0; i < resolverAddressesRequired.length; i++) {
bytes32 name = resolverAddressesRequired[i];
// false if our cache is invalid or if the resolver doesn't have the required address
if (resolver.getAddress(name) != addressCache[name] || addressCache[name] == address(0)) {
return false;
}
}
return true;
}
| function isResolverCached(AddressResolver _resolver) external view returns (bool) {
if (resolver != _resolver) {
return false;
}
// otherwise, check everything
for (uint i = 0; i < resolverAddressesRequired.length; i++) {
bytes32 name = resolverAddressesRequired[i];
// false if our cache is invalid or if the resolver doesn't have the required address
if (resolver.getAddress(name) != addressCache[name] || addressCache[name] == address(0)) {
return false;
}
}
return true;
}
| 39,283 |
41 | // Registers a new version with its implementation address version representing the version name of the new implementation to be registered implementation representing the address of the new implementation to be registered / | function addVersion(
string contractName,
string version,
address implementation
)
public
onlyCoreDev
| function addVersion(
string contractName,
string version,
address implementation
)
public
onlyCoreDev
| 37,538 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.