Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- StakingV1
- Optimization enabled
- true
- Compiler version
- v0.8.6+commit.11564f7e
- Optimization runs
- 200
- EVM Version
- default
- Verified at
- 2023-10-15T06:26:23.769524Z
contracts/StakingV1.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.6;
import {ERC721HolderUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol";
import {EnumerableMapUpgradeable as EnumerableMap} from "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableMapUpgradeable.sol";
import {EnumerableSetUpgradeable as EnumerableSet} from "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol";
import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import {SafeMathUpgradeable as SafeMath} from "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol";
import {PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import {IERC20Upgradeable as IERC20} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import {IERC721Upgradeable as IERC721} from "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol";
import {MathUpgradeable as Math} from "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol";
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {INFTProperty} from "./interface/INFTProperty.sol";
import {IBFuel} from "./interface/IBFuel.sol";
contract StakingV1 is
ReentrancyGuardUpgradeable,
OwnableUpgradeable,
PausableUpgradeable,
ERC721HolderUpgradeable,
UUPSUpgradeable
{
using SafeMath for uint256;
using EnumerableSet for EnumerableSet.UintSet;
using EnumerableMap for EnumerableMap.UintToAddressMap;
mapping(address => EnumerableMap.UintToAddressMap) private _minerOwners;
struct NftStake {
address staker;
address nftAddr;
uint256 minerId;
uint256 hashRate;
uint256 consumption;
uint256 lastUpdateTime;
}
mapping(address => bool) public minerList;
INFTProperty public property;
/* ========== STATE VARIABLES ========== */
// addreses
IBFuel public bFuel;
IERC721 public NFTMiner;
uint256 private _totalHashRate;
uint256 private _totalConsumption;
address public fuelReceiver;
uint256 public lastUpdateTime;
uint256 public bFuelRate;
uint256 public rewardRate;
uint256 public consumptionRate;
uint256 public periodFinish;
uint256 public deductionCount;
uint256 public rewardsDuration;
uint256 public rewardPerHashRateStored;
uint256 public consumptionPerHashRateStored;
uint256 public BASE_DIVIDER;
uint256 public FIRST_EPOCH_REWARDS;
// User's reward amount
mapping(address => uint256) public rewards;
mapping(address => mapping(uint256 => NftStake)) public nftStakes;
mapping(address => uint256) public consumptions;
// user's computing power
mapping(address => uint256) private _hashRateOf;
// User consumption
mapping(address => uint256) private _consumptionOf;
// User consumption all
mapping(address => uint256) private _consumptionAllOf;
mapping(address => uint256) public userRewardPerHashRatePaid;
mapping(address => uint256) public userConsumptionPerHashRatePaid;
mapping(address => mapping(address => EnumerableSet.UintSet)) private _holderMiners;
/* ========== CONSTRUCTOR ========== */
constructor() {
_disableInitializers();
}
receive() external payable {}
modifier onlyValidMiner(address miner) {
require(minerList[miner] == true, "E: miner is not valid");
_;
}
function initialize(
address _bFuelToken,
address _property,
uint256 _rewardsDuration
) external initializer {
__ERC721Holder_init();
__ReentrancyGuard_init();
__Pausable_init();
__Ownable_init();
__UUPSUpgradeable_init();
require(_rewardsDuration != 0, "rewardsDuration is zero");
bFuel = IBFuel(_bFuelToken);
property = INFTProperty(_property);
rewardsDuration = _rewardsDuration;
bFuelRate = 50;
BASE_DIVIDER = 100;
FIRST_EPOCH_REWARDS = 50 * 6 * 24 * 365 * 4 ether;
}
// Open mining pool
function start() external payable onlyOwner {
notifyRewardAmount(FIRST_EPOCH_REWARDS);
emit Start(msg.sender);
}
// Initialize basic data
function notifyRewardAmount(uint256 reward)
private
updateReward(address(0))
{
consumptionRate = uint256(1e18).div(3600);
if (block.timestamp >= periodFinish) {
rewardRate = reward.div(rewardsDuration);
} else {
uint256 remaining = periodFinish.sub(block.timestamp);
uint256 leftover = remaining.mul(rewardRate);
rewardRate = reward.add(leftover).div(rewardsDuration);
}
lastUpdateTime = block.timestamp;
periodFinish = block.timestamp.add(rewardsDuration);
emit RewardAdded(reward);
}
function lastTimeRewardApplicable() public view returns (uint256) {
return Math.min(block.timestamp, periodFinish);
}
// Reward per unit of token
function rewardPerToken() public view returns (uint256) {
if (_totalHashRate == 0) {
return rewardPerHashRateStored;
}
return
rewardPerHashRateStored.add(
lastTimeRewardApplicable()
.sub(lastUpdateTime)
.mul(rewardRate)
.mul(1e18)
.div(_totalHashRate)
);
}
function consumptionPerToken() public view returns (uint256) {
if (_totalHashRate == 0) {
return consumptionPerHashRateStored;
}
return
consumptionPerHashRateStored.add(
lastTimeRewardApplicable().sub(lastUpdateTime).mul(
consumptionRate
)
);
}
// Calculate earnings
function earned(address _owner) public view returns (uint256) {
return
_hashRateOf[_owner]
.mul(rewardPerToken().sub(userRewardPerHashRatePaid[_owner]))
.div(1e18)
.add(rewards[_owner]);
}
// Calculate consumption
function consumption(address _owner) public view returns (uint256) {
return
_consumptionOf[_owner]
.mul(
consumptionPerToken().sub(
userConsumptionPerHashRatePaid[_owner]
)
)
.add(consumptions[_owner]);
}
/**
* @notice nft deposit contract
* @param minerIds => array of nft ids
*/
function batchStake(address[] calldata nftAddrs, uint256[] calldata minerIds) external {
for (uint256 i = 0; i < minerIds.length; i++) {
stake(nftAddrs[i], minerIds[i]);
}
}
/**
* @notice nft deposit contract
* @param minerId => nft id
*/
function stake(address nftAddr, uint256 minerId)
public
whenNotPaused
onlyValidMiner(nftAddr)
updateReward(msg.sender)
nonReentrant
{
uint256 hashRate = property.getHashRate(nftAddr, minerId);
require(hashRate != 0, "Staking: Id not exist");
uint256 _consumption = property.getConsumption(nftAddr, minerId);
require(_consumption != 0, "Staking: Id not exist");
IERC721(nftAddr).safeTransferFrom(msg.sender, address(this), minerId);
nftStakes[nftAddr][minerId] = NftStake({
staker: msg.sender,
nftAddr: nftAddr,
minerId: minerId,
hashRate: hashRate,
consumption: _consumption,
lastUpdateTime: block.timestamp
});
_holderMiners[nftAddr][msg.sender].add(minerId);
_minerOwners[nftAddr].set(minerId, msg.sender);
_totalHashRate = _totalHashRate.add(hashRate);
_hashRateOf[msg.sender] = _hashRateOf[msg.sender].add(hashRate);
_consumptionOf[msg.sender] = _consumptionOf[msg.sender].add(
_consumption
);
emit MinerStaked(msg.sender, nftAddr, minerId);
}
/**
* @notice withdraw nft from contract
*/
function batchWithdrawMiners(address[] calldata nftAddrs, uint256[] calldata minerIds) external {
for (uint256 i = 0; i < minerIds.length; i++) {
withdrawMiner(nftAddrs[i], minerIds[i]);
}
}
/**
* @notice withdraw nft from contract
*/
function withdrawAllMiners(address nftAddr) external {
uint256 amount = minerAmountOf(nftAddr, msg.sender);
for (uint256 i = 0; i < amount; i++) {
withdrawMiner(nftAddr, minerOfOwnerByIndex(nftAddr, msg.sender, 0));
}
}
/**
* @notice withdraw nft from contract
*/
function withdrawMiner(address nftAddr, uint256 minerId)
public
updateReward(msg.sender)
onlyValidMiner(nftAddr)
checkDeduction
nonReentrant
{
require(
minerOwnerOf(nftAddr, minerId) == msg.sender,
"withdraw of token that is not own"
);
NftStake memory nftStake = nftStakes[nftAddr][minerId];
_totalHashRate = _totalHashRate.sub(nftStake.hashRate);
_hashRateOf[msg.sender] = _hashRateOf[msg.sender].sub(
nftStake.hashRate
);
_consumptionOf[msg.sender] = _consumptionOf[msg.sender].sub(
nftStake.consumption
);
_holderMiners[nftAddr][msg.sender].remove(minerId);
_minerOwners[nftAddr].set(minerId, address(0));
delete nftStakes[nftAddr][minerId];
IERC721(nftAddr).safeTransferFrom(address(this), msg.sender, minerId);
emit MinerWithdrawn(msg.sender, nftAddr, minerId);
}
// Receive award
function getReward()
public
nonReentrant
updateReward(msg.sender)
checkDeduction
{
uint256 reward = rewards[msg.sender];
uint256 currentConsumption = consumptions[msg.sender];
uint256 bFuelAmount = bFuel.balanceOf(msg.sender);
require(
bFuelAmount >= currentConsumption,
"ZWatt Insufficient balance"
);
_consumptionAllOf[msg.sender] = _consumptionAllOf[msg.sender].add(
currentConsumption
);
_totalConsumption = _totalConsumption.add(currentConsumption);
if (reward > 0) {
uint256 burnAmount = currentConsumption.mul(bFuelRate).div(
BASE_DIVIDER
);
bFuel.transferFrom(
msg.sender,
fuelReceiver,
currentConsumption.sub(burnAmount)
);
//mFuel burn
bFuel.transferFrom(msg.sender, address(this), burnAmount);
bFuel.burn(burnAmount);
rewards[msg.sender] = 0;
consumptions[msg.sender] = 0;
(bool success, ) = payable(msg.sender).call{value: reward}("");
require(success, "E: reward transfer error");
emit RewardPaid(msg.sender, reward);
}
}
// total hashrate
function totalHashRate() external view returns (uint256) {
return _totalHashRate;
}
// owner hashrate
function hashRateOf(address _owner) external view returns (uint256) {
return _hashRateOf[_owner];
}
// total consumption
function totalConsumption() external view returns (uint256) {
return _totalConsumption;
}
// owner consumption
function consumptionOf(address _owner) external view returns (uint256) {
return _consumptionOf[_owner];
}
// owner consumption all
function consumptionAllOf(address _owner) external view returns (uint256) {
return _consumptionAllOf[_owner];
}
function minerOwnerOf(address nftAddr, uint256 tokenId) private view returns (address) {
return _minerOwners[nftAddr].get(tokenId, "query for nonexistent token");
}
function minerAmountOf(address nftAddr, address owner) public view returns (uint256) {
require(
owner != address(0),
"Staking: balance query for the zero address"
);
return _holderMiners[nftAddr][owner].length();
}
function minerOfOwnerByIndex(address nftAddr, address owner, uint256 index)
public
view
returns (uint256)
{
return _holderMiners[nftAddr][owner].at(index);
}
function setBFuelAddress(address _addr) external onlyOwner whenNotPaused {
require(_addr != address(0), "address is zero");
bFuel = IBFuel(_addr);
}
function setNFTStatus(address _addr, bool status) external onlyOwner whenNotPaused {
require(_addr != address(0), "address is zero");
minerList[_addr] = status;
}
function setProperty(address _addr) external onlyOwner whenNotPaused {
require(_addr != address(0), "address is zero");
property = INFTProperty(_addr);
}
function setBFuelRate(uint256 rate) external onlyOwner whenNotPaused {
require(rate > 0, "rate is zero");
bFuelRate = rate;
emit SetBFuelRate(rate, msg.sender);
}
function setFuelReceiver(address _address)
external
onlyOwner
whenNotPaused
{
require(_address != address(0), "address is zero");
fuelReceiver = _address;
emit SetFuelReceiver(_address, msg.sender);
}
function setRewardsDuration(uint256 _rewardsDuration) external onlyOwner {
require(
block.timestamp > periodFinish,
"Previous rewards period must be complete before changing the duration for the new period"
);
rewardsDuration = _rewardsDuration;
emit RewardsDurationUpdated(rewardsDuration);
}
function getRewardForDuration() external view returns (uint256) {
return rewardRate.mul(rewardsDuration);
}
function pause() public virtual onlyOwner {
_pause();
emit SetPause(msg.sender);
}
function unpause() public virtual onlyOwner {
_unpause();
emit SetUnPause(msg.sender);
}
// Added to support recovering LP Rewards from other systems such as BAL to be distributed to holders
function recover(address recipient)
external
onlyOwner
{
// Cannot recover the staking token or the rewards token
require(
recipient != address(0),
"E: recipient address can'be 0"
);
uint256 balance = address(this).balance;
(bool success, ) = payable(recipient).call{value: balance}("");
require(success, "E: recover transfer error");
emit Recovered(recipient, balance);
}
/* ========== MODIFIERS ========== */
modifier updateReward(address owner) {
rewardPerHashRateStored = rewardPerToken();
consumptionPerHashRateStored = consumptionPerToken();
lastUpdateTime = lastTimeRewardApplicable();
if (owner != address(0)) {
rewards[owner] = earned(owner);
consumptions[owner] = consumption(owner);
userRewardPerHashRatePaid[owner] = rewardPerHashRateStored;
userConsumptionPerHashRatePaid[
owner
] = consumptionPerHashRateStored;
}
_;
}
// todo periodFinish > 0
modifier checkDeduction() {
if (periodFinish != 0) {
if (block.timestamp > periodFinish) {
deductionCount = deductionCount.add(1);
uint256 nextEpochRewards = FIRST_EPOCH_REWARDS;
for (uint256 i = 1; i <= deductionCount; i++) {
nextEpochRewards = nextEpochRewards.div(2);
}
notifyRewardAmount(nextEpochRewards);
}
}
_;
}
/// uups interface
function _authorizeUpgrade(address newImplementation)
internal
override
view
onlyOwner
{ }
/* ========== EVENTS ========== */
event Start(address user);
event SetPause(address _owner);
event SetUnPause(address _owner);
event RewardAdded(uint256 reward);
event MinerStaked(address indexed user, address indexed nftAddr, uint256 id);
event MinerWithdrawn(address indexed user, address indexed nftAddr, uint256 id);
event RewardPaid(address indexed user, uint256 reward);
event RewardsDurationUpdated(uint256 newDuration);
event Recovered(address token, uint256 amount);
event SetBFuelRate(uint256 rate, address user);
event SetFuelReceiver(address recevier, address user);
}
@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
function __Ownable_init() internal onlyInitializing {
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal onlyInitializing {
_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 anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing 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);
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}
@openzeppelin/contracts-upgradeable/interfaces/draft-IERC1822Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)
pragma solidity ^0.8.0;
/**
* @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822ProxiableUpgradeable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}
@openzeppelin/contracts-upgradeable/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)
pragma solidity ^0.8.2;
import "../beacon/IBeaconUpgradeable.sol";
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import "../utils/Initializable.sol";
/**
* @dev This abstract contract provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
*
* _Available since v4.1._
*
* @custom:oz-upgrades-unsafe-allow delegatecall
*/
abstract contract ERC1967UpgradeUpgradeable is Initializable {
function __ERC1967Upgrade_init() internal onlyInitializing {
}
function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
}
// This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Returns the current implementation address.
*/
function _getImplementation() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Perform implementation upgrade
*
* Emits an {Upgraded} event.
*/
function _upgradeTo(address newImplementation) internal {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
}
/**
* @dev Perform implementation upgrade with additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCall(
address newImplementation,
bytes memory data,
bool forceCall
) internal {
_upgradeTo(newImplementation);
if (data.length > 0 || forceCall) {
_functionDelegateCall(newImplementation, data);
}
}
/**
* @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCallUUPS(
address newImplementation,
bytes memory data,
bool forceCall
) internal {
// Upgrades from old implementations will perform a rollback test. This test requires the new
// implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
// this special case will break upgrade paths from old UUPS implementation to new ones.
if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {
_setImplementation(newImplementation);
} else {
try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {
require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
} catch {
revert("ERC1967Upgrade: new implementation is not UUPS");
}
_upgradeToAndCall(newImplementation, data, forceCall);
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Returns the current admin.
*/
function _getAdmin() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
require(newAdmin != address(0), "ERC1967: new admin is the zero address");
StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {AdminChanged} event.
*/
function _changeAdmin(address newAdmin) internal {
emit AdminChanged(_getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
*/
bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Emitted when the beacon is upgraded.
*/
event BeaconUpgraded(address indexed beacon);
/**
* @dev Returns the current beacon.
*/
function _getBeacon() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the EIP1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
require(
AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
"ERC1967: beacon implementation is not a contract"
);
StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
}
/**
* @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
* not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
*
* Emits a {BeaconUpgraded} event.
*/
function _upgradeBeaconToAndCall(
address newBeacon,
bytes memory data,
bool forceCall
) internal {
_setBeacon(newBeacon);
emit BeaconUpgraded(newBeacon);
if (data.length > 0 || forceCall) {
_functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
}
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {
require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed");
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}
@openzeppelin/contracts-upgradeable/proxy/beacon/IBeaconUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.0;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeaconUpgradeable {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {BeaconProxy} will check that this address is a contract.
*/
function implementation() external view returns (address);
}
@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
* initialization step. This is essential to configure modules that are added through upgrades and that require
* initialization.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*/
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized < type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
}
@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.0;
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import "./Initializable.sol";
/**
* @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
* {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
*
* A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
* reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
* `UUPSUpgradeable` with a custom implementation of upgrades.
*
* The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
*
* _Available since v4.1._
*/
abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {
function __UUPSUpgradeable_init() internal onlyInitializing {
}
function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
}
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
address private immutable __self = address(this);
/**
* @dev Check that the execution is being performed through a delegatecall call and that the execution context is
* a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
* for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
* function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
* fail.
*/
modifier onlyProxy() {
require(address(this) != __self, "Function must be called through delegatecall");
require(_getImplementation() == __self, "Function must be called through active proxy");
_;
}
/**
* @dev Check that the execution is not being performed through a delegate call. This allows a function to be
* callable on the implementing contract but not through proxies.
*/
modifier notDelegated() {
require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall");
_;
}
/**
* @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
* implementation. It is used to validate that the this implementation remains valid after an upgrade.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
*/
function proxiableUUID() external view virtual override notDelegated returns (bytes32) {
return _IMPLEMENTATION_SLOT;
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*/
function upgradeTo(address newImplementation) external virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*/
function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, data, true);
}
/**
* @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeTo} and {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal override onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}
@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
function __Pausable_init() internal onlyInitializing {
__Pausable_init_unchained();
}
function __Pausable_init_unchained() internal onlyInitializing {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}
@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @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 ReentrancyGuardUpgradeable is Initializable {
// 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;
function __ReentrancyGuard_init() internal onlyInitializing {
__ReentrancyGuard_init_unchained();
}
function __ReentrancyGuard_init_unchained() internal onlyInitializing {
_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() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}
@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20Upgradeable {
/**
* @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);
}
@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721ReceiverUpgradeable {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165Upgradeable.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721Upgradeable is IERC165Upgradeable {
/**
* @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: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* 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);
}
@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/utils/ERC721Holder.sol)
pragma solidity ^0.8.0;
import "../IERC721ReceiverUpgradeable.sol";
import "../../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the {IERC721Receiver} interface.
*
* Accepts all token transfers.
* Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}.
*/
contract ERC721HolderUpgradeable is Initializable, IERC721ReceiverUpgradeable {
function __ERC721Holder_init() internal onlyInitializing {
}
function __ERC721Holder_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC721Receiver-onERC721Received}.
*
* Always returns `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address,
address,
uint256,
bytes memory
) public virtual override returns (bytes4) {
return this.onERC721Received.selector;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}
@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @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 ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}
@openzeppelin/contracts-upgradeable/utils/StorageSlotUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)
pragma solidity ^0.8.0;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC1967 implementation slot:
* ```
* contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
*/
library StorageSlotUpgradeable {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
}
@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol
// 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 IERC165Upgradeable {
/**
* @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);
}
@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library MathUpgradeable {
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) {
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1);
///////////////////////////////////////////////
// 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. It 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)`.
// We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`.
// This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`.
// Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a
// good first aproximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1;
uint256 x = a;
if (x >> 128 > 0) {
x >>= 128;
result <<= 64;
}
if (x >> 64 > 0) {
x >>= 64;
result <<= 32;
}
if (x >> 32 > 0) {
x >>= 32;
result <<= 16;
}
if (x >> 16 > 0) {
x >>= 16;
result <<= 8;
}
if (x >> 8 > 0) {
x >>= 8;
result <<= 4;
}
if (x >> 4 > 0) {
x >>= 4;
result <<= 2;
}
if (x >> 2 > 0) {
result <<= 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) {
uint256 result = sqrt(a);
if (rounding == Rounding.Up && result * result < a) {
result += 1;
}
return result;
}
}
@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/
library SafeMathUpgradeable {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
@openzeppelin/contracts-upgradeable/utils/structs/EnumerableMapUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableMap.sol)
pragma solidity ^0.8.0;
import "./EnumerableSetUpgradeable.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.
*
* ```
* 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` (`Bytes32ToBytes32`) 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 EnumerableMapUpgradeable {
using EnumerableSetUpgradeable for EnumerableSetUpgradeable.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
EnumerableSetUpgradeable.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;
}
// 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 set. 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 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(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));
}
// 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 set. 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 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(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.
*
* _Available since v3.4._
*/
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))));
}
// 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 set. 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 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(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));
}
// 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 set. 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 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(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));
}
}
@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)
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.
*
* ```
* 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 EnumerableSetUpgradeable {
// 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) {
return _values(set._inner);
}
// 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 on 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;
}
}
@openzeppelin/contracts/interfaces/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol)
pragma solidity ^0.8.0;
import "../token/ERC20/IERC20.sol";
@openzeppelin/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.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);
}
contracts/interface/IBFuel.sol
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.1.0
// Creator: Chiru Labs
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/interfaces/IERC20.sol";
interface IBFuel is IERC20 {
function burn(uint256 amount) external returns (bool);
}
contracts/interface/INFTProperty.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.6;
interface INFTProperty {
function addProperty(address nftAddr, uint256 id, uint256[] calldata properties) external;
function removeProperty(address nftAddr, uint256 id) external;
function getHashRate(address nftAddr, uint256 id) external view returns (uint256 hashRate);
function getConsumption(address nftAddr, uint256 id)
external
view
returns (uint256 consumption);
function getCreateTime(address nftAddr, uint256 id) external view returns (uint256 time);
}
Compiler Settings
{"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers"]}},"optimizer":{"runs":200,"enabled":true},"libraries":{}}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[]},{"type":"event","name":"AdminChanged","inputs":[{"type":"address","name":"previousAdmin","internalType":"address","indexed":false},{"type":"address","name":"newAdmin","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"BeaconUpgraded","inputs":[{"type":"address","name":"beacon","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Initialized","inputs":[{"type":"uint8","name":"version","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"event","name":"MinerStaked","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"address","name":"nftAddr","internalType":"address","indexed":true},{"type":"uint256","name":"id","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"MinerWithdrawn","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"address","name":"nftAddr","internalType":"address","indexed":true},{"type":"uint256","name":"id","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Paused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Recovered","inputs":[{"type":"address","name":"token","internalType":"address","indexed":false},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RewardAdded","inputs":[{"type":"uint256","name":"reward","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RewardPaid","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"uint256","name":"reward","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RewardsDurationUpdated","inputs":[{"type":"uint256","name":"newDuration","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"SetBFuelRate","inputs":[{"type":"uint256","name":"rate","internalType":"uint256","indexed":false},{"type":"address","name":"user","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"SetFuelReceiver","inputs":[{"type":"address","name":"recevier","internalType":"address","indexed":false},{"type":"address","name":"user","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"SetPause","inputs":[{"type":"address","name":"_owner","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"SetUnPause","inputs":[{"type":"address","name":"_owner","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Start","inputs":[{"type":"address","name":"user","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Unpaused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Upgraded","inputs":[{"type":"address","name":"implementation","internalType":"address","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"BASE_DIVIDER","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"FIRST_EPOCH_REWARDS","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IERC721Upgradeable"}],"name":"NFTMiner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IBFuel"}],"name":"bFuel","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"bFuelRate","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"batchStake","inputs":[{"type":"address[]","name":"nftAddrs","internalType":"address[]"},{"type":"uint256[]","name":"minerIds","internalType":"uint256[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"batchWithdrawMiners","inputs":[{"type":"address[]","name":"nftAddrs","internalType":"address[]"},{"type":"uint256[]","name":"minerIds","internalType":"uint256[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"consumption","inputs":[{"type":"address","name":"_owner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"consumptionAllOf","inputs":[{"type":"address","name":"_owner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"consumptionOf","inputs":[{"type":"address","name":"_owner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"consumptionPerHashRateStored","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"consumptionPerToken","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"consumptionRate","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"consumptions","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"deductionCount","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"earned","inputs":[{"type":"address","name":"_owner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"fuelReceiver","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"getReward","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getRewardForDuration","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"hashRateOf","inputs":[{"type":"address","name":"_owner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_bFuelToken","internalType":"address"},{"type":"address","name":"_property","internalType":"address"},{"type":"uint256","name":"_rewardsDuration","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"lastTimeRewardApplicable","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"lastUpdateTime","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"minerAmountOf","inputs":[{"type":"address","name":"nftAddr","internalType":"address"},{"type":"address","name":"owner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"minerList","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"minerOfOwnerByIndex","inputs":[{"type":"address","name":"nftAddr","internalType":"address"},{"type":"address","name":"owner","internalType":"address"},{"type":"uint256","name":"index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"staker","internalType":"address"},{"type":"address","name":"nftAddr","internalType":"address"},{"type":"uint256","name":"minerId","internalType":"uint256"},{"type":"uint256","name":"hashRate","internalType":"uint256"},{"type":"uint256","name":"consumption","internalType":"uint256"},{"type":"uint256","name":"lastUpdateTime","internalType":"uint256"}],"name":"nftStakes","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bytes4","name":"","internalType":"bytes4"}],"name":"onERC721Received","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"bytes","name":"","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"pause","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"paused","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"periodFinish","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract INFTProperty"}],"name":"property","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"proxiableUUID","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"recover","inputs":[{"type":"address","name":"recipient","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rewardPerHashRateStored","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rewardPerToken","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rewardRate","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rewards","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"rewardsDuration","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setBFuelAddress","inputs":[{"type":"address","name":"_addr","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setBFuelRate","inputs":[{"type":"uint256","name":"rate","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setFuelReceiver","inputs":[{"type":"address","name":"_address","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setNFTStatus","inputs":[{"type":"address","name":"_addr","internalType":"address"},{"type":"bool","name":"status","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setProperty","inputs":[{"type":"address","name":"_addr","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setRewardsDuration","inputs":[{"type":"uint256","name":"_rewardsDuration","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"stake","inputs":[{"type":"address","name":"nftAddr","internalType":"address"},{"type":"uint256","name":"minerId","internalType":"uint256"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"start","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalConsumption","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalHashRate","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unpause","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"upgradeTo","inputs":[{"type":"address","name":"newImplementation","internalType":"address"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"upgradeToAndCall","inputs":[{"type":"address","name":"newImplementation","internalType":"address"},{"type":"bytes","name":"data","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"userConsumptionPerHashRatePaid","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"userRewardPerHashRatePaid","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawAllMiners","inputs":[{"type":"address","name":"nftAddr","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawMiner","inputs":[{"type":"address","name":"nftAddr","internalType":"address"},{"type":"uint256","name":"minerId","internalType":"uint256"}]},{"type":"receive","stateMutability":"payable"}]
Contract Creation Code
0x60a06040523060601b6080523480156200001857600080fd5b506200002362000029565b620000eb565b600054610100900460ff1615620000965760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff9081161015620000e9576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b60805160601c61391b620001266000396000818161111201528181611152015281816117b1015281816117f10152611884015261391b6000f3fe60806040526004361061038f5760003560e01c80636cf7f80e116101dc578063bb40501911610102578063cd3daf9d116100a0578063e671b61a1161006f578063e671b61a14610af8578063ebe2b12b14610b0f578063ee1f188414610b26578063f2fde38b14610b4657600080fd5b8063cd3daf9d14610a68578063d9d11b4d14610a7d578063da3b6b3514610aab578063e30d80da14610ac157600080fd5b8063c722f719116100dc578063c722f719146109fb578063c8f33c9114610a1b578063c9f9cc5214610a32578063cc1a378f14610a4857600080fd5b8063bb405019146109b3578063be36c1c1146109d3578063be9a6555146109f357600080fd5b80638456cb591161017a578063a8cb026d11610149578063a8cb026d14610937578063a9a5a51d14610965578063ac294d8e1461097c578063adc9772e1461099357600080fd5b80638456cb59146108b65780638557b84a146108cb5780638da5cb5b1461090257806397a6a62b1461092057600080fd5b8063760ff3c9116101b6578063760ff3c9146108335780637b0a47ee1461086a57806380faa57d1461088157806382d7db3c1461089657600080fd5b80636cf7f80e146107de578063715018a6146107fe57806374fcbd411461081357600080fd5b806331d1b220116102c1578063400f92111161025f57806352d1902d1161022e57806352d1902d146106f05780635c975abb14610705578063633f71551461071d5780636b950e641461073d57600080fd5b8063400f92111461065b57806341671ca11461067b5780634f1ef286146106bc5780635242d76d146106cf57600080fd5b8063386a95251161029b578063386a9525146105f95780633d18b912146106105780633d8c2d20146106255780633f4ba83a1461064657600080fd5b806331d1b220146105a257806332b95a6f146105b95780633659cfe6146105d957600080fd5b8063150b7a021161032e5780631c1f78eb116103085780631c1f78eb1461052a5780631e492f511461053f5780631fff315d1461056d57806320c18f301461058d57600080fd5b8063150b7a02146104a5578063176fd3f0146104e95780631794bb3c1461050a57600080fd5b80630cd865ec1161036a5780630cd865ec14610413578063139656cb14610435578063144441b41461044c57806314e44a9d1461046c57600080fd5b80628cc2621461039b57806305c1fec4146103ce5780630700037d146103e557600080fd5b3661039657005b600080fd5b3480156103a757600080fd5b506103bb6103b636600461336f565b610b66565b6040519081526020015b60405180910390f35b3480156103da57600080fd5b506103bb6101715481565b3480156103f157600080fd5b506103bb61040036600461336f565b6101726020526000908152604090205481565b34801561041f57600080fd5b5061043361042e36600461336f565b610be7565b005b34801561044157600080fd5b506103bb6101705481565b34801561045857600080fd5b5061043361046736600461336f565b610d34565b34801561047857600080fd5b506101665461048d906001600160a01b031681565b6040516001600160a01b0390911681526020016103c5565b3480156104b157600080fd5b506104d06104c03660046133f9565b630a85bd0160e11b949350505050565b6040516001600160e01b031990911681526020016103c5565b3480156104f557600080fd5b506101615461048d906001600160a01b031681565b34801561051657600080fd5b506104336105253660046133bd565b610dc5565b34801561053657600080fd5b506103bb610f9a565b34801561054b57600080fd5b506103bb61055a36600461336f565b6101786020526000908152604090205481565b34801561057957600080fd5b506103bb61058836600461338a565b610fba565b34801561059957600080fd5b506103bb61105c565b3480156105ae57600080fd5b506103bb61016c5481565b3480156105c557600080fd5b506104336105d4366004613510565b61109b565b3480156105e557600080fd5b506104336105f436600461336f565b611107565b34801561060557600080fd5b506103bb61016d5481565b34801561061c57600080fd5b506104336111e7565b34801561063157600080fd5b506101625461048d906001600160a01b031681565b34801561065257600080fd5b506104336116fe565b34801561066757600080fd5b50610433610676366004613461565b611744565b34801561068757600080fd5b506106ac61069636600461336f565b6101606020526000908152604090205460ff1681565b60405190151581526020016103c5565b6104336106ca366004613498565b6117a6565b3480156106db57600080fd5b506101635461048d906001600160a01b031681565b3480156106fc57600080fd5b506103bb611877565b34801561071157600080fd5b5060975460ff166106ac565b34801561072957600080fd5b506103bb61073836600461336f565b61192a565b34801561074957600080fd5b506107a66107583660046134e6565b6101736020908152600092835260408084209091529082529020805460018201546002830154600384015460048501546005909501546001600160a01b039485169593909416939192909186565b604080516001600160a01b039788168152969095166020870152938501929092526060840152608083015260a082015260c0016103c5565b3480156107ea57600080fd5b506104336107f936600461336f565b611985565b34801561080a57600080fd5b506104336119de565b34801561081f57600080fd5b5061043361082e36600461336f565b6119f2565b34801561083f57600080fd5b506103bb61084e36600461336f565b6001600160a01b03166000908152610175602052604090205490565b34801561087657600080fd5b506103bb6101695481565b34801561088d57600080fd5b506103bb611a4b565b3480156108a257600080fd5b506104336108b13660046134e6565b611a5a565b3480156108c257600080fd5b50610433611e83565b3480156108d757600080fd5b506103bb6108e636600461336f565b6001600160a01b03166000908152610176602052604090205490565b34801561090e57600080fd5b506065546001600160a01b031661048d565b34801561092c57600080fd5b506103bb6101685481565b34801561094357600080fd5b506103bb61095236600461336f565b6101746020526000908152604090205481565b34801561097157600080fd5b506103bb61016f5481565b34801561098857600080fd5b506103bb61016e5481565b34801561099f57600080fd5b506104336109ae3660046134e6565b611ec3565b3480156109bf57600080fd5b506104336109ce3660046135b2565b612422565b3480156109df57600080fd5b506104336109ee366004613510565b6124ac565b610433612511565b348015610a0757600080fd5b50610433610a1636600461336f565b612555565b348015610a2757600080fd5b506103bb6101675481565b348015610a3e57600080fd5b50610165546103bb565b348015610a5457600080fd5b50610433610a633660046135b2565b612595565b348015610a7457600080fd5b506103bb612671565b348015610a8957600080fd5b506103bb610a9836600461336f565b6101796020526000908152604090205481565b348015610ab757600080fd5b50610164546103bb565b348015610acd57600080fd5b506103bb610adc36600461336f565b6001600160a01b03166000908152610177602052604090205490565b348015610b0457600080fd5b506103bb61016a5481565b348015610b1b57600080fd5b506103bb61016b5481565b348015610b3257600080fd5b506103bb610b413660046133bd565b6126bd565b348015610b5257600080fd5b50610433610b6136600461336f565b6126f7565b6001600160a01b03811660009081526101726020908152604080832054610178909252822054610be19190610bdb90670de0b6b3a764000090610bd590610bb590610baf612671565b9061276d565b6001600160a01b0388166000908152610175602052604090205490612779565b90612785565b90612791565b92915050565b610bef61279d565b6001600160a01b038116610c4a5760405162461bcd60e51b815260206004820152601d60248201527f453a20726563697069656e7420616464726573732063616e276265203000000060448201526064015b60405180910390fd5b60405147906000906001600160a01b0384169083908381818185875af1925050503d8060008114610c97576040519150601f19603f3d011682016040523d82523d6000602084013e610c9c565b606091505b5050905080610ced5760405162461bcd60e51b815260206004820152601960248201527f453a207265636f766572207472616e73666572206572726f72000000000000006044820152606401610c41565b604080516001600160a01b0385168152602081018490527f8c1256b8896378cd5044f80c202f9772b9d77dc85c8a6eb51967210b09bfaa28910160405180910390a1505050565b610d3c61279d565b610d446127f7565b6001600160a01b038116610d6a5760405162461bcd60e51b8152600401610c41906136d6565b61016680546001600160a01b0319166001600160a01b038316908117909155604080519182523360208301527f725540d4066d55e571d1f3a39840626c921529b8df65b93b870c24df49e57eaa91015b60405180910390a150565b600054610100900460ff1615808015610de55750600054600160ff909116105b80610dff5750303b158015610dff575060005460ff166001145b610e625760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610c41565b6000805460ff191660011790558015610e85576000805461ff0019166101001790555b610e8d61283d565b610e95612864565b610e9d612893565b610ea56128c2565b610ead61283d565b81610efa5760405162461bcd60e51b815260206004820152601760248201527f726577617264734475726174696f6e206973207a65726f0000000000000000006044820152606401610c41565b61016280546001600160a01b038087166001600160a01b03199283161790925561016180549286169290911691909117905561016d8290556032610168556064610170556a08b200a96f8d058a000000610171558015610f94576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b6000610fb561016d546101695461277990919063ffffffff16565b905090565b60006001600160a01b0382166110265760405162461bcd60e51b815260206004820152602b60248201527f5374616b696e673a2062616c616e636520717565727920666f7220746865207a60448201526a65726f206164647265737360a81b6064820152608401610c41565b6001600160a01b03808416600090815261017a60209081526040808320938616835292905220611055906128f1565b9392505050565b60006101645460001415611072575061016f5490565b610fb561109161016a5461108b61016754610baf611a4b565b90612779565b61016f5490612791565b60005b81811015611100576110ee8585838181106110bb576110bb613864565b90506020020160208101906110d0919061336f565b8484848181106110e2576110e2613864565b90506020020135611ec3565b806110f88161381d565b91505061109e565b5050505050565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614156111505760405162461bcd60e51b8152600401610c419061363e565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661119960008051602061389f833981519152546001600160a01b031690565b6001600160a01b0316146111bf5760405162461bcd60e51b8152600401610c419061368a565b6111c8816128fb565b604080516000808252602082019092526111e491839190612903565b50565b6002600154141561120a5760405162461bcd60e51b8152600401610c419061374a565b600260015533611218612671565b61016e5561122461105c565b61016f55611230611a4b565b610167556001600160a01b038116156112ab5761124c81610b66565b6001600160a01b0382166000908152610172602052604090205561126f8161192a565b6001600160a01b0382166000908152610174602090815260408083209390935561016e5461017882528383205561016f54610179909152919020555b61016b541561130e5761016b5442111561130e5761016c546112ce906001612791565b61016c556101715460015b61016c548111611302576112ee826002612785565b9150806112fa8161381d565b9150506112d9565b5061130c81612a7d565b505b3360008181526101726020908152604080832054610174909252808320546101625491516370a0823160e01b8152600481019590955291939192916001600160a01b03909116906370a082319060240160206040518083038186803b15801561137657600080fd5b505afa15801561138a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113ae9190613599565b9050818110156114005760405162461bcd60e51b815260206004820152601a60248201527f5a5761747420496e73756666696369656e742062616c616e63650000000000006044820152606401610c41565b336000908152610177602052604090205461141b9083612791565b33600090815261017760205260409020556101655461143a9083612791565b6101655582156116f457600061146361017054610bd5610168548661277990919063ffffffff16565b61016254610166549192506001600160a01b03908116916323b872dd9133911661148d878661276d565b6040518463ffffffff1660e01b81526004016114ab939291906135e7565b602060405180830381600087803b1580156114c557600080fd5b505af11580156114d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114fd919061357c565b50610162546040516323b872dd60e01b81526001600160a01b03909116906323b872dd90611533903390309086906004016135e7565b602060405180830381600087803b15801561154d57600080fd5b505af1158015611561573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611585919061357c565b5061016254604051630852cd8d60e31b8152600481018390526001600160a01b03909116906342966c6890602401602060405180830381600087803b1580156115cd57600080fd5b505af11580156115e1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611605919061357c565b50336000818152610172602090815260408083208390556101749091528082208290555190919086908381818185875af1925050503d8060008114611666576040519150601f19603f3d011682016040523d82523d6000602084013e61166b565b606091505b50509050806116bc5760405162461bcd60e51b815260206004820152601860248201527f453a20726577617264207472616e73666572206572726f7200000000000000006044820152606401610c41565b60405185815233907fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e04869060200160405180910390a250505b5050600180555050565b61170661279d565b61170e612beb565b6040513381527f9f0682ebfbd7a5387c2fd5dce8c4a5022b7f8a7090392ac53f6416c63efa9c67906020015b60405180910390a1565b61174c61279d565b6117546127f7565b6001600160a01b03821661177a5760405162461bcd60e51b8152600401610c41906136d6565b6001600160a01b0391909116600090815261016060205260409020805460ff1916911515919091179055565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614156117ef5760405162461bcd60e51b8152600401610c419061363e565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661183860008051602061389f833981519152546001600160a01b031690565b6001600160a01b03161461185e5760405162461bcd60e51b8152600401610c419061368a565b611867826128fb565b61187382826001612903565b5050565b6000306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146119175760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610c41565b5060008051602061389f83398151915290565b6001600160a01b03811660009081526101746020908152604080832054610179909252822054610be19190610bdb9061196590610baf61105c565b6001600160a01b0386166000908152610176602052604090205490612779565b61198d61279d565b6119956127f7565b6001600160a01b0381166119bb5760405162461bcd60e51b8152600401610c41906136d6565b61016280546001600160a01b0319166001600160a01b0392909216919091179055565b6119e661279d565b6119f06000612c38565b565b6119fa61279d565b611a026127f7565b6001600160a01b038116611a285760405162461bcd60e51b8152600401610c41906136d6565b61016180546001600160a01b0319166001600160a01b0392909216919091179055565b6000610fb54261016b54612c8a565b33611a63612671565b61016e55611a6f61105c565b61016f55611a7b611a4b565b610167556001600160a01b03811615611af657611a9781610b66565b6001600160a01b03821660009081526101726020526040902055611aba8161192a565b6001600160a01b0382166000908152610174602090815260408083209390935561016e5461017882528383205561016f54610179909152919020555b6001600160a01b03831660009081526101606020526040902054839060ff161515600114611b5e5760405162461bcd60e51b8152602060048201526015602482015274114e881b5a5b995c881a5cc81b9bdd081d985b1a59605a1b6044820152606401610c41565b61016b5415611bc15761016b54421115611bc15761016c54611b81906001612791565b61016c556101715460015b61016c548111611bb557611ba1826002612785565b915080611bad8161381d565b915050611b8c565b50611bbf81612a7d565b505b60026001541415611be45760405162461bcd60e51b8152600401610c419061374a565b600260015533611bf48585612ca0565b6001600160a01b031614611c545760405162461bcd60e51b815260206004820152602160248201527f7769746864726177206f6620746f6b656e2074686174206973206e6f74206f776044820152603760f91b6064820152608401610c41565b6001600160a01b03808516600090815261017360209081526040808320878452825291829020825160c0810184528154851681526001820154909416918401919091526002810154918301919091526003810154606083018190526004820154608084015260059091015460a083015261016454611cd19161276d565b6101645560608101513360009081526101756020526040902054611cf49161276d565b3360009081526101756020908152604080832093909355608084015161017690915291902054611d239161276d565b33600081815261017660209081526040808320949094556001600160a01b038916825261017a81528382209282529190915220611d609085612cfa565b506001600160a01b038516600090815261015f60205260408120611d85918690612d06565b506001600160a01b03851660008181526101736020908152604080832088845290915280822080546001600160a01b0319908116825560018201805490911690556002810183905560038101839055600480820184905560059091019290925551632142170760e11b81526342842e0e91611e0691309133918a91016135e7565b600060405180830381600087803b158015611e2057600080fd5b505af1158015611e34573d6000803e3d6000fd5b50506040518681526001600160a01b03881692503391507f948747f71e0c7df022c400908551bb18008e76b080a45255da5d373bca5823e69060200160405180910390a3505060018055505050565b611e8b61279d565b611e93612d1c565b6040513381527fcefccc61a219f93791fb6e4db09576ac77dc4e7edf2a73b47634321897eee98a9060200161173a565b611ecb6127f7565b6001600160a01b03821660009081526101606020526040902054829060ff161515600114611f335760405162461bcd60e51b8152602060048201526015602482015274114e881b5a5b995c881a5cc81b9bdd081d985b1a59605a1b6044820152606401610c41565b33611f3c612671565b61016e55611f4861105c565b61016f55611f54611a4b565b610167556001600160a01b03811615611fcf57611f7081610b66565b6001600160a01b03821660009081526101726020526040902055611f938161192a565b6001600160a01b0382166000908152610174602090815260408083209390935561016e5461017882528383205561016f54610179909152919020555b60026001541415611ff25760405162461bcd60e51b8152600401610c419061374a565b60026001556101615460405163a38b54a960e01b81526001600160a01b03868116600483015260248201869052600092169063a38b54a99060440160206040518083038186803b15801561204557600080fd5b505afa158015612059573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061207d9190613599565b9050806120c45760405162461bcd60e51b815260206004820152601560248201527414dd185ada5b99ce881259081b9bdd08195e1a5cdd605a1b6044820152606401610c41565b6101615460405163d1e118c560e01b81526001600160a01b03878116600483015260248201879052600092169063d1e118c59060440160206040518083038186803b15801561211257600080fd5b505afa158015612126573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061214a9190613599565b9050806121915760405162461bcd60e51b815260206004820152601560248201527414dd185ada5b99ce881259081b9bdd08195e1a5cdd605a1b6044820152606401610c41565b604051632142170760e11b81526001600160a01b038716906342842e0e906121c190339030908a906004016135e7565b600060405180830381600087803b1580156121db57600080fd5b505af11580156121ef573d6000803e3d6000fd5b505050506040518060c00160405280336001600160a01b03168152602001876001600160a01b03168152602001868152602001838152602001828152602001428152506101736000886001600160a01b03166001600160a01b03168152602001908152602001600020600087815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060408201518160020155606082015181600301556080820151816004015560a082015181600501559050506123498561017a6000896001600160a01b03166001600160a01b031681526020019081526020016000206000336001600160a01b03166001600160a01b03168152602001908152602001600020612d5990919063ffffffff16565b506001600160a01b038616600090815261015f6020526040902061236e908633612d06565b506101645461237d9083612791565b61016455336000908152610175602052604090205461239c9083612791565b3360009081526101756020908152604080832093909355610176905220546123c49082612791565b336000818152610176602090815260409182902093909355518781526001600160a01b038916927ff39659f2ff90ba8a58bd5ee61a35788fcab5766770b69e851a764d220db98e0d910160405180910390a350506001805550505050565b61242a61279d565b6124326127f7565b600081116124715760405162461bcd60e51b815260206004820152600c60248201526b72617465206973207a65726f60a01b6044820152606401610c41565b610168819055604080518281523360208201527fced933e7b0edc2a2e41e6be78c54b8ae9d95e86592ebb76c357bb89df0d261719101610dba565b60005b81811015611100576124ff8585838181106124cc576124cc613864565b90506020020160208101906124e1919061336f565b8484848181106124f3576124f3613864565b90506020020135611a5a565b806125098161381d565b9150506124af565b61251961279d565b61252561017154612a7d565b6040513381527f84d0447ca38875fa61115673259a210915bc1dd53a3c112d6f0790f15956a9659060200161173a565b60006125618233610fba565b905060005b818110156125905761257e836108b1853360006126bd565b806125888161381d565b915050612566565b505050565b61259d61279d565b61016b54421161263b5760405162461bcd60e51b815260206004820152605860248201527f50726576696f7573207265776172647320706572696f64206d7573742062652060448201527f636f6d706c657465206265666f7265206368616e67696e67207468652064757260648201527f6174696f6e20666f7220746865206e657720706572696f640000000000000000608482015260a401610c41565b61016d8190556040518181527ffb46ca5a5e06d4540d6387b930a7c978bce0db5f449ec6b3f5d07c6e1d44f2d390602001610dba565b60006101645460001415612687575061016e5490565b610fb56126b361016454610bd5670de0b6b3a764000061108b6101695461108b61016754610baf611a4b565b61016e5490612791565b6001600160a01b03808416600090815261017a6020908152604080832093861683529290529081206126ef9083612d65565b949350505050565b6126ff61279d565b6001600160a01b0381166127645760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610c41565b6111e481612c38565b600061105582846137da565b600061105582846137bb565b60006110558284613799565b60006110558284613781565b6065546001600160a01b031633146119f05760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c41565b60975460ff16156119f05760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610c41565b600054610100900460ff166119f05760405162461bcd60e51b8152600401610c41906136ff565b600054610100900460ff1661288b5760405162461bcd60e51b8152600401610c41906136ff565b6119f0612d71565b600054610100900460ff166128ba5760405162461bcd60e51b8152600401610c41906136ff565b6119f0612d9e565b600054610100900460ff166128e95760405162461bcd60e51b8152600401610c41906136ff565b6119f0612dd1565b6000610be1825490565b6111e461279d565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156129365761259083612e01565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561296f57600080fd5b505afa92505050801561299f575060408051601f3d908101601f1916820190925261299c91810190613599565b60015b612a025760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608401610c41565b60008051602061389f8339815191528114612a715760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401610c41565b50612590838383612e9d565b6000612a87612671565b61016e55612a9361105c565b61016f55612a9f611a4b565b610167556001600160a01b03811615612b1a57612abb81610b66565b6001600160a01b03821660009081526101726020526040902055612ade8161192a565b6001600160a01b0382166000908152610174602090815260408083209390935561016e5461017882528383205561016f54610179909152919020555b612b2e670de0b6b3a7640000610e10612785565b61016a5561016b544210612b545761016d54612b4b908390612785565b61016955612b9b565b61016b54600090612b65904261276d565b90506000612b7f610169548361277990919063ffffffff16565b61016d54909150612b9490610bd58684612791565b6101695550505b4261016781905561016d54612bb09190612791565b61016b556040518281527fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9060200160405180910390a15050565b612bf3612ec2565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200161173a565b606580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000818310612c995781611055565b5090919050565b604080518082018252601b81527f717565727920666f72206e6f6e6578697374656e7420746f6b656e00000000006020808301919091526001600160a01b038516600090815261015f909152918220611055918490612f0b565b60006110558383612f18565b60006126ef84846001600160a01b03851661300b565b612d246127f7565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612c203390565b60006110558383613028565b60006110558383613077565b600054610100900460ff16612d985760405162461bcd60e51b8152600401610c41906136ff565b60018055565b600054610100900460ff16612dc55760405162461bcd60e51b8152600401610c41906136ff565b6097805460ff19169055565b600054610100900460ff16612df85760405162461bcd60e51b8152600401610c41906136ff565b6119f033612c38565b6001600160a01b0381163b612e6e5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610c41565b60008051602061389f83398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b612ea6836130a1565b600082511180612eb35750805b1561259057610f9483836130e1565b60975460ff166119f05760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610c41565b60006126ef8484846131d5565b60008181526001830160205260408120548015613001576000612f3c6001836137da565b8554909150600090612f50906001906137da565b9050818114612fb5576000866000018281548110612f7057612f70613864565b9060005260206000200154905080876000018481548110612f9357612f93613864565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612fc657612fc661384e565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610be1565b6000915050610be1565b600082815260028401602052604081208290556126ef8484612d59565b600081815260018301602052604081205461306f57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610be1565b506000610be1565b600082600001828154811061308e5761308e613864565b9060005260206000200154905092915050565b6130aa81612e01565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b6131495760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610c41565b600080846001600160a01b03168460405161316491906135cb565b600060405180830381855af49150503d806000811461319f576040519150601f19603f3d011682016040523d82523d6000602084013e6131a4565b606091505b50915091506131cc82826040518060600160405280602781526020016138bf60279139613221565b95945050505050565b6000828152600284016020526040812054801515806131f957506131f9858561325a565b83906132185760405162461bcd60e51b8152600401610c41919061360b565b50949350505050565b60608315613230575081611055565b8251156132405782518084602001fd5b8160405162461bcd60e51b8152600401610c41919061360b565b600081815260018301602052604081205461105590849084908490151584565b80356001600160a01b038116811461329157600080fd5b919050565b60008083601f8401126132a857600080fd5b50813567ffffffffffffffff8111156132c057600080fd5b6020830191508360208260051b85010111156132db57600080fd5b9250929050565b600082601f8301126132f357600080fd5b813567ffffffffffffffff8082111561330e5761330e61387a565b604051601f8301601f19908116603f011681019082821181831017156133365761333661387a565b8160405283815286602085880101111561334f57600080fd5b836020870160208301376000602085830101528094505050505092915050565b60006020828403121561338157600080fd5b6110558261327a565b6000806040838503121561339d57600080fd5b6133a68361327a565b91506133b46020840161327a565b90509250929050565b6000806000606084860312156133d257600080fd5b6133db8461327a565b92506133e96020850161327a565b9150604084013590509250925092565b6000806000806080858703121561340f57600080fd5b6134188561327a565b93506134266020860161327a565b925060408501359150606085013567ffffffffffffffff81111561344957600080fd5b613455878288016132e2565b91505092959194509250565b6000806040838503121561347457600080fd5b61347d8361327a565b9150602083013561348d81613890565b809150509250929050565b600080604083850312156134ab57600080fd5b6134b48361327a565b9150602083013567ffffffffffffffff8111156134d057600080fd5b6134dc858286016132e2565b9150509250929050565b600080604083850312156134f957600080fd5b6135028361327a565b946020939093013593505050565b6000806000806040858703121561352657600080fd5b843567ffffffffffffffff8082111561353e57600080fd5b61354a88838901613296565b9096509450602087013591508082111561356357600080fd5b5061357087828801613296565b95989497509550505050565b60006020828403121561358e57600080fd5b815161105581613890565b6000602082840312156135ab57600080fd5b5051919050565b6000602082840312156135c457600080fd5b5035919050565b600082516135dd8184602087016137f1565b9190910192915050565b6001600160a01b039384168152919092166020820152604081019190915260600190565b602081526000825180602084015261362a8160408501602087016137f1565b601f01601f19169190910160400192915050565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b6020808252600f908201526e61646472657373206973207a65726f60881b604082015260600190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6000821982111561379457613794613838565b500190565b6000826137b657634e487b7160e01b600052601260045260246000fd5b500490565b60008160001904831182151516156137d5576137d5613838565b500290565b6000828210156137ec576137ec613838565b500390565b60005b8381101561380c5781810151838201526020016137f4565b83811115610f945750506000910152565b600060001982141561383157613831613838565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b80151581146111e457600080fdfe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a9056b7f42bab9fc65e4ebe1d8e440b7f65fdd1a57780ebc3c031b40dd9079a464736f6c63430008060033
Deployed ByteCode
0x60806040526004361061038f5760003560e01c80636cf7f80e116101dc578063bb40501911610102578063cd3daf9d116100a0578063e671b61a1161006f578063e671b61a14610af8578063ebe2b12b14610b0f578063ee1f188414610b26578063f2fde38b14610b4657600080fd5b8063cd3daf9d14610a68578063d9d11b4d14610a7d578063da3b6b3514610aab578063e30d80da14610ac157600080fd5b8063c722f719116100dc578063c722f719146109fb578063c8f33c9114610a1b578063c9f9cc5214610a32578063cc1a378f14610a4857600080fd5b8063bb405019146109b3578063be36c1c1146109d3578063be9a6555146109f357600080fd5b80638456cb591161017a578063a8cb026d11610149578063a8cb026d14610937578063a9a5a51d14610965578063ac294d8e1461097c578063adc9772e1461099357600080fd5b80638456cb59146108b65780638557b84a146108cb5780638da5cb5b1461090257806397a6a62b1461092057600080fd5b8063760ff3c9116101b6578063760ff3c9146108335780637b0a47ee1461086a57806380faa57d1461088157806382d7db3c1461089657600080fd5b80636cf7f80e146107de578063715018a6146107fe57806374fcbd411461081357600080fd5b806331d1b220116102c1578063400f92111161025f57806352d1902d1161022e57806352d1902d146106f05780635c975abb14610705578063633f71551461071d5780636b950e641461073d57600080fd5b8063400f92111461065b57806341671ca11461067b5780634f1ef286146106bc5780635242d76d146106cf57600080fd5b8063386a95251161029b578063386a9525146105f95780633d18b912146106105780633d8c2d20146106255780633f4ba83a1461064657600080fd5b806331d1b220146105a257806332b95a6f146105b95780633659cfe6146105d957600080fd5b8063150b7a021161032e5780631c1f78eb116103085780631c1f78eb1461052a5780631e492f511461053f5780631fff315d1461056d57806320c18f301461058d57600080fd5b8063150b7a02146104a5578063176fd3f0146104e95780631794bb3c1461050a57600080fd5b80630cd865ec1161036a5780630cd865ec14610413578063139656cb14610435578063144441b41461044c57806314e44a9d1461046c57600080fd5b80628cc2621461039b57806305c1fec4146103ce5780630700037d146103e557600080fd5b3661039657005b600080fd5b3480156103a757600080fd5b506103bb6103b636600461336f565b610b66565b6040519081526020015b60405180910390f35b3480156103da57600080fd5b506103bb6101715481565b3480156103f157600080fd5b506103bb61040036600461336f565b6101726020526000908152604090205481565b34801561041f57600080fd5b5061043361042e36600461336f565b610be7565b005b34801561044157600080fd5b506103bb6101705481565b34801561045857600080fd5b5061043361046736600461336f565b610d34565b34801561047857600080fd5b506101665461048d906001600160a01b031681565b6040516001600160a01b0390911681526020016103c5565b3480156104b157600080fd5b506104d06104c03660046133f9565b630a85bd0160e11b949350505050565b6040516001600160e01b031990911681526020016103c5565b3480156104f557600080fd5b506101615461048d906001600160a01b031681565b34801561051657600080fd5b506104336105253660046133bd565b610dc5565b34801561053657600080fd5b506103bb610f9a565b34801561054b57600080fd5b506103bb61055a36600461336f565b6101786020526000908152604090205481565b34801561057957600080fd5b506103bb61058836600461338a565b610fba565b34801561059957600080fd5b506103bb61105c565b3480156105ae57600080fd5b506103bb61016c5481565b3480156105c557600080fd5b506104336105d4366004613510565b61109b565b3480156105e557600080fd5b506104336105f436600461336f565b611107565b34801561060557600080fd5b506103bb61016d5481565b34801561061c57600080fd5b506104336111e7565b34801561063157600080fd5b506101625461048d906001600160a01b031681565b34801561065257600080fd5b506104336116fe565b34801561066757600080fd5b50610433610676366004613461565b611744565b34801561068757600080fd5b506106ac61069636600461336f565b6101606020526000908152604090205460ff1681565b60405190151581526020016103c5565b6104336106ca366004613498565b6117a6565b3480156106db57600080fd5b506101635461048d906001600160a01b031681565b3480156106fc57600080fd5b506103bb611877565b34801561071157600080fd5b5060975460ff166106ac565b34801561072957600080fd5b506103bb61073836600461336f565b61192a565b34801561074957600080fd5b506107a66107583660046134e6565b6101736020908152600092835260408084209091529082529020805460018201546002830154600384015460048501546005909501546001600160a01b039485169593909416939192909186565b604080516001600160a01b039788168152969095166020870152938501929092526060840152608083015260a082015260c0016103c5565b3480156107ea57600080fd5b506104336107f936600461336f565b611985565b34801561080a57600080fd5b506104336119de565b34801561081f57600080fd5b5061043361082e36600461336f565b6119f2565b34801561083f57600080fd5b506103bb61084e36600461336f565b6001600160a01b03166000908152610175602052604090205490565b34801561087657600080fd5b506103bb6101695481565b34801561088d57600080fd5b506103bb611a4b565b3480156108a257600080fd5b506104336108b13660046134e6565b611a5a565b3480156108c257600080fd5b50610433611e83565b3480156108d757600080fd5b506103bb6108e636600461336f565b6001600160a01b03166000908152610176602052604090205490565b34801561090e57600080fd5b506065546001600160a01b031661048d565b34801561092c57600080fd5b506103bb6101685481565b34801561094357600080fd5b506103bb61095236600461336f565b6101746020526000908152604090205481565b34801561097157600080fd5b506103bb61016f5481565b34801561098857600080fd5b506103bb61016e5481565b34801561099f57600080fd5b506104336109ae3660046134e6565b611ec3565b3480156109bf57600080fd5b506104336109ce3660046135b2565b612422565b3480156109df57600080fd5b506104336109ee366004613510565b6124ac565b610433612511565b348015610a0757600080fd5b50610433610a1636600461336f565b612555565b348015610a2757600080fd5b506103bb6101675481565b348015610a3e57600080fd5b50610165546103bb565b348015610a5457600080fd5b50610433610a633660046135b2565b612595565b348015610a7457600080fd5b506103bb612671565b348015610a8957600080fd5b506103bb610a9836600461336f565b6101796020526000908152604090205481565b348015610ab757600080fd5b50610164546103bb565b348015610acd57600080fd5b506103bb610adc36600461336f565b6001600160a01b03166000908152610177602052604090205490565b348015610b0457600080fd5b506103bb61016a5481565b348015610b1b57600080fd5b506103bb61016b5481565b348015610b3257600080fd5b506103bb610b413660046133bd565b6126bd565b348015610b5257600080fd5b50610433610b6136600461336f565b6126f7565b6001600160a01b03811660009081526101726020908152604080832054610178909252822054610be19190610bdb90670de0b6b3a764000090610bd590610bb590610baf612671565b9061276d565b6001600160a01b0388166000908152610175602052604090205490612779565b90612785565b90612791565b92915050565b610bef61279d565b6001600160a01b038116610c4a5760405162461bcd60e51b815260206004820152601d60248201527f453a20726563697069656e7420616464726573732063616e276265203000000060448201526064015b60405180910390fd5b60405147906000906001600160a01b0384169083908381818185875af1925050503d8060008114610c97576040519150601f19603f3d011682016040523d82523d6000602084013e610c9c565b606091505b5050905080610ced5760405162461bcd60e51b815260206004820152601960248201527f453a207265636f766572207472616e73666572206572726f72000000000000006044820152606401610c41565b604080516001600160a01b0385168152602081018490527f8c1256b8896378cd5044f80c202f9772b9d77dc85c8a6eb51967210b09bfaa28910160405180910390a1505050565b610d3c61279d565b610d446127f7565b6001600160a01b038116610d6a5760405162461bcd60e51b8152600401610c41906136d6565b61016680546001600160a01b0319166001600160a01b038316908117909155604080519182523360208301527f725540d4066d55e571d1f3a39840626c921529b8df65b93b870c24df49e57eaa91015b60405180910390a150565b600054610100900460ff1615808015610de55750600054600160ff909116105b80610dff5750303b158015610dff575060005460ff166001145b610e625760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610c41565b6000805460ff191660011790558015610e85576000805461ff0019166101001790555b610e8d61283d565b610e95612864565b610e9d612893565b610ea56128c2565b610ead61283d565b81610efa5760405162461bcd60e51b815260206004820152601760248201527f726577617264734475726174696f6e206973207a65726f0000000000000000006044820152606401610c41565b61016280546001600160a01b038087166001600160a01b03199283161790925561016180549286169290911691909117905561016d8290556032610168556064610170556a08b200a96f8d058a000000610171558015610f94576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b6000610fb561016d546101695461277990919063ffffffff16565b905090565b60006001600160a01b0382166110265760405162461bcd60e51b815260206004820152602b60248201527f5374616b696e673a2062616c616e636520717565727920666f7220746865207a60448201526a65726f206164647265737360a81b6064820152608401610c41565b6001600160a01b03808416600090815261017a60209081526040808320938616835292905220611055906128f1565b9392505050565b60006101645460001415611072575061016f5490565b610fb561109161016a5461108b61016754610baf611a4b565b90612779565b61016f5490612791565b60005b81811015611100576110ee8585838181106110bb576110bb613864565b90506020020160208101906110d0919061336f565b8484848181106110e2576110e2613864565b90506020020135611ec3565b806110f88161381d565b91505061109e565b5050505050565b306001600160a01b037f000000000000000000000000700f05b0c90dcdd5d75ae7106fed7b7ed44759f01614156111505760405162461bcd60e51b8152600401610c419061363e565b7f000000000000000000000000700f05b0c90dcdd5d75ae7106fed7b7ed44759f06001600160a01b031661119960008051602061389f833981519152546001600160a01b031690565b6001600160a01b0316146111bf5760405162461bcd60e51b8152600401610c419061368a565b6111c8816128fb565b604080516000808252602082019092526111e491839190612903565b50565b6002600154141561120a5760405162461bcd60e51b8152600401610c419061374a565b600260015533611218612671565b61016e5561122461105c565b61016f55611230611a4b565b610167556001600160a01b038116156112ab5761124c81610b66565b6001600160a01b0382166000908152610172602052604090205561126f8161192a565b6001600160a01b0382166000908152610174602090815260408083209390935561016e5461017882528383205561016f54610179909152919020555b61016b541561130e5761016b5442111561130e5761016c546112ce906001612791565b61016c556101715460015b61016c548111611302576112ee826002612785565b9150806112fa8161381d565b9150506112d9565b5061130c81612a7d565b505b3360008181526101726020908152604080832054610174909252808320546101625491516370a0823160e01b8152600481019590955291939192916001600160a01b03909116906370a082319060240160206040518083038186803b15801561137657600080fd5b505afa15801561138a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113ae9190613599565b9050818110156114005760405162461bcd60e51b815260206004820152601a60248201527f5a5761747420496e73756666696369656e742062616c616e63650000000000006044820152606401610c41565b336000908152610177602052604090205461141b9083612791565b33600090815261017760205260409020556101655461143a9083612791565b6101655582156116f457600061146361017054610bd5610168548661277990919063ffffffff16565b61016254610166549192506001600160a01b03908116916323b872dd9133911661148d878661276d565b6040518463ffffffff1660e01b81526004016114ab939291906135e7565b602060405180830381600087803b1580156114c557600080fd5b505af11580156114d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114fd919061357c565b50610162546040516323b872dd60e01b81526001600160a01b03909116906323b872dd90611533903390309086906004016135e7565b602060405180830381600087803b15801561154d57600080fd5b505af1158015611561573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611585919061357c565b5061016254604051630852cd8d60e31b8152600481018390526001600160a01b03909116906342966c6890602401602060405180830381600087803b1580156115cd57600080fd5b505af11580156115e1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611605919061357c565b50336000818152610172602090815260408083208390556101749091528082208290555190919086908381818185875af1925050503d8060008114611666576040519150601f19603f3d011682016040523d82523d6000602084013e61166b565b606091505b50509050806116bc5760405162461bcd60e51b815260206004820152601860248201527f453a20726577617264207472616e73666572206572726f7200000000000000006044820152606401610c41565b60405185815233907fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e04869060200160405180910390a250505b5050600180555050565b61170661279d565b61170e612beb565b6040513381527f9f0682ebfbd7a5387c2fd5dce8c4a5022b7f8a7090392ac53f6416c63efa9c67906020015b60405180910390a1565b61174c61279d565b6117546127f7565b6001600160a01b03821661177a5760405162461bcd60e51b8152600401610c41906136d6565b6001600160a01b0391909116600090815261016060205260409020805460ff1916911515919091179055565b306001600160a01b037f000000000000000000000000700f05b0c90dcdd5d75ae7106fed7b7ed44759f01614156117ef5760405162461bcd60e51b8152600401610c419061363e565b7f000000000000000000000000700f05b0c90dcdd5d75ae7106fed7b7ed44759f06001600160a01b031661183860008051602061389f833981519152546001600160a01b031690565b6001600160a01b03161461185e5760405162461bcd60e51b8152600401610c419061368a565b611867826128fb565b61187382826001612903565b5050565b6000306001600160a01b037f000000000000000000000000700f05b0c90dcdd5d75ae7106fed7b7ed44759f016146119175760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610c41565b5060008051602061389f83398151915290565b6001600160a01b03811660009081526101746020908152604080832054610179909252822054610be19190610bdb9061196590610baf61105c565b6001600160a01b0386166000908152610176602052604090205490612779565b61198d61279d565b6119956127f7565b6001600160a01b0381166119bb5760405162461bcd60e51b8152600401610c41906136d6565b61016280546001600160a01b0319166001600160a01b0392909216919091179055565b6119e661279d565b6119f06000612c38565b565b6119fa61279d565b611a026127f7565b6001600160a01b038116611a285760405162461bcd60e51b8152600401610c41906136d6565b61016180546001600160a01b0319166001600160a01b0392909216919091179055565b6000610fb54261016b54612c8a565b33611a63612671565b61016e55611a6f61105c565b61016f55611a7b611a4b565b610167556001600160a01b03811615611af657611a9781610b66565b6001600160a01b03821660009081526101726020526040902055611aba8161192a565b6001600160a01b0382166000908152610174602090815260408083209390935561016e5461017882528383205561016f54610179909152919020555b6001600160a01b03831660009081526101606020526040902054839060ff161515600114611b5e5760405162461bcd60e51b8152602060048201526015602482015274114e881b5a5b995c881a5cc81b9bdd081d985b1a59605a1b6044820152606401610c41565b61016b5415611bc15761016b54421115611bc15761016c54611b81906001612791565b61016c556101715460015b61016c548111611bb557611ba1826002612785565b915080611bad8161381d565b915050611b8c565b50611bbf81612a7d565b505b60026001541415611be45760405162461bcd60e51b8152600401610c419061374a565b600260015533611bf48585612ca0565b6001600160a01b031614611c545760405162461bcd60e51b815260206004820152602160248201527f7769746864726177206f6620746f6b656e2074686174206973206e6f74206f776044820152603760f91b6064820152608401610c41565b6001600160a01b03808516600090815261017360209081526040808320878452825291829020825160c0810184528154851681526001820154909416918401919091526002810154918301919091526003810154606083018190526004820154608084015260059091015460a083015261016454611cd19161276d565b6101645560608101513360009081526101756020526040902054611cf49161276d565b3360009081526101756020908152604080832093909355608084015161017690915291902054611d239161276d565b33600081815261017660209081526040808320949094556001600160a01b038916825261017a81528382209282529190915220611d609085612cfa565b506001600160a01b038516600090815261015f60205260408120611d85918690612d06565b506001600160a01b03851660008181526101736020908152604080832088845290915280822080546001600160a01b0319908116825560018201805490911690556002810183905560038101839055600480820184905560059091019290925551632142170760e11b81526342842e0e91611e0691309133918a91016135e7565b600060405180830381600087803b158015611e2057600080fd5b505af1158015611e34573d6000803e3d6000fd5b50506040518681526001600160a01b03881692503391507f948747f71e0c7df022c400908551bb18008e76b080a45255da5d373bca5823e69060200160405180910390a3505060018055505050565b611e8b61279d565b611e93612d1c565b6040513381527fcefccc61a219f93791fb6e4db09576ac77dc4e7edf2a73b47634321897eee98a9060200161173a565b611ecb6127f7565b6001600160a01b03821660009081526101606020526040902054829060ff161515600114611f335760405162461bcd60e51b8152602060048201526015602482015274114e881b5a5b995c881a5cc81b9bdd081d985b1a59605a1b6044820152606401610c41565b33611f3c612671565b61016e55611f4861105c565b61016f55611f54611a4b565b610167556001600160a01b03811615611fcf57611f7081610b66565b6001600160a01b03821660009081526101726020526040902055611f938161192a565b6001600160a01b0382166000908152610174602090815260408083209390935561016e5461017882528383205561016f54610179909152919020555b60026001541415611ff25760405162461bcd60e51b8152600401610c419061374a565b60026001556101615460405163a38b54a960e01b81526001600160a01b03868116600483015260248201869052600092169063a38b54a99060440160206040518083038186803b15801561204557600080fd5b505afa158015612059573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061207d9190613599565b9050806120c45760405162461bcd60e51b815260206004820152601560248201527414dd185ada5b99ce881259081b9bdd08195e1a5cdd605a1b6044820152606401610c41565b6101615460405163d1e118c560e01b81526001600160a01b03878116600483015260248201879052600092169063d1e118c59060440160206040518083038186803b15801561211257600080fd5b505afa158015612126573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061214a9190613599565b9050806121915760405162461bcd60e51b815260206004820152601560248201527414dd185ada5b99ce881259081b9bdd08195e1a5cdd605a1b6044820152606401610c41565b604051632142170760e11b81526001600160a01b038716906342842e0e906121c190339030908a906004016135e7565b600060405180830381600087803b1580156121db57600080fd5b505af11580156121ef573d6000803e3d6000fd5b505050506040518060c00160405280336001600160a01b03168152602001876001600160a01b03168152602001868152602001838152602001828152602001428152506101736000886001600160a01b03166001600160a01b03168152602001908152602001600020600087815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060408201518160020155606082015181600301556080820151816004015560a082015181600501559050506123498561017a6000896001600160a01b03166001600160a01b031681526020019081526020016000206000336001600160a01b03166001600160a01b03168152602001908152602001600020612d5990919063ffffffff16565b506001600160a01b038616600090815261015f6020526040902061236e908633612d06565b506101645461237d9083612791565b61016455336000908152610175602052604090205461239c9083612791565b3360009081526101756020908152604080832093909355610176905220546123c49082612791565b336000818152610176602090815260409182902093909355518781526001600160a01b038916927ff39659f2ff90ba8a58bd5ee61a35788fcab5766770b69e851a764d220db98e0d910160405180910390a350506001805550505050565b61242a61279d565b6124326127f7565b600081116124715760405162461bcd60e51b815260206004820152600c60248201526b72617465206973207a65726f60a01b6044820152606401610c41565b610168819055604080518281523360208201527fced933e7b0edc2a2e41e6be78c54b8ae9d95e86592ebb76c357bb89df0d261719101610dba565b60005b81811015611100576124ff8585838181106124cc576124cc613864565b90506020020160208101906124e1919061336f565b8484848181106124f3576124f3613864565b90506020020135611a5a565b806125098161381d565b9150506124af565b61251961279d565b61252561017154612a7d565b6040513381527f84d0447ca38875fa61115673259a210915bc1dd53a3c112d6f0790f15956a9659060200161173a565b60006125618233610fba565b905060005b818110156125905761257e836108b1853360006126bd565b806125888161381d565b915050612566565b505050565b61259d61279d565b61016b54421161263b5760405162461bcd60e51b815260206004820152605860248201527f50726576696f7573207265776172647320706572696f64206d7573742062652060448201527f636f6d706c657465206265666f7265206368616e67696e67207468652064757260648201527f6174696f6e20666f7220746865206e657720706572696f640000000000000000608482015260a401610c41565b61016d8190556040518181527ffb46ca5a5e06d4540d6387b930a7c978bce0db5f449ec6b3f5d07c6e1d44f2d390602001610dba565b60006101645460001415612687575061016e5490565b610fb56126b361016454610bd5670de0b6b3a764000061108b6101695461108b61016754610baf611a4b565b61016e5490612791565b6001600160a01b03808416600090815261017a6020908152604080832093861683529290529081206126ef9083612d65565b949350505050565b6126ff61279d565b6001600160a01b0381166127645760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610c41565b6111e481612c38565b600061105582846137da565b600061105582846137bb565b60006110558284613799565b60006110558284613781565b6065546001600160a01b031633146119f05760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c41565b60975460ff16156119f05760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610c41565b600054610100900460ff166119f05760405162461bcd60e51b8152600401610c41906136ff565b600054610100900460ff1661288b5760405162461bcd60e51b8152600401610c41906136ff565b6119f0612d71565b600054610100900460ff166128ba5760405162461bcd60e51b8152600401610c41906136ff565b6119f0612d9e565b600054610100900460ff166128e95760405162461bcd60e51b8152600401610c41906136ff565b6119f0612dd1565b6000610be1825490565b6111e461279d565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156129365761259083612e01565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561296f57600080fd5b505afa92505050801561299f575060408051601f3d908101601f1916820190925261299c91810190613599565b60015b612a025760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608401610c41565b60008051602061389f8339815191528114612a715760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401610c41565b50612590838383612e9d565b6000612a87612671565b61016e55612a9361105c565b61016f55612a9f611a4b565b610167556001600160a01b03811615612b1a57612abb81610b66565b6001600160a01b03821660009081526101726020526040902055612ade8161192a565b6001600160a01b0382166000908152610174602090815260408083209390935561016e5461017882528383205561016f54610179909152919020555b612b2e670de0b6b3a7640000610e10612785565b61016a5561016b544210612b545761016d54612b4b908390612785565b61016955612b9b565b61016b54600090612b65904261276d565b90506000612b7f610169548361277990919063ffffffff16565b61016d54909150612b9490610bd58684612791565b6101695550505b4261016781905561016d54612bb09190612791565b61016b556040518281527fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9060200160405180910390a15050565b612bf3612ec2565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200161173a565b606580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000818310612c995781611055565b5090919050565b604080518082018252601b81527f717565727920666f72206e6f6e6578697374656e7420746f6b656e00000000006020808301919091526001600160a01b038516600090815261015f909152918220611055918490612f0b565b60006110558383612f18565b60006126ef84846001600160a01b03851661300b565b612d246127f7565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612c203390565b60006110558383613028565b60006110558383613077565b600054610100900460ff16612d985760405162461bcd60e51b8152600401610c41906136ff565b60018055565b600054610100900460ff16612dc55760405162461bcd60e51b8152600401610c41906136ff565b6097805460ff19169055565b600054610100900460ff16612df85760405162461bcd60e51b8152600401610c41906136ff565b6119f033612c38565b6001600160a01b0381163b612e6e5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610c41565b60008051602061389f83398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b612ea6836130a1565b600082511180612eb35750805b1561259057610f9483836130e1565b60975460ff166119f05760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610c41565b60006126ef8484846131d5565b60008181526001830160205260408120548015613001576000612f3c6001836137da565b8554909150600090612f50906001906137da565b9050818114612fb5576000866000018281548110612f7057612f70613864565b9060005260206000200154905080876000018481548110612f9357612f93613864565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612fc657612fc661384e565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610be1565b6000915050610be1565b600082815260028401602052604081208290556126ef8484612d59565b600081815260018301602052604081205461306f57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610be1565b506000610be1565b600082600001828154811061308e5761308e613864565b9060005260206000200154905092915050565b6130aa81612e01565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b6131495760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610c41565b600080846001600160a01b03168460405161316491906135cb565b600060405180830381855af49150503d806000811461319f576040519150601f19603f3d011682016040523d82523d6000602084013e6131a4565b606091505b50915091506131cc82826040518060600160405280602781526020016138bf60279139613221565b95945050505050565b6000828152600284016020526040812054801515806131f957506131f9858561325a565b83906132185760405162461bcd60e51b8152600401610c41919061360b565b50949350505050565b60608315613230575081611055565b8251156132405782518084602001fd5b8160405162461bcd60e51b8152600401610c41919061360b565b600081815260018301602052604081205461105590849084908490151584565b80356001600160a01b038116811461329157600080fd5b919050565b60008083601f8401126132a857600080fd5b50813567ffffffffffffffff8111156132c057600080fd5b6020830191508360208260051b85010111156132db57600080fd5b9250929050565b600082601f8301126132f357600080fd5b813567ffffffffffffffff8082111561330e5761330e61387a565b604051601f8301601f19908116603f011681019082821181831017156133365761333661387a565b8160405283815286602085880101111561334f57600080fd5b836020870160208301376000602085830101528094505050505092915050565b60006020828403121561338157600080fd5b6110558261327a565b6000806040838503121561339d57600080fd5b6133a68361327a565b91506133b46020840161327a565b90509250929050565b6000806000606084860312156133d257600080fd5b6133db8461327a565b92506133e96020850161327a565b9150604084013590509250925092565b6000806000806080858703121561340f57600080fd5b6134188561327a565b93506134266020860161327a565b925060408501359150606085013567ffffffffffffffff81111561344957600080fd5b613455878288016132e2565b91505092959194509250565b6000806040838503121561347457600080fd5b61347d8361327a565b9150602083013561348d81613890565b809150509250929050565b600080604083850312156134ab57600080fd5b6134b48361327a565b9150602083013567ffffffffffffffff8111156134d057600080fd5b6134dc858286016132e2565b9150509250929050565b600080604083850312156134f957600080fd5b6135028361327a565b946020939093013593505050565b6000806000806040858703121561352657600080fd5b843567ffffffffffffffff8082111561353e57600080fd5b61354a88838901613296565b9096509450602087013591508082111561356357600080fd5b5061357087828801613296565b95989497509550505050565b60006020828403121561358e57600080fd5b815161105581613890565b6000602082840312156135ab57600080fd5b5051919050565b6000602082840312156135c457600080fd5b5035919050565b600082516135dd8184602087016137f1565b9190910192915050565b6001600160a01b039384168152919092166020820152604081019190915260600190565b602081526000825180602084015261362a8160408501602087016137f1565b601f01601f19169190910160400192915050565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b6020808252600f908201526e61646472657373206973207a65726f60881b604082015260600190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6000821982111561379457613794613838565b500190565b6000826137b657634e487b7160e01b600052601260045260246000fd5b500490565b60008160001904831182151516156137d5576137d5613838565b500290565b6000828210156137ec576137ec613838565b500390565b60005b8381101561380c5781810151838201526020016137f4565b83811115610f945750506000910152565b600060001982141561383157613831613838565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b80151581146111e457600080fdfe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a9056b7f42bab9fc65e4ebe1d8e440b7f65fdd1a57780ebc3c031b40dd9079a464736f6c63430008060033