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 |
|---|---|---|---|---|
34 | // Total tokens should be more than user want's to buy | require(balances[owner]>safeMul(tokens, multiplier));
| require(balances[owner]>safeMul(tokens, multiplier));
| 37,379 |
120 | // called by oracles when they have witnessed a need to update _roundId is the ID of the round this submission pertains to _submission is the updated data that the oracle is submitting / | function submit(uint256 _roundId, int256 _submission)
external
| function submit(uint256 _roundId, int256 _submission)
external
| 23,872 |
46 | // Creates a new pool if it does not exist, then initializes if not initialized/This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool/token0 The contract address of token0 of the pool/token1 The contract address of token1 of the pool/fee The fee amount of the v3 pool for the specified token pair/sqrtPriceX96 The initial square root price of the pool as a Q64.96 value/ return pool Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary | function createAndInitializePoolIfNecessary(
address token0,
address token1,
uint24 fee,
uint160 sqrtPriceX96
) external payable returns (address pool);
| function createAndInitializePoolIfNecessary(
address token0,
address token1,
uint24 fee,
uint160 sqrtPriceX96
) external payable returns (address pool);
| 1,866 |
27 | // send fails are ignored hence there is always a direct way to withdraw. | delete pendingWithdrawals[i];
bytes22 packedBalanceKey = packAddressAndTokenId(to, tokenId);
uint128 amount = balancesToWithdraw[packedBalanceKey].balanceToWithdraw;
| delete pendingWithdrawals[i];
bytes22 packedBalanceKey = packAddressAndTokenId(to, tokenId);
uint128 amount = balancesToWithdraw[packedBalanceKey].balanceToWithdraw;
| 29,663 |
105 | // Check if there is enough in the reserve | require(_updateInterest());
require(_amount <= underlyingBalance() && _amount <= totalReserve, Errors.RESERVE_FUNDS_INSUFFICIENT);
totalReserve = totalReserve.sub(_amount);
| require(_updateInterest());
require(_amount <= underlyingBalance() && _amount <= totalReserve, Errors.RESERVE_FUNDS_INSUFFICIENT);
totalReserve = totalReserve.sub(_amount);
| 27,515 |
2 | // An event emitted when a vote has been cast on a proposal/voter The address which casted a vote/proposalId The proposal id which was voted on/support Support value for the vote. 0=against, 1=for, 2=abstain/votes Number of votes which were cast by the voter/reason The reason given for the vote by the voter | event VoteCast(
address indexed voter,
uint256 proposalId,
uint8 support,
uint256 votes,
string reason
);
| event VoteCast(
address indexed voter,
uint256 proposalId,
uint8 support,
uint256 votes,
string reason
);
| 24,372 |
14 | // Grant / revoke a role from a given signer. | function changeRole(RoleRequest calldata _req, bytes calldata _signature) external virtual {
require(_req.role != bytes32(0), "AccountPermissions: role cannot be empty");
require(
_req.validityStartTimestamp < block.timestamp && block.timestamp < _req.validityEndTimestamp,
"AccountPermissions: invalid validity period"
);
(bool success, address signer) = verifyRoleRequest(_req, _signature);
require(success, "AccountPermissions: invalid signature");
AccountPermissionsStorage.Data storage data = AccountPermissionsStorage.accountPermissionsStorage();
data.executed[_req.uid] = true;
if (_req.action == RoleAction.GRANT) {
data.roleOfAccount[_req.target] = _req.role;
data.roleMembers[_req.role].add(_req.target);
} else {
delete data.roleOfAccount[_req.target];
data.roleMembers[_req.role].remove(_req.target);
}
emit RoleAssignment(_req.role, _req.target, signer, _req);
}
| function changeRole(RoleRequest calldata _req, bytes calldata _signature) external virtual {
require(_req.role != bytes32(0), "AccountPermissions: role cannot be empty");
require(
_req.validityStartTimestamp < block.timestamp && block.timestamp < _req.validityEndTimestamp,
"AccountPermissions: invalid validity period"
);
(bool success, address signer) = verifyRoleRequest(_req, _signature);
require(success, "AccountPermissions: invalid signature");
AccountPermissionsStorage.Data storage data = AccountPermissionsStorage.accountPermissionsStorage();
data.executed[_req.uid] = true;
if (_req.action == RoleAction.GRANT) {
data.roleOfAccount[_req.target] = _req.role;
data.roleMembers[_req.role].add(_req.target);
} else {
delete data.roleOfAccount[_req.target];
data.roleMembers[_req.role].remove(_req.target);
}
emit RoleAssignment(_req.role, _req.target, signer, _req);
}
| 4,768 |
66 | // Storage position of the owner and pendingOwner of the contract keccak256("OUSD.governor"); | bytes32
private constant governorPosition = 0x7bea13895fa79d2831e0a9e28edede30099005a50d652d8957cf8a607ee6ca4a;
| bytes32
private constant governorPosition = 0x7bea13895fa79d2831e0a9e28edede30099005a50d652d8957cf8a607ee6ca4a;
| 3,153 |
0 | // list of CLient Records | ClientRecord[] ClientRecords;
| ClientRecord[] ClientRecords;
| 16,219 |
10 | // The contract that stores splits for each project. | IJBSplitsStore public immutable override splitsStore;
| IJBSplitsStore public immutable override splitsStore;
| 14,259 |
82 | // This will get the slippage rate from configuration contract and calculate how much amount user can get after slippage. | uint256 sliprate= IPoolConfiguration(_poolConf).getslippagerate();
uint rate = _amount.mul(sliprate).div(100);
| uint256 sliprate= IPoolConfiguration(_poolConf).getslippagerate();
uint rate = _amount.mul(sliprate).div(100);
| 46,456 |
168 | // whitelist mint | function mintWhitelist(bytes32[] calldata proof, uint256 _mintAmount)
public
payable
| function mintWhitelist(bytes32[] calldata proof, uint256 _mintAmount)
public
payable
| 46,716 |
177 | // Insert an empty request so as to initialize the requests array with length > 0 | DataRequest memory request;
requests.push(request);
| DataRequest memory request;
requests.push(request);
| 29,128 |
3 | // copy | let ptr := start
| let ptr := start
| 28,325 |
29 | // Copies the balance of a single addresses from the legacy contract _holder Address to migrate balancereturn True if balance was copied, false if was already copied or address had no balance / | function migrateBalanceFromLegacyRep(address _holder, ERC20 _legacyRepToken) private whenMigratingFromLegacy afterInitialized returns (bool) {
if (balances[_holder] > 0) {
return false; // Already copied, move on
}
uint256 amount = _legacyRepToken.balanceOf(_holder);
if (amount == 0) {
return false; // Has no balance in legacy contract, move on
}
mint(_holder, amount);
if (targetSupply == supply) {
isMigratingFromLegacy = false;
}
return true;
}
| function migrateBalanceFromLegacyRep(address _holder, ERC20 _legacyRepToken) private whenMigratingFromLegacy afterInitialized returns (bool) {
if (balances[_holder] > 0) {
return false; // Already copied, move on
}
uint256 amount = _legacyRepToken.balanceOf(_holder);
if (amount == 0) {
return false; // Has no balance in legacy contract, move on
}
mint(_holder, amount);
if (targetSupply == supply) {
isMigratingFromLegacy = false;
}
return true;
}
| 46,281 |
21 | // To delete an element from the _values array in O(1), we swap the element to delete with the last one in the array, and then remove the last element (sometimes called as 'swap and pop'). This modifies the order of the array, as noted in {at}. |
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
|
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
| 1,305 |
49 | // This means the index itself is not an available token, but the val at that index is. | result = valAtIndex;
| result = valAtIndex;
| 12,195 |
31 | // Replacement for Solidity's `transfer`: sends `amount` wei to `recipient`, forwarding all available gas and reverting on errors. of certain opcodes, possibly making contracts go over the 2300 gas limit imposed by `transfer`, making them unable to receive funds via | * `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
| * `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
| 1,954 |
130 | // 转出操作 | function transferToken(
address _to,
uint _value,
address _erc20Addr
| function transferToken(
address _to,
uint _value,
address _erc20Addr
| 26,996 |
1 | // Maps an L2 ERC721 token address to a boolean that returns true if the token was createdwith the L2StandardERC721Factory. / | function isStandardERC721(address _account) external view returns (bool);
| function isStandardERC721(address _account) external view returns (bool);
| 19,505 |
154 | // token owner's balance must be enough to spend tokens | require (
coloredTokens[colorIndex].balances[from] >= tokens,
"Insufficient tokens to spend"
);
| require (
coloredTokens[colorIndex].balances[from] >= tokens,
"Insufficient tokens to spend"
);
| 14,710 |
45 | // Agile Connect ERC20 tokenImplemantation of the ABC token. / | contract ABCToken is MintableToken {
string public name = "ABCToken";
string public symbol = "ABC";
uint256 public decimals = 18;
/**
* This unnamed function is called whenever someone tries to send ether to it
*/
function() {
revert();
// Prevents accidental sending of ether
}
}
| contract ABCToken is MintableToken {
string public name = "ABCToken";
string public symbol = "ABC";
uint256 public decimals = 18;
/**
* This unnamed function is called whenever someone tries to send ether to it
*/
function() {
revert();
// Prevents accidental sending of ether
}
}
| 48,293 |
54 | // ark, round 27 | st0 := addmod(st0, 0x2b56973364c4c4f5c1a3ec4da3cdce038811eb116fb3e45bc1768d26fc0b3758, q)
st1 := addmod(st1, 0x123769dd49d5b054dcd76b89804b1bcb8e1392b385716a5d83feb65d437f29ef, q)
st2 := addmod(st2, 0x2147b424fc48c80a88ee52b91169aacea989f6446471150994257b2fb01c63e9, q)
| st0 := addmod(st0, 0x2b56973364c4c4f5c1a3ec4da3cdce038811eb116fb3e45bc1768d26fc0b3758, q)
st1 := addmod(st1, 0x123769dd49d5b054dcd76b89804b1bcb8e1392b385716a5d83feb65d437f29ef, q)
st2 := addmod(st2, 0x2147b424fc48c80a88ee52b91169aacea989f6446471150994257b2fb01c63e9, q)
| 8,287 |
443 | // reverts if the caller does not have access by the accessControllercontract or is the contract itself. / | modifier checkAccess() {
AccessControllerInterface ac = accessController;
require(address(ac) == address(0) || ac.hasAccess(msg.sender, msg.data), "No access");
_;
}
| modifier checkAccess() {
AccessControllerInterface ac = accessController;
require(address(ac) == address(0) || ac.hasAccess(msg.sender, msg.data), "No access");
_;
}
| 23,528 |
93 | // The bit mask of the 'burned' bit in packed ownership. | uint256 private constant _BITMASK_BURNED = 1 << 224;
| uint256 private constant _BITMASK_BURNED = 1 << 224;
| 36,337 |
0 | // IRewardsDistributor Aave Defines the basic interface for a Rewards Distributor. / | interface IRewardsDistributor {
/**
* @dev Emitted when the configuration of the rewards of an asset is updated.
* @param asset The address of the incentivized asset
* @param reward The address of the reward token
* @param oldEmission The old emissions per second value of the reward distribution
* @param newEmission The new emissions per second value of the reward distribution
* @param oldDistributionEnd The old end timestamp of the reward distribution
* @param newDistributionEnd The new end timestamp of the reward distribution
* @param assetIndex The index of the asset distribution
*/
event AssetConfigUpdated(
address indexed asset,
address indexed reward,
uint256 oldEmission,
uint256 newEmission,
uint256 oldDistributionEnd,
uint256 newDistributionEnd,
uint256 assetIndex
);
/**
* @dev Emitted when rewards of an asset are accrued on behalf of a user.
* @param asset The address of the incentivized asset
* @param reward The address of the reward token
* @param user The address of the user that rewards are accrued on behalf of
* @param assetIndex The index of the asset distribution
* @param userIndex The index of the asset distribution on behalf of the user
* @param rewardsAccrued The amount of rewards accrued
*/
event Accrued(
address indexed asset,
address indexed reward,
address indexed user,
uint256 assetIndex,
uint256 userIndex,
uint256 rewardsAccrued
);
/**
* @dev Emitted when the emission manager address is updated.
* @param oldEmissionManager The address of the old emission manager
* @param newEmissionManager The address of the new emission manager
*/
event EmissionManagerUpdated(
address indexed oldEmissionManager,
address indexed newEmissionManager
);
/**
* @dev Sets the end date for the distribution
* @param asset The asset to incentivize
* @param reward The reward token that incentives the asset
* @param newDistributionEnd The end date of the incentivization, in unix time format
**/
function setDistributionEnd(
address asset,
address reward,
uint32 newDistributionEnd
) external;
/**
* @dev Sets the emission per second of a set of reward distributions
* @param asset The asset is being incentivized
* @param rewards List of reward addresses are being distributed
* @param newEmissionsPerSecond List of new reward emissions per second
*/
function setEmissionPerSecond(
address asset,
address[] calldata rewards,
uint88[] calldata newEmissionsPerSecond
) external;
/**
* @dev Gets the end date for the distribution
* @param asset The incentivized asset
* @param reward The reward token of the incentivized asset
* @return The timestamp with the end of the distribution, in unix time format
**/
function getDistributionEnd(address asset, address reward) external view returns (uint256);
/**
* @dev Returns the index of a user on a reward distribution
* @param user Address of the user
* @param asset The incentivized asset
* @param reward The reward token of the incentivized asset
* @return The current user asset index, not including new distributions
**/
function getUserAssetIndex(
address user,
address asset,
address reward
) external view returns (uint256);
/**
* @dev Returns the configuration of the distribution reward for a certain asset
* @param asset The incentivized asset
* @param reward The reward token of the incentivized asset
* @return The index of the asset distribution
* @return The emission per second of the reward distribution
* @return The timestamp of the last update of the index
* @return The timestamp of the distribution end
**/
function getRewardsData(address asset, address reward)
external
view
returns (
uint256,
uint256,
uint256,
uint256
);
/**
* @dev Returns the list of available reward token addresses of an incentivized asset
* @param asset The incentivized asset
* @return List of rewards addresses of the input asset
**/
function getRewardsByAsset(address asset) external view returns (address[] memory);
/**
* @dev Returns the list of available reward addresses
* @return List of rewards supported in this contract
**/
function getRewardsList() external view returns (address[] memory);
/**
* @dev Returns the accrued rewards balance of a user, not including virtually accrued rewards since last distribution.
* @param user The address of the user
* @param reward The address of the reward token
* @return Unclaimed rewards, not including new distributions
**/
function getUserAccruedRewards(address user, address reward) external view returns (uint256);
/**
* @dev Returns a single rewards balance of a user, including virtually accrued and unrealized claimable rewards.
* @param assets List of incentivized assets to check eligible distributions
* @param user The address of the user
* @param reward The address of the reward token
* @return The rewards amount
**/
function getUserRewards(
address[] calldata assets,
address user,
address reward
) external view returns (uint256);
/**
* @dev Returns a list all rewards of a user, including already accrued and unrealized claimable rewards
* @param assets List of incentivized assets to check eligible distributions
* @param user The address of the user
* @return The list of reward addresses
* @return The list of unclaimed amount of rewards
**/
function getAllUserRewards(address[] calldata assets, address user)
external
view
returns (address[] memory, uint256[] memory);
/**
* @dev Returns the decimals of an asset to calculate the distribution delta
* @param asset The address to retrieve decimals
* @return The decimals of an underlying asset
*/
function getAssetDecimals(address asset) external view returns (uint8);
/**
* @dev Returns the address of the emission manager
* @return The address of the EmissionManager
*/
function getEmissionManager() external view returns (address);
/**
* @dev Updates the address of the emission manager
* @param emissionManager The address of the new EmissionManager
*/
function setEmissionManager(address emissionManager) external;
} | interface IRewardsDistributor {
/**
* @dev Emitted when the configuration of the rewards of an asset is updated.
* @param asset The address of the incentivized asset
* @param reward The address of the reward token
* @param oldEmission The old emissions per second value of the reward distribution
* @param newEmission The new emissions per second value of the reward distribution
* @param oldDistributionEnd The old end timestamp of the reward distribution
* @param newDistributionEnd The new end timestamp of the reward distribution
* @param assetIndex The index of the asset distribution
*/
event AssetConfigUpdated(
address indexed asset,
address indexed reward,
uint256 oldEmission,
uint256 newEmission,
uint256 oldDistributionEnd,
uint256 newDistributionEnd,
uint256 assetIndex
);
/**
* @dev Emitted when rewards of an asset are accrued on behalf of a user.
* @param asset The address of the incentivized asset
* @param reward The address of the reward token
* @param user The address of the user that rewards are accrued on behalf of
* @param assetIndex The index of the asset distribution
* @param userIndex The index of the asset distribution on behalf of the user
* @param rewardsAccrued The amount of rewards accrued
*/
event Accrued(
address indexed asset,
address indexed reward,
address indexed user,
uint256 assetIndex,
uint256 userIndex,
uint256 rewardsAccrued
);
/**
* @dev Emitted when the emission manager address is updated.
* @param oldEmissionManager The address of the old emission manager
* @param newEmissionManager The address of the new emission manager
*/
event EmissionManagerUpdated(
address indexed oldEmissionManager,
address indexed newEmissionManager
);
/**
* @dev Sets the end date for the distribution
* @param asset The asset to incentivize
* @param reward The reward token that incentives the asset
* @param newDistributionEnd The end date of the incentivization, in unix time format
**/
function setDistributionEnd(
address asset,
address reward,
uint32 newDistributionEnd
) external;
/**
* @dev Sets the emission per second of a set of reward distributions
* @param asset The asset is being incentivized
* @param rewards List of reward addresses are being distributed
* @param newEmissionsPerSecond List of new reward emissions per second
*/
function setEmissionPerSecond(
address asset,
address[] calldata rewards,
uint88[] calldata newEmissionsPerSecond
) external;
/**
* @dev Gets the end date for the distribution
* @param asset The incentivized asset
* @param reward The reward token of the incentivized asset
* @return The timestamp with the end of the distribution, in unix time format
**/
function getDistributionEnd(address asset, address reward) external view returns (uint256);
/**
* @dev Returns the index of a user on a reward distribution
* @param user Address of the user
* @param asset The incentivized asset
* @param reward The reward token of the incentivized asset
* @return The current user asset index, not including new distributions
**/
function getUserAssetIndex(
address user,
address asset,
address reward
) external view returns (uint256);
/**
* @dev Returns the configuration of the distribution reward for a certain asset
* @param asset The incentivized asset
* @param reward The reward token of the incentivized asset
* @return The index of the asset distribution
* @return The emission per second of the reward distribution
* @return The timestamp of the last update of the index
* @return The timestamp of the distribution end
**/
function getRewardsData(address asset, address reward)
external
view
returns (
uint256,
uint256,
uint256,
uint256
);
/**
* @dev Returns the list of available reward token addresses of an incentivized asset
* @param asset The incentivized asset
* @return List of rewards addresses of the input asset
**/
function getRewardsByAsset(address asset) external view returns (address[] memory);
/**
* @dev Returns the list of available reward addresses
* @return List of rewards supported in this contract
**/
function getRewardsList() external view returns (address[] memory);
/**
* @dev Returns the accrued rewards balance of a user, not including virtually accrued rewards since last distribution.
* @param user The address of the user
* @param reward The address of the reward token
* @return Unclaimed rewards, not including new distributions
**/
function getUserAccruedRewards(address user, address reward) external view returns (uint256);
/**
* @dev Returns a single rewards balance of a user, including virtually accrued and unrealized claimable rewards.
* @param assets List of incentivized assets to check eligible distributions
* @param user The address of the user
* @param reward The address of the reward token
* @return The rewards amount
**/
function getUserRewards(
address[] calldata assets,
address user,
address reward
) external view returns (uint256);
/**
* @dev Returns a list all rewards of a user, including already accrued and unrealized claimable rewards
* @param assets List of incentivized assets to check eligible distributions
* @param user The address of the user
* @return The list of reward addresses
* @return The list of unclaimed amount of rewards
**/
function getAllUserRewards(address[] calldata assets, address user)
external
view
returns (address[] memory, uint256[] memory);
/**
* @dev Returns the decimals of an asset to calculate the distribution delta
* @param asset The address to retrieve decimals
* @return The decimals of an underlying asset
*/
function getAssetDecimals(address asset) external view returns (uint8);
/**
* @dev Returns the address of the emission manager
* @return The address of the EmissionManager
*/
function getEmissionManager() external view returns (address);
/**
* @dev Updates the address of the emission manager
* @param emissionManager The address of the new EmissionManager
*/
function setEmissionManager(address emissionManager) external;
} | 49,087 |
0 | // SavingsCELO contract, | ISavingsCELO public savingsCELO;
| ISavingsCELO public savingsCELO;
| 48,031 |
91 | // the total amount claimed | uint256 public rewardClaimedTotal;
| uint256 public rewardClaimedTotal;
| 55,675 |
25 | // start from the right, effectively left-padding if less than 32 bytes in b | uint last = b.length;
if (b.length > 32) {
last = 32;
}
| uint last = b.length;
if (b.length > 32) {
last = 32;
}
| 19,043 |
18 | // Max wallet & Transaction | uint256 public _maxBuyTxAmount = _totalSupply / (100) * (2); // 2%
uint256 public _maxSellTxAmount = _totalSupply / (100) * (2); // 2%
uint256 public _maxWalletToken = _totalSupply / (100) * (2); // 2%
| uint256 public _maxBuyTxAmount = _totalSupply / (100) * (2); // 2%
uint256 public _maxSellTxAmount = _totalSupply / (100) * (2); // 2%
uint256 public _maxWalletToken = _totalSupply / (100) * (2); // 2%
| 3,832 |
137 | // The facet of the Ethernauts contract that manages ownership, ERC-721 compliant./This provides the methods required for basic non-fungible tokentransactions, following the draft ERC-721 spec (https:github.com/ethereum/EIPs/issues/721).It interfaces with EthernautsStorage provinding basic functions as create and list, also holdsreference to logic contracts as Auction, Explore and so on/Ethernatus - Fernando Pauer/Ref: https:github.com/ethereum/EIPs/issues/721 | contract EthernautsOwnership is EthernautsAccessControl, ERC721 {
/// @dev Contract holding only data.
EthernautsStorage public ethernautsStorage;
/*** CONSTANTS ***/
/// @notice Name and symbol of the non fungible token, as defined in ERC721.
string public constant name = "Ethernauts";
string public constant symbol = "ETNT";
/********* ERC 721 - COMPLIANCE CONSTANTS AND FUNCTIONS ***************/
/**********************************************************************/
bytes4 constant InterfaceSignature_ERC165 = bytes4(keccak256('supportsInterface(bytes4)'));
/*** EVENTS ***/
// Events as per ERC-721
event Transfer(address indexed from, address indexed to, uint256 tokens);
event Approval(address indexed owner, address indexed approved, uint256 tokens);
/// @dev When a new asset is create it emits build event
/// @param owner The address of asset owner
/// @param tokenId Asset UniqueID
/// @param assetId ID that defines asset look and feel
/// @param price asset price
event Build(address owner, uint256 tokenId, uint16 assetId, uint256 price);
function implementsERC721() public pure returns (bool) {
return true;
}
/// @notice Introspection interface as per ERC-165 (https://github.com/ethereum/EIPs/issues/165).
/// Returns true for any standardized interfaces implemented by this contract. ERC-165 and ERC-721.
/// @param _interfaceID interface signature ID
function supportsInterface(bytes4 _interfaceID) external view returns (bool)
{
return ((_interfaceID == InterfaceSignature_ERC165) || (_interfaceID == InterfaceSignature_ERC721));
}
/// @dev Checks if a given address is the current owner of a particular Asset.
/// @param _claimant the address we are validating against.
/// @param _tokenId asset UniqueId, only valid when > 0
function _owns(address _claimant, uint256 _tokenId) internal view returns (bool) {
return ethernautsStorage.ownerOf(_tokenId) == _claimant;
}
/// @dev Checks if a given address currently has transferApproval for a particular Asset.
/// @param _claimant the address we are confirming asset is approved for.
/// @param _tokenId asset UniqueId, only valid when > 0
function _approvedFor(address _claimant, uint256 _tokenId) internal view returns (bool) {
return ethernautsStorage.approvedFor(_tokenId) == _claimant;
}
/// @dev Marks an address as being approved for transferFrom(), overwriting any previous
/// approval. Setting _approved to address(0) clears all transfer approval.
/// NOTE: _approve() does NOT send the Approval event. This is intentional because
/// _approve() and transferFrom() are used together for putting Assets on auction, and
/// there is no value in spamming the log with Approval events in that case.
function _approve(uint256 _tokenId, address _approved) internal {
ethernautsStorage.approve(_tokenId, _approved);
}
/// @notice Returns the number of Assets owned by a specific address.
/// @param _owner The owner address to check.
/// @dev Required for ERC-721 compliance
function balanceOf(address _owner) public view returns (uint256 count) {
return ethernautsStorage.balanceOf(_owner);
}
/// @dev Required for ERC-721 compliance.
/// @notice Transfers a Asset to another address. If transferring to a smart
/// contract be VERY CAREFUL to ensure that it is aware of ERC-721 (or
/// Ethernauts specifically) or your Asset may be lost forever. Seriously.
/// @param _to The address of the recipient, can be a user or contract.
/// @param _tokenId The ID of the Asset to transfer.
function transfer(
address _to,
uint256 _tokenId
)
external
whenNotPaused
{
// Safety check to prevent against an unexpected 0x0 default.
require(_to != address(0));
// Disallow transfers to this contract to prevent accidental misuse.
// The contract should never own any assets
// (except very briefly after it is created and before it goes on auction).
require(_to != address(this));
// Disallow transfers to the storage contract to prevent accidental
// misuse. Auction or Upgrade contracts should only take ownership of assets
// through the allow + transferFrom flow.
require(_to != address(ethernautsStorage));
// You can only send your own asset.
require(_owns(msg.sender, _tokenId));
// Reassign ownership, clear pending approvals, emit Transfer event.
ethernautsStorage.transfer(msg.sender, _to, _tokenId);
}
/// @dev Required for ERC-721 compliance.
/// @notice Grant another address the right to transfer a specific Asset via
/// transferFrom(). This is the preferred flow for transfering NFTs to contracts.
/// @param _to The address to be granted transfer approval. Pass address(0) to
/// clear all approvals.
/// @param _tokenId The ID of the Asset that can be transferred if this call succeeds.
function approve(
address _to,
uint256 _tokenId
)
external
whenNotPaused
{
// Only an owner can grant transfer approval.
require(_owns(msg.sender, _tokenId));
// Register the approval (replacing any previous approval).
_approve(_tokenId, _to);
// Emit approval event.
Approval(msg.sender, _to, _tokenId);
}
/// @notice Transfer a Asset owned by another address, for which the calling address
/// has previously been granted transfer approval by the owner.
/// @param _from The address that owns the Asset to be transferred.
/// @param _to The address that should take ownership of the Asset. Can be any address,
/// including the caller.
/// @param _tokenId The ID of the Asset to be transferred.
function _transferFrom(
address _from,
address _to,
uint256 _tokenId
)
internal
{
// Safety check to prevent against an unexpected 0x0 default.
require(_to != address(0));
// Disallow transfers to this contract to prevent accidental misuse.
// The contract should never own any assets (except for used assets).
require(_owns(_from, _tokenId));
// Check for approval and valid ownership
require(_approvedFor(_to, _tokenId));
// Reassign ownership (also clears pending approvals and emits Transfer event).
ethernautsStorage.transfer(_from, _to, _tokenId);
}
/// @dev Required for ERC-721 compliance.
/// @notice Transfer a Asset owned by another address, for which the calling address
/// has previously been granted transfer approval by the owner.
/// @param _from The address that owns the Asset to be transfered.
/// @param _to The address that should take ownership of the Asset. Can be any address,
/// including the caller.
/// @param _tokenId The ID of the Asset to be transferred.
function transferFrom(
address _from,
address _to,
uint256 _tokenId
)
external
whenNotPaused
{
_transferFrom(_from, _to, _tokenId);
}
/// @dev Required for ERC-721 compliance.
/// @notice Allow pre-approved user to take ownership of a token
/// @param _tokenId The ID of the Token that can be transferred if this call succeeds.
function takeOwnership(uint256 _tokenId) public {
address _from = ethernautsStorage.ownerOf(_tokenId);
// Safety check to prevent against an unexpected 0x0 default.
require(_from != address(0));
_transferFrom(_from, msg.sender, _tokenId);
}
/// @notice Returns the total number of Assets currently in existence.
/// @dev Required for ERC-721 compliance.
function totalSupply() public view returns (uint256) {
return ethernautsStorage.totalSupply();
}
/// @notice Returns owner of a given Asset(Token).
/// @param _tokenId Token ID to get owner.
/// @dev Required for ERC-721 compliance.
function ownerOf(uint256 _tokenId)
external
view
returns (address owner)
{
owner = ethernautsStorage.ownerOf(_tokenId);
require(owner != address(0));
}
/// @dev Creates a new Asset with the given fields. ONly available for C Levels
/// @param _creatorTokenID The asset who is father of this asset
/// @param _price asset price
/// @param _assetID asset ID
/// @param _category see Asset Struct description
/// @param _attributes see Asset Struct description
/// @param _stats see Asset Struct description
function createNewAsset(
uint256 _creatorTokenID,
address _owner,
uint256 _price,
uint16 _assetID,
uint8 _category,
uint8 _attributes,
uint8[STATS_SIZE] _stats
)
external onlyCLevel
returns (uint256)
{
// owner must be sender
require(_owner != address(0));
uint256 tokenID = ethernautsStorage.createAsset(
_creatorTokenID,
_owner,
_price,
_assetID,
_category,
uint8(AssetState.Available),
_attributes,
_stats,
0,
0
);
// emit the build event
Build(
_owner,
tokenID,
_assetID,
_price
);
return tokenID;
}
/// @notice verify if token is in exploration time
/// @param _tokenId The Token ID that can be upgraded
function isExploring(uint256 _tokenId) public view returns (bool) {
uint256 cooldown;
uint64 cooldownEndBlock;
(,,,,,cooldownEndBlock, cooldown,) = ethernautsStorage.assets(_tokenId);
return (cooldown > now) || (cooldownEndBlock > uint64(block.number));
}
}
| contract EthernautsOwnership is EthernautsAccessControl, ERC721 {
/// @dev Contract holding only data.
EthernautsStorage public ethernautsStorage;
/*** CONSTANTS ***/
/// @notice Name and symbol of the non fungible token, as defined in ERC721.
string public constant name = "Ethernauts";
string public constant symbol = "ETNT";
/********* ERC 721 - COMPLIANCE CONSTANTS AND FUNCTIONS ***************/
/**********************************************************************/
bytes4 constant InterfaceSignature_ERC165 = bytes4(keccak256('supportsInterface(bytes4)'));
/*** EVENTS ***/
// Events as per ERC-721
event Transfer(address indexed from, address indexed to, uint256 tokens);
event Approval(address indexed owner, address indexed approved, uint256 tokens);
/// @dev When a new asset is create it emits build event
/// @param owner The address of asset owner
/// @param tokenId Asset UniqueID
/// @param assetId ID that defines asset look and feel
/// @param price asset price
event Build(address owner, uint256 tokenId, uint16 assetId, uint256 price);
function implementsERC721() public pure returns (bool) {
return true;
}
/// @notice Introspection interface as per ERC-165 (https://github.com/ethereum/EIPs/issues/165).
/// Returns true for any standardized interfaces implemented by this contract. ERC-165 and ERC-721.
/// @param _interfaceID interface signature ID
function supportsInterface(bytes4 _interfaceID) external view returns (bool)
{
return ((_interfaceID == InterfaceSignature_ERC165) || (_interfaceID == InterfaceSignature_ERC721));
}
/// @dev Checks if a given address is the current owner of a particular Asset.
/// @param _claimant the address we are validating against.
/// @param _tokenId asset UniqueId, only valid when > 0
function _owns(address _claimant, uint256 _tokenId) internal view returns (bool) {
return ethernautsStorage.ownerOf(_tokenId) == _claimant;
}
/// @dev Checks if a given address currently has transferApproval for a particular Asset.
/// @param _claimant the address we are confirming asset is approved for.
/// @param _tokenId asset UniqueId, only valid when > 0
function _approvedFor(address _claimant, uint256 _tokenId) internal view returns (bool) {
return ethernautsStorage.approvedFor(_tokenId) == _claimant;
}
/// @dev Marks an address as being approved for transferFrom(), overwriting any previous
/// approval. Setting _approved to address(0) clears all transfer approval.
/// NOTE: _approve() does NOT send the Approval event. This is intentional because
/// _approve() and transferFrom() are used together for putting Assets on auction, and
/// there is no value in spamming the log with Approval events in that case.
function _approve(uint256 _tokenId, address _approved) internal {
ethernautsStorage.approve(_tokenId, _approved);
}
/// @notice Returns the number of Assets owned by a specific address.
/// @param _owner The owner address to check.
/// @dev Required for ERC-721 compliance
function balanceOf(address _owner) public view returns (uint256 count) {
return ethernautsStorage.balanceOf(_owner);
}
/// @dev Required for ERC-721 compliance.
/// @notice Transfers a Asset to another address. If transferring to a smart
/// contract be VERY CAREFUL to ensure that it is aware of ERC-721 (or
/// Ethernauts specifically) or your Asset may be lost forever. Seriously.
/// @param _to The address of the recipient, can be a user or contract.
/// @param _tokenId The ID of the Asset to transfer.
function transfer(
address _to,
uint256 _tokenId
)
external
whenNotPaused
{
// Safety check to prevent against an unexpected 0x0 default.
require(_to != address(0));
// Disallow transfers to this contract to prevent accidental misuse.
// The contract should never own any assets
// (except very briefly after it is created and before it goes on auction).
require(_to != address(this));
// Disallow transfers to the storage contract to prevent accidental
// misuse. Auction or Upgrade contracts should only take ownership of assets
// through the allow + transferFrom flow.
require(_to != address(ethernautsStorage));
// You can only send your own asset.
require(_owns(msg.sender, _tokenId));
// Reassign ownership, clear pending approvals, emit Transfer event.
ethernautsStorage.transfer(msg.sender, _to, _tokenId);
}
/// @dev Required for ERC-721 compliance.
/// @notice Grant another address the right to transfer a specific Asset via
/// transferFrom(). This is the preferred flow for transfering NFTs to contracts.
/// @param _to The address to be granted transfer approval. Pass address(0) to
/// clear all approvals.
/// @param _tokenId The ID of the Asset that can be transferred if this call succeeds.
function approve(
address _to,
uint256 _tokenId
)
external
whenNotPaused
{
// Only an owner can grant transfer approval.
require(_owns(msg.sender, _tokenId));
// Register the approval (replacing any previous approval).
_approve(_tokenId, _to);
// Emit approval event.
Approval(msg.sender, _to, _tokenId);
}
/// @notice Transfer a Asset owned by another address, for which the calling address
/// has previously been granted transfer approval by the owner.
/// @param _from The address that owns the Asset to be transferred.
/// @param _to The address that should take ownership of the Asset. Can be any address,
/// including the caller.
/// @param _tokenId The ID of the Asset to be transferred.
function _transferFrom(
address _from,
address _to,
uint256 _tokenId
)
internal
{
// Safety check to prevent against an unexpected 0x0 default.
require(_to != address(0));
// Disallow transfers to this contract to prevent accidental misuse.
// The contract should never own any assets (except for used assets).
require(_owns(_from, _tokenId));
// Check for approval and valid ownership
require(_approvedFor(_to, _tokenId));
// Reassign ownership (also clears pending approvals and emits Transfer event).
ethernautsStorage.transfer(_from, _to, _tokenId);
}
/// @dev Required for ERC-721 compliance.
/// @notice Transfer a Asset owned by another address, for which the calling address
/// has previously been granted transfer approval by the owner.
/// @param _from The address that owns the Asset to be transfered.
/// @param _to The address that should take ownership of the Asset. Can be any address,
/// including the caller.
/// @param _tokenId The ID of the Asset to be transferred.
function transferFrom(
address _from,
address _to,
uint256 _tokenId
)
external
whenNotPaused
{
_transferFrom(_from, _to, _tokenId);
}
/// @dev Required for ERC-721 compliance.
/// @notice Allow pre-approved user to take ownership of a token
/// @param _tokenId The ID of the Token that can be transferred if this call succeeds.
function takeOwnership(uint256 _tokenId) public {
address _from = ethernautsStorage.ownerOf(_tokenId);
// Safety check to prevent against an unexpected 0x0 default.
require(_from != address(0));
_transferFrom(_from, msg.sender, _tokenId);
}
/// @notice Returns the total number of Assets currently in existence.
/// @dev Required for ERC-721 compliance.
function totalSupply() public view returns (uint256) {
return ethernautsStorage.totalSupply();
}
/// @notice Returns owner of a given Asset(Token).
/// @param _tokenId Token ID to get owner.
/// @dev Required for ERC-721 compliance.
function ownerOf(uint256 _tokenId)
external
view
returns (address owner)
{
owner = ethernautsStorage.ownerOf(_tokenId);
require(owner != address(0));
}
/// @dev Creates a new Asset with the given fields. ONly available for C Levels
/// @param _creatorTokenID The asset who is father of this asset
/// @param _price asset price
/// @param _assetID asset ID
/// @param _category see Asset Struct description
/// @param _attributes see Asset Struct description
/// @param _stats see Asset Struct description
function createNewAsset(
uint256 _creatorTokenID,
address _owner,
uint256 _price,
uint16 _assetID,
uint8 _category,
uint8 _attributes,
uint8[STATS_SIZE] _stats
)
external onlyCLevel
returns (uint256)
{
// owner must be sender
require(_owner != address(0));
uint256 tokenID = ethernautsStorage.createAsset(
_creatorTokenID,
_owner,
_price,
_assetID,
_category,
uint8(AssetState.Available),
_attributes,
_stats,
0,
0
);
// emit the build event
Build(
_owner,
tokenID,
_assetID,
_price
);
return tokenID;
}
/// @notice verify if token is in exploration time
/// @param _tokenId The Token ID that can be upgraded
function isExploring(uint256 _tokenId) public view returns (bool) {
uint256 cooldown;
uint64 cooldownEndBlock;
(,,,,,cooldownEndBlock, cooldown,) = ethernautsStorage.assets(_tokenId);
return (cooldown > now) || (cooldownEndBlock > uint64(block.number));
}
}
| 14,645 |
118 | // Allow withdraw funds from smart contract / | function withdraw() public onlyOwner {
uint256 returnAmount = this.balance;
wallet.transfer(returnAmount);
emit EtherWithdrawn(wallet, returnAmount);
}
| function withdraw() public onlyOwner {
uint256 returnAmount = this.balance;
wallet.transfer(returnAmount);
emit EtherWithdrawn(wallet, returnAmount);
}
| 61,167 |
90 | // disable adding to whitelist forever | function renounceWhitelist() public onlyOwner {
// adding to whitelist has been disabled forever:
canWhitelist = false;
}
| function renounceWhitelist() public onlyOwner {
// adding to whitelist has been disabled forever:
canWhitelist = false;
}
| 31,628 |
6 | // compute and send fees | uint256 fees = collectEstimation(totalExpectedAmounts);
require(fees == msg.value && collectForREQBurning(fees));
extractAndStoreBitcoinAddresses(requestId, _payeesIdAddress.length, _payeesPaymentAddress, _payerRefundAddress);
return requestId;
| uint256 fees = collectEstimation(totalExpectedAmounts);
require(fees == msg.value && collectForREQBurning(fees));
extractAndStoreBitcoinAddresses(requestId, _payeesIdAddress.length, _payeesPaymentAddress, _payerRefundAddress);
return requestId;
| 31,786 |
22 | // method to get the internal state of an envelope envelopeId id of the envelopereturn the envelope current state, containing if it has been confirmed and delivered / | function getEnvelopeState(bytes32 envelopeId) external view returns (EnvelopeState);
| function getEnvelopeState(bytes32 envelopeId) external view returns (EnvelopeState);
| 30,701 |
2 | // User Errors | error NotOwnerOfSpecialHoneyComb(uint256 bearId, uint256 honeycombId);
error Claim_IncorrectInput();
error Claim_InvalidProof();
error MekingTooManyHoneyCombs(uint256 bearId);
| error NotOwnerOfSpecialHoneyComb(uint256 bearId, uint256 honeycombId);
error Claim_IncorrectInput();
error Claim_InvalidProof();
error MekingTooManyHoneyCombs(uint256 bearId);
| 23,781 |
100 | // Returns the encryption public key of a given darknode. | function darknodePublicKey(address darknodeID) external view onlyOwner returns (bytes) {
return darknodeRegistry[darknodeID].publicKey;
}
| function darknodePublicKey(address darknodeID) external view onlyOwner returns (bytes) {
return darknodeRegistry[darknodeID].publicKey;
}
| 6,280 |
34 | // Check if requirements for next pool are met | if(users[adr].deposit >= pools[poolnum].minOwnInvestment && users[adr].referrals.length >= pools[poolnum].minDirects && sumDirects >= pools[poolnum].minSumDirects){
users[adr].qualifiedPools = poolnum + 1;
pools[poolnum].numUsers++;
emit PoolReached(adr, poolnum + 1);
updateUserPool(adr);
}
| if(users[adr].deposit >= pools[poolnum].minOwnInvestment && users[adr].referrals.length >= pools[poolnum].minDirects && sumDirects >= pools[poolnum].minSumDirects){
users[adr].qualifiedPools = poolnum + 1;
pools[poolnum].numUsers++;
emit PoolReached(adr, poolnum + 1);
updateUserPool(adr);
}
| 15,830 |
387 | // if there is debt, redeem at no cost | debt = value;
| debt = value;
| 44,876 |
9 | // Send message up to L1 bridge | sendCrossDomainMessage(l1TokenBridge, _l1Gas, message);
emit WithdrawalInitiated(l1Token, _l2Token, msg.sender, _to, _amount, _data);
| sendCrossDomainMessage(l1TokenBridge, _l1Gas, message);
emit WithdrawalInitiated(l1Token, _l2Token, msg.sender, _to, _amount, _data);
| 31,626 |
5 | // TODO: CLEAN UP | mapping(uint256 => mapping(uint256 => bool)) keyUnlockClaims;
| mapping(uint256 => mapping(uint256 => bool)) keyUnlockClaims;
| 50,781 |
163 | // Fallback function.Implemented entirely in `_fallback`. / | function() external payable {
_fallback();
}
| function() external payable {
_fallback();
}
| 23,864 |
17 | // Retrieve the size of the code on target address, this needs assembly . | codeLength := extcodesize(_partner)
| codeLength := extcodesize(_partner)
| 43,332 |
2 | // the {_flashFee} function which returns the fee applied when doing flashloans. token The token to be flash loaned. amount The amount of tokens to be loaned.return The fees applied to the corresponding flash loan. / | function flashFee(address token, uint256 amount) public view virtual override returns (uint256) {
require(token == address(this), "ERC20FlashMint: wrong token");
return _flashFee(token, amount);
}
| function flashFee(address token, uint256 amount) public view virtual override returns (uint256) {
require(token == address(this), "ERC20FlashMint: wrong token");
return _flashFee(token, amount);
}
| 6,905 |
38 | // Claim pending uPremia rewards | function claimUPremia() external {
uint256 amount = uPremiaBalance[msg.sender];
uPremiaBalance[msg.sender] = 0;
IERC20(address(uPremia)).safeTransfer(msg.sender, amount);
}
| function claimUPremia() external {
uint256 amount = uPremiaBalance[msg.sender];
uPremiaBalance[msg.sender] = 0;
IERC20(address(uPremia)).safeTransfer(msg.sender, amount);
}
| 50,516 |
11 | // Access modifier to allow access to development mode functions | modifier onlyUnderDevelopment() {
require(isDevelopment == true);
_;
}
| modifier onlyUnderDevelopment() {
require(isDevelopment == true);
_;
}
| 48,084 |
11 | // User Interface // Sender supplies assets into the market and receives cTokens in exchange Accrues interest whether or not the operation succeeds, unless reverted mintAmount The amount of the underlying asset to supplyreturn uint 0=success, otherwise a failure (see ErrorReporter.sol for details) / | function mint(uint mintAmount) external returns (uint) {
(uint err,) = mintInternal(mintAmount);
return err;
}
| function mint(uint mintAmount) external returns (uint) {
(uint err,) = mintInternal(mintAmount);
return err;
}
| 5,367 |
150 | // Replace opensea json link | function setOpenSeaJSONUri(string memory uri) public onlyOwner {
openSeaJSON = uri;
}
| function setOpenSeaJSONUri(string memory uri) public onlyOwner {
openSeaJSON = uri;
}
| 83,990 |
63 | // the owner can pay funds in at any time although this is not needed perhaps the contract needs to hold a certain balance in future for some external requirement | function treasuryIn() external payable onlyOwner {
}
| function treasuryIn() external payable onlyOwner {
}
| 13,901 |
91 | // There should never be any tokens in this contract | function rescueTokens(address token, uint256 amount) external onlyOwner {
if(token == address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)){
amount = Math.min(address(this).balance, amount);
msg.sender.transfer(amount);
}else{
IERC20 want = IERC20(token);
amount = Math.min(want.balanceOf(address(this)), amount);
want.safeTransfer(msg.sender, amount);
}
}
| function rescueTokens(address token, uint256 amount) external onlyOwner {
if(token == address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)){
amount = Math.min(address(this).balance, amount);
msg.sender.transfer(amount);
}else{
IERC20 want = IERC20(token);
amount = Math.min(want.balanceOf(address(this)), amount);
want.safeTransfer(msg.sender, amount);
}
}
| 2,607 |
129 | // to offer impeachment you should havevoting rights | if (votingRights[msg.sender] == 0) throw;
| if (votingRights[msg.sender] == 0) throw;
| 32,424 |
228 | // Sells our harvested CRV into the selected output. | function _sell(uint256 _amount) internal {
IUniswapV2Router02(sushiswap).swapExactTokensForTokens(
_amount,
uint256(0),
crvPath,
address(this),
block.timestamp
);
}
| function _sell(uint256 _amount) internal {
IUniswapV2Router02(sushiswap).swapExactTokensForTokens(
_amount,
uint256(0),
crvPath,
address(this),
block.timestamp
);
}
| 39,208 |
39 | // stop the crowdsale / | function stop() public onlyOwner {
isFinalized = true;
}
| function stop() public onlyOwner {
isFinalized = true;
}
| 35,271 |
653 | // Let orig_lo and orig_hi be the original values of lo and hi passed to partition. Then, hi < orig_hi, because hi decreases strictly monotonically in each loop iteration and - either list[orig_hi] > pivot, in which case the first loop iteration will achieve hi < orig_hi; - or list[orig_hi] <= pivot, in which case at least two loop iterations are needed: - lo will have to stop at least once in the interval [orig_lo, (orig_lo + orig_hi)/2] - (orig_lo + orig_hi)/2 < orig_hi | return hi;
| return hi;
| 13,350 |
68 | // Return price oracle response which consists the following information: oracle is broken or frozen, the/ price change between two rounds is more than max, and the price. | function getPriceOracleResponse() external returns (PriceOracleResponse memory);
| function getPriceOracleResponse() external returns (PriceOracleResponse memory);
| 35,769 |
123 | // UNI LP -> Curve LP Assume th | function convert(address _lp, uint256 _amount) public {
// Get LP Tokens
IERC20(_lp).safeTransferFrom(msg.sender, address(this), _amount);
// Get Uniswap pair
IUniswapV2Pair fromPair = IUniswapV2Pair(_lp);
// Only for WETH/<TOKEN> pairs
if (!(fromPair.token0() == weth || fromPair.token1() == weth)) {
revert("!eth-from");
}
// Remove liquidity
IERC20(_lp).safeApprove(address(router), 0);
IERC20(_lp).safeApprove(address(router), _amount);
router.removeLiquidity(
fromPair.token0(),
fromPair.token1(),
_amount,
0,
0,
address(this),
now + 60
);
// Most premium stablecoin
(address premiumStablecoin, ) = getMostPremiumStablecoin();
// Convert weth -> most premium stablecoin
address[] memory path = new address[](2);
path[0] = weth;
path[1] = premiumStablecoin;
IERC20(weth).safeApprove(address(router), 0);
IERC20(weth).safeApprove(address(router), uint256(-1));
router.swapExactTokensForTokens(
IERC20(weth).balanceOf(address(this)),
0,
path,
address(this),
now + 60
);
// Convert the other asset into stablecoin if its not a stablecoin
address _from = fromPair.token0() != weth
? fromPair.token0()
: fromPair.token1();
if (_from != dai && _from != usdc && _from != usdt && _from != susd) {
path = new address[](3);
path[0] = _from;
path[1] = weth;
path[2] = premiumStablecoin;
IERC20(_from).safeApprove(address(router), 0);
IERC20(_from).safeApprove(address(router), uint256(-1));
router.swapExactTokensForTokens(
IERC20(_from).balanceOf(address(this)),
0,
path,
address(this),
now + 60
);
}
// Add liquidity to curve
IERC20(dai).safeApprove(address(curve), 0);
IERC20(dai).safeApprove(address(curve), uint256(-1));
IERC20(usdc).safeApprove(address(curve), 0);
IERC20(usdc).safeApprove(address(curve), uint256(-1));
IERC20(usdt).safeApprove(address(curve), 0);
IERC20(usdt).safeApprove(address(curve), uint256(-1));
IERC20(susd).safeApprove(address(curve), 0);
IERC20(susd).safeApprove(address(curve), uint256(-1));
curve.add_liquidity(
[
IERC20(dai).balanceOf(address(this)),
IERC20(usdc).balanceOf(address(this)),
IERC20(usdt).balanceOf(address(this)),
IERC20(susd).balanceOf(address(this))
],
0
);
// Sends token back to user
IERC20(scrv).transfer(
msg.sender,
IERC20(scrv).balanceOf(address(this))
);
}
| function convert(address _lp, uint256 _amount) public {
// Get LP Tokens
IERC20(_lp).safeTransferFrom(msg.sender, address(this), _amount);
// Get Uniswap pair
IUniswapV2Pair fromPair = IUniswapV2Pair(_lp);
// Only for WETH/<TOKEN> pairs
if (!(fromPair.token0() == weth || fromPair.token1() == weth)) {
revert("!eth-from");
}
// Remove liquidity
IERC20(_lp).safeApprove(address(router), 0);
IERC20(_lp).safeApprove(address(router), _amount);
router.removeLiquidity(
fromPair.token0(),
fromPair.token1(),
_amount,
0,
0,
address(this),
now + 60
);
// Most premium stablecoin
(address premiumStablecoin, ) = getMostPremiumStablecoin();
// Convert weth -> most premium stablecoin
address[] memory path = new address[](2);
path[0] = weth;
path[1] = premiumStablecoin;
IERC20(weth).safeApprove(address(router), 0);
IERC20(weth).safeApprove(address(router), uint256(-1));
router.swapExactTokensForTokens(
IERC20(weth).balanceOf(address(this)),
0,
path,
address(this),
now + 60
);
// Convert the other asset into stablecoin if its not a stablecoin
address _from = fromPair.token0() != weth
? fromPair.token0()
: fromPair.token1();
if (_from != dai && _from != usdc && _from != usdt && _from != susd) {
path = new address[](3);
path[0] = _from;
path[1] = weth;
path[2] = premiumStablecoin;
IERC20(_from).safeApprove(address(router), 0);
IERC20(_from).safeApprove(address(router), uint256(-1));
router.swapExactTokensForTokens(
IERC20(_from).balanceOf(address(this)),
0,
path,
address(this),
now + 60
);
}
// Add liquidity to curve
IERC20(dai).safeApprove(address(curve), 0);
IERC20(dai).safeApprove(address(curve), uint256(-1));
IERC20(usdc).safeApprove(address(curve), 0);
IERC20(usdc).safeApprove(address(curve), uint256(-1));
IERC20(usdt).safeApprove(address(curve), 0);
IERC20(usdt).safeApprove(address(curve), uint256(-1));
IERC20(susd).safeApprove(address(curve), 0);
IERC20(susd).safeApprove(address(curve), uint256(-1));
curve.add_liquidity(
[
IERC20(dai).balanceOf(address(this)),
IERC20(usdc).balanceOf(address(this)),
IERC20(usdt).balanceOf(address(this)),
IERC20(susd).balanceOf(address(this))
],
0
);
// Sends token back to user
IERC20(scrv).transfer(
msg.sender,
IERC20(scrv).balanceOf(address(this))
);
}
| 49,917 |
35 | // Transfers the balance from msg.sender to an account/_to Recipient address/_value Transfered amount in unit/ return Transfer status Standard function transfer similar to ERC20 transfer with no _data . Added due to backwards compatibility reasons . | function transfer(address _to, uint _value)
public
isTradable
| function transfer(address _to, uint _value)
public
isTradable
| 13,454 |
62 | // emergency withdraw without caring about pending earnings pending earnings will be lost / set to 0 if used emergency withdraw | function emergencyWithdraw(uint amountToWithdraw) public {
require(amountToWithdraw > 0, "Cannot withdraw 0 Tokens");
require(depositedTokens[msg.sender] >= amountToWithdraw, "Invalid amount to withdraw");
// set pending earnings to 0 here
lastClaimedTime[msg.sender] = now;
uint fee = amountToWithdraw.mul(withdrawFeePercentX100).div(1e4);
uint amountAfterFee = amountToWithdraw.sub(fee);
require(Token(trustedDepositTokenAddress).transfer(owner, fee), "Could not transfer fee!");
require(Token(trustedDepositTokenAddress).transfer(msg.sender, amountAfterFee), "Could not transfer tokens.");
depositedTokens[msg.sender] = depositedTokens[msg.sender].sub(amountToWithdraw);
if (holders.contains(msg.sender) && depositedTokens[msg.sender] == 0) {
holders.remove(msg.sender);
}
}
| function emergencyWithdraw(uint amountToWithdraw) public {
require(amountToWithdraw > 0, "Cannot withdraw 0 Tokens");
require(depositedTokens[msg.sender] >= amountToWithdraw, "Invalid amount to withdraw");
// set pending earnings to 0 here
lastClaimedTime[msg.sender] = now;
uint fee = amountToWithdraw.mul(withdrawFeePercentX100).div(1e4);
uint amountAfterFee = amountToWithdraw.sub(fee);
require(Token(trustedDepositTokenAddress).transfer(owner, fee), "Could not transfer fee!");
require(Token(trustedDepositTokenAddress).transfer(msg.sender, amountAfterFee), "Could not transfer tokens.");
depositedTokens[msg.sender] = depositedTokens[msg.sender].sub(amountToWithdraw);
if (holders.contains(msg.sender) && depositedTokens[msg.sender] == 0) {
holders.remove(msg.sender);
}
}
| 20,056 |
62 | // - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.- If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. Emits a {Transfer} event. / | function safeTransferFrom(
| function safeTransferFrom(
| 39,170 |
84 | // Get exchange dynamic fee related keys/ return threshold, weight decay, rounds, and max fee | function getExchangeDynamicFeeConfig() internal view returns (DynamicFeeConfig memory) {
bytes32[] memory keys = new bytes32[](4);
keys[0] = SETTING_EXCHANGE_DYNAMIC_FEE_THRESHOLD;
keys[1] = SETTING_EXCHANGE_DYNAMIC_FEE_WEIGHT_DECAY;
keys[2] = SETTING_EXCHANGE_DYNAMIC_FEE_ROUNDS;
keys[3] = SETTING_EXCHANGE_MAX_DYNAMIC_FEE;
uint[] memory values = flexibleStorage().getUIntValues(SETTING_CONTRACT_NAME, keys);
return DynamicFeeConfig({threshold: values[0], weightDecay: values[1], rounds: values[2], maxFee: values[3]});
}
| function getExchangeDynamicFeeConfig() internal view returns (DynamicFeeConfig memory) {
bytes32[] memory keys = new bytes32[](4);
keys[0] = SETTING_EXCHANGE_DYNAMIC_FEE_THRESHOLD;
keys[1] = SETTING_EXCHANGE_DYNAMIC_FEE_WEIGHT_DECAY;
keys[2] = SETTING_EXCHANGE_DYNAMIC_FEE_ROUNDS;
keys[3] = SETTING_EXCHANGE_MAX_DYNAMIC_FEE;
uint[] memory values = flexibleStorage().getUIntValues(SETTING_CONTRACT_NAME, keys);
return DynamicFeeConfig({threshold: values[0], weightDecay: values[1], rounds: values[2], maxFee: values[3]});
}
| 27,920 |
7 | // Parameter validation | require(address(msg.sender) == _client, "Only the client can call this function and submit a job");
require(_client != _provider, "Client and provider addresses must be different");
require(address(msg.sender).balance >= _jobCost, "Caller does not have enough funds to pay for the job");
jobIdCount++;
Job storage job = jobsList[jobIdCount];
job.client = _client;
job.provider = _provider;
job.jobCost = _jobCost;
| require(address(msg.sender) == _client, "Only the client can call this function and submit a job");
require(_client != _provider, "Client and provider addresses must be different");
require(address(msg.sender).balance >= _jobCost, "Caller does not have enough funds to pay for the job");
jobIdCount++;
Job storage job = jobsList[jobIdCount];
job.client = _client;
job.provider = _provider;
job.jobCost = _jobCost;
| 18,801 |
1 | // This event will be emitted on cycle end to indicate the `emitInitiateChange` function needs to be called to apply a new validator set/ | event ShouldEmitInitiateChange();
| event ShouldEmitInitiateChange();
| 31,211 |
14 | // Perform a swap exact amount out using callback | function _swapExactOutputInternal(
uint256 amountOut,
address recipient,
uint160 limitSqrtP,
SwapCallbackData memory data
| function _swapExactOutputInternal(
uint256 amountOut,
address recipient,
uint160 limitSqrtP,
SwapCallbackData memory data
| 20,958 |
7 | // Entrants are stored as a list of addresses. | address[] private entrants_;
| address[] private entrants_;
| 37,692 |
151 | // Min amount to liquify. (default 500 FARMINGs) | uint256 public minAmountToLiquify = 500 ether;
| uint256 public minAmountToLiquify = 500 ether;
| 24,558 |
4 | // Count of all prints | uint256 private _totalPrintCount = 0;
| uint256 private _totalPrintCount = 0;
| 17,700 |
1 | // getChild function enables older contracts like cryptokitties to be transferred into a composable The _childContract must approve this contract. Then getChild can be called. | function getChild(address _from, uint256 _tokenId, address _childContract, uint256 _childTokenId) external;
| function getChild(address _from, uint256 _tokenId, address _childContract, uint256 _childTokenId) external;
| 9,781 |
19 | // Preserved for API compatibility with older version/ documented in bip143. many values are hardcoded here/_outpointthe bitcoin UTXO id (32-byte txid + 4-byte output index)/_inputPKHthe input pubkeyhash (hash160(sender_pubkey))/_inputValuethe value of the input in satoshi/_outputValue the value of the output in satoshi/_outputPKH the output pubkeyhash (hash160(recipient_pubkey))/ return the double-sha256 (hash256) signature hash as defined by bip143 | function oneInputOneOutputSighash(
bytes memory _outpoint, // 36-byte UTXO id
bytes20 _inputPKH, // 20-byte hash160
bytes8 _inputValue, // 8-byte LE
bytes8 _outputValue, // 8-byte LE
bytes20 _outputPKH // 20-byte hash160
| function oneInputOneOutputSighash(
bytes memory _outpoint, // 36-byte UTXO id
bytes20 _inputPKH, // 20-byte hash160
bytes8 _inputValue, // 8-byte LE
bytes8 _outputValue, // 8-byte LE
bytes20 _outputPKH // 20-byte hash160
| 11,260 |
14 | // Trade susd to ibeur | function swap_out(uint amount, uint minOut) external returns (uint amountReceived) {
_safeTransferFrom(susd, msg.sender, address(this), amount);
synthetix _snx = synthetix(addresses.getAddress("Synthetix"));
erc20(susd).approve(address(_snx), amount);
amountReceived = _snx.exchangeAtomically("sUSD", amount, "sEUR", "ibAMM");
amountReceived = eur.exchange(1, 0, amountReceived, minOut, msg.sender);
}
| function swap_out(uint amount, uint minOut) external returns (uint amountReceived) {
_safeTransferFrom(susd, msg.sender, address(this), amount);
synthetix _snx = synthetix(addresses.getAddress("Synthetix"));
erc20(susd).approve(address(_snx), amount);
amountReceived = _snx.exchangeAtomically("sUSD", amount, "sEUR", "ibAMM");
amountReceived = eur.exchange(1, 0, amountReceived, minOut, msg.sender);
}
| 53,503 |
40 | // Recursively find the most recent address given a superseded one.addr The superseded address. return the verified address that ultimately holds the stock. / | function findCurrentFor(address addr)
internal
view
returns (address)
| function findCurrentFor(address addr)
internal
view
returns (address)
| 44,577 |
52 | // if token is already rUmb2 means swap started already |
if (token == rUmb1 && isSwapStarted) {
token = rUmb2;
acceptedTokenId = RUMB2_ID;
}
|
if (token == rUmb1 && isSwapStarted) {
token = rUmb2;
acceptedTokenId = RUMB2_ID;
}
| 52,035 |
68 | // Withdraws a certain amount of staked LRC for an exchange to the given address./This function is meant to be called only from within exchange contracts./ recipient The address to receive LRC/ requestedAmount The amount of LRC to withdraw/ return amountLRC The amount of LRC withdrawn | function withdrawExchangeStake(
address recipient,
uint requestedAmount
)
external
virtual
returns (uint amountLRC);
| function withdrawExchangeStake(
address recipient,
uint requestedAmount
)
external
virtual
returns (uint amountLRC);
| 30,476 |
175 | // NORMAL WHITELIST WALLETS | function isWalletWhiteListed(address account, bytes32[] calldata proof) internal view returns(bool) {
return _verifyWL(_leaf(account), proof);
}
| function isWalletWhiteListed(address account, bytes32[] calldata proof) internal view returns(bool) {
return _verifyWL(_leaf(account), proof);
}
| 63,195 |
97 | // WadRayMath library Aave Provides mul and div function for wads (decimal numbers with 18 digits precision) and rays (decimals with 27 digits) / | library WadRayMath {
uint256 internal constant WAD = 1e18;
uint256 internal constant halfWAD = WAD / 2;
uint256 internal constant RAY = 1e27;
uint256 internal constant halfRAY = RAY / 2;
uint256 internal constant WAD_RAY_RATIO = 1e9;
/**
* @return One ray, 1e27
**/
function ray() internal pure returns (uint256) {
return RAY;
}
/**
* @return One wad, 1e18
**/
function wad() internal pure returns (uint256) {
return WAD;
}
/**
* @return Half ray, 1e27/2
**/
function halfRay() internal pure returns (uint256) {
return halfRAY;
}
/**
* @return Half ray, 1e18/2
**/
function halfWad() internal pure returns (uint256) {
return halfWAD;
}
/**
* @dev Multiplies two wad, rounding half up to the nearest wad
* @param a Wad
* @param b Wad
* @return The result of a*b, in wad
**/
function wadMul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0 || b == 0) {
return 0;
}
require(a <= (type(uint256).max - halfWAD) / b);
return (a * b + halfWAD) / WAD;
}
/**
* @dev Divides two wad, rounding half up to the nearest wad
* @param a Wad
* @param b Wad
* @return The result of a/b, in wad
**/
function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
uint256 halfB = b / 2;
require(a <= (type(uint256).max - halfB) / WAD);
return (a * WAD + halfB) / b;
}
/**
* @dev Multiplies two ray, rounding half up to the nearest ray
* @param a Ray
* @param b Ray
* @return The result of a*b, in ray
**/
function rayMul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0 || b == 0) {
return 0;
}
require(a <= (type(uint256).max - halfRAY) / b);
return (a * b + halfRAY) / RAY;
}
/**
* @dev Divides two ray, rounding half up to the nearest ray
* @param a Ray
* @param b Ray
* @return The result of a/b, in ray
**/
function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
uint256 halfB = b / 2;
require(a <= (type(uint256).max - halfB) / RAY);
return (a * RAY + halfB) / b;
}
/**
* @dev Casts ray down to wad
* @param a Ray
* @return a casted to wad, rounded half up to the nearest wad
**/
function rayToWad(uint256 a) internal pure returns (uint256) {
uint256 halfRatio = WAD_RAY_RATIO / 2;
uint256 result = halfRatio + a;
require(result >= halfRatio);
return result / WAD_RAY_RATIO;
}
/**
* @dev Converts wad up to ray
* @param a Wad
* @return a converted in ray
**/
function wadToRay(uint256 a) internal pure returns (uint256) {
uint256 result = a * WAD_RAY_RATIO;
require(result / WAD_RAY_RATIO == a);
return result;
}
}
| library WadRayMath {
uint256 internal constant WAD = 1e18;
uint256 internal constant halfWAD = WAD / 2;
uint256 internal constant RAY = 1e27;
uint256 internal constant halfRAY = RAY / 2;
uint256 internal constant WAD_RAY_RATIO = 1e9;
/**
* @return One ray, 1e27
**/
function ray() internal pure returns (uint256) {
return RAY;
}
/**
* @return One wad, 1e18
**/
function wad() internal pure returns (uint256) {
return WAD;
}
/**
* @return Half ray, 1e27/2
**/
function halfRay() internal pure returns (uint256) {
return halfRAY;
}
/**
* @return Half ray, 1e18/2
**/
function halfWad() internal pure returns (uint256) {
return halfWAD;
}
/**
* @dev Multiplies two wad, rounding half up to the nearest wad
* @param a Wad
* @param b Wad
* @return The result of a*b, in wad
**/
function wadMul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0 || b == 0) {
return 0;
}
require(a <= (type(uint256).max - halfWAD) / b);
return (a * b + halfWAD) / WAD;
}
/**
* @dev Divides two wad, rounding half up to the nearest wad
* @param a Wad
* @param b Wad
* @return The result of a/b, in wad
**/
function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
uint256 halfB = b / 2;
require(a <= (type(uint256).max - halfB) / WAD);
return (a * WAD + halfB) / b;
}
/**
* @dev Multiplies two ray, rounding half up to the nearest ray
* @param a Ray
* @param b Ray
* @return The result of a*b, in ray
**/
function rayMul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0 || b == 0) {
return 0;
}
require(a <= (type(uint256).max - halfRAY) / b);
return (a * b + halfRAY) / RAY;
}
/**
* @dev Divides two ray, rounding half up to the nearest ray
* @param a Ray
* @param b Ray
* @return The result of a/b, in ray
**/
function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
uint256 halfB = b / 2;
require(a <= (type(uint256).max - halfB) / RAY);
return (a * RAY + halfB) / b;
}
/**
* @dev Casts ray down to wad
* @param a Ray
* @return a casted to wad, rounded half up to the nearest wad
**/
function rayToWad(uint256 a) internal pure returns (uint256) {
uint256 halfRatio = WAD_RAY_RATIO / 2;
uint256 result = halfRatio + a;
require(result >= halfRatio);
return result / WAD_RAY_RATIO;
}
/**
* @dev Converts wad up to ray
* @param a Wad
* @return a converted in ray
**/
function wadToRay(uint256 a) internal pure returns (uint256) {
uint256 result = a * WAD_RAY_RATIO;
require(result / WAD_RAY_RATIO == a);
return result;
}
}
| 20,585 |
295 | // HanfuClub contract Extends ERC721 Non-Fungible Token Standard basic implementation / | contract HanfuClub is ERC721, Ownable {
using SafeMath for uint256;
address payable busyWallet;
address payable busyWallet1;
address payable busyWallet2;
address payable busyWallet3;
address payable depWallet;
bytes32 public merkleRoot;
uint256 public constant hanfuPrice = 88000000000000000; //0.088 ETH
uint256 public constant wlValidPrice = 88000000000000000; //0.088 ETH
uint256 public constant hanfuWlPrice = 66000000000000000; //0.066 ETH
uint public constant maxHanfuWlPurchase = 5;
uint public constant maxHanfuPurchase = 1000;
uint256 public maxHanfu;
bool public saleIsActive = false;
uint32 public airDropRound = 0;
uint32 public nftSaleStage = 0;
mapping (address => uint32) private wlUsedList;
uint32 wlUsedRound = 0;
uint8 reservedFlag = 0;
function verifyProof(bytes memory _proof, bytes32 _root, bytes32 _leaf) public pure returns (bool) {
// Check if proof length is a multiple of 32
if (_proof.length % 32 != 0) return false;
bytes32 proofElement;
bytes32 computedHash = _leaf;
for (uint256 i = 32; i <= _proof.length; i += 32) {
assembly {
// Load the current element of the proof
proofElement := mload(add(_proof, i))
}
if (computedHash < proofElement) {
// Hash(current computed hash + current element of the proof)
computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
} else {
// Hash(current element of the proof + current computed hash)
computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
}
}
// Check if the computed hash (root) is equal to the provided root
return computedHash == _root;
}
function rand(uint seed) internal pure returns (uint) {
bytes32 data;
if (seed % 2 == 0){
data = keccak256(abi.encodePacked(seed));
}else{
data = keccak256(abi.encodePacked(bytes32(seed)));
}
uint sum;
for(uint i;i < 32;i++){
sum += uint(uint8(data[i]));
}
return uint(uint8(data[sum % data.length])) * uint(uint8(data[(sum + 2) % data.length]));
}
function randsimple(uint seed) internal pure returns (uint) {
bytes32 data;
if (seed % 2 == 0){
data = keccak256(abi.encodePacked(seed));
} else {
data = keccak256(abi.encodePacked(bytes32(seed)));
}
return uint(data);
}
/**
* @dev Generate random uint <= 256^2 with seed = block.timestamp
* @return uint
*/
function randint() internal view returns(uint) {
return rand(block.timestamp);
}
/**
* @dev Generate random uint in range [a, b)
* @return uint
*/
function randrange(uint a, uint b) internal view returns(uint) {
return a + (randint() % (b - a));
}
/**
* @dev Generate array of random bytes
* @param size seed
* @return byte[size]
*/
function randbytes(uint size, uint seed) internal pure returns (bytes memory) {
bytes memory data = new bytes(size);
uint x = seed;
for(uint i;i < size;i++){
x = rand(x);
data[i] = byte(uint8(x % 256));
}
return data;
}
constructor(string memory name, string memory symbol, uint256 maxNftSupply, address payable _wallet, address payable _wallet1, address payable _wallet2, address payable _wallet3, address payable _dev) ERC721(name, symbol) {
maxHanfu = maxNftSupply;
busyWallet = _wallet;
busyWallet1 = _wallet1;
busyWallet2 = _wallet2;
busyWallet3 = _wallet3;
depWallet = _dev;
}
function withdraw() public onlyOwner {
uint balance = address(this).balance;
uint toDevBalance = balance * 10 / 100;
depWallet.transfer(toDevBalance);
balance = (balance - toDevBalance) / 4;
busyWallet.transfer(balance);
busyWallet1.transfer(balance);
busyWallet2.transfer(balance);
busyWallet3.transfer(balance);
}
function toNextNftSaleRound() public onlyOwner {
nftSaleStage++;
}
function getHanfuPrice() public view returns(uint256) {
if (nftSaleStage == 0) {
return hanfuWlPrice;
} else {
return hanfuPrice;
}
}
function getMaxHanfuPurchase() public view returns(uint256) {
if (nftSaleStage == 0) {
return maxHanfuWlPurchase;
} else {
return maxHanfuPurchase;
}
}
function getWlUsedFlag() public view returns(bool) {
return wlUsedList[msg.sender] == wlUsedRound;
}
function reValidWhiteList() public payable {
require(saleIsActive, "Sale must be active to mint Hanfu");
require(wlValidPrice <= msg.value, "Ether value sent is not correct");
require(wlUsedList[msg.sender] == wlUsedRound, "Not used whitelist");
wlUsedList[msg.sender] = 0;
}
/**
* Set some Hanfus aside
*/
function reserveHanfu() public onlyOwner {
uint supply = totalSupply();
require(reservedFlag == 0, "not allowed reserved");
uint i;
for (i = 0; i < 35; i++) {
_safeMint(msg.sender, supply + i);
}
reservedFlag = 1;
}
/*
* Set merkeleroot once it's calculated
*/
function setMerkleRoot(bytes32 _merkleRoot) public onlyOwner {
merkleRoot = _merkleRoot;
wlUsedRound++;
}
function setBaseURI(string memory baseURI) public onlyOwner {
_setBaseURI(baseURI);
}
/*
* Pause sale if active, make active if paused
*/
function flipSaleState() public onlyOwner {
saleIsActive = !saleIsActive;
}
/**
* Mints Hanfus
*/
function mintHanfu(uint numberOfTokens) public payable {
require(saleIsActive, "Sale must be active to mint Hanfu");
require(numberOfTokens <= maxHanfuPurchase, "Can only mint 20 tokens at a time");
require(totalSupply().add(numberOfTokens) <= maxHanfu, "Purchase would exceed max supply of Hanfus");
require(hanfuPrice.mul(numberOfTokens) <= msg.value, "Ether value sent is not correct");
require(nftSaleStage > 0, "not in public sale state");
for(uint i = 0; i < numberOfTokens; i++) {
uint mintIndex = totalSupply();
if (totalSupply() < maxHanfu) {
_safeMint(msg.sender, mintIndex);
}
}
}
function mintHanfuWl(uint numberOfTokens, bytes memory proof) public payable {
require(saleIsActive, "Sale must be active to mint Hanfu");
require(numberOfTokens <= maxHanfuWlPurchase, "Can only mint 5 tokens at a time");
require(totalSupply().add(numberOfTokens) <= maxHanfu, "Purchase would exceed max supply of Hanfus");
require(hanfuWlPrice.mul(numberOfTokens) <= msg.value, "Ether value sent is not correct");
require(wlUsedList[msg.sender] != wlUsedRound, "Already Use Wl");
require(verifyProof(proof, merkleRoot, keccak256(abi.encodePacked(msg.sender))), "Not in Whitelist");
wlUsedList[msg.sender] = wlUsedRound;
for(uint i = 0; i < numberOfTokens; i++) {
uint mintIndex = totalSupply();
if (totalSupply() < maxHanfu) {
_safeMint(msg.sender, mintIndex);
}
}
}
function airDropRun() public onlyOwner {
uint mintIndex = totalSupply();
uint startIndex = 0;
uint endIndex = 0;
if (airDropRound == 0) {
require(mintIndex >= 100, "Not allowed AirDrop");
airDropRound = 50;
startIndex = 0;
endIndex = 100;
} else if (airDropRound == 50) {
require(mintIndex >= 500, "Not allowed AirDrop");
airDropRound = 100;
startIndex = 100;
endIndex = 500;
} else if (airDropRound == 100) {
require(mintIndex >= 1500, "Not allowed AirDrop");
airDropRound = 150;
startIndex = 500;
endIndex = 1500;
} else {
require(false, "Not allowed AirDrop");
}
uint seed = rand(block.timestamp);
for(uint i = 0; i < airDropRound; i++) {
seed = randsimple(seed);
uint tokenId = (seed % (endIndex - startIndex)) + startIndex;
if (_exists(tokenId)) {
if (totalSupply() < maxHanfu) {
_safeMint(ownerOf(tokenId), mintIndex + i);
}
}
}
}
function setOpenedNumber(uint _index) public onlyOwner {
openedNum = _index;
}
} | contract HanfuClub is ERC721, Ownable {
using SafeMath for uint256;
address payable busyWallet;
address payable busyWallet1;
address payable busyWallet2;
address payable busyWallet3;
address payable depWallet;
bytes32 public merkleRoot;
uint256 public constant hanfuPrice = 88000000000000000; //0.088 ETH
uint256 public constant wlValidPrice = 88000000000000000; //0.088 ETH
uint256 public constant hanfuWlPrice = 66000000000000000; //0.066 ETH
uint public constant maxHanfuWlPurchase = 5;
uint public constant maxHanfuPurchase = 1000;
uint256 public maxHanfu;
bool public saleIsActive = false;
uint32 public airDropRound = 0;
uint32 public nftSaleStage = 0;
mapping (address => uint32) private wlUsedList;
uint32 wlUsedRound = 0;
uint8 reservedFlag = 0;
function verifyProof(bytes memory _proof, bytes32 _root, bytes32 _leaf) public pure returns (bool) {
// Check if proof length is a multiple of 32
if (_proof.length % 32 != 0) return false;
bytes32 proofElement;
bytes32 computedHash = _leaf;
for (uint256 i = 32; i <= _proof.length; i += 32) {
assembly {
// Load the current element of the proof
proofElement := mload(add(_proof, i))
}
if (computedHash < proofElement) {
// Hash(current computed hash + current element of the proof)
computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
} else {
// Hash(current element of the proof + current computed hash)
computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
}
}
// Check if the computed hash (root) is equal to the provided root
return computedHash == _root;
}
function rand(uint seed) internal pure returns (uint) {
bytes32 data;
if (seed % 2 == 0){
data = keccak256(abi.encodePacked(seed));
}else{
data = keccak256(abi.encodePacked(bytes32(seed)));
}
uint sum;
for(uint i;i < 32;i++){
sum += uint(uint8(data[i]));
}
return uint(uint8(data[sum % data.length])) * uint(uint8(data[(sum + 2) % data.length]));
}
function randsimple(uint seed) internal pure returns (uint) {
bytes32 data;
if (seed % 2 == 0){
data = keccak256(abi.encodePacked(seed));
} else {
data = keccak256(abi.encodePacked(bytes32(seed)));
}
return uint(data);
}
/**
* @dev Generate random uint <= 256^2 with seed = block.timestamp
* @return uint
*/
function randint() internal view returns(uint) {
return rand(block.timestamp);
}
/**
* @dev Generate random uint in range [a, b)
* @return uint
*/
function randrange(uint a, uint b) internal view returns(uint) {
return a + (randint() % (b - a));
}
/**
* @dev Generate array of random bytes
* @param size seed
* @return byte[size]
*/
function randbytes(uint size, uint seed) internal pure returns (bytes memory) {
bytes memory data = new bytes(size);
uint x = seed;
for(uint i;i < size;i++){
x = rand(x);
data[i] = byte(uint8(x % 256));
}
return data;
}
constructor(string memory name, string memory symbol, uint256 maxNftSupply, address payable _wallet, address payable _wallet1, address payable _wallet2, address payable _wallet3, address payable _dev) ERC721(name, symbol) {
maxHanfu = maxNftSupply;
busyWallet = _wallet;
busyWallet1 = _wallet1;
busyWallet2 = _wallet2;
busyWallet3 = _wallet3;
depWallet = _dev;
}
function withdraw() public onlyOwner {
uint balance = address(this).balance;
uint toDevBalance = balance * 10 / 100;
depWallet.transfer(toDevBalance);
balance = (balance - toDevBalance) / 4;
busyWallet.transfer(balance);
busyWallet1.transfer(balance);
busyWallet2.transfer(balance);
busyWallet3.transfer(balance);
}
function toNextNftSaleRound() public onlyOwner {
nftSaleStage++;
}
function getHanfuPrice() public view returns(uint256) {
if (nftSaleStage == 0) {
return hanfuWlPrice;
} else {
return hanfuPrice;
}
}
function getMaxHanfuPurchase() public view returns(uint256) {
if (nftSaleStage == 0) {
return maxHanfuWlPurchase;
} else {
return maxHanfuPurchase;
}
}
function getWlUsedFlag() public view returns(bool) {
return wlUsedList[msg.sender] == wlUsedRound;
}
function reValidWhiteList() public payable {
require(saleIsActive, "Sale must be active to mint Hanfu");
require(wlValidPrice <= msg.value, "Ether value sent is not correct");
require(wlUsedList[msg.sender] == wlUsedRound, "Not used whitelist");
wlUsedList[msg.sender] = 0;
}
/**
* Set some Hanfus aside
*/
function reserveHanfu() public onlyOwner {
uint supply = totalSupply();
require(reservedFlag == 0, "not allowed reserved");
uint i;
for (i = 0; i < 35; i++) {
_safeMint(msg.sender, supply + i);
}
reservedFlag = 1;
}
/*
* Set merkeleroot once it's calculated
*/
function setMerkleRoot(bytes32 _merkleRoot) public onlyOwner {
merkleRoot = _merkleRoot;
wlUsedRound++;
}
function setBaseURI(string memory baseURI) public onlyOwner {
_setBaseURI(baseURI);
}
/*
* Pause sale if active, make active if paused
*/
function flipSaleState() public onlyOwner {
saleIsActive = !saleIsActive;
}
/**
* Mints Hanfus
*/
function mintHanfu(uint numberOfTokens) public payable {
require(saleIsActive, "Sale must be active to mint Hanfu");
require(numberOfTokens <= maxHanfuPurchase, "Can only mint 20 tokens at a time");
require(totalSupply().add(numberOfTokens) <= maxHanfu, "Purchase would exceed max supply of Hanfus");
require(hanfuPrice.mul(numberOfTokens) <= msg.value, "Ether value sent is not correct");
require(nftSaleStage > 0, "not in public sale state");
for(uint i = 0; i < numberOfTokens; i++) {
uint mintIndex = totalSupply();
if (totalSupply() < maxHanfu) {
_safeMint(msg.sender, mintIndex);
}
}
}
function mintHanfuWl(uint numberOfTokens, bytes memory proof) public payable {
require(saleIsActive, "Sale must be active to mint Hanfu");
require(numberOfTokens <= maxHanfuWlPurchase, "Can only mint 5 tokens at a time");
require(totalSupply().add(numberOfTokens) <= maxHanfu, "Purchase would exceed max supply of Hanfus");
require(hanfuWlPrice.mul(numberOfTokens) <= msg.value, "Ether value sent is not correct");
require(wlUsedList[msg.sender] != wlUsedRound, "Already Use Wl");
require(verifyProof(proof, merkleRoot, keccak256(abi.encodePacked(msg.sender))), "Not in Whitelist");
wlUsedList[msg.sender] = wlUsedRound;
for(uint i = 0; i < numberOfTokens; i++) {
uint mintIndex = totalSupply();
if (totalSupply() < maxHanfu) {
_safeMint(msg.sender, mintIndex);
}
}
}
function airDropRun() public onlyOwner {
uint mintIndex = totalSupply();
uint startIndex = 0;
uint endIndex = 0;
if (airDropRound == 0) {
require(mintIndex >= 100, "Not allowed AirDrop");
airDropRound = 50;
startIndex = 0;
endIndex = 100;
} else if (airDropRound == 50) {
require(mintIndex >= 500, "Not allowed AirDrop");
airDropRound = 100;
startIndex = 100;
endIndex = 500;
} else if (airDropRound == 100) {
require(mintIndex >= 1500, "Not allowed AirDrop");
airDropRound = 150;
startIndex = 500;
endIndex = 1500;
} else {
require(false, "Not allowed AirDrop");
}
uint seed = rand(block.timestamp);
for(uint i = 0; i < airDropRound; i++) {
seed = randsimple(seed);
uint tokenId = (seed % (endIndex - startIndex)) + startIndex;
if (_exists(tokenId)) {
if (totalSupply() < maxHanfu) {
_safeMint(ownerOf(tokenId), mintIndex + i);
}
}
}
}
function setOpenedNumber(uint _index) public onlyOwner {
openedNum = _index;
}
} | 78,706 |
270 | // Exit pool only with liquid tokensThis function will withdraw TUSD but with a small penaltyUses the sync() modifier to reduce gas costs of using curve amount amount of pool tokens to redeem for underlying tokens / | function liquidExit(uint256 amount) external nonReentrant sync {
require(block.number != latestJoinBlock[tx.origin], "TrueFiPool: Cannot join and exit in same block");
require(amount <= balanceOf(msg.sender), "TrueFiPool: Insufficient funds");
uint256 amountToWithdraw = poolValue().mul(amount).div(totalSupply());
require(amountToWithdraw <= liquidValue(), "TrueFiPool: Not enough liquidity in pool");
// burn tokens sent
_burn(msg.sender, amount);
if (amountToWithdraw > currencyBalance()) {
removeLiquidityFromCurve(amountToWithdraw.sub(currencyBalance()));
require(amountToWithdraw <= currencyBalance(), "TrueFiPool: Not enough funds were withdrawn from Curve");
}
require(token.transfer(msg.sender, amountToWithdraw));
emit Exited(msg.sender, amountToWithdraw);
}
| function liquidExit(uint256 amount) external nonReentrant sync {
require(block.number != latestJoinBlock[tx.origin], "TrueFiPool: Cannot join and exit in same block");
require(amount <= balanceOf(msg.sender), "TrueFiPool: Insufficient funds");
uint256 amountToWithdraw = poolValue().mul(amount).div(totalSupply());
require(amountToWithdraw <= liquidValue(), "TrueFiPool: Not enough liquidity in pool");
// burn tokens sent
_burn(msg.sender, amount);
if (amountToWithdraw > currencyBalance()) {
removeLiquidityFromCurve(amountToWithdraw.sub(currencyBalance()));
require(amountToWithdraw <= currencyBalance(), "TrueFiPool: Not enough funds were withdrawn from Curve");
}
require(token.transfer(msg.sender, amountToWithdraw));
emit Exited(msg.sender, amountToWithdraw);
}
| 22,106 |
461 | // kill starverd NFT and get fatalityPct of his points. | function fatality(uint256 _deadId, uint256 _tokenId) external notPaused {
require(
!isVnftAlive(_deadId),
"The vNFT has to be starved to claim his points"
);
vnftScore[_tokenId] = vnftScore[_tokenId].add(
(vnftScore[_deadId].mul(fatalityPct).div(100))
);
vnftScore[_deadId] = 0;
delete vnftDetails[_deadId];
_burn(_deadId);
emit VnftFatalized(_deadId, msg.sender);
}
| function fatality(uint256 _deadId, uint256 _tokenId) external notPaused {
require(
!isVnftAlive(_deadId),
"The vNFT has to be starved to claim his points"
);
vnftScore[_tokenId] = vnftScore[_tokenId].add(
(vnftScore[_deadId].mul(fatalityPct).div(100))
);
vnftScore[_deadId] = 0;
delete vnftDetails[_deadId];
_burn(_deadId);
emit VnftFatalized(_deadId, msg.sender);
}
| 10,714 |
249 | // 2. Eliminate debt | uint256 totalDebt = totalDebt();
if (newSupply > 0 && totalDebt > 0) {
lessDebt = totalDebt > newSupply ? newSupply : totalDebt;
decreaseDebt(lessDebt);
newSupply = newSupply.sub(lessDebt);
}
| uint256 totalDebt = totalDebt();
if (newSupply > 0 && totalDebt > 0) {
lessDebt = totalDebt > newSupply ? newSupply : totalDebt;
decreaseDebt(lessDebt);
newSupply = newSupply.sub(lessDebt);
}
| 15,130 |
27 | // After replace completed syncFlag set to 0 | syncFlag = 0;
snapshotAssets = tempAssets;
tempAssets = 0;
success = true;
| syncFlag = 0;
snapshotAssets = tempAssets;
tempAssets = 0;
success = true;
| 39,818 |
5 | // Extract ECDSA signature variables from `sig` | assembly {
r := mload(add(_sig, 32))
s := mload(add(_sig, 64))
v := byte(0, mload(add(_sig, 96)))
}
| assembly {
r := mload(add(_sig, 32))
s := mload(add(_sig, 64))
v := byte(0, mload(add(_sig, 96)))
}
| 6,809 |
2 | // Owner has power to abort, discount addresses, sweep successful funds, change owner, sweep alien tokens. | address public owner = 0xB353cF41A0CAa38D6597A7a1337debf0b09dd8ae; // Primary address checksummed
| address public owner = 0xB353cF41A0CAa38D6597A7a1337debf0b09dd8ae; // Primary address checksummed
| 38,977 |
17 | // Withdraw balance from the Guild/Only the guild owner can execute/_tokenAddress token asset to withdraw some balance/_amount amount to be withdraw in wei/_beneficiary beneficiary to send funds. If 0x is specified, funds will be sent to the guild owner | function withdraw(
address _tokenAddress,
uint256 _amount,
address _beneficiary
| function withdraw(
address _tokenAddress,
uint256 _amount,
address _beneficiary
| 25,304 |
2 | // constructor only runs when we deploy contract is created. | constructor() {
minter = msg.sender;
}
| constructor() {
minter = msg.sender;
}
| 22,135 |
58 | // 如果原来的CFO没有设置 则sender必须是owner 否则必须是原来的CFO | if(cfo == address(0)) {
require(msg.sender == owner);
}else{
| if(cfo == address(0)) {
require(msg.sender == owner);
}else{
| 23,426 |
21 | // user pays for specified num of tokens, address and qty are indexed for later use by minting contract | function prepayment(uint256 numTokens) external payable {
require (prepayActive, "round inactive");
require (msg.value >= prepayCost*numTokens, "Incorrect value sent");
require (numTokens + currentToken <= prepayLimit, "No more left");
require (numTokens <= prepay_txnLimit);
if (prepaid[msg.sender] == 0) {
i++;
prepayer[i] = msg.sender;
}
prepaid[msg.sender] += numTokens;
currentToken += numTokens;
}
| function prepayment(uint256 numTokens) external payable {
require (prepayActive, "round inactive");
require (msg.value >= prepayCost*numTokens, "Incorrect value sent");
require (numTokens + currentToken <= prepayLimit, "No more left");
require (numTokens <= prepay_txnLimit);
if (prepaid[msg.sender] == 0) {
i++;
prepayer[i] = msg.sender;
}
prepaid[msg.sender] += numTokens;
currentToken += numTokens;
}
| 9,600 |
50 | // Get the appropriate rate which applies | getCurrentVUPRate();
| getCurrentVUPRate();
| 30,160 |
4 | // TODO: More robust parsing that handles whitespace and multiple key/value pairs | if (str.readUint32(idx) != 0x613d3078) return (address(0x0), false); // 0x613d3078 == 'a=0x'
if (len < 44) return (address(0x0), false);
return hexToAddress(str, idx + 4);
| if (str.readUint32(idx) != 0x613d3078) return (address(0x0), false); // 0x613d3078 == 'a=0x'
if (len < 44) return (address(0x0), false);
return hexToAddress(str, idx + 4);
| 37,352 |
13 | // Allow _spender to withdraw from your account, multiple times, up to the _value amount. If this function is called again it overwrites the current allowance with _value. this function is required for some DEX functionality | function approve(address spender, uint256 value) public returns (bool);
| function approve(address spender, uint256 value) public returns (bool);
| 29,914 |
23 | // Set royalty for marketplaces complying with ERC2981 standard | function setDefaultRoyalty(address receiver, uint96 feeNumerator) public onlyAdmin {
_setDefaultRoyalty(receiver, feeNumerator);
}
| function setDefaultRoyalty(address receiver, uint96 feeNumerator) public onlyAdmin {
_setDefaultRoyalty(receiver, feeNumerator);
}
| 10,417 |
52 | // a mapping of interface id to whether or not it's supported / | mapping(bytes4 => bool) private _supportedInterfaces;
| mapping(bytes4 => bool) private _supportedInterfaces;
| 3,253 |
425 | // computes the largest integer smaller than or equal to the binary logarithm of the input. / | function floorLog2(uint256 _n) internal pure returns (uint8) {
uint8 res = 0;
if (_n < 256) {
// At most 8 iterations
while (_n > 1) {
_n >>= 1;
res += 1;
}
} else {
// Exactly 8 iterations
for (uint8 s = 128; s > 0; s >>= 1) {
if (_n >= (ONE << s)) {
_n >>= s;
res |= s;
}
}
}
return res;
}
| function floorLog2(uint256 _n) internal pure returns (uint8) {
uint8 res = 0;
if (_n < 256) {
// At most 8 iterations
while (_n > 1) {
_n >>= 1;
res += 1;
}
} else {
// Exactly 8 iterations
for (uint8 s = 128; s > 0; s >>= 1) {
if (_n >= (ONE << s)) {
_n >>= s;
res |= s;
}
}
}
return res;
}
| 33,217 |
91 | // Recursively distribute deposit fee between parents _node Parent address _prevPercentage The percentage for previous parent _depositsCount Count of depositer deposits _amount The amount of deposit / | function distribute(
address _node,
uint _prevPercentage,
uint8 _depositsCount,
uint _amount
)
private
| function distribute(
address _node,
uint _prevPercentage,
uint8 _depositsCount,
uint _amount
)
private
| 35,131 |
59 | // redeem underlying collateral | JErc20Interface(joinedAddresses.JTokenCollateralToSeize).redeem(retrnVals.earnedJToken);
| JErc20Interface(joinedAddresses.JTokenCollateralToSeize).redeem(retrnVals.earnedJToken);
| 25,054 |
38 | // add to points buyback and send user their share | pointsBuybackBalance = pointsBuybackBalance.add(feeAmount);
safeTokenTransfer(msg.sender, DeFiatPoints, remainingUserAmount);
emit EmergencyWithdraw(msg.sender, remainingUserAmount);
| pointsBuybackBalance = pointsBuybackBalance.add(feeAmount);
safeTokenTransfer(msg.sender, DeFiatPoints, remainingUserAmount);
emit EmergencyWithdraw(msg.sender, remainingUserAmount);
| 35,535 |
140 | // Increase rebasing credits, totalSupply remains unchanged so no adjustment necessary | rebasingCredits = rebasingCredits.add(_creditBalances[msg.sender]);
rebaseState[msg.sender] = RebaseOptions.OptIn;
| rebasingCredits = rebasingCredits.add(_creditBalances[msg.sender]);
rebaseState[msg.sender] = RebaseOptions.OptIn;
| 42,074 |
394 | // Setup Data Area / This area holds `assetData`. | let dataArea := add(cdStart, 132)
| let dataArea := add(cdStart, 132)
| 8,869 |
37 | // If account is frozen through a governance then only way to move out its balance is through governance. Data renting fees still run out from this account, but it cannot rent. | Frozen,
| Frozen,
| 38,644 |
311 | // if sumSupplies < sumBorrows, then the user is under collateralized and has account shortfall. else the user meets the collateral ratio and has account liquidity. | if (lessThanExp(sumSupplyValuesFinal, sumBorrowValuesFinal)) {
| if (lessThanExp(sumSupplyValuesFinal, sumBorrowValuesFinal)) {
| 12,226 |
174 | // function to calculate the interest using a linear interest rateformula _rate the interest rate, in ray _lastUpdateTimestamp the timestamp of the last update of theinterestreturn the interest rate linearly accumulated during the timeDelta, inray / | {
//solium-disable-next-line
uint256 timeDifference =
block.timestamp.sub(uint256(_lastUpdateTimestamp));
uint256 timeDelta =
timeDifference.wadToRay().rayDiv(SECONDS_PER_YEAR.wadToRay());
return _rate.rayMul(timeDelta).add(WadRayMath.ray());
}
| {
//solium-disable-next-line
uint256 timeDifference =
block.timestamp.sub(uint256(_lastUpdateTimestamp));
uint256 timeDelta =
timeDifference.wadToRay().rayDiv(SECONDS_PER_YEAR.wadToRay());
return _rate.rayMul(timeDelta).add(WadRayMath.ray());
}
| 9,558 |
213 | // safeTransfer constants | bytes4 internal constant ERC721O_RECEIVED = 0xf891ffe0;
bytes4 internal constant ERC721O_BATCH_RECEIVED = 0xd0e17c0b;
| bytes4 internal constant ERC721O_RECEIVED = 0xf891ffe0;
bytes4 internal constant ERC721O_BATCH_RECEIVED = 0xd0e17c0b;
| 47,015 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.