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 |
|---|---|---|---|---|
76 | // Determine the amount of coverage left for a specific protocol. _protocol The address of the protocol we're determining coverage left for./ | returns (uint256) {
(/* uint256 shield */, uint256 allowed) = _checkBuyerAllowed(_protocol);
return allowed;
}
| returns (uint256) {
(/* uint256 shield */, uint256 allowed) = _checkBuyerAllowed(_protocol);
return allowed;
}
| 26,730 |
25 | // Define Types.Order | sellOrder.nonce = airswapNonce++;
sellOrder.expiry = block.timestamp + 1 days;
sellOrder.signer = signer;
sellOrder.sender = sender;
ISwap(exchange).swap(sellOrder);
| sellOrder.nonce = airswapNonce++;
sellOrder.expiry = block.timestamp + 1 days;
sellOrder.signer = signer;
sellOrder.sender = sender;
ISwap(exchange).swap(sellOrder);
| 13,911 |
7 | // get a claim corresponding to a creator contract and instanceId creatorContractAddressthe address of the creator contract instanceIdthe claim instanceId for the creator contractreturnthe claim object / | function getClaim(address creatorContractAddress, uint256 instanceId) external view returns(Claim memory);
| function getClaim(address creatorContractAddress, uint256 instanceId) external view returns(Claim memory);
| 23,099 |
52 | // get balance of caller | uint256 bal = _balances[msg.sender];
require(bal >= nHoldings && bal > 0, "Zero Holdings");
| uint256 bal = _balances[msg.sender];
require(bal >= nHoldings && bal > 0, "Zero Holdings");
| 29,614 |
156 | // returns the address of the LendingPoolConfigurator proxy return the lending pool configurator proxy address/ | function getLendingPoolConfigurator() public view returns (address) {
return getAddress(LENDING_POOL_CONFIGURATOR);
}
| function getLendingPoolConfigurator() public view returns (address) {
return getAddress(LENDING_POOL_CONFIGURATOR);
}
| 34,813 |
162 | // Issue a new NFT of the specified kind. that will throw if kind has reached its maximum or is invalid _beneficiary - owner of the token _optionId - option id _issuedId - issued id / | function issueToken(address _beneficiary, uint256 _optionId, uint256 _issuedId) external onlyAllowed {
_issueToken(_beneficiary, _optionId, _issuedId);
}
| function issueToken(address _beneficiary, uint256 _optionId, uint256 _issuedId) external onlyAllowed {
_issueToken(_beneficiary, _optionId, _issuedId);
}
| 57,640 |
18 | // src Pointer to source dest Pointer to destination len Amount of memory to copy from the source / | function copy(
uint256 src,
uint256 dest,
uint256 len
| function copy(
uint256 src,
uint256 dest,
uint256 len
| 36,729 |
75 | // Add new totals for new protocol/cover amounts. _newProtocols Protocols that are being borrowed for. _newCoverAmounts Cover amounts (in Wei) that are being borrowed./ | function _addNewTotals(address[] memory _newProtocols, uint256[] memory _newCoverAmounts) internal {
for (uint256 i = 0; i < _newProtocols.length; i++) {
(uint256 shield, uint256 allowed) = _checkBuyerAllowed(_newProtocols[i]);
require(allowed >= _newCoverAmounts[i], "Ex... | function _addNewTotals(address[] memory _newProtocols, uint256[] memory _newCoverAmounts) internal {
for (uint256 i = 0; i < _newProtocols.length; i++) {
(uint256 shield, uint256 allowed) = _checkBuyerAllowed(_newProtocols[i]);
require(allowed >= _newCoverAmounts[i], "Ex... | 26,729 |
203 | // verify the provided _merkleProof | bytes32 leaf = keccak256(abi.encodePacked(msg.sender));
require(MerkleProof.verify(_merkleProof, merkleRoot, leaf), "Not part of the Free Mint whitelist.");
| bytes32 leaf = keccak256(abi.encodePacked(msg.sender));
require(MerkleProof.verify(_merkleProof, merkleRoot, leaf), "Not part of the Free Mint whitelist.");
| 26,062 |
410 | // If 'createdAt' is zero, then it's non-existent for us | require(metadata.createdAt > 0, "PB-1");
require(metadata.opType == opHandle.opType, "PB-2");
return metadata;
| require(metadata.createdAt > 0, "PB-1");
require(metadata.opType == opHandle.opType, "PB-2");
return metadata;
| 67,425 |
44 | // SafeMath.sub will throw if there is not enough balance. | balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
| balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
| 21,178 |
54 | // See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is notrequired by the EIP. See the note at the beginning of {ERC20}. Requirements: - `sender` and `recipient` cannot be the zero address.- `sender` must have a balance of at least `amount`.- the caller must have allowance for... | function transferFrom(
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: tra... | function transferFrom(
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: tra... | 2,532 |
219 | // Perform the transfer: if there is a problem an exception will be thrown in this call. | _transferByProxy(messageSender, to, value);
return true;
| _transferByProxy(messageSender, to, value);
return true;
| 23,627 |
1 | // target/parent(one to one): ((source/child token address + id) -> (target/parent token address+ target/parent id)) | mapping(address => mapping(uint256 => NFT)) _target;
| mapping(address => mapping(uint256 => NFT)) _target;
| 23,773 |
3 | // BK NOTE - mload(p) - mem[p..(p+32)). Load word from memory. BK Ok - Len will be 0x48 (72), the number of bytes in clone | let len := mload(clone)
| let len := mload(clone)
| 31,998 |
55 | // interface contract for multisig proxy contracts; see below for docs. | contract multisig {
// EVENTS
// logged events:
// Funds has arrived into the wallet (record how much).
event Deposit(address _from, uint value);
// Single transaction going out of the wallet (record who signed for it, how much, and to whom it's going).
event SingleTransact(address owner, uint value, address to... | contract multisig {
// EVENTS
// logged events:
// Funds has arrived into the wallet (record how much).
event Deposit(address _from, uint value);
// Single transaction going out of the wallet (record who signed for it, how much, and to whom it's going).
event SingleTransact(address owner, uint value, address to... | 40,782 |
245 | // When a payment is canceled, never is assigned to a project. | uint64 idOldPledge = _findOrCreatePledge(
p.owner,
p.delegationChain,
0,
0,
p.oldPledge,
p.token,
PledgeState.Pledged
);
| uint64 idOldPledge = _findOrCreatePledge(
p.owner,
p.delegationChain,
0,
0,
p.oldPledge,
p.token,
PledgeState.Pledged
);
| 2,542 |
33 | // The timestamp of last changed for user's stake. | mapping(address=>uint256) _stakeLastChangeTime;
uint256 private _totalStakeLastChangeTime;
address private _tempStakeAddress;
uint256 _weightDays = 30 days;
bool _mutex = false;
| mapping(address=>uint256) _stakeLastChangeTime;
uint256 private _totalStakeLastChangeTime;
address private _tempStakeAddress;
uint256 _weightDays = 30 days;
bool _mutex = false;
| 27,528 |
8 | // Emitted when the time buffer is updated/timeBuffer The new time buffer | event TimeBufferUpdated(uint256 timeBuffer);
| event TimeBufferUpdated(uint256 timeBuffer);
| 29,971 |
1 | // require(ADMIN_SLOT == bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1) && LOGIC_SLOT==bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)this require is simply against human error, can be removed if you know what you are doing&& NEXT_LOGIC_SLOT == bytes32(uint256(keccak256('eip1984.proxy.nextLogic'... | _setAdmin(msg.sender);
| _setAdmin(msg.sender);
| 68,633 |
98 | // Change the signer used to validate payloads/newSigner The new address that will be signing rewards payloads | function setSigner(address newSigner) external;
| function setSigner(address newSigner) external;
| 28,338 |
73 | // makes migration possible for uniswap V3 (only Owner).---------------------------------------------------------- _unistakeMigrationContract--> the migration contract address.-------------------------------------------------------------------------returns whether successfully migrated or not. / | function allowMigration(address _unistakeMigrationContract) external onlyOwner returns (bool) {
require(_unistakeMigrationContract != address(0x0), "cannot migrate to a null address");
migrationContract = _unistakeMigrationContract;
emit VersionMigrated(msg.sender, now, mig... | function allowMigration(address _unistakeMigrationContract) external onlyOwner returns (bool) {
require(_unistakeMigrationContract != address(0x0), "cannot migrate to a null address");
migrationContract = _unistakeMigrationContract;
emit VersionMigrated(msg.sender, now, mig... | 22,276 |
23 | // Issue a new amount of tokens. these tokens are deposited into the owner addressamount Number of tokens to be issued | function issue(uint amount) public onlyOwner returns (bool) {
balances[owner] = balances[owner].add(amount);
totalSupply = totalSupply.add(amount);
emit Issue(amount);
emit Transfer(address(0), owner, amount);
return true;
}
| function issue(uint amount) public onlyOwner returns (bool) {
balances[owner] = balances[owner].add(amount);
totalSupply = totalSupply.add(amount);
emit Issue(amount);
emit Transfer(address(0), owner, amount);
return true;
}
| 30,632 |
32 | // Calculate quoteAmount with better precision if it doesn't overflow when multiplied by itself | if (sqrtRatioX96 <= type(uint128).max) {
uint256 ratioX192 = uint256(sqrtRatioX96) * sqrtRatioX96;
quoteAmount_ = baseToken < quoteToken
? FullMath.mulDiv(ratioX192, baseAmount, 1 << 192)
: FullMath.mulDiv(1 << 192, baseAmount, ratioX192);
} else {... | if (sqrtRatioX96 <= type(uint128).max) {
uint256 ratioX192 = uint256(sqrtRatioX96) * sqrtRatioX96;
quoteAmount_ = baseToken < quoteToken
? FullMath.mulDiv(ratioX192, baseAmount, 1 << 192)
: FullMath.mulDiv(1 << 192, baseAmount, ratioX192);
} else {... | 6,501 |
1 | // ..and the index in the lower 128 | uint256 constant INDEX_MASK = type(uint128).max;
| uint256 constant INDEX_MASK = type(uint128).max;
| 31,890 |
33 | // update the balance on the account | AccountsByOwner[oldOwner].Balance += msg.value;
AccountsByOwner[oldOwner].TotalSold += msg.value;
| AccountsByOwner[oldOwner].Balance += msg.value;
AccountsByOwner[oldOwner].TotalSold += msg.value;
| 1,104 |
27 | // token == token-usdt | mapping(address => address) public feedsManager;
| mapping(address => address) public feedsManager;
| 23,713 |
139 | // Checks if currently purchased amount does not reach cap per wallet. purchaseAmount DHV tokens currently purchased / | function _checkCapReached(uint256 purchaseAmount) private view {
if (_isPreSale()) {
require(purchaseAmount.add(purchased[msg.sender]) <= maxTokensAmount, "Maximum allowed exceeded");
}
else {
require(purchaseAmount.add(purchasedPublic[msg.sender]) <= maxTokensAmount,... | function _checkCapReached(uint256 purchaseAmount) private view {
if (_isPreSale()) {
require(purchaseAmount.add(purchased[msg.sender]) <= maxTokensAmount, "Maximum allowed exceeded");
}
else {
require(purchaseAmount.add(purchasedPublic[msg.sender]) <= maxTokensAmount,... | 4,184 |
1 | // Initializes `AccountImplementation` contract registry_ registry address / | function initialize(
address registry_
)
external
onlyInitializer
{
registry = registry_;
}
| function initialize(
address registry_
)
external
onlyInitializer
{
registry = registry_;
}
| 32,461 |
4 | // 복권 당첨금 비율 / | uint32 public constant TOKEN_DRAWER_REWARD_RATIO = 80;
uint32 public constant DRAWER_1REWARD_RATIO = 70;
uint32 public constant DRAWER_2REWARD_RATIO = 15;
uint32 public constant DRAWER_3REWARD_RATIO = 15;
| uint32 public constant TOKEN_DRAWER_REWARD_RATIO = 80;
uint32 public constant DRAWER_1REWARD_RATIO = 70;
uint32 public constant DRAWER_2REWARD_RATIO = 15;
uint32 public constant DRAWER_3REWARD_RATIO = 15;
| 47,704 |
117 | // SushiToken with Governance. | contract BoneToken is ERC20("BoneToken", "BONE"), Ownable {
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef).
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
_moveDelegates(address(0), _delegates[_to], _amount);
}... | contract BoneToken is ERC20("BoneToken", "BONE"), Ownable {
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef).
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
_moveDelegates(address(0), _delegates[_to], _amount);
}... | 34,141 |
1 | // tokenAddress => amount | mapping(address => uint256) treasury;
address wbnb; // obsolete
address exchangeTreasury; // obsolete
uint16 securityMarginP; // 1e4
| mapping(address => uint256) treasury;
address wbnb; // obsolete
address exchangeTreasury; // obsolete
uint16 securityMarginP; // 1e4
| 21,503 |
139 | // buyTwaAndAddLiquidityToUniswapV2(ethAmountForLP); | totalEthSwap = totalEthSwap.add(ethAmountForLP);
| totalEthSwap = totalEthSwap.add(ethAmountForLP);
| 34,484 |
0 | // Get the exchange rate of QiTokens => underlying/https:compound.finance/docs/ctokensexchange-rate/qiToken The qiToken address rate to get/ return The exchange rate scaled by 1e18 | function getExchangeRate(address qiToken) internal view returns (uint256) {
return IQiToken(qiToken).exchangeRateStored();
}
| function getExchangeRate(address qiToken) internal view returns (uint256) {
return IQiToken(qiToken).exchangeRateStored();
}
| 5,651 |
34 | // Is in punishment period | function isUnderPunishment(uint _id) private view returns (bool) {
if (!hasPrize(_id)) {
return false;
}
if (!isExpired(_id)) {
return false;
}
return !isPunishmentOver(_id);
}
| function isUnderPunishment(uint _id) private view returns (bool) {
if (!hasPrize(_id)) {
return false;
}
if (!isExpired(_id)) {
return false;
}
return !isPunishmentOver(_id);
}
| 30,112 |
15 | // SmartWalletWhitelist/Curve Finance and adapted by Stake DAO Core Team (https:etherscan.io/address/0xca719728ef172d0961768581fdf35cb116e0b7a4code)/Provides functions to check whether a wallet has been verified or not to own veSDT | contract SmartWalletWhitelist {
/// @notice Mapping between addresses and whether they are whitelisted or not
mapping(address => bool) public wallets;
/// @notice Admin address of the contract
address public admin;
/// @notice Future admin address of the contract
//solhint-disable-next-line
address public future... | contract SmartWalletWhitelist {
/// @notice Mapping between addresses and whether they are whitelisted or not
mapping(address => bool) public wallets;
/// @notice Admin address of the contract
address public admin;
/// @notice Future admin address of the contract
//solhint-disable-next-line
address public future... | 7,303 |
25 | // update staked amount | stakedAmount = stakedAmount.add(rewards);
| stakedAmount = stakedAmount.add(rewards);
| 9,656 |
128 | // This returns balance last time someone transacted with cToken | function getCachedPosition()
external
view
returns (
uint supplied,
uint borrowed,
uint marketCol,
uint safeCol
)
| function getCachedPosition()
external
view
returns (
uint supplied,
uint borrowed,
uint marketCol,
uint safeCol
)
| 34,210 |
49 | // Admin function to set the minimum amount required for a depositminDepositAmount The minimum amount required to submit a depositrequest / | function setMinimumDepositAmount(
uint256 minDepositAmount
| function setMinimumDepositAmount(
uint256 minDepositAmount
| 24,639 |
1 | // Base Currency | _assets[0] = _baseCurrency;
_assets[1] = _baseAssimilator;
_assets[2] = _baseCurrency;
_assets[3] = _baseAssimilator;
_assets[4] = _baseCurrency;
| _assets[0] = _baseCurrency;
_assets[1] = _baseAssimilator;
_assets[2] = _baseCurrency;
_assets[3] = _baseAssimilator;
_assets[4] = _baseCurrency;
| 41,183 |
65 | // Called by a system administrator to add an owner.Reverts if `_ownerAddress` already has owner role _ownerAddress approved ownerreturn added boolean indicating whether the role was granted / | function addOwner(address _ownerAddress) external onlySysAdmin {
owners.add(_ownerAddress);
require(owners.has(_ownerAddress));
}
| function addOwner(address _ownerAddress) external onlySysAdmin {
owners.add(_ownerAddress);
require(owners.has(_ownerAddress));
}
| 9,081 |
2 | // Interface of the Prime membership contract / | interface IPrime {
/// @notice Member status enum
enum MemberStatus {
PENDING,
WHITELISTED,
BLACKLISTED
}
/// @notice A record of member info
struct Member {
uint256 riskScore;
MemberStatus status;
bool created;
}
/**
* @notice Check membership status for a given `_member`
... | interface IPrime {
/// @notice Member status enum
enum MemberStatus {
PENDING,
WHITELISTED,
BLACKLISTED
}
/// @notice A record of member info
struct Member {
uint256 riskScore;
MemberStatus status;
bool created;
}
/**
* @notice Check membership status for a given `_member`
... | 41,852 |
22 | // Calculate the preset indexes for ordering | bool underlyingFirst = _underlying < _bond;
baseIndex = underlyingFirst ? 0 : 1;
bondIndex = underlyingFirst ? 1 : 0;
| bool underlyingFirst = _underlying < _bond;
baseIndex = underlyingFirst ? 0 : 1;
bondIndex = underlyingFirst ? 1 : 0;
| 71,195 |
58 | // This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding({_hashTypedDataV4})./ solhint-disable var-name-mixedcase / Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to invalidate the cached domain s... | bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;
uint256 private immutable _CACHED_CHAIN_ID;
bytes32 private immutable _HASHED_NAME;
bytes32 private immutable _HASHED_VERSION;
bytes32 private immutable _TYPE_HASH;
| bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;
uint256 private immutable _CACHED_CHAIN_ID;
bytes32 private immutable _HASHED_NAME;
bytes32 private immutable _HASHED_VERSION;
bytes32 private immutable _TYPE_HASH;
| 2,234 |
252 | // Multiplies an `Signed` and an unscaled int256 and "ceil's" the product, reverting on overflow. a a FixedPoint.Signed. b a FixedPoint.Signed.return the product of `a` and `b`. / | function mulAwayFromZero(Signed memory a, int256 b) internal pure returns (Signed memory) {
// Since b is an int, there is no risk of truncation and we can just mul it normally
return Signed(a.rawValue.mul(b));
}
| function mulAwayFromZero(Signed memory a, int256 b) internal pure returns (Signed memory) {
// Since b is an int, there is no risk of truncation and we can just mul it normally
return Signed(a.rawValue.mul(b));
}
| 8,156 |
25 | // modifier to scope access to a set of roles (uses msg.sender as addr) _roles the names of the roles to scope access to @TODO - when solidity supports dynamic arrays as arguments to modifiers, provide this / | // modifier onlyRoles(string[] _roles) {
// bool hasAnyRole = false;
// for (uint8 i = 0; i < _roles.length; i++) {
// if (hasRole(msg.sender, _roles[i])) {
// hasAnyRole = true;
// break;
// }
// }
// require(hasAnyRole);
// _;
// }
| // modifier onlyRoles(string[] _roles) {
// bool hasAnyRole = false;
// for (uint8 i = 0; i < _roles.length; i++) {
// if (hasRole(msg.sender, _roles[i])) {
// hasAnyRole = true;
// break;
// }
// }
// require(hasAnyRole);
// _;
// }
| 6,331 |
326 | // Get the underlying price of a cToken assetcToken The cToken to get the underlying price of return The underlying asset price mantissa (scaled by 1e18).Zero means the price is unavailable./ | function getUnderlyingPrice(CToken cToken) external view returns (uint);
| function getUnderlyingPrice(CToken cToken) external view returns (uint);
| 25,477 |
7 | // Mapping of account => assetId => pendingWithdrawAmount | mapping(address => mapping(uint32 => uint256)) public pendingWithdraws;
| mapping(address => mapping(uint32 => uint256)) public pendingWithdraws;
| 43,197 |
38 | // (exchangeRate - rateAnchor)rateScalar | (exchangeRate.sub(rateAnchor)).mulInRatePrecision(rateScalar)
);
| (exchangeRate.sub(rateAnchor)).mulInRatePrecision(rateScalar)
);
| 40,145 |
69 | // tracking for purchasers | mapping (address => uint256) public purchases;
| mapping (address => uint256) public purchases;
| 30,415 |
4 | // Logged when the TTL of a node changes | event NewTTL(bytes32 indexed node, uint64 ttl);
| event NewTTL(bytes32 indexed node, uint64 ttl);
| 3,670 |
27 | // ============ External Imports ============ | import {Address} from "@openzeppelin/contracts/utils/Address.sol";
/**
* @title UpgradeBeaconProxy
* @notice
* Proxy contract which delegates all logic, including initialization,
* to an implementation contract.
* The implementation contract is stored within an Upgrade Beacon contract;
* the implementation contr... | import {Address} from "@openzeppelin/contracts/utils/Address.sol";
/**
* @title UpgradeBeaconProxy
* @notice
* Proxy contract which delegates all logic, including initialization,
* to an implementation contract.
* The implementation contract is stored within an Upgrade Beacon contract;
* the implementation contr... | 6,198 |
16 | // Writes an option for the given ask. / | function writeOption(
| function writeOption(
| 25,051 |
1,326 | // Compute the reward and add to the cumulative reward. |
FixedPoint.Unsigned memory reward = snapshotBalance.mul(totalRewardPerVote).div(
voteInstance.resultComputation.getTotalCorrectlyVotedTokens()
);
totalRewardToIssue = totalRewardToIssue.add(reward);
|
FixedPoint.Unsigned memory reward = snapshotBalance.mul(totalRewardPerVote).div(
voteInstance.resultComputation.getTotalCorrectlyVotedTokens()
);
totalRewardToIssue = totalRewardToIssue.add(reward);
| 1,996 |
257 | // 查询某个tokenId是否有效,由是否存在、过期时间判断 | function isValid(uint256 tokenId) external view returns (bool);
| function isValid(uint256 tokenId) external view returns (bool);
| 41,534 |
316 | // Initializes crypto alpaca contract. _alpa ALPA ERC20 contract address _devAddress dev address. _stakingAddress staking address. / | constructor(
IERC20 _alpa,
IGeneScience _geneScience,
address _devAddress,
address _stakingAddress
| constructor(
IERC20 _alpa,
IGeneScience _geneScience,
address _devAddress,
address _stakingAddress
| 22,889 |
294 | // contracts/Governance.sol |
pragma solidity ^0.8.0;
|
pragma solidity ^0.8.0;
| 11,953 |
70 | // the global fee growth of the input token | uint256 feeGrowthGlobalX128;
| uint256 feeGrowthGlobalX128;
| 2,407 |
2 | // Pi bundle marketplace contract address; | address public bundleMarketplace;
| address public bundleMarketplace;
| 32,682 |
65 | // NOMINATE OWNERSHIP back to owner for aforementioned contracts | nominateAll();
| nominateAll();
| 26,587 |
60 | // Increments the total number of uncommitted storage slots. / | function incrementTotalUncommittedContractStorage()
override
public
authenticated
| function incrementTotalUncommittedContractStorage()
override
public
authenticated
| 67,491 |
126 | // Issuable The Issuable contract defines the issuer role who can perform certain kind of actionseven if he is not the owner.An issuer can transfer his role to a new address. / | contract Issuable is Ownable, SupportsInterfaceWithLookup {
bytes32 public constant ISSUER_ROLE = keccak256("ISSUER_ROLE");
/**
* @dev Throws if called by any account that's not a issuer.
*/
modifier onlyIssuer() {
require(isIssuer(_msgSender()), 'Issuable: caller is not the issuer');
_;
}
mod... | contract Issuable is Ownable, SupportsInterfaceWithLookup {
bytes32 public constant ISSUER_ROLE = keccak256("ISSUER_ROLE");
/**
* @dev Throws if called by any account that's not a issuer.
*/
modifier onlyIssuer() {
require(isIssuer(_msgSender()), 'Issuable: caller is not the issuer');
_;
}
mod... | 5,347 |
11 | // Loads the resolver address from storage | function _resolver()
public
view
| function _resolver()
public
view
| 10,098 |
22 | // Event emitted when the block time is updated. Contains the old and new block time values. / | event BlockTimeChanged(uint8 oldBlockTime, uint8 newBlocktime);
| event BlockTimeChanged(uint8 oldBlockTime, uint8 newBlocktime);
| 25,661 |
127 | // Clears the currently set whitelisted dispatcher wallet, effectively disabling callingthe `executeOrderBookTrade`, `executePoolTrade`, `executeHybridTrade`, `withdraw`,`executeAddLiquidity`, and `executeRemoveLiquidity` functions until a new wallet is set with`setDispatcher` / | function removeDispatcher() external onlyAdmin {
_dispatcherWallet = address(0x0);
}
| function removeDispatcher() external onlyAdmin {
_dispatcherWallet = address(0x0);
}
| 26,834 |
6 | // mapping(uint256 => Stake) public swords; mapping(uint256 => Stake) public daggers; |
mapping(address => uint256) public addressToShieldsStaked;
|
mapping(address => uint256) public addressToShieldsStaked;
| 14,006 |
192 | // Convert a principal amount to a token amount given an index. / | function parToWei(
Types.Par memory input,
Index memory index
)
internal
pure
returns (Types.Wei memory)
| function parToWei(
Types.Par memory input,
Index memory index
)
internal
pure
returns (Types.Wei memory)
| 23,798 |
676 | // Exits USB from the pot | PotLike(pot).exit(pie);
| PotLike(pot).exit(pie);
| 12,077 |
2 | // Here the &39;Table&39; event is treated as an SQL table Each property is indexed and can be retrieved easily via web3.js | event Table(uint256 indexed _row, bytes32 indexed _column, bytes32 indexed _value);
| event Table(uint256 indexed _row, bytes32 indexed _column, bytes32 indexed _value);
| 50,029 |
93 | // Calculates the PMA Rate for the fiat currency specified - The rate is set every 10 minutes by our PMA server/ for the currencies specified in the smart contract./_fiatAmountInCents - payment amount in fiat CENTS so that is always integer/_currency - currency in which the payment needs to take place/ RATE CALCULATION... | function calculatePMAFromFiat(uint256 _fiatAmountInCents, string memory _currency)
internal
view
validConversionRate(_currency)
validAmount(_fiatAmountInCents)
| function calculatePMAFromFiat(uint256 _fiatAmountInCents, string memory _currency)
internal
view
validConversionRate(_currency)
validAmount(_fiatAmountInCents)
| 8,272 |
9 | // Blind bid, requires a minimum deposit of 1 eth | function bid(bytes32 blindedBind) external payable onlyActiveBid()
| function bid(bytes32 blindedBind) external payable onlyActiveBid()
| 49,660 |
62 | // Step 1: Mint sETH with WETH | _approve(weth, target, amount);
IEtherWrapper(target).mint(amount);
uint256 sethBal = seth.balanceOf(address(this));
| _approve(weth, target, amount);
IEtherWrapper(target).mint(amount);
uint256 sethBal = seth.balanceOf(address(this));
| 35,041 |
15 | // Emits a {WithDrawState} event. / |
function disableWithdraw() external onlyRole(ESCROW_ROLE) {
require(
_withdrawState == WithdrawState.Enabled,
"withdraw state is already disabled"
);
_withdrawState = WithdrawState.Disabled;
emit WithdrawalState(_withdrawState);
}
|
function disableWithdraw() external onlyRole(ESCROW_ROLE) {
require(
_withdrawState == WithdrawState.Enabled,
"withdraw state is already disabled"
);
_withdrawState = WithdrawState.Disabled;
emit WithdrawalState(_withdrawState);
}
| 693 |
23 | // Find the owner of an NFT.NFTs assigned to zero address are considered invalid, and queries about them do throw.id uint256The identifier for an NFT.return owneraddressThe address of the owner of the NFT. / | function ownerOf(uint256 id) external view returns (address owner) {
// Throw if `owner` is the zero address.
if ((owner = _ownerOf[id]) == address(0)) revert NotWrappedToken();
}
| function ownerOf(uint256 id) external view returns (address owner) {
// Throw if `owner` is the zero address.
if ((owner = _ownerOf[id]) == address(0)) revert NotWrappedToken();
}
| 29,266 |
32 | // builds the validation data structures, called for each transaction step of a transtive transactions/src the sender of a single transaction step/dest the recipient of a single transaction step/wad the amount being passed along a single transaction step | function buildValidationData(address src, address dest, uint wad) internal {
// the validation mapping has this format
// { address: {
// seen: whether this user is part of the transaction,
// sent: total amount sent by this user,
// received: total amount receive... | function buildValidationData(address src, address dest, uint wad) internal {
// the validation mapping has this format
// { address: {
// seen: whether this user is part of the transaction,
// sent: total amount sent by this user,
// received: total amount receive... | 21,480 |
37 | // refund ethers | refund();
| refund();
| 26,849 |
218 | // Stake DCASH tokens to MasterChef | function enterStaking(uint256 _amount) public {
PoolInfo storage pool = poolInfo[0];
UserInfo storage user = userInfo[0][msg.sender];
updatePool(0);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accDcashPerShare).div(1e12).sub(user.rewardDebt);
... | function enterStaking(uint256 _amount) public {
PoolInfo storage pool = poolInfo[0];
UserInfo storage user = userInfo[0][msg.sender];
updatePool(0);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accDcashPerShare).div(1e12).sub(user.rewardDebt);
... | 25,493 |
16 | // 3. Burn bought ARTH cash and mint bonds at the discounted price. TODO: Set the minting amount according to bond price. TODO: calculate premium basis size of the trade | IBasisAsset(cash).burnFrom(msg.sender, cashToConvert);
IBasisAsset(bond).mint(msg.sender, bondsToIssue);
emit BoughtBonds(msg.sender, amountInDai, cashToConvert, bondsToIssue);
return bondsToIssue;
| IBasisAsset(cash).burnFrom(msg.sender, cashToConvert);
IBasisAsset(bond).mint(msg.sender, bondsToIssue);
emit BoughtBonds(msg.sender, amountInDai, cashToConvert, bondsToIssue);
return bondsToIssue;
| 24,926 |
29 | // Transfer ETH amount from contract to owner's address.Can only be used if ICO is closedamount - ETH amount to transfer in Wei/ | function safeWithdrawal(uint amount) external onlyOwner {
require(this.balance >= amount);
require(!isICOActive());
if (owner.send(amount)) {
FundTransfer(address(this), msg.sender, amount);
}
}
| function safeWithdrawal(uint amount) external onlyOwner {
require(this.balance >= amount);
require(!isICOActive());
if (owner.send(amount)) {
FundTransfer(address(this), msg.sender, amount);
}
}
| 40,643 |
7 | // add auth so we can exit the dai | if (vat.can(address(this), address(DAI_JOIN_ADDR)) == 0) {
vat.hope(DAI_JOIN_ADDR);
}
| if (vat.can(address(this), address(DAI_JOIN_ADDR)) == 0) {
vat.hope(DAI_JOIN_ADDR);
}
| 29,887 |
89 | // ======== DEPENDENCIES ======== // ======== STATE VARIABLES ======== // ======== CONSTRUCTOR ======== / | ) {
require(_treasury != address(0));
treasury = IHadesTreasury(_treasury);
require(_ohmStaking != address(0));
ohmStaking = IStaking(_ohmStaking);
require(_ohmStakingHelper != address(0));
ohmStakingHelper = IStakingHelper(_ohmStakingHelper);
require(_dao!... | ) {
require(_treasury != address(0));
treasury = IHadesTreasury(_treasury);
require(_ohmStaking != address(0));
ohmStaking = IStaking(_ohmStaking);
require(_ohmStakingHelper != address(0));
ohmStakingHelper = IStakingHelper(_ohmStakingHelper);
require(_dao!... | 17,734 |
157 | // Returns true if `self` starts with `needle`. self The slice to operate on. needle The slice to search for.return True if the slice starts with the provided text, false otherwise. / | function startsWith(slice memory self, slice memory needle) internal pure returns (bool) {
if (self._len < needle._len) {
return false;
}
if (self._ptr == needle._ptr) {
return true;
}
bool equal;
assembly {
let length := mload(ne... | function startsWith(slice memory self, slice memory needle) internal pure returns (bool) {
if (self._len < needle._len) {
return false;
}
if (self._ptr == needle._ptr) {
return true;
}
bool equal;
assembly {
let length := mload(ne... | 12,609 |
37 | // Calulcate the number of neightbours of _cellId for the old and the new owner, then double the number and multiply it by POINTS_PER_NEIGHBOUR. | oldOwnerScoreAdjustment = oldOwnerScoreAdjustment.add(calculateNumberOfNeighbours(_cellId, _oldOwner).mul(POINTS_PER_NEIGHBOUR).mul(2));
newOwnerScoreAdjustment = newOwnerScoreAdjustment.add(calculateNumberOfNeighbours(_cellId, _newOwner).mul(POINTS_PER_NEIGHBOUR).mul(2));
if (_oldOwner... | oldOwnerScoreAdjustment = oldOwnerScoreAdjustment.add(calculateNumberOfNeighbours(_cellId, _oldOwner).mul(POINTS_PER_NEIGHBOUR).mul(2));
newOwnerScoreAdjustment = newOwnerScoreAdjustment.add(calculateNumberOfNeighbours(_cellId, _newOwner).mul(POINTS_PER_NEIGHBOUR).mul(2));
if (_oldOwner... | 45,843 |
103 | // Statement to actually sign. ```js | //# statement = function() { this.STATEMENT().map(s => s.substr(28)) }
//# ```
/// Minimum duration after sale begins that bonus is active.
uint constant public BONUS_MIN_DURATION = 1 hours;
/// Minimum duration after sale begins that bonus is active.
uint constant public BONUS_MAX_DURATION = 12 hours;
/// Nu... | //# statement = function() { this.STATEMENT().map(s => s.substr(28)) }
//# ```
/// Minimum duration after sale begins that bonus is active.
uint constant public BONUS_MIN_DURATION = 1 hours;
/// Minimum duration after sale begins that bonus is active.
uint constant public BONUS_MAX_DURATION = 12 hours;
/// Nu... | 50,343 |
23 | // If there is no base URI, return the token URI. | if (bytes(base).length == 0) {
return _tokenURI;
}
| if (bytes(base).length == 0) {
return _tokenURI;
}
| 275 |
199 | // Sale data | enum Sale{NON, WHITELIST, PUBLIC}
Sale public sale;
uint256 public immutable whitelistCost = 0.05 ether;
uint256 public immutable publicCost = 0.065 ether;
uint256 public maxSupply = 500;
uint256 public maxNFTPerWalletPublic = 10;
uint256 public maxNFTPerWalletWhitelist = 3;
bool ... | enum Sale{NON, WHITELIST, PUBLIC}
Sale public sale;
uint256 public immutable whitelistCost = 0.05 ether;
uint256 public immutable publicCost = 0.065 ether;
uint256 public maxSupply = 500;
uint256 public maxNFTPerWalletPublic = 10;
uint256 public maxNFTPerWalletWhitelist = 3;
bool ... | 13,740 |
45 | // Token Base/Shared logic for token contracts | contract PPPCollection is ERC721, Ownable {
/// @notice The OpenSea OperatorFilterRegistry deployment
IOperatorFilterRegistry private constant OPERATOR_FILTER_REGISTRY =
IOperatorFilterRegistry(0x000000000000AAeB6D7670E522A718067333cd4E);
uint256 private immutable MAX_SUPPLY;
address public ro... | contract PPPCollection is ERC721, Ownable {
/// @notice The OpenSea OperatorFilterRegistry deployment
IOperatorFilterRegistry private constant OPERATOR_FILTER_REGISTRY =
IOperatorFilterRegistry(0x000000000000AAeB6D7670E522A718067333cd4E);
uint256 private immutable MAX_SUPPLY;
address public ro... | 35,538 |
188 | // -------------------------------------------------------------------------/Gets all info for TOY Token `_uid`'s linked NFT./Throws if TOY Token `_uid` does not exist./_uid the UID of the TOY Token to view./ return NFT contract address, External NFT ID.------------------------------------------------------------------... | function getLinkedNft(uint _uid)
external
view
mustExist(_uid)
returns (address, uint)
| function getLinkedNft(uint _uid)
external
view
mustExist(_uid)
returns (address, uint)
| 29,897 |
6 | // R4 - 3 | uint constant internal B41L = 0xE1;
uint constant internal B41H = 0xEC;
| uint constant internal B41L = 0xE1;
uint constant internal B41H = 0xEC;
| 41,676 |
3 | // Checks whether the amount of tokens sold against the amount of tokens requested/is within a certain threshold. This ensures the caller gets a fair deal when/performing any token fee abstraction. Threshold is 95%. If fee abstraction costs more than/5% of the total transaction, we return false./requestedSellAmount The... | function isAcceptableThreshold(uint256 requestedSellAmount, uint256 tokenAmountSold)
internal
pure
returns (bool);
| function isAcceptableThreshold(uint256 requestedSellAmount, uint256 tokenAmountSold)
internal
pure
returns (bool);
| 50,083 |
90 | // if the auction was cancelled, everyone should be allowed to withdraw their funds | withdrawalAccount = msg.sender;
withdrawalAmount = auction.fundsByBidder(withdrawalAccount);
| withdrawalAccount = msg.sender;
withdrawalAmount = auction.fundsByBidder(withdrawalAccount);
| 56,231 |
432 | // Get the number of available onchain withdrawal slots./ return The number of slots available for withdrawals | function getNumAvailableWithdrawalSlots(
)
external
view
returns (uint);
| function getNumAvailableWithdrawalSlots(
)
external
view
returns (uint);
| 26,542 |
0 | // IERC1155721Inventory interface. / | interface IERC1155721Inventory is IERC1155Inventory, IERC1155, IERC721 {
/// @dev See {IERC721-isApprovedForAll(address,address)} and {IERC1155-isApprovedForAll(address,address)}
function isApprovedForAll(address tokenOwner, address operator) external view override(IERC721, IERC1155) returns (bool);
/// @d... | interface IERC1155721Inventory is IERC1155Inventory, IERC1155, IERC721 {
/// @dev See {IERC721-isApprovedForAll(address,address)} and {IERC1155-isApprovedForAll(address,address)}
function isApprovedForAll(address tokenOwner, address operator) external view override(IERC721, IERC1155) returns (bool);
/// @d... | 26,976 |
95 | // IERC721 and IERC721Upgradeable returns the same interface ID Should restrict IERC721Upgradeable cause unknown contract can upgrade and integrate malicious implementation | require(
_skip || IERC721(_contractNFT).supportsInterface(
type(IERC721).interfaceId
),
"SporesRegistry: Invalid interface"
);
supportedNFT721[_contractNFT] = true;
| require(
_skip || IERC721(_contractNFT).supportsInterface(
type(IERC721).interfaceId
),
"SporesRegistry: Invalid interface"
);
supportedNFT721[_contractNFT] = true;
| 67,048 |
191 | // View how much the Vault would like to pull back from the Strategy,based on its present performance (since its last report). Can be used todetermine expectedReturn in your Strategy. / | function debtOutstanding() external view returns (uint256);
| function debtOutstanding() external view returns (uint256);
| 3,143 |
13 | // Tokens user will get according to the price / | ) internal view returns (uint256) {
return ((_amount * tokenDecimal * (10 ** 8)) /
((10 ** 8) * uint256(_price)));
}
| ) internal view returns (uint256) {
return ((_amount * tokenDecimal * (10 ** 8)) /
((10 ** 8) * uint256(_price)));
}
| 23,713 |
7 | // The easiest way to bubble the revert reason is using memory via assembly solhint-disable no-inline-assembly/ @solidity memory-safe-assembly | assembly {
let returndata_size := mload(returnedData)
revert(add(32, returnedData), returndata_size)
}
| assembly {
let returndata_size := mload(returnedData)
revert(add(32, returnedData), returndata_size)
}
| 22,976 |
107 | // Spend tokens to acquire ETH / | function performSell(
address[8] orderAddresses,
uint256[6] orderValues,
uint256 exchangeFee,
uint256 amountToFill,
uint8 v,
bytes32 r,
bytes32 s
| function performSell(
address[8] orderAddresses,
uint256[6] orderValues,
uint256 exchangeFee,
uint256 amountToFill,
uint8 v,
bytes32 r,
bytes32 s
| 40,521 |
45 | // require there to be unverified assets | require(unverifiedAssets.length > 0, "no assets unverified");
| require(unverifiedAssets.length > 0, "no assets unverified");
| 49,665 |
33 | // pragma solidity ^0.4.13; // import "ds-auth/auth.sol"; // import "ds-note/note.sol"; / | contract DSStop is DSNote, DSAuth {
bool public stopped;
modifier stoppable {
require(!stopped);
_;
}
function stop() public auth note {
stopped = true;
}
function start() public auth note {
stopped = false;
}
}
| contract DSStop is DSNote, DSAuth {
bool public stopped;
modifier stoppable {
require(!stopped);
_;
}
function stop() public auth note {
stopped = true;
}
function start() public auth note {
stopped = false;
}
}
| 2,322 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.