Source Code
Latest 25 from a total of 1,097 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Unstake | 84996354 | 132 days ago | IN | 0 MNT | 0.00466106 | ||||
| Update Total Sha... | 84996337 | 132 days ago | IN | 0 MNT | 0.05717114 | ||||
| Claim | 84996326 | 132 days ago | IN | 0 MNT | 0.00302748 | ||||
| Unstake | 80328264 | 240 days ago | IN | 0 MNT | 0.00504041 | ||||
| Claim | 79041603 | 269 days ago | IN | 0 MNT | 0.00358522 | ||||
| Unstake | 79035870 | 270 days ago | IN | 0 MNT | 0.00427043 | ||||
| Unstake | 79014912 | 270 days ago | IN | 0 MNT | 0.00332741 | ||||
| Unstake | 78884159 | 273 days ago | IN | 0 MNT | 0.00412143 | ||||
| Unstake | 78759612 | 276 days ago | IN | 0 MNT | 0.00405215 | ||||
| Unstake | 78585772 | 280 days ago | IN | 0 MNT | 0.00402732 | ||||
| Unstake | 78540762 | 281 days ago | IN | 0 MNT | 0.00412172 | ||||
| Unstake | 78241551 | 288 days ago | IN | 0 MNT | 0.00395084 | ||||
| Stake | 78241491 | 288 days ago | IN | 0 MNT | 0.00290167 | ||||
| Unstake | 78071668 | 292 days ago | IN | 0 MNT | 0.00388012 | ||||
| Stake | 78016799 | 293 days ago | IN | 0 MNT | 0.00277173 | ||||
| Stake | 77969993 | 294 days ago | IN | 0 MNT | 0.00277519 | ||||
| Unstake | 77793941 | 298 days ago | IN | 0 MNT | 0.00356612 | ||||
| Stake | 77793832 | 298 days ago | IN | 0 MNT | 0.0032306 | ||||
| Stake | 77667530 | 301 days ago | IN | 0 MNT | 0.00284911 | ||||
| Stake | 77507309 | 305 days ago | IN | 0 MNT | 0.0028357 | ||||
| Claim | 77331868 | 309 days ago | IN | 0 MNT | 0.00346717 | ||||
| Update Total Sha... | 77215026 | 312 days ago | IN | 0 MNT | 0.05240988 | ||||
| Stake | 77215004 | 312 days ago | IN | 0 MNT | 0.00310844 | ||||
| Claim | 77214942 | 312 days ago | IN | 0 MNT | 0.00359786 | ||||
| Claim | 77214269 | 312 days ago | IN | 0 MNT | 0.00276125 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Cross-Chain Transactions
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
ZombieVan
Compiler Version
v0.8.19+commit.7dd6d404
Optimization Enabled:
Yes with 500000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableMap.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "./util/IERC721WithUtilityHelpers.sol";
/**
* @title ZombieVan: a contract to stake tokens and earn rewards, for specific NFT holders only.
* @notice This is for Ice Cream Zombies (ICZ) holders only. New collections may be added too.
* Users not holding eligible NFTs may stake tokens, but they won't receive any rewards.
*/
contract ZombieVan is Ownable, AccessControl, ReentrancyGuard {
using EnumerableMap for EnumerableMap.AddressToUintMap;
using EnumerableSet for EnumerableSet.AddressSet;
/// @notice Address of the token to stake
IERC20 public immutable stakeToken;
/// @notice Address of the token used for the rewards
IERC20 public immutable rewardsToken;
/// @notice Minimum amount of rewards to distribute when calling updateUserRewards
uint256 public minRewardsToUpdate;
/// @notice Total accumulated deposits since contract creation
uint256 public totalAccumulatedDeposits;
/// @notice Total accumulated withdrawals since contract creation
uint256 public totalAccumulatedWithdrawals;
/// @notice Total accumulated rewards claimed since contract creation
uint256 public totalAccumulatedRewardsClaimed;
/// @notice Total rewards unclaimed (the contract must have enough balanc to cover this)
uint256 public totalRewardsUnclaimed;
/// @notice Total shares (used to calculate user shares)
uint256 public totalShares;
/// @notice Last block when totalShares was updated
uint256 public totalSharesLastUpdateBlock;
/// @notice Max amount of blocks before allowing to update totalShares again
uint256 public totalSharesLastUpdateMaxBlocks = 240;
/// @notice Total amount of stakeToken staked
uint256 public totalStaked;
/** @notice Withdrawal fee.
* Divide by 10000 to get the percentage, e.g. 1 = 0.01%, 10 = 0.1%, 100 = 1%
*/
uint256 public withdrawalFee;
/// @notice Withdrawal fee receiver address
address public feeAddress;
/// @notice Determines if the updateRewards function is in progress (useful when partialUpdateUserRewards)
bool public updateRewardsInProgress;
/// @notice Determines if the updateTotalShares function is in progress (useful when partialUpdateTotalShares)
bool public updateTotalSharesInProgress;
/// @notice Determines if an NFT holder is exempt from the withdrawal fee
bool public nftHolderExemptFromWithdrawalFee;
/// @notice Mapping of user address to their deposit amount
mapping(address => uint256) public userDeposits;
/// @notice Mapping of user address to their rewards amount
mapping(address => uint256) public userRewards;
/// @notice The operator role
bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE");
/// @notice State of the (partial) updateUserRewards function
UpdateState public rewardsUpdateState;
/// @notice State of the (partial) updateTotalShares function
UpdateState public totalSharesUpdateState;
/**
* @notice NFT collections implementing IERC721WithUtility are set to `true`; for standard IERC721 collections,
* owning them has already utility, without checking their status
*/
mapping(address => bool) public nftIERC721WithUtility;
/**
* @dev Mapping of NFT address to multiplier.
* Multiplier is a percentage, e.g. 100 = 1 (100%), 10 = 0.1 (10%), 1 = 0.01 (1%)
*/
EnumerableMap.AddressToUintMap private nftCollections;
/// @dev Used to iterate over users when updating rewards
EnumerableSet.AddressSet private users;
/**
* @notice NFT collection info
* @param nftAddress Address of the NFT contract
* @param multiplier Multiplier for this NFT collection (100 = 100% = 1x)
*/
struct NftCollection {
address nftAddress;
uint256 multiplier;
}
/**
* This is used to keep track of the current state of the updateUserRewards and updateTotalShares functions
* @param usersLength Length of the users array
* @param from Index last used to start iterating from
* @param to Index last used to stop iterating at
*/
struct UpdateState {
uint256 usersLength;
uint256 from;
uint256 to;
}
/// @notice Emitted when a user stakes tokens
event Stake(address indexed user, uint256 amount);
/// @notice Emitted when a user unstakes tokens
event Unstake(address indexed user, uint256 amount, uint256 fee);
/// @notice Emitted when a user claims rewards
event Claim(address indexed user, uint256 amount);
/// @notice Emitted when usersRewards are updated
event UpdateUserRewards(address indexed user, uint256 amount);
/// @notice Emitted when totalShares are updated
event UpdateTotalShares(address indexed user, uint256 amount);
/// @notice Emitted when usersRewards are partially updated
event PartialUpdateUserRewards(uint256 amount, uint256 from, uint256 to);
/// @notice Emitted when totalShares are partially updated
event PartialUpdateTotalShares(uint256 amount, uint256 from, uint256 to);
modifier onlyOperator() {
require(hasRole(OPERATOR_ROLE, msg.sender), "OPERATOR_ROLE_REQUIRED");
_;
}
/**
* @notice Initializes the contract
* @param stakeToken_ Address of the token to stake
* @param rewardsToken_ Address of the token used for the rewards
* @param nft_ Address of the initial NFT contract
*/
constructor(address stakeToken_, address rewardsToken_, address nft_) {
stakeToken = IERC20(stakeToken_);
rewardsToken = IERC20(rewardsToken_);
nftCollections.set(nft_, 100); // default is 1 = 100 (100%)
nftIERC721WithUtility[nft_] = true;
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(OPERATOR_ROLE, msg.sender);
}
/**
* @notice Get all NFT collections (and their multiplier) supported by this contract
*/
function getNftCollections() external view returns (NftCollection[] memory) {
NftCollection[] memory result = new NftCollection[](nftCollections.length());
for (uint256 i = 0; i < nftCollections.length(); i++) {
(address nftAddress, uint256 nftMultiplier) = nftCollections.at(i);
result[i] = NftCollection(nftAddress, nftMultiplier);
}
return result;
}
/**
* @notice Get the amount of rewards that will be distributed to all users via updateUserRewards
*/
function getUndistributedRewards() public view returns (uint256) {
uint256 rewardsBalance = rewardsToken.balanceOf(address(this));
uint256 undistributedRewards = rewardsBalance - totalRewardsUnclaimed;
return undistributedRewards;
}
/**
* @notice Returns the multiplier needed to calculate the user shares
* @param user Address of the user
*/
function userMultiplier(address user) public view returns (uint256) {
uint256 multiplier = 0;
for (uint256 c = 0; c < nftCollections.length(); c++) {
(address nftAddress, uint256 nftMultiplier) = nftCollections.at(c);
uint256 nftBalance = IERC721WithUtilityHelpers.balanceWithUtilityOf(
user, nftAddress, nftIERC721WithUtility[nftAddress]
);
if (nftBalance == 0) continue;
multiplier += nftBalance * nftMultiplier;
}
return multiplier;
}
/**
* @notice Get the shares of a user (useful after running updateUserRewards)
* @param user Address of the user
*/
function userShares(address user) public view returns (uint256) {
uint256 multiplier = userMultiplier(user);
return userDeposits[user] * multiplier / 100;
}
/**
* @notice Get the array of all users (if it runs out of gas: use getUsersRange)
*/
function getUsers() external view returns (address[] memory) {
return users.values();
}
/**
* @notice Get the number of unique depositors
*/
function getUsersLength() external view returns (uint256) {
return users.length();
}
/**
* @notice Get all users in a range (useful if there are too many users to fetch at once)
* @param from Index to start iterating from
* @param to Index to stop iterating at
*/
function getUsersRange(uint256 from, uint256 to) external view returns (address[] memory) {
require(from < to, "from < to");
require(to <= users.length(), "to <= users.length");
address[] memory result = new address[](to - from);
for (uint256 i = from; i < to; i++) {
result[i - from] = users.at(i);
}
return result;
}
/**
* @notice Stake amount of stakeToken (stakeToken must be approved first)
* @param amount Amount of stakeToken to stake
*/
function stake(uint256 amount) external {
require(!updateTotalSharesInProgress, "TotalShares update in progress");
require(!updateRewardsInProgress, "Rewards update in progress");
require(amount > 0, "Amount must be greater than 0");
// Transfer the tokens from the user to this contract
bool success = stakeToken.transferFrom(msg.sender, address(this), amount);
require(success, "TransferFrom failed");
// Update the user's deposit balance
userDeposits[msg.sender] += amount;
totalAccumulatedDeposits += amount;
totalStaked += amount;
users.add(msg.sender);
emit Stake(msg.sender, amount);
}
/**
* @notice Unstake amount of stakeToken, unstake all if amount is set to 0
* @param amount Amount of stakeToken to unstake
*/
function unstake(uint256 amount) external nonReentrant {
require(!updateTotalSharesInProgress, "TotalShares update in progress");
require(!updateRewardsInProgress, "Rewards update in progress");
require(amount <= totalStaked, "Invalid amount");
// Check if the user has enough tokens to unstake
uint256 balance = userDeposits[msg.sender];
require(balance >= amount && balance > 0, "Insufficient staked balance");
if (amount == 0) amount = balance;
uint256 fee = 0;
bool success = false;
if (withdrawalFee > 0) {
bool userMustPayFee = true;
if (nftHolderExemptFromWithdrawalFee) {
// If multiplier > 0, user is exempt from the withdrawal fee
userMustPayFee = (userMultiplier(msg.sender) == 0);
}
if (userMustPayFee) {
// Transfer withdrawal fee to feeAddress
fee = (amount * withdrawalFee) / 10000;
success = stakeToken.transfer(feeAddress, fee);
require(success, "Transfer Failed");
}
}
// Transfer the staked tokens back to the user (and fee to feeAddress)
uint256 userAmount = amount - fee;
success = stakeToken.transfer(msg.sender, userAmount);
require(success, "Transfer Failed");
// Update the user's deposit balance and total withdrawals
userDeposits[msg.sender] -= amount;
totalAccumulatedWithdrawals += amount;
totalStaked -= amount;
// Call the claim function to transfer the rewards
_claim();
if (userDeposits[msg.sender] == 0) {
// Reset userDeposits and remove user from users and from userRewards
users.remove(msg.sender);
delete userDeposits[msg.sender];
delete userRewards[msg.sender];
}
emit Unstake(msg.sender, amount, fee);
}
/**
* @notice Withdraw rewards (and leave stakeToken staked)
*/
function claim() external nonReentrant {
require(!updateTotalSharesInProgress, "TotalShares update in progress");
require(!updateRewardsInProgress, "Rewards update in progress");
require(userRewards[msg.sender] > 0, "No rewards to claim");
_claim();
}
/**
* @notice Updates userRewards balances (call this function after depositing new rewards)
*/
function updateUserRewards() external {
// totalSharesLastUpdateBlock must not be older than totalSharesLastUpdateMaxBlocks ago
if (block.number > totalSharesLastUpdateBlock + totalSharesLastUpdateMaxBlocks) {
_updateTotalShares(0, users.length());
}
uint256 rewardsDistributed = _updateUserRewards(0, users.length());
emit UpdateUserRewards(msg.sender, rewardsDistributed);
}
/**
* @notice Partially update userRewards, specifying from/to index.
* This is needed to avoid hitting gas limits when there are many users.
* @param from Index to start iterating from
* @param to Index to stop iterating at
*/
function partialUpdateUserRewards(uint256 from, uint256 to) external onlyOperator {
uint256 rewardsDistributed = _updateUserRewards(from, to);
emit PartialUpdateUserRewards(rewardsDistributed, from, to);
}
/**
* @notice Updates totalShares, depening on each user staked balance and owned NFTs
*/
function updateTotalShares() public {
// Check if the last update was made within the totalSharesLastUpdateMaxBlocks tolerated
require(block.number > totalSharesLastUpdateBlock + totalSharesLastUpdateMaxBlocks, "Wait more blocks");
totalShares = _updateTotalShares(0, users.length());
emit UpdateTotalShares(msg.sender, totalShares);
}
/*****************************************************/
/****************** ADMIN FUNCTIONS ******************/
/*****************************************************/
/**
* @notice Partially update userRewards, specifying from/to index.
* This is needed to avoid hitting gas limits when there are many users.
* @param from Index to start iterating from
* @param to Index to stop iterating at
*/
function partialUpdateTotalShares(uint256 from, uint256 to) external onlyOperator {
uint256 sharesAdded = _updateTotalShares(from, to);
emit PartialUpdateTotalShares(sharesAdded, from, to);
}
/**
* @notice Edit or remove an NFT collection. To remove a collection, set its multiplier to 0.
* @param nftAddress Address of the NFT contract
* @param multiplier Multiplier for this NFT collection (100 = 100% = 1x)
*/
function setNftCollection(address nftAddress, uint256 multiplier, bool isIERC721WithUtility) external onlyOperator {
if (multiplier > 0) {
// Add/Edit the NFT collection
nftCollections.set(nftAddress, multiplier);
nftIERC721WithUtility[nftAddress] = isIERC721WithUtility;
} else {
// Remove the NFT collection & multiplier
nftCollections.remove(nftAddress);
delete nftIERC721WithUtility[nftAddress];
}
}
/**
* @notice Sets whether an NFT holder is exempt from the withdrawal fee or not
* @param value True if NFT holders are exempt from the withdrawal fee
*/
function setNftHolderExemptFromWithdrawalFee(bool value) external onlyOperator {
nftHolderExemptFromWithdrawalFee = value;
}
/**
* @notice Sets the minRewardsToUpdate (amount in wei)
* @param amountInWei Amount in wei
*/
function setMinRewardsToUpdate(uint256 amountInWei) external onlyOperator {
minRewardsToUpdate = amountInWei;
}
/**
* @notice Sets the max amount of blocks tolerated for the updateRewards function.
* If the last update was done more than this amount of blocks ago, updateTotalShares must be called again.
* @param value Amount of blocks
*/
function setTotalSharesLastUpdateMaxBlocks(uint256 value) external onlyOperator {
totalSharesLastUpdateMaxBlocks = value;
}
/**
* @notice Sets the withdrawal fee (divide by 10000 to get the percentage, e.g. 1 = 0.01%, 10 = 0.1%, 100 = 1%)
* @param value Withdrawal fee
*/
function setWithdrawalFee(uint256 value) external onlyOwner {
require(value <= 100, "Max 1% (100 / 10000) withdrawal fee");
withdrawalFee = value;
}
/**
* @notice Sets the withdrawal fee receiver address
* @param value Withdrawal fee receiver address
*/
function setFeeAddress(address value) external onlyOwner {
feeAddress = value;
}
/**
* @notice Withdraws the entire balance of a given ERC20 token.
* This is intended to sweep tokens sent to the contract by mistake, or "airdrops", spam tokens etc.
* Stake & Rewards tokens not allowed for obvious reasons (else you may think we added a backdoor to rug the contract)
* @param token Address of the ERC20 token to withdraw
*/
function sweepErc20(IERC20 token) external onlyOperator {
require(token != stakeToken && token != rewardsToken, "Sweeping stakeToken & rewardsToken is not allowed");
uint256 balance = token.balanceOf(address(this));
require(balance > 0, "Insufficient balance");
token.transfer(owner(), balance);
}
/**
* @dev Transfer unclaimed rewards to the user and update totals
*/
function _claim() private {
uint256 amount = userRewards[msg.sender];
if (amount == 0) return;
// Transfer the rewards tokens to the user
bool success = rewardsToken.transfer(msg.sender, amount);
require(success, "Transfer Failed");
// Update the totals and reset the user's rewards to 0
totalRewardsUnclaimed -= amount;
totalAccumulatedRewardsClaimed += amount;
userRewards[msg.sender] = 0;
emit Claim(msg.sender, amount);
}
/**
* @dev Update userRewards balances for a subset of users
* @param from Index to start iterating from
* @param to Index to stop iterating at
*/
function _updateUserRewards(uint256 from, uint256 to) private returns (uint256) {
uint256 rewardsToDistribute = getUndistributedRewards();
require(rewardsToDistribute > minRewardsToUpdate, "Rewards too low");
require(totalShares > 0, "TotalShares too low");
require(from < to && to <= users.length(), "from/to out of bounds");
if (rewardsUpdateState.to != 0) {
require(from == rewardsUpdateState.to, "Continue from previous state");
}
rewardsUpdateState = UpdateState(users.length(), from, to);
updateRewardsInProgress = true;
uint256 rewardsDistributed = 0;
uint256 eligibleUsers = 0;
// Iterate over each user and update their rewards entitlement
for (uint256 i = from; i < to; i++) {
address user = users.at(i);
// Calculate the user's shares based on their deposit and NFT balance
uint256 multiplier = userMultiplier(user);
if (multiplier == 0) continue;
eligibleUsers++;
// Calculate the user's rewards based on their shares and rewards to distribute
uint256 _userShares = userDeposits[user] * multiplier / 100;
uint256 newUserRewards = rewardsToDistribute * _userShares / totalShares;
// Handle (rewardsDistributed + newUserRewards) > rewardsToDistribute
bool stopDistribution;
if (rewardsDistributed + newUserRewards > rewardsToDistribute) {
newUserRewards = rewardsToDistribute - rewardsDistributed;
stopDistribution = true;
}
userRewards[user] += newUserRewards;
rewardsDistributed += newUserRewards;
if (stopDistribution) break;
}
if (to == users.length()) {
// Handle edge case when no user received rewards (no eligible users)
if (rewardsDistributed < rewardsToDistribute && eligibleUsers > 0) {
// Handle remainder
uint256 remainder = rewardsToDistribute - rewardsDistributed;
userRewards[owner()] += remainder;
rewardsDistributed += remainder;
}
require(rewardsDistributed == rewardsToDistribute, "rewardsDistributed != rewardsToDistribute");
rewardsUpdateState = UpdateState(0, 0, 0); // reset state
updateRewardsInProgress = false;
}
totalRewardsUnclaimed += rewardsDistributed;
return rewardsDistributed;
}
/**
* @dev Update totalShares, considering a subset of users
* @param from Index to start iterating from
* @param to Index to stop iterating at
*/
function _updateTotalShares(uint256 from, uint256 to) private returns (uint256) {
require(from < to && to <= users.length(), "from/to out of bounds");
uint256 sharesAdded = 0;
if (totalSharesUpdateState.to == 0) {
totalShares = 0;
} else {
require(from == totalSharesUpdateState.to, "Continue from previous state");
}
totalSharesUpdateState = UpdateState(users.length(), from, to);
updateTotalSharesInProgress = true;
// Iterate over each user and sum their shares
for (uint256 i = from; i < to; i++) {
address user = users.at(i);
uint256 multiplier = userMultiplier(user);
if (multiplier == 0) continue;
sharesAdded += userDeposits[user] * multiplier / 100;
}
if (to == users.length()) {
totalSharesUpdateState = UpdateState(0, 0, 0); // reset state
updateTotalSharesInProgress = false;
totalSharesLastUpdateBlock = block.number;
}
totalShares += sharesAdded;
return sharesAdded;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `_msgSender()` is missing `role`.
* Overriding this function changes the behavior of the {onlyRole} modifier.
*
* Format of the revert message is described in {_checkRole}.
*
* _Available since v4.6._
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(account),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* May emit a {RoleGranted} event.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*
* NOTE: This function is deprecated in favor of {_grantRole}.
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Grants `role` to `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
/**
* @dev Revokes `role` from `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved 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(address from, address to, uint256 tokenId, bytes calldata data) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must 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(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/Math.sol";
import "./math/SignedMath.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toString(int256 value) internal pure returns (string memory) {
return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return keccak256(bytes(a)) == keccak256(bytes(b));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1, "Math: mulDiv overflow");
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableMap.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableMap.js.
pragma solidity ^0.8.0;
import "./EnumerableSet.sol";
/**
* @dev Library for managing an enumerable variant of Solidity's
* https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]
* type.
*
* Maps have the following properties:
*
* - Entries are added, removed, and checked for existence in constant time
* (O(1)).
* - Entries are enumerated in O(n). No guarantees are made on the ordering.
*
* ```solidity
* contract Example {
* // Add the library methods
* using EnumerableMap for EnumerableMap.UintToAddressMap;
*
* // Declare a set state variable
* EnumerableMap.UintToAddressMap private myMap;
* }
* ```
*
* The following map types are supported:
*
* - `uint256 -> address` (`UintToAddressMap`) since v3.0.0
* - `address -> uint256` (`AddressToUintMap`) since v4.6.0
* - `bytes32 -> bytes32` (`Bytes32ToBytes32Map`) since v4.6.0
* - `uint256 -> uint256` (`UintToUintMap`) since v4.7.0
* - `bytes32 -> uint256` (`Bytes32ToUintMap`) since v4.7.0
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
* unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableMap, you can either remove all elements one by one or create a fresh instance using an
* array of EnumerableMap.
* ====
*/
library EnumerableMap {
using EnumerableSet for EnumerableSet.Bytes32Set;
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Map type with
// bytes32 keys and values.
// The Map implementation uses private functions, and user-facing
// implementations (such as Uint256ToAddressMap) are just wrappers around
// the underlying Map.
// This means that we can only create new EnumerableMaps for types that fit
// in bytes32.
struct Bytes32ToBytes32Map {
// Storage of keys
EnumerableSet.Bytes32Set _keys;
mapping(bytes32 => bytes32) _values;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function set(Bytes32ToBytes32Map storage map, bytes32 key, bytes32 value) internal returns (bool) {
map._values[key] = value;
return map._keys.add(key);
}
/**
* @dev Removes a key-value pair from a map. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function remove(Bytes32ToBytes32Map storage map, bytes32 key) internal returns (bool) {
delete map._values[key];
return map._keys.remove(key);
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function contains(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool) {
return map._keys.contains(key);
}
/**
* @dev Returns the number of key-value pairs in the map. O(1).
*/
function length(Bytes32ToBytes32Map storage map) internal view returns (uint256) {
return map._keys.length();
}
/**
* @dev Returns the key-value pair stored at position `index` in the map. O(1).
*
* Note that there are no guarantees on the ordering of entries inside the
* array, and it may change when more entries are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32ToBytes32Map storage map, uint256 index) internal view returns (bytes32, bytes32) {
bytes32 key = map._keys.at(index);
return (key, map._values[key]);
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*/
function tryGet(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool, bytes32) {
bytes32 value = map._values[key];
if (value == bytes32(0)) {
return (contains(map, key), bytes32(0));
} else {
return (true, value);
}
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function get(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bytes32) {
bytes32 value = map._values[key];
require(value != 0 || contains(map, key), "EnumerableMap: nonexistent key");
return value;
}
/**
* @dev Same as {get}, with a custom error message when `key` is not in the map.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryGet}.
*/
function get(
Bytes32ToBytes32Map storage map,
bytes32 key,
string memory errorMessage
) internal view returns (bytes32) {
bytes32 value = map._values[key];
require(value != 0 || contains(map, key), errorMessage);
return value;
}
/**
* @dev Return the an array containing all the keys
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function keys(Bytes32ToBytes32Map storage map) internal view returns (bytes32[] memory) {
return map._keys.values();
}
// UintToUintMap
struct UintToUintMap {
Bytes32ToBytes32Map _inner;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function set(UintToUintMap storage map, uint256 key, uint256 value) internal returns (bool) {
return set(map._inner, bytes32(key), bytes32(value));
}
/**
* @dev Removes a value from a map. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function remove(UintToUintMap storage map, uint256 key) internal returns (bool) {
return remove(map._inner, bytes32(key));
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function contains(UintToUintMap storage map, uint256 key) internal view returns (bool) {
return contains(map._inner, bytes32(key));
}
/**
* @dev Returns the number of elements in the map. O(1).
*/
function length(UintToUintMap storage map) internal view returns (uint256) {
return length(map._inner);
}
/**
* @dev Returns the element stored at position `index` in the map. O(1).
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintToUintMap storage map, uint256 index) internal view returns (uint256, uint256) {
(bytes32 key, bytes32 value) = at(map._inner, index);
return (uint256(key), uint256(value));
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*/
function tryGet(UintToUintMap storage map, uint256 key) internal view returns (bool, uint256) {
(bool success, bytes32 value) = tryGet(map._inner, bytes32(key));
return (success, uint256(value));
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function get(UintToUintMap storage map, uint256 key) internal view returns (uint256) {
return uint256(get(map._inner, bytes32(key)));
}
/**
* @dev Same as {get}, with a custom error message when `key` is not in the map.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryGet}.
*/
function get(UintToUintMap storage map, uint256 key, string memory errorMessage) internal view returns (uint256) {
return uint256(get(map._inner, bytes32(key), errorMessage));
}
/**
* @dev Return the an array containing all the keys
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function keys(UintToUintMap storage map) internal view returns (uint256[] memory) {
bytes32[] memory store = keys(map._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// UintToAddressMap
struct UintToAddressMap {
Bytes32ToBytes32Map _inner;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) {
return set(map._inner, bytes32(key), bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a map. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) {
return remove(map._inner, bytes32(key));
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) {
return contains(map._inner, bytes32(key));
}
/**
* @dev Returns the number of elements in the map. O(1).
*/
function length(UintToAddressMap storage map) internal view returns (uint256) {
return length(map._inner);
}
/**
* @dev Returns the element stored at position `index` in the map. O(1).
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) {
(bytes32 key, bytes32 value) = at(map._inner, index);
return (uint256(key), address(uint160(uint256(value))));
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*/
function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) {
(bool success, bytes32 value) = tryGet(map._inner, bytes32(key));
return (success, address(uint160(uint256(value))));
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function get(UintToAddressMap storage map, uint256 key) internal view returns (address) {
return address(uint160(uint256(get(map._inner, bytes32(key)))));
}
/**
* @dev Same as {get}, with a custom error message when `key` is not in the map.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryGet}.
*/
function get(
UintToAddressMap storage map,
uint256 key,
string memory errorMessage
) internal view returns (address) {
return address(uint160(uint256(get(map._inner, bytes32(key), errorMessage))));
}
/**
* @dev Return the an array containing all the keys
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function keys(UintToAddressMap storage map) internal view returns (uint256[] memory) {
bytes32[] memory store = keys(map._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// AddressToUintMap
struct AddressToUintMap {
Bytes32ToBytes32Map _inner;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function set(AddressToUintMap storage map, address key, uint256 value) internal returns (bool) {
return set(map._inner, bytes32(uint256(uint160(key))), bytes32(value));
}
/**
* @dev Removes a value from a map. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function remove(AddressToUintMap storage map, address key) internal returns (bool) {
return remove(map._inner, bytes32(uint256(uint160(key))));
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function contains(AddressToUintMap storage map, address key) internal view returns (bool) {
return contains(map._inner, bytes32(uint256(uint160(key))));
}
/**
* @dev Returns the number of elements in the map. O(1).
*/
function length(AddressToUintMap storage map) internal view returns (uint256) {
return length(map._inner);
}
/**
* @dev Returns the element stored at position `index` in the map. O(1).
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressToUintMap storage map, uint256 index) internal view returns (address, uint256) {
(bytes32 key, bytes32 value) = at(map._inner, index);
return (address(uint160(uint256(key))), uint256(value));
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*/
function tryGet(AddressToUintMap storage map, address key) internal view returns (bool, uint256) {
(bool success, bytes32 value) = tryGet(map._inner, bytes32(uint256(uint160(key))));
return (success, uint256(value));
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function get(AddressToUintMap storage map, address key) internal view returns (uint256) {
return uint256(get(map._inner, bytes32(uint256(uint160(key)))));
}
/**
* @dev Same as {get}, with a custom error message when `key` is not in the map.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryGet}.
*/
function get(
AddressToUintMap storage map,
address key,
string memory errorMessage
) internal view returns (uint256) {
return uint256(get(map._inner, bytes32(uint256(uint160(key))), errorMessage));
}
/**
* @dev Return the an array containing all the keys
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function keys(AddressToUintMap storage map) internal view returns (address[] memory) {
bytes32[] memory store = keys(map._inner);
address[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// Bytes32ToUintMap
struct Bytes32ToUintMap {
Bytes32ToBytes32Map _inner;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function set(Bytes32ToUintMap storage map, bytes32 key, uint256 value) internal returns (bool) {
return set(map._inner, key, bytes32(value));
}
/**
* @dev Removes a value from a map. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function remove(Bytes32ToUintMap storage map, bytes32 key) internal returns (bool) {
return remove(map._inner, key);
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function contains(Bytes32ToUintMap storage map, bytes32 key) internal view returns (bool) {
return contains(map._inner, key);
}
/**
* @dev Returns the number of elements in the map. O(1).
*/
function length(Bytes32ToUintMap storage map) internal view returns (uint256) {
return length(map._inner);
}
/**
* @dev Returns the element stored at position `index` in the map. O(1).
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32ToUintMap storage map, uint256 index) internal view returns (bytes32, uint256) {
(bytes32 key, bytes32 value) = at(map._inner, index);
return (key, uint256(value));
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*/
function tryGet(Bytes32ToUintMap storage map, bytes32 key) internal view returns (bool, uint256) {
(bool success, bytes32 value) = tryGet(map._inner, key);
return (success, uint256(value));
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function get(Bytes32ToUintMap storage map, bytes32 key) internal view returns (uint256) {
return uint256(get(map._inner, key));
}
/**
* @dev Same as {get}, with a custom error message when `key` is not in the map.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryGet}.
*/
function get(
Bytes32ToUintMap storage map,
bytes32 key,
string memory errorMessage
) internal view returns (uint256) {
return uint256(get(map._inner, key, errorMessage));
}
/**
* @dev Return the an array containing all the keys
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function keys(Bytes32ToUintMap storage map) internal view returns (bytes32[] memory) {
bytes32[] memory store = keys(map._inner);
bytes32[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
pragma solidity ^0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```solidity
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
* unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
* array of EnumerableSet.
* ====
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping(bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
// Equivalent to contains(set, value)
// 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;
if (lastIndex != toDeleteIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastValue;
// Update the index for the moved value
set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;
interface IERC721WithUtility {
function hasUtility(uint256 tokenId) external view returns (bool);
function balanceWithUtilityOf(address owner) external view returns (uint256);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../interfaces/IERC721WithUtility.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
library IERC721WithUtilityHelpers {
/**
* @notice Returns the balance of NFTs with utility (of `nftCollection`) of a given owner
* @param owner Address of the owner to query the balance of
* @param nftCollection Address of the NFT collection
* @param isIERC721WithUtility Whether the NFT collection implements IERC721WithUtility
*/
function balanceWithUtilityOf(address owner, address nftCollection, bool isIERC721WithUtility) public view returns (uint256 balance) {
if (isIERC721WithUtility) {
balance = IERC721WithUtility(nftCollection).balanceWithUtilityOf(owner);
} else {
balance = IERC721(nftCollection).balanceOf(owner);
}
}
/**
* @notice Returns whether the given owner owns at least one NFT with utility (of `nftCollection`)
* @param owner Address of the owner to query the balance of
* @param nftCollection Address of the NFT collection
* @param isIERC721WithUtility Whether the NFT collection implements IERC721WithUtility
*/
function ownsNftWithUtility(address owner, address nftCollection, bool isIERC721WithUtility) public view returns (bool) {
return balanceWithUtilityOf(owner, nftCollection, isIERC721WithUtility) > 0;
}
}{
"libraries": {
"contracts/util/IERC721WithUtilityHelpers.sol": {
"IERC721WithUtilityHelpers": "0x2626658bb9186b22c798ea85a4623c2c1eba2901"
}
},
"metadata": {
"useLiteralContent": true
},
"optimizer": {
"enabled": true,
"runs": 500000
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"stakeToken_","type":"address"},{"internalType":"address","name":"rewardsToken_","type":"address"},{"internalType":"address","name":"nft_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Claim","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"from","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"to","type":"uint256"}],"name":"PartialUpdateTotalShares","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"from","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"to","type":"uint256"}],"name":"PartialUpdateUserRewards","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Stake","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"Unstake","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"UpdateTotalShares","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"UpdateUserRewards","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OPERATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNftCollections","outputs":[{"components":[{"internalType":"address","name":"nftAddress","type":"address"},{"internalType":"uint256","name":"multiplier","type":"uint256"}],"internalType":"struct ZombieVan.NftCollection[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getUndistributedRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getUsers","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getUsersLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"from","type":"uint256"},{"internalType":"uint256","name":"to","type":"uint256"}],"name":"getUsersRange","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minRewardsToUpdate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nftHolderExemptFromWithdrawalFee","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nftIERC721WithUtility","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"from","type":"uint256"},{"internalType":"uint256","name":"to","type":"uint256"}],"name":"partialUpdateTotalShares","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"from","type":"uint256"},{"internalType":"uint256","name":"to","type":"uint256"}],"name":"partialUpdateUserRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardsToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardsUpdateState","outputs":[{"internalType":"uint256","name":"usersLength","type":"uint256"},{"internalType":"uint256","name":"from","type":"uint256"},{"internalType":"uint256","name":"to","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"value","type":"address"}],"name":"setFeeAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountInWei","type":"uint256"}],"name":"setMinRewardsToUpdate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"nftAddress","type":"address"},{"internalType":"uint256","name":"multiplier","type":"uint256"},{"internalType":"bool","name":"isIERC721WithUtility","type":"bool"}],"name":"setNftCollection","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"value","type":"bool"}],"name":"setNftHolderExemptFromWithdrawalFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"name":"setTotalSharesLastUpdateMaxBlocks","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"name":"setWithdrawalFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakeToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"}],"name":"sweepErc20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"totalAccumulatedDeposits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalAccumulatedRewardsClaimed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalAccumulatedWithdrawals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalRewardsUnclaimed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSharesLastUpdateBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSharesLastUpdateMaxBlocks","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSharesUpdateState","outputs":[{"internalType":"uint256","name":"usersLength","type":"uint256"},{"internalType":"uint256","name":"from","type":"uint256"},{"internalType":"uint256","name":"to","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalStaked","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"unstake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"updateRewardsInProgress","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"updateTotalShares","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"updateTotalSharesInProgress","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"updateUserRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userDeposits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"userMultiplier","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"userShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdrawalFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]Contract Creation Code
60c060405260f0600a553480156200001657600080fd5b5060405162003ff238038062003ff283398101604081905262000039916200027d565b6200004433620000d0565b60016002556001600160a01b03808416608052821660a0526200006b601782606462000120565b506001600160a01b0381166000908152601660205260408120805460ff191660011790556200009b903362000140565b620000c77f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b9293362000140565b505050620002c7565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600062000138846001600160a01b0385168462000150565b949350505050565b6200014c82826200016f565b5050565b60008281526002840160205260408120829055620001388484620001f7565b60008281526001602090815260408083206001600160a01b038516845290915290205460ff166200014c5760008281526001602081815260408084206001600160a01b0386168086529252808420805460ff19169093179092559051339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b60006200020583836200020e565b90505b92915050565b6000818152600183016020526040812054620002575750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915562000208565b50600062000208565b80516001600160a01b03811681146200027857600080fd5b919050565b6000806000606084860312156200029357600080fd5b6200029e8462000260565b9250620002ae6020850162000260565b9150620002be6040850162000260565b90509250925092565b60805160a051613cd46200031e600039600081816106a101528181611dd40152818161227c01526125f401526000818161051b01528181610d1101528181610e2d0152818161170d0152611d7d0152613cd46000f3fe608060405234801561001057600080fd5b50600436106103555760003560e01c806391d14854116101c8578063dadaaca111610104578063ec0f0238116100a2578063f2fde38b1161007c578063f2fde38b14610795578063f397f667146107a8578063f5b541a6146107b0578063fefcd274146107d757600080fd5b8063ec0f023814610770578063edfed34314610779578063f0dd1efa1461078257600080fd5b8063dc9c223b116100de578063dc9c223b14610744578063dd89b7361461074d578063de69b3aa14610755578063e993adcc1461076857600080fd5b8063dadaaca1146106e9578063dbafb9e41461070c578063dc4ade111461073157600080fd5b8063b1a03b6b11610171578063ba7ef2cb1161014b578063ba7ef2cb14610689578063d1af0c7d1461069c578063d547741f146106c3578063d9fe3eae146106d657600080fd5b8063b1a03b6b1461065b578063b66438bc1461066e578063ba0ce59f1461068057600080fd5b8063a694fc3a116101a2578063a694fc3a14610620578063ac1e502514610633578063b1686ab61461064657600080fd5b806391d14854146105bf578063a05e84b514610605578063a217fddf1461061857600080fd5b806340fd399411610297578063595b1a3e11610240578063817b1cd21161021a578063817b1cd21461057c5780638705fcd4146105855780638bc7e8c4146105985780638da5cb5b146105a157600080fd5b8063595b1a3e14610546578063631a58bd1461054e578063715018a61461057457600080fd5b80634e71d92d116102715780634e71d92d1461050e57806351ed6a30146105165780635811cbfb1461053d57600080fd5b806340fd3994146104a357806341275358146104b657806344bc86ef146104fb57600080fd5b80630ba36dcd116103045780632f2ff15d116102de5780632f2ff15d1461046b57806334838afa1461047e57806336568abe146104875780633a98ef391461049a57600080fd5b80630ba36dcd14610412578063248a9ca3146104325780632e17de781461045657600080fd5b806301ffc9a71161033557806301ffc9a7146103b85780630660f1e8146103db57806306dd29e51461040957600080fd5b806218b4c41461035a578062ce8e3e1461038357806301aa7f2f1461038b575b600080fd5b61036d6103683660046137b9565b6107fe565b60405161037a91906137db565b60405180910390f35b61036d6109a2565b60105460115460125461039d92919083565b6040805193845260208401929092529082015260600161037a565b6103cb6103c6366004613835565b6109b3565b604051901515815260200161037a565b6103fb6103e9366004613899565b600f6020526000908152604090205481565b60405190815260200161037a565b6103fb60075481565b6103fb610420366004613899565b600e6020526000908152604090205481565b6103fb6104403660046138b6565b6000908152600160208190526040909120015490565b6104696104643660046138b6565b610a4a565b005b6104696104793660046138cf565b611003565b6103fb60035481565b6104696104953660046138cf565b61102e565b6103fb60085481565b6104696104b13660046137b9565b6110e1565b600d546104d69073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161037a565b61046961050936600461390d565b6111cf565b6104696112b3565b6104d67f000000000000000000000000000000000000000000000000000000000000000081565b6103fb60095481565b6103fb611450565b600d546103cb907501000000000000000000000000000000000000000000900460ff1681565b61046961145c565b6103fb600b5481565b610469610593366004613899565b61146e565b6103fb600c5481565b60005473ffffffffffffffffffffffffffffffffffffffff166104d6565b6103cb6105cd3660046138cf565b600091825260016020908152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b6104696106133660046138b6565b6114bd565b6103fb600081565b61046961062e3660046138b6565b61155a565b6104696106413660046138b6565b611895565b61064e611933565b60405161037a919061392a565b6103fb610669366004613899565b611a2a565b60135460145460155461039d92919083565b6103fb60065481565b61046961069736600461398f565b611b62565b6104d67f000000000000000000000000000000000000000000000000000000000000000081565b6104696106d13660046138cf565b611cbd565b6104696106e4366004613899565b611ce3565b6103cb6106f7366004613899565b60166020526000908152604090205460ff1681565b600d546103cb9074010000000000000000000000000000000000000000900460ff1681565b61046961073f3660046137b9565b61207d565b6103fb60055481565b610469612162565b6103fb610763366004613899565b6121e0565b6103fb612234565b6103fb60045481565b6103fb600a5481565b6104696107903660046138b6565b6122f9565b6104696107a3366004613899565b612396565b61046961244a565b6103fb7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b92981565b600d546103cb90760100000000000000000000000000000000000000000000900460ff1681565b606081831061086e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600960248201527f66726f6d203c20746f000000000000000000000000000000000000000000000060448201526064015b60405180910390fd5b610878601a61250d565b8211156108e1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f746f203c3d2075736572732e6c656e67746800000000000000000000000000006044820152606401610865565b60006108ed8484613a00565b67ffffffffffffffff81111561090557610905613a13565b60405190808252806020026020018201604052801561092e578160200160208202803683370190505b509050835b8381101561099857610946601a82612517565b826109518784613a00565b8151811061096157610961613a42565b73ffffffffffffffffffffffffffffffffffffffff909216602092830291909101909101528061099081613a71565b915050610933565b5090505b92915050565b60606109ae601a612523565b905090565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061099c57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff0000000000000000000000000000000000000000000000000000000083161461099c565b610a52612530565b600d547501000000000000000000000000000000000000000000900460ff1615610ad8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f546f74616c5368617265732075706461746520696e2070726f677265737300006044820152606401610865565b600d5474010000000000000000000000000000000000000000900460ff1615610b5d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f526577617264732075706461746520696e2070726f67726573730000000000006044820152606401610865565b600b54811115610bc9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f496e76616c696420616d6f756e740000000000000000000000000000000000006044820152606401610865565b336000908152600e6020526040902054818110801590610be95750600081115b610c4f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f496e73756666696369656e74207374616b65642062616c616e636500000000006044820152606401610865565b81600003610c5b578091505b6000806000600c541115610de957600d54600190760100000000000000000000000000000000000000000000900460ff1615610c9e57610c9a33611a2a565b1590505b8015610de757612710600c5486610cb59190613aa9565b610cbf9190613ac0565b600d546040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9182166004820152602481018390529194507f0000000000000000000000000000000000000000000000000000000000000000169063a9059cbb906044016020604051808303816000875af1158015610d5a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d7e9190613afb565b915081610de7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5472616e73666572204661696c656400000000000000000000000000000000006044820152606401610865565b505b6000610df58386613a00565b6040517fa9059cbb000000000000000000000000000000000000000000000000000000008152336004820152602481018290529091507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063a9059cbb906044016020604051808303816000875af1158015610e8b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eaf9190613afb565b915081610f18576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5472616e73666572204661696c656400000000000000000000000000000000006044820152606401610865565b336000908152600e602052604081208054879290610f37908490613a00565b925050819055508460056000828254610f509190613b18565b9250508190555084600b6000828254610f699190613a00565b90915550610f7790506125a1565b336000908152600e60205260408120549003610fb757610f98601a33612753565b50336000908152600e60209081526040808320839055600f9091528120555b604080518681526020810185905233917ff960dbf9e5d0682f7a298ed974e33a28b4464914b7a2bfac12ae419a9afeb280910160405180910390a2505050506110006001600255565b50565b6000828152600160208190526040909120015461101f81612775565b611029838361277f565b505050565b73ffffffffffffffffffffffffffffffffffffffff811633146110d3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608401610865565b6110dd828261283e565b5050565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff16611179576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4f50455241544f525f524f4c455f5245515549524544000000000000000000006044820152606401610865565b600061118583836128f9565b60408051828152602081018690529081018490529091507ffe09bb62011e31711d366bc46c68ceb330bf7d8eb5b45fbdad70e21dedd241f5906060015b60405180910390a1505050565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff16611267576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4f50455241544f525f524f4c455f5245515549524544000000000000000000006044820152606401610865565b600d8054911515760100000000000000000000000000000000000000000000027fffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffffff909216919091179055565b6112bb612530565b600d547501000000000000000000000000000000000000000000900460ff1615611341576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f546f74616c5368617265732075706461746520696e2070726f677265737300006044820152606401610865565b600d5474010000000000000000000000000000000000000000900460ff16156113c6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f526577617264732075706461746520696e2070726f67726573730000000000006044820152606401610865565b336000908152600f602052604090205461143c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4e6f207265776172647320746f20636c61696d000000000000000000000000006044820152606401610865565b6114446125a1565b61144e6001600255565b565b60006109ae601a61250d565b611464612e30565b61144e6000612eb1565b611476612e30565b600d80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff16611555576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4f50455241544f525f524f4c455f5245515549524544000000000000000000006044820152606401610865565b600a55565b600d547501000000000000000000000000000000000000000000900460ff16156115e0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f546f74616c5368617265732075706461746520696e2070726f677265737300006044820152606401610865565b600d5474010000000000000000000000000000000000000000900460ff1615611665576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f526577617264732075706461746520696e2070726f67726573730000000000006044820152606401610865565b600081116116cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416d6f756e74206d7573742062652067726561746572207468616e20300000006044820152606401610865565b6040517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018290526000907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16906323b872dd906064016020604051808303816000875af115801561176b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061178f9190613afb565b9050806117f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f5472616e7366657246726f6d206661696c6564000000000000000000000000006044820152606401610865565b336000908152600e602052604081208054849290611817908490613b18565b9250508190555081600460008282546118309190613b18565b9250508190555081600b60008282546118499190613b18565b9091555061185a9050601a33612f26565b5060405182815233907febedb8b3c678666e7f36970bc8f57abf6d8fa2e828c0da91ea5b75bf68ed101a906020015b60405180910390a25050565b61189d612e30565b606481111561192e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f4d61782031252028313030202f20313030303029207769746864726177616c2060448201527f66656500000000000000000000000000000000000000000000000000000000006064820152608401610865565b600c55565b606060006119416017612f48565b67ffffffffffffffff81111561195957611959613a13565b60405190808252806020026020018201604052801561199e57816020015b60408051808201909152600080825260208201528152602001906001900390816119775790505b50905060005b6119ae6017612f48565b811015611a24576000806119c3601784612f53565b9150915060405180604001604052808373ffffffffffffffffffffffffffffffffffffffff16815260200182815250848481518110611a0457611a04613a42565b602002602001018190525050508080611a1c90613a71565b9150506119a4565b50919050565b600080805b611a396017612f48565b811015611b5b57600080611a4e601784612f53565b73ffffffffffffffffffffffffffffffffffffffff8281166000818152601660205260408082205490517f64a2dbfd000000000000000000000000000000000000000000000000000000008152938c166004850152602484019290925260ff90911615156044830152929450909250732626658bb9186b22c798ea85a4623c2c1eba2901906364a2dbfd90606401602060405180830381865af4158015611af9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b1d9190613b2b565b905080600003611b2f57505050611b49565b611b398282613aa9565b611b439086613b18565b94505050505b80611b5381613a71565b915050611a2f565b5092915050565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff16611bfa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4f50455241544f525f524f4c455f5245515549524544000000000000000000006044820152606401610865565b8115611c6357611c0c60178484612f6f565b5073ffffffffffffffffffffffffffffffffffffffff8316600090815260166020526040902080548215157fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00909116179055505050565b611c6e601784612f9a565b50505073ffffffffffffffffffffffffffffffffffffffff16600090815260166020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b60008281526001602081905260409091200154611cd981612775565b611029838361283e565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff16611d7b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4f50455241544f525f524f4c455f5245515549524544000000000000000000006044820152606401610865565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614158015611e2357507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614155b611eaf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f5377656570696e67207374616b65546f6b656e20262072657761726473546f6b60448201527f656e206973206e6f7420616c6c6f7765640000000000000000000000000000006064820152608401610865565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8316906370a0823190602401602060405180830381865afa158015611f1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f409190613b2b565b905060008111611fac576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f496e73756666696369656e742062616c616e63650000000000000000000000006044820152606401610865565b8173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb611fe760005473ffffffffffffffffffffffffffffffffffffffff1690565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b16815273ffffffffffffffffffffffffffffffffffffffff9091166004820152602481018490526044016020604051808303816000875af1158015612059573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110299190613afb565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff16612115576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4f50455241544f525f524f4c455f5245515549524544000000000000000000006044820152606401610865565b60006121218383612fbc565b60408051828152602081018690529081018490529091507f108ff657c361e093e274ff76ec3c40fb3bbdcba36ea12504ac29acee7de37e6b906060016111c2565b600a546009546121729190613b18565b43111561218f5761218d6000612188601a61250d565b612fbc565b505b60006121a560006121a0601a61250d565b6128f9565b60405181815290915033907f3cfb677850d1e217a25e51615a1975a24243c082a5f41a3958208a9d318ed93a9060200160405180910390a250565b6000806121ec83611a2a565b73ffffffffffffffffffffffffffffffffffffffff84166000908152600e6020526040902054909150606490612223908390613aa9565b61222d9190613ac0565b9392505050565b6040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152600090819073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa1580156122c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122e79190613b2b565b905060006007548261222d9190613a00565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff16612391576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4f50455241544f525f524f4c455f5245515549524544000000000000000000006044820152606401610865565b600355565b61239e612e30565b73ffffffffffffffffffffffffffffffffffffffff8116612441576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610865565b61100081612eb1565b600a5460095461245a9190613b18565b43116124c2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f57616974206d6f726520626c6f636b73000000000000000000000000000000006044820152606401610865565b6124d16000612188601a61250d565b600881905560405190815233907fd5c1fbd294766e92a3d82455da9aaab838d5d20fd8514fe010f7090f4485e71e9060200160405180910390a2565b600061099c825490565b600061222d838361324d565b6060600061222d83613277565b600280540361259b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610865565b60028055565b336000908152600f6020526040812054908190036125bc5750565b6040517fa9059cbb000000000000000000000000000000000000000000000000000000008152336004820152602481018290526000907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063a9059cbb906044016020604051808303816000875af1158015612652573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126769190613afb565b9050806126df576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5472616e73666572204661696c656400000000000000000000000000000000006044820152606401610865565b81600760008282546126f19190613a00565b92505081905550816006600082825461270a9190613b18565b9091555050336000818152600f602052604080822091909155517f47cee97cb7acd717b3c0aa1435d004cd5b3c8c57d70dbceb4e4458bbd60e39d4906118899085815260200190565b600061222d8373ffffffffffffffffffffffffffffffffffffffff84166132d3565b61100081336133c6565b600082815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166110dd57600082815260016020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616808652925280842080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169093179092559051339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b600082815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16156110dd57600082815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600080612904612234565b90506003548111612971576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5265776172647320746f6f206c6f7700000000000000000000000000000000006044820152606401610865565b6000600854116129dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f546f74616c53686172657320746f6f206c6f77000000000000000000000000006044820152606401610865565b82841080156129f557506129f1601a61250d565b8311155b612a5b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f66726f6d2f746f206f7574206f6620626f756e647300000000000000000000006044820152606401610865565b60125415612ace576012548414612ace576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f436f6e74696e75652066726f6d2070726576696f7573207374617465000000006044820152606401610865565b6040518060600160405280612ae3601a61250d565b81526020808201879052604091820186905282516010558201516011550151601255600d80547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055600080855b85811015612c7b576000612b5e601a83612517565b90506000612b6b82611a2a565b905080600003612b7c575050612c69565b83612b8681613a71565b73ffffffffffffffffffffffffffffffffffffffff84166000908152600e60205260408120549196509150606490612bbf908490613aa9565b612bc99190613ac0565b905060006008548289612bdc9190613aa9565b612be69190613ac0565b9050600088612bf5838a613b18565b1115612c0c57612c05888a613a00565b9150600190505b73ffffffffffffffffffffffffffffffffffffffff85166000908152600f602052604081208054849290612c41908490613b18565b90915550612c5190508289613b18565b97508015612c63575050505050612c7b565b50505050505b80612c7381613a71565b915050612b49565b50612c86601a61250d565b8503612e0f578282108015612c9b5750600081115b15612d2f576000612cac8385613a00565b905080600f6000612cd260005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612d1b9190613b18565b90915550612d2b90508184613b18565b9250505b828214612dbe576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f72657761726473446973747269627574656420213d2072657761726473546f4460448201527f69737472696275746500000000000000000000000000000000000000000000006064820152608401610865565b60408051606081018252600080825260208201819052910181905260108190556011819055601255600d80547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1690555b8160076000828254612e219190613b18565b90915550919695505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461144e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610865565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600061222d8373ffffffffffffffffffffffffffffffffffffffff8416613480565b600061099c826134cf565b6000808080612f6286866134da565b9097909650945050505050565b6000612f928473ffffffffffffffffffffffffffffffffffffffff851684613505565b949350505050565b600061222d8373ffffffffffffffffffffffffffffffffffffffff8416613522565b60008183108015612fd65750612fd2601a61250d565b8211155b61303c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f66726f6d2f746f206f7574206f6620626f756e647300000000000000000000006044820152606401610865565b60155460009081036130525760006008556130bd565b60155484146130bd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f436f6e74696e75652066726f6d2070726576696f7573207374617465000000006044820152606401610865565b60405180606001604052806130d2601a61250d565b81526020808201879052604091820186905282516013558201516014550151601555600d80547fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff167501000000000000000000000000000000000000000000179055835b838110156131c857600061314b601a83612517565b9050600061315882611a2a565b9050806000036131695750506131b6565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600e602052604090205460649061319d908390613aa9565b6131a79190613ac0565b6131b19085613b18565b935050505b806131c081613a71565b915050613136565b506131d3601a61250d565b830361322e5760408051606081018252600080825260208201819052910181905260138190556014819055601555600d80547fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff169055436009555b80600860008282546132409190613b18565b9091555090949350505050565b600082600001828154811061326457613264613a42565b9060005260206000200154905092915050565b6060816000018054806020026020016040519081016040528092919081815260200182805480156132c757602002820191906000526020600020905b8154815260200190600101908083116132b3575b50505050509050919050565b600081815260018301602052604081205480156133bc5760006132f7600183613a00565b855490915060009061330b90600190613a00565b905081811461337057600086600001828154811061332b5761332b613a42565b906000526020600020015490508087600001848154811061334e5761334e613a42565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061338157613381613b44565b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061099c565b600091505061099c565b600082815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166110dd576134068161353f565b61341183602061355e565b604051602001613422929190613b97565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a000000000000000000000000000000000000000000000000000000000825261086591600401613c18565b60008181526001830160205260408120546134c75750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561099c565b50600061099c565b600061099c8261250d565b600080806134e88585612517565b600081815260029690960160205260409095205494959350505050565b60008281526002840160205260408120829055612f9284846137a1565b6000818152600283016020526040812081905561222d83836137ad565b606061099c73ffffffffffffffffffffffffffffffffffffffff831660145b6060600061356d836002613aa9565b613578906002613b18565b67ffffffffffffffff81111561359057613590613a13565b6040519080825280601f01601f1916602001820160405280156135ba576020820181803683370190505b5090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106135f1576135f1613a42565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f78000000000000000000000000000000000000000000000000000000000000008160018151811061365457613654613a42565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000613690846002613aa9565b61369b906001613b18565b90505b6001811115613738577f303132333435363738396162636465660000000000000000000000000000000085600f16601081106136dc576136dc613a42565b1a60f81b8282815181106136f2576136f2613a42565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c9361373181613c69565b905061369e565b50831561222d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610865565b600061222d8383613480565b600061222d83836132d3565b600080604083850312156137cc57600080fd5b50508035926020909101359150565b6020808252825182820181905260009190848201906040850190845b8181101561382957835173ffffffffffffffffffffffffffffffffffffffff16835292840192918401916001016137f7565b50909695505050505050565b60006020828403121561384757600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461222d57600080fd5b73ffffffffffffffffffffffffffffffffffffffff8116811461100057600080fd5b6000602082840312156138ab57600080fd5b813561222d81613877565b6000602082840312156138c857600080fd5b5035919050565b600080604083850312156138e257600080fd5b8235915060208301356138f481613877565b809150509250929050565b801515811461100057600080fd5b60006020828403121561391f57600080fd5b813561222d816138ff565b602080825282518282018190526000919060409081850190868401855b82811015613982578151805173ffffffffffffffffffffffffffffffffffffffff168552860151868501529284019290850190600101613947565b5091979650505050505050565b6000806000606084860312156139a457600080fd5b83356139af81613877565b92506020840135915060408401356139c6816138ff565b809150509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8181038181111561099c5761099c6139d1565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203613aa257613aa26139d1565b5060010190565b808202811582820484141761099c5761099c6139d1565b600082613af6577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b600060208284031215613b0d57600080fd5b815161222d816138ff565b8082018082111561099c5761099c6139d1565b600060208284031215613b3d57600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b60005b83811015613b8e578181015183820152602001613b76565b50506000910152565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351613bcf816017850160208801613b73565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351613c0c816028840160208801613b73565b01602801949350505050565b6020815260008251806020840152613c37816040850160208701613b73565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b600081613c7857613c786139d1565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fea26469706673582212208c393287ce377219e6442221e468e8cd20c847e2ac691e0f1376b6915050862e64736f6c63430008130033000000000000000000000000005e16eccdfd3ea76e7b777a1beb7b826e3aa7e300000000000000000000000078c1b0c915c4faa5fffa6cabf0219da63d7f4cb800000000000000000000000018f0335cda0085df8fbc2812ff9ca30153e32f7f
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106103555760003560e01c806391d14854116101c8578063dadaaca111610104578063ec0f0238116100a2578063f2fde38b1161007c578063f2fde38b14610795578063f397f667146107a8578063f5b541a6146107b0578063fefcd274146107d757600080fd5b8063ec0f023814610770578063edfed34314610779578063f0dd1efa1461078257600080fd5b8063dc9c223b116100de578063dc9c223b14610744578063dd89b7361461074d578063de69b3aa14610755578063e993adcc1461076857600080fd5b8063dadaaca1146106e9578063dbafb9e41461070c578063dc4ade111461073157600080fd5b8063b1a03b6b11610171578063ba7ef2cb1161014b578063ba7ef2cb14610689578063d1af0c7d1461069c578063d547741f146106c3578063d9fe3eae146106d657600080fd5b8063b1a03b6b1461065b578063b66438bc1461066e578063ba0ce59f1461068057600080fd5b8063a694fc3a116101a2578063a694fc3a14610620578063ac1e502514610633578063b1686ab61461064657600080fd5b806391d14854146105bf578063a05e84b514610605578063a217fddf1461061857600080fd5b806340fd399411610297578063595b1a3e11610240578063817b1cd21161021a578063817b1cd21461057c5780638705fcd4146105855780638bc7e8c4146105985780638da5cb5b146105a157600080fd5b8063595b1a3e14610546578063631a58bd1461054e578063715018a61461057457600080fd5b80634e71d92d116102715780634e71d92d1461050e57806351ed6a30146105165780635811cbfb1461053d57600080fd5b806340fd3994146104a357806341275358146104b657806344bc86ef146104fb57600080fd5b80630ba36dcd116103045780632f2ff15d116102de5780632f2ff15d1461046b57806334838afa1461047e57806336568abe146104875780633a98ef391461049a57600080fd5b80630ba36dcd14610412578063248a9ca3146104325780632e17de781461045657600080fd5b806301ffc9a71161033557806301ffc9a7146103b85780630660f1e8146103db57806306dd29e51461040957600080fd5b806218b4c41461035a578062ce8e3e1461038357806301aa7f2f1461038b575b600080fd5b61036d6103683660046137b9565b6107fe565b60405161037a91906137db565b60405180910390f35b61036d6109a2565b60105460115460125461039d92919083565b6040805193845260208401929092529082015260600161037a565b6103cb6103c6366004613835565b6109b3565b604051901515815260200161037a565b6103fb6103e9366004613899565b600f6020526000908152604090205481565b60405190815260200161037a565b6103fb60075481565b6103fb610420366004613899565b600e6020526000908152604090205481565b6103fb6104403660046138b6565b6000908152600160208190526040909120015490565b6104696104643660046138b6565b610a4a565b005b6104696104793660046138cf565b611003565b6103fb60035481565b6104696104953660046138cf565b61102e565b6103fb60085481565b6104696104b13660046137b9565b6110e1565b600d546104d69073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161037a565b61046961050936600461390d565b6111cf565b6104696112b3565b6104d67f000000000000000000000000005e16eccdfd3ea76e7b777a1beb7b826e3aa7e381565b6103fb60095481565b6103fb611450565b600d546103cb907501000000000000000000000000000000000000000000900460ff1681565b61046961145c565b6103fb600b5481565b610469610593366004613899565b61146e565b6103fb600c5481565b60005473ffffffffffffffffffffffffffffffffffffffff166104d6565b6103cb6105cd3660046138cf565b600091825260016020908152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b6104696106133660046138b6565b6114bd565b6103fb600081565b61046961062e3660046138b6565b61155a565b6104696106413660046138b6565b611895565b61064e611933565b60405161037a919061392a565b6103fb610669366004613899565b611a2a565b60135460145460155461039d92919083565b6103fb60065481565b61046961069736600461398f565b611b62565b6104d67f00000000000000000000000078c1b0c915c4faa5fffa6cabf0219da63d7f4cb881565b6104696106d13660046138cf565b611cbd565b6104696106e4366004613899565b611ce3565b6103cb6106f7366004613899565b60166020526000908152604090205460ff1681565b600d546103cb9074010000000000000000000000000000000000000000900460ff1681565b61046961073f3660046137b9565b61207d565b6103fb60055481565b610469612162565b6103fb610763366004613899565b6121e0565b6103fb612234565b6103fb60045481565b6103fb600a5481565b6104696107903660046138b6565b6122f9565b6104696107a3366004613899565b612396565b61046961244a565b6103fb7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b92981565b600d546103cb90760100000000000000000000000000000000000000000000900460ff1681565b606081831061086e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600960248201527f66726f6d203c20746f000000000000000000000000000000000000000000000060448201526064015b60405180910390fd5b610878601a61250d565b8211156108e1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f746f203c3d2075736572732e6c656e67746800000000000000000000000000006044820152606401610865565b60006108ed8484613a00565b67ffffffffffffffff81111561090557610905613a13565b60405190808252806020026020018201604052801561092e578160200160208202803683370190505b509050835b8381101561099857610946601a82612517565b826109518784613a00565b8151811061096157610961613a42565b73ffffffffffffffffffffffffffffffffffffffff909216602092830291909101909101528061099081613a71565b915050610933565b5090505b92915050565b60606109ae601a612523565b905090565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061099c57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff0000000000000000000000000000000000000000000000000000000083161461099c565b610a52612530565b600d547501000000000000000000000000000000000000000000900460ff1615610ad8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f546f74616c5368617265732075706461746520696e2070726f677265737300006044820152606401610865565b600d5474010000000000000000000000000000000000000000900460ff1615610b5d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f526577617264732075706461746520696e2070726f67726573730000000000006044820152606401610865565b600b54811115610bc9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f496e76616c696420616d6f756e740000000000000000000000000000000000006044820152606401610865565b336000908152600e6020526040902054818110801590610be95750600081115b610c4f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f496e73756666696369656e74207374616b65642062616c616e636500000000006044820152606401610865565b81600003610c5b578091505b6000806000600c541115610de957600d54600190760100000000000000000000000000000000000000000000900460ff1615610c9e57610c9a33611a2a565b1590505b8015610de757612710600c5486610cb59190613aa9565b610cbf9190613ac0565b600d546040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9182166004820152602481018390529194507f000000000000000000000000005e16eccdfd3ea76e7b777a1beb7b826e3aa7e3169063a9059cbb906044016020604051808303816000875af1158015610d5a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d7e9190613afb565b915081610de7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5472616e73666572204661696c656400000000000000000000000000000000006044820152606401610865565b505b6000610df58386613a00565b6040517fa9059cbb000000000000000000000000000000000000000000000000000000008152336004820152602481018290529091507f000000000000000000000000005e16eccdfd3ea76e7b777a1beb7b826e3aa7e373ffffffffffffffffffffffffffffffffffffffff169063a9059cbb906044016020604051808303816000875af1158015610e8b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eaf9190613afb565b915081610f18576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5472616e73666572204661696c656400000000000000000000000000000000006044820152606401610865565b336000908152600e602052604081208054879290610f37908490613a00565b925050819055508460056000828254610f509190613b18565b9250508190555084600b6000828254610f699190613a00565b90915550610f7790506125a1565b336000908152600e60205260408120549003610fb757610f98601a33612753565b50336000908152600e60209081526040808320839055600f9091528120555b604080518681526020810185905233917ff960dbf9e5d0682f7a298ed974e33a28b4464914b7a2bfac12ae419a9afeb280910160405180910390a2505050506110006001600255565b50565b6000828152600160208190526040909120015461101f81612775565b611029838361277f565b505050565b73ffffffffffffffffffffffffffffffffffffffff811633146110d3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608401610865565b6110dd828261283e565b5050565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff16611179576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4f50455241544f525f524f4c455f5245515549524544000000000000000000006044820152606401610865565b600061118583836128f9565b60408051828152602081018690529081018490529091507ffe09bb62011e31711d366bc46c68ceb330bf7d8eb5b45fbdad70e21dedd241f5906060015b60405180910390a1505050565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff16611267576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4f50455241544f525f524f4c455f5245515549524544000000000000000000006044820152606401610865565b600d8054911515760100000000000000000000000000000000000000000000027fffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffffff909216919091179055565b6112bb612530565b600d547501000000000000000000000000000000000000000000900460ff1615611341576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f546f74616c5368617265732075706461746520696e2070726f677265737300006044820152606401610865565b600d5474010000000000000000000000000000000000000000900460ff16156113c6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f526577617264732075706461746520696e2070726f67726573730000000000006044820152606401610865565b336000908152600f602052604090205461143c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4e6f207265776172647320746f20636c61696d000000000000000000000000006044820152606401610865565b6114446125a1565b61144e6001600255565b565b60006109ae601a61250d565b611464612e30565b61144e6000612eb1565b611476612e30565b600d80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff16611555576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4f50455241544f525f524f4c455f5245515549524544000000000000000000006044820152606401610865565b600a55565b600d547501000000000000000000000000000000000000000000900460ff16156115e0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f546f74616c5368617265732075706461746520696e2070726f677265737300006044820152606401610865565b600d5474010000000000000000000000000000000000000000900460ff1615611665576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f526577617264732075706461746520696e2070726f67726573730000000000006044820152606401610865565b600081116116cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416d6f756e74206d7573742062652067726561746572207468616e20300000006044820152606401610865565b6040517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018290526000907f000000000000000000000000005e16eccdfd3ea76e7b777a1beb7b826e3aa7e373ffffffffffffffffffffffffffffffffffffffff16906323b872dd906064016020604051808303816000875af115801561176b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061178f9190613afb565b9050806117f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f5472616e7366657246726f6d206661696c6564000000000000000000000000006044820152606401610865565b336000908152600e602052604081208054849290611817908490613b18565b9250508190555081600460008282546118309190613b18565b9250508190555081600b60008282546118499190613b18565b9091555061185a9050601a33612f26565b5060405182815233907febedb8b3c678666e7f36970bc8f57abf6d8fa2e828c0da91ea5b75bf68ed101a906020015b60405180910390a25050565b61189d612e30565b606481111561192e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f4d61782031252028313030202f20313030303029207769746864726177616c2060448201527f66656500000000000000000000000000000000000000000000000000000000006064820152608401610865565b600c55565b606060006119416017612f48565b67ffffffffffffffff81111561195957611959613a13565b60405190808252806020026020018201604052801561199e57816020015b60408051808201909152600080825260208201528152602001906001900390816119775790505b50905060005b6119ae6017612f48565b811015611a24576000806119c3601784612f53565b9150915060405180604001604052808373ffffffffffffffffffffffffffffffffffffffff16815260200182815250848481518110611a0457611a04613a42565b602002602001018190525050508080611a1c90613a71565b9150506119a4565b50919050565b600080805b611a396017612f48565b811015611b5b57600080611a4e601784612f53565b73ffffffffffffffffffffffffffffffffffffffff8281166000818152601660205260408082205490517f64a2dbfd000000000000000000000000000000000000000000000000000000008152938c166004850152602484019290925260ff90911615156044830152929450909250732626658bb9186b22c798ea85a4623c2c1eba2901906364a2dbfd90606401602060405180830381865af4158015611af9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b1d9190613b2b565b905080600003611b2f57505050611b49565b611b398282613aa9565b611b439086613b18565b94505050505b80611b5381613a71565b915050611a2f565b5092915050565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff16611bfa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4f50455241544f525f524f4c455f5245515549524544000000000000000000006044820152606401610865565b8115611c6357611c0c60178484612f6f565b5073ffffffffffffffffffffffffffffffffffffffff8316600090815260166020526040902080548215157fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00909116179055505050565b611c6e601784612f9a565b50505073ffffffffffffffffffffffffffffffffffffffff16600090815260166020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b60008281526001602081905260409091200154611cd981612775565b611029838361283e565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff16611d7b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4f50455241544f525f524f4c455f5245515549524544000000000000000000006044820152606401610865565b7f000000000000000000000000005e16eccdfd3ea76e7b777a1beb7b826e3aa7e373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614158015611e2357507f00000000000000000000000078c1b0c915c4faa5fffa6cabf0219da63d7f4cb873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614155b611eaf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f5377656570696e67207374616b65546f6b656e20262072657761726473546f6b60448201527f656e206973206e6f7420616c6c6f7765640000000000000000000000000000006064820152608401610865565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8316906370a0823190602401602060405180830381865afa158015611f1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f409190613b2b565b905060008111611fac576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f496e73756666696369656e742062616c616e63650000000000000000000000006044820152606401610865565b8173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb611fe760005473ffffffffffffffffffffffffffffffffffffffff1690565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b16815273ffffffffffffffffffffffffffffffffffffffff9091166004820152602481018490526044016020604051808303816000875af1158015612059573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110299190613afb565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff16612115576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4f50455241544f525f524f4c455f5245515549524544000000000000000000006044820152606401610865565b60006121218383612fbc565b60408051828152602081018690529081018490529091507f108ff657c361e093e274ff76ec3c40fb3bbdcba36ea12504ac29acee7de37e6b906060016111c2565b600a546009546121729190613b18565b43111561218f5761218d6000612188601a61250d565b612fbc565b505b60006121a560006121a0601a61250d565b6128f9565b60405181815290915033907f3cfb677850d1e217a25e51615a1975a24243c082a5f41a3958208a9d318ed93a9060200160405180910390a250565b6000806121ec83611a2a565b73ffffffffffffffffffffffffffffffffffffffff84166000908152600e6020526040902054909150606490612223908390613aa9565b61222d9190613ac0565b9392505050565b6040517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152600090819073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000078c1b0c915c4faa5fffa6cabf0219da63d7f4cb816906370a0823190602401602060405180830381865afa1580156122c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122e79190613b2b565b905060006007548261222d9190613a00565b3360009081527f31c1e66639f421f1853aeefe8ad6b62a3b96f3287efe23106923cd924aa025c2602052604090205460ff16612391576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4f50455241544f525f524f4c455f5245515549524544000000000000000000006044820152606401610865565b600355565b61239e612e30565b73ffffffffffffffffffffffffffffffffffffffff8116612441576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610865565b61100081612eb1565b600a5460095461245a9190613b18565b43116124c2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f57616974206d6f726520626c6f636b73000000000000000000000000000000006044820152606401610865565b6124d16000612188601a61250d565b600881905560405190815233907fd5c1fbd294766e92a3d82455da9aaab838d5d20fd8514fe010f7090f4485e71e9060200160405180910390a2565b600061099c825490565b600061222d838361324d565b6060600061222d83613277565b600280540361259b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610865565b60028055565b336000908152600f6020526040812054908190036125bc5750565b6040517fa9059cbb000000000000000000000000000000000000000000000000000000008152336004820152602481018290526000907f00000000000000000000000078c1b0c915c4faa5fffa6cabf0219da63d7f4cb873ffffffffffffffffffffffffffffffffffffffff169063a9059cbb906044016020604051808303816000875af1158015612652573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126769190613afb565b9050806126df576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5472616e73666572204661696c656400000000000000000000000000000000006044820152606401610865565b81600760008282546126f19190613a00565b92505081905550816006600082825461270a9190613b18565b9091555050336000818152600f602052604080822091909155517f47cee97cb7acd717b3c0aa1435d004cd5b3c8c57d70dbceb4e4458bbd60e39d4906118899085815260200190565b600061222d8373ffffffffffffffffffffffffffffffffffffffff84166132d3565b61100081336133c6565b600082815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166110dd57600082815260016020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616808652925280842080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169093179092559051339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b600082815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16156110dd57600082815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600080612904612234565b90506003548111612971576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5265776172647320746f6f206c6f7700000000000000000000000000000000006044820152606401610865565b6000600854116129dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f546f74616c53686172657320746f6f206c6f77000000000000000000000000006044820152606401610865565b82841080156129f557506129f1601a61250d565b8311155b612a5b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f66726f6d2f746f206f7574206f6620626f756e647300000000000000000000006044820152606401610865565b60125415612ace576012548414612ace576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f436f6e74696e75652066726f6d2070726576696f7573207374617465000000006044820152606401610865565b6040518060600160405280612ae3601a61250d565b81526020808201879052604091820186905282516010558201516011550151601255600d80547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000179055600080855b85811015612c7b576000612b5e601a83612517565b90506000612b6b82611a2a565b905080600003612b7c575050612c69565b83612b8681613a71565b73ffffffffffffffffffffffffffffffffffffffff84166000908152600e60205260408120549196509150606490612bbf908490613aa9565b612bc99190613ac0565b905060006008548289612bdc9190613aa9565b612be69190613ac0565b9050600088612bf5838a613b18565b1115612c0c57612c05888a613a00565b9150600190505b73ffffffffffffffffffffffffffffffffffffffff85166000908152600f602052604081208054849290612c41908490613b18565b90915550612c5190508289613b18565b97508015612c63575050505050612c7b565b50505050505b80612c7381613a71565b915050612b49565b50612c86601a61250d565b8503612e0f578282108015612c9b5750600081115b15612d2f576000612cac8385613a00565b905080600f6000612cd260005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612d1b9190613b18565b90915550612d2b90508184613b18565b9250505b828214612dbe576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f72657761726473446973747269627574656420213d2072657761726473546f4460448201527f69737472696275746500000000000000000000000000000000000000000000006064820152608401610865565b60408051606081018252600080825260208201819052910181905260108190556011819055601255600d80547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1690555b8160076000828254612e219190613b18565b90915550919695505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461144e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610865565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600061222d8373ffffffffffffffffffffffffffffffffffffffff8416613480565b600061099c826134cf565b6000808080612f6286866134da565b9097909650945050505050565b6000612f928473ffffffffffffffffffffffffffffffffffffffff851684613505565b949350505050565b600061222d8373ffffffffffffffffffffffffffffffffffffffff8416613522565b60008183108015612fd65750612fd2601a61250d565b8211155b61303c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f66726f6d2f746f206f7574206f6620626f756e647300000000000000000000006044820152606401610865565b60155460009081036130525760006008556130bd565b60155484146130bd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f436f6e74696e75652066726f6d2070726576696f7573207374617465000000006044820152606401610865565b60405180606001604052806130d2601a61250d565b81526020808201879052604091820186905282516013558201516014550151601555600d80547fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff167501000000000000000000000000000000000000000000179055835b838110156131c857600061314b601a83612517565b9050600061315882611a2a565b9050806000036131695750506131b6565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600e602052604090205460649061319d908390613aa9565b6131a79190613ac0565b6131b19085613b18565b935050505b806131c081613a71565b915050613136565b506131d3601a61250d565b830361322e5760408051606081018252600080825260208201819052910181905260138190556014819055601555600d80547fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff169055436009555b80600860008282546132409190613b18565b9091555090949350505050565b600082600001828154811061326457613264613a42565b9060005260206000200154905092915050565b6060816000018054806020026020016040519081016040528092919081815260200182805480156132c757602002820191906000526020600020905b8154815260200190600101908083116132b3575b50505050509050919050565b600081815260018301602052604081205480156133bc5760006132f7600183613a00565b855490915060009061330b90600190613a00565b905081811461337057600086600001828154811061332b5761332b613a42565b906000526020600020015490508087600001848154811061334e5761334e613a42565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061338157613381613b44565b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061099c565b600091505061099c565b600082815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166110dd576134068161353f565b61341183602061355e565b604051602001613422929190613b97565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a000000000000000000000000000000000000000000000000000000000825261086591600401613c18565b60008181526001830160205260408120546134c75750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561099c565b50600061099c565b600061099c8261250d565b600080806134e88585612517565b600081815260029690960160205260409095205494959350505050565b60008281526002840160205260408120829055612f9284846137a1565b6000818152600283016020526040812081905561222d83836137ad565b606061099c73ffffffffffffffffffffffffffffffffffffffff831660145b6060600061356d836002613aa9565b613578906002613b18565b67ffffffffffffffff81111561359057613590613a13565b6040519080825280601f01601f1916602001820160405280156135ba576020820181803683370190505b5090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106135f1576135f1613a42565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f78000000000000000000000000000000000000000000000000000000000000008160018151811061365457613654613a42565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000613690846002613aa9565b61369b906001613b18565b90505b6001811115613738577f303132333435363738396162636465660000000000000000000000000000000085600f16601081106136dc576136dc613a42565b1a60f81b8282815181106136f2576136f2613a42565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c9361373181613c69565b905061369e565b50831561222d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610865565b600061222d8383613480565b600061222d83836132d3565b600080604083850312156137cc57600080fd5b50508035926020909101359150565b6020808252825182820181905260009190848201906040850190845b8181101561382957835173ffffffffffffffffffffffffffffffffffffffff16835292840192918401916001016137f7565b50909695505050505050565b60006020828403121561384757600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461222d57600080fd5b73ffffffffffffffffffffffffffffffffffffffff8116811461100057600080fd5b6000602082840312156138ab57600080fd5b813561222d81613877565b6000602082840312156138c857600080fd5b5035919050565b600080604083850312156138e257600080fd5b8235915060208301356138f481613877565b809150509250929050565b801515811461100057600080fd5b60006020828403121561391f57600080fd5b813561222d816138ff565b602080825282518282018190526000919060409081850190868401855b82811015613982578151805173ffffffffffffffffffffffffffffffffffffffff168552860151868501529284019290850190600101613947565b5091979650505050505050565b6000806000606084860312156139a457600080fd5b83356139af81613877565b92506020840135915060408401356139c6816138ff565b809150509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8181038181111561099c5761099c6139d1565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203613aa257613aa26139d1565b5060010190565b808202811582820484141761099c5761099c6139d1565b600082613af6577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b600060208284031215613b0d57600080fd5b815161222d816138ff565b8082018082111561099c5761099c6139d1565b600060208284031215613b3d57600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b60005b83811015613b8e578181015183820152602001613b76565b50506000910152565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351613bcf816017850160208801613b73565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351613c0c816028840160208801613b73565b01602801949350505050565b6020815260008251806020840152613c37816040850160208701613b73565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b600081613c7857613c786139d1565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fea26469706673582212208c393287ce377219e6442221e468e8cd20c847e2ac691e0f1376b6915050862e64736f6c63430008130033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000005e16eccdfd3ea76e7b777a1beb7b826e3aa7e300000000000000000000000078c1b0c915c4faa5fffa6cabf0219da63d7f4cb800000000000000000000000018f0335cda0085df8fbc2812ff9ca30153e32f7f
-----Decoded View---------------
Arg [0] : stakeToken_ (address): 0x005E16eccDFd3EA76E7B777A1bEb7b826E3AA7E3
Arg [1] : rewardsToken_ (address): 0x78c1b0C915c4FAA5FffA6CAbf0219DA63d7f4cb8
Arg [2] : nft_ (address): 0x18F0335Cda0085df8fBc2812ff9CA30153e32F7F
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 000000000000000000000000005e16eccdfd3ea76e7b777a1beb7b826e3aa7e3
Arg [1] : 00000000000000000000000078c1b0c915c4faa5fffa6cabf0219da63d7f4cb8
Arg [2] : 00000000000000000000000018f0335cda0085df8fbc2812ff9ca30153e32f7f
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$9.15
Net Worth in MNT
Token Allocations
WMNT
100.00%
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|---|---|---|---|---|
| MANTLE | 100.00% | $0.882543 | 10.3732 | $9.15 |
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.