Source Code
Overview
GLMR Balance
GLMR Value
$0.00View more zero value Internal Transactions in Advanced View mode
Cross-Chain Transactions
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
KugleNFT
Compiler Version
v0.8.28+commit.7893614a
Optimization Enabled:
Yes with 200 runs
Other Settings:
prague EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;
import "./Breeding.sol";
import "./Hatch.sol";
import "./interfaces/IKugleNFT.sol";
contract KugleNFT is IKugleNFT, Breeding, Hatch {
event NewNFTMinted(address indexed from, uint256 itemId);
function mintKuglesTo(uint256[] memory _toMint, address _to)
external
onlyBoosterSellerContractOrOwner
{
for (uint16 i = 0; i < _toMint.length; i++) {
_mintKugle(_to, _toMint[i]);
}
}
function tokenOfOwner(address _owner) external view returns (uint256[] memory) {
uint256 tokenCount = balanceOf(_owner);
uint256[] memory result = new uint256[](tokenCount);
for (uint256 i = 0; i < tokenCount; i++) {
// tokenOfOwnerByIndex returns the token owned by user at index i
result[i] = tokenOfOwnerByIndex(_owner, i);
}
return result;
}
function getKugleLevel(uint256 _kugleId) public view returns (uint8) {
return (_kugleLevel[_kugleId]);
}
function getKugleGeneration(uint256 _kugleId) external view returns (uint8) {
return (_kugleGeneration[_kugleId]);
}
function getKuglesLevels(uint256[] calldata _kuglesIds)
external
view
returns (uint8[] memory)
{
uint8[] memory levels = new uint8[](_kuglesIds.length);
for (uint16 i = 0; i < _kuglesIds.length; i++) {
levels[i] = getKugleLevel(_kuglesIds[i]);
}
return levels;
}
function setKugleLevel(uint256 _kugleId, uint8 _level) external onlyPotContractOrOwner {
_kugleLevel[_kugleId] = _level;
}
function setKugleGeneration(uint256 _kugleId, uint8 _generation) external onlyOwner {
_kugleGeneration[_kugleId] = _generation;
}
// @dev: _stakeKugle allow user to stake his kugle directly after mint
function _mintKugle(address _to, uint256 _newTokenId) internal {
_safeMint(_to, _newTokenId);
_kugleLevel[_newTokenId] = 1;
if (_newTokenId <= GENESIS_AMOUNT) {
_kugleGeneration[_newTokenId] = 0;
} else {
_kugleGeneration[_newTokenId] = 1;
}
emit NewNFTMinted(_to, _newTokenId);
_totalKugles++;
}
function emitBatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId) external onlyOwner {
emit BatchMetadataUpdate(_fromTokenId, _toTokenId);
}
function ownerOf(uint256 tokenId)
public
view
override(IKugleNFT, KugleFactory)
returns (address)
{
return super.ownerOf(tokenId);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;
import "./Staking.sol";
error BreedingPaused();
error SameKugle();
error KugleNotFertile(uint256 kugleId);
error NotOwnerOrStaked(uint256 kugleId);
abstract contract Breeding is Staking {
/**
* from : user that call breeding function
* itemId: Id of new NFT
* parent1: Id of parent 1
* parent2: Id of parent 2
* pricePaid: price (in carbon) paid by user
* ressourcesUsed: array of ressources user spend for breeding
*/
event NewBreeding(
address indexed from, uint256 itemId, uint256 parent1, uint256 parent2, uint256 pricePaid
);
// uint256[] ressourcesUsed
bool internal _breedingPaused;
function breed(
uint256 _kugleId1,
uint256 _kugleId2,
bool _stakeKugle, // uint256[] calldata _ressources
uint256 _priceAdditionnalCarbon,
uint256 _carbonRewardsClaimed
) external {
// check price is above minimum price
require(!_breedingPaused, BreedingPaused());
require(_kugleId1 != _kugleId2, SameKugle());
// check fertility of both kugles are > 0, mean their level are < 4
// 1: egg
// 2: kugle fertility 100%
// 3: kugle fertility 50%
// 4: kugle fertility 0%
// GENESIS => 2: kugle fertility 200%
// GENESIS => 3: kugle fertility 150%
// GENESIS => 4: kugle fertility 100%
// GENESIS => 5: kugle fertility 50%
// GENESIS => 6: kugle fertility 0%
uint8 maxLevelKugle1 = _kugleId1 <= GENESIS_AMOUNT ? 6 : 4;
uint8 maxLevelKugle2 = _kugleId2 <= GENESIS_AMOUNT ? 6 : 4;
require(
_kugleLevel[_kugleId1] > 1 && _kugleLevel[_kugleId1] < maxLevelKugle1,
KugleNotFertile(_kugleId1)
);
require(
_kugleLevel[_kugleId2] > 1 && _kugleLevel[_kugleId2] < maxLevelKugle2,
KugleNotFertile(_kugleId2)
);
// check kugle are owned by user
require(
(ownerOf(_kugleId1) == msg.sender || _stakedKugles[_kugleId1].owner == msg.sender),
NotOwnerOrStaked(_kugleId1)
);
require(
(ownerOf(_kugleId2) == msg.sender || _stakedKugles[_kugleId2].owner == msg.sender),
NotOwnerOrStaked(_kugleId2)
);
uint256[] memory kugleIds = new uint256[](2);
kugleIds[0] = _kugleId1;
kugleIds[1] = _kugleId2;
claimReward(0, _carbonRewardsClaimed, kugleIds);
uint8 _kugleGen1 = _kugleGeneration[_kugleId1];
uint8 _kugleGen2 = _kugleGeneration[_kugleId2];
uint8 generation = (_kugleGen1 > _kugleGen2 ? _kugleGen1 : _kugleGen2) + 1;
uint256 _price = (
_breedPrice * _priceMulplier ** (generation - 1) + _priceAdditionnalCarbon
) / (10 ** ((generation - 1) * _multiplierDecimals));
carbonContract.burn(msg.sender, _price);
// if kugle is staked, update lastRewardClaimDate
if (_stakedKugles[_kugleId1].owner == msg.sender) {
_stakedKugles[_kugleId1].lastRewardClaimDate = block.timestamp;
}
if (_stakedKugles[_kugleId2].owner == msg.sender) {
_stakedKugles[_kugleId2].lastRewardClaimDate = block.timestamp;
}
_kugleLevel[_kugleId1]++;
_kugleLevel[_kugleId2]++;
// Get the next available token ID that doesn't conflict with booster editions
uint256 newTokenId = getNextAvailableTokenId();
// mint a new NFT
_safeMint(msg.sender, newTokenId);
// set level 1 = egg
_kugleLevel[newTokenId] = 1;
// set generation
_kugleGeneration[newTokenId] = generation;
if (_stakeKugle) {
_stake(newTokenId, msg.sender);
}
// emit an event
// emit NewBreeding(msg.sender, _tokenId, _kugleId1, _kugleId2, _price, _ressources);
emit NewBreeding(msg.sender, newTokenId, _kugleId1, _kugleId2, _price);
_totalKugles++;
// Update the booster seller's kugle count to reflect the new NFT created
boosterSellerContract.incrementKugleCount();
}
function setBreedingPaused(bool _paused) external onlyOwner {
_breedingPaused = _paused;
}
function getBreedingPaused() external view returns (bool) {
return _breedingPaused;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;
import "./Staking.sol";
abstract contract Hatch is Staking {
event NewHatching(address indexed from, uint256 itemId);
function hatch(
uint256[] calldata _kugleIds,
bool _stakeKugle, // stakeKugle = true means all Kugles should be staked, false mean, don't change situation (if staked it's still staked, else not staked)
uint256 _heatRewardsClaimed
) external {
claimReward(_heatRewardsClaimed, 0, _kugleIds);
uint256 _price = 0;
for (uint256 i = 0; i < _kugleIds.length; i++) {
require(_kugleLevel[_kugleIds[i]] == 1, AlreadyHatch(_kugleIds[i]));
require(
ownerOf(_kugleIds[i]) == msg.sender
|| _stakedKugles[_kugleIds[i]].owner == msg.sender,
NotOwned(_kugleIds[i], msg.sender)
);
_price += (_hatchPrice * _priceMulplier ** (_kugleGeneration[uint256(_kugleIds[i])]))
/ 10 ** (_kugleGeneration[uint256(_kugleIds[i])] * _multiplierDecimals);
// if kugle is staked, update lastRewardClaimDate
if (_stakedKugles[_kugleIds[i]].owner == msg.sender) {
_stakedKugles[_kugleIds[i]].lastRewardClaimDate = block.timestamp;
} else if (_stakeKugle) {
// stake Kugle
_stake(_kugleIds[i], msg.sender);
}
// level > 1 means NFT is a Kugle (1 = Egg)
_kugleLevel[_kugleIds[i]] = 2;
emit NewHatching(msg.sender, _kugleIds[i]);
}
heatContract.burn(msg.sender, _price);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;
interface IKugleNFT {
struct GuRewardTier {
uint256 guHeld;
uint256 popCap;
}
struct StakeInfo {
address owner;
uint256 stakingDate;
uint256 lastRewardClaimDate;
uint256 kugleId;
}
struct SpecialSeries {
uint256 startId;
uint8 maxNFTInSeries;
uint256 currentId;
}
struct RewardsInfos {
uint256 dailyHeatPerKugle;
uint256 dailyCarbonPerKugle;
uint256 maxCapacityHeatPerKugle;
uint256 maxCapacityCarbonPerKugle;
uint256 assignedHeatRewards;
uint256 assignedCarbonRewards;
uint256 rewardsMultiplier;
uint256 multiplierDecimals;
}
function stakedTokenOfOwner(address owner) external view returns (uint256[] memory);
function getGuRewardTiers() external view returns (GuRewardTier[] memory);
function ownerOf(uint256 tokenId) external view returns (address);
function getStakedKugleInfos(uint256 _kugleId) external view returns (StakeInfo memory);
function setKugleLevel(uint256 _kugleId, uint8 _level) external;
function getKugleLevel(uint256 _kugleId) external view returns (uint8);
function getPopCapFromAmount(uint256 amount) external view returns (uint256 popCap);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;
import "./Rewards.sol";
import "../Seller/interfaces/IBoosterSeller.sol";
error UserCanNotStake(address _owner);
abstract contract Staking is Rewards {
event StartStaking(address indexed from, uint256 kugleId);
event EndStaking(address indexed from, uint256 kugleId);
// vérifie que le owner original, donc avant le staking (qui change le owner pour éviter la revente) est bien l'utilisateur à l'origine de l'action
modifier onlyOriginalOwner(uint256[] memory _kugleIds) {
for (uint16 i = 0; i < _kugleIds.length; i++) {
require(_stakedKugles[_kugleIds[i]].owner == msg.sender);
}
_;
}
modifier onlyBoosterContract() {
require(msg.sender == address(boosterSellerContract));
_;
}
function stake(uint256[] calldata _kugleIds) external {
for (uint16 i = 0; i < _kugleIds.length; i++) {
require(ownerOf(_kugleIds[i]) == msg.sender, "o");
_stake(_kugleIds[i], msg.sender);
}
}
function stakeFromBoosterContract(uint256[] calldata _kugleIds, address _owner)
external
onlyBoosterContract
{
require(userCanStake(_owner), UserCanNotStake(_owner));
for (uint16 i = 0; i < _kugleIds.length; i++) {
_stake(_kugleIds[i], _owner);
}
}
function _stake(uint256 _kugleId, address _owner) internal {
require(userCanStake(_owner), UserCanNotStake(_owner));
transferFrom(msg.sender, address(this), _kugleId);
StakeInfo memory stakedKugle = StakeInfo({
owner: _owner,
stakingDate: block.timestamp,
lastRewardClaimDate: block.timestamp,
kugleId: _kugleId
});
_stakedKugles[_kugleId] = stakedKugle;
_nbStakedKugles[_owner]++;
_totalStakedKugles++;
userStakedKugleId[_owner].push(_kugleId);
emit StartStaking(_owner, _kugleId);
}
function userCanStake(address _owner) internal view returns (bool) {
return _nbStakedKugles[_owner] < getUserPopCap(_owner);
}
function getUserPopCap(address user) public view returns (uint256 popCap) {
uint256 guBlocked = guHeldContract.getBlockedGuByAddress(user);
return getPopCapFromAmount(guBlocked);
}
function getPopCapFromAmount(uint256 amount) public view returns (uint256 popCap) {
GuRewardTier[] memory tiers = _guRewardTiers;
for (uint256 i = tiers.length - 1; i >= 0; i--) {
if (amount >= _guRewardTiers[i].guHeld) {
return tiers[i].popCap;
}
}
return 0;
}
// @dev : rewardsClaimed = 0 means player doesn't want to claim rewards
// _heat & _carbon are calculated by server (nodejs)
function unstake(
uint256[] calldata _kugleIds,
uint256 _heatRewardsClaimed,
uint256 _carbonRewardsClaimed
) external onlyOriginalOwner(_kugleIds) {
claimReward(_heatRewardsClaimed, _carbonRewardsClaimed, _kugleIds);
for (uint16 i = 0; i < _kugleIds.length; i++) {
_safeTransfer(address(this), msg.sender, _kugleIds[i]);
delete _stakedKugles[_kugleIds[i]];
_nbStakedKugles[msg.sender]--;
_totalStakedKugles--;
unstakeUsersKugle(_kugleIds[i]);
emit EndStaking(msg.sender, _kugleIds[i]);
}
}
function unstakeUsersKugle(uint256 _kugleId) internal {
uint256[] storage kugleIds = userStakedKugleId[msg.sender];
for (uint256 i = 0; i < kugleIds.length; i++) {
if (kugleIds[i] == _kugleId) {
kugleIds[i] = kugleIds[kugleIds.length - 1];
kugleIds.pop();
break;
}
}
}
// list kugle + egg
// list staked NFT for original (legit) owner
function stakedTokenOfOwner(address owner) external view returns (uint256[] memory) {
return userStakedKugleId[owner];
}
function getStakedKugleInfos(uint256 _kugleId) external view returns (StakeInfo memory) {
require(_stakedKugles[_kugleId].owner != address(0x0));
return _stakedKugles[_kugleId];
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;
import "./KugleFactory.sol";
error InsufficientRewards(
uint256 maxHeat, uint256 claimedHeat, uint256 maxCarbon, uint256 claimedCarbon
);
abstract contract Rewards is KugleFactory {
function claimReward(
uint256 _heatRewardsClaimed,
uint256 _carbonRewardsClaimed,
uint256[] memory _tokenIds
) public {
// calculate max rewards available
(uint256 maxHeatRewards, uint256 maxCarbonRewards) = calculateMaxRewards(_tokenIds);
// si on veut pénaliser le joueur qui tente une triche, une peu faire un if et un return
// ainsi la suite de la fonction ne sera pas exécutée mais en l'absence de revert, le gas n'est pas remboursé
require(
maxHeatRewards >= _heatRewardsClaimed && maxCarbonRewards >= _carbonRewardsClaimed,
InsufficientRewards(
maxHeatRewards, _heatRewardsClaimed, maxCarbonRewards, _carbonRewardsClaimed
)
);
if (_heatRewardsClaimed > 0) {
// transfer heat to user
heatContract.mint(msg.sender, _heatRewardsClaimed);
// store lastRewardClaimDate on every staked NFT that are eggs
for (uint16 i = 0; i < _tokenIds.length; i++) {
if (_kugleLevel[_tokenIds[i]] == 1) {
_stakedKugles[_tokenIds[i]].lastRewardClaimDate = block.timestamp;
}
}
}
if (_carbonRewardsClaimed > 0) {
// transfer carbon to user
carbonContract.mint(msg.sender, _carbonRewardsClaimed);
// store lastRewardClaimDate on every staked NFT that are Kugles
for (uint16 i = 0; i < _tokenIds.length; i++) {
if (_kugleLevel[_tokenIds[i]] > 1) {
_stakedKugles[_tokenIds[i]].lastRewardClaimDate = block.timestamp;
}
}
}
}
// it calculates the maximum of reward
function calculateMaxRewardOfKugle(StakeInfo memory _stakedKugle)
internal
view
returns (uint256 maxHeat, uint256 maxCarbon)
{
uint256 delayInHours = 3600 * _delayBetweenRewards;
// calculate time in h between stakedTime and now
uint256 elapsedDays = block.timestamp - _stakedKugle.stakingDate;
// calculate time between lastRewardClaimDate and now
uint256 lastClaimAfter = _stakedKugle.lastRewardClaimDate - _stakedKugle.stakingDate;
uint256 stakedTime = elapsedDays - lastClaimAfter;
uint256 kugleGeneration = _kugleGeneration[_stakedKugle.kugleId];
// Kugle state
if (_kugleLevel[_stakedKugle.kugleId] > 1) {
uint256 index = _dailyCarbonPerKugle.length - 1;
if (kugleGeneration < _dailyCarbonPerKugle.length) {
index = kugleGeneration;
}
maxCarbon = _dailyCarbonPerKugle[index] * stakedTime / delayInHours;
}
// Egg state
else {
uint256 index = _dailyHeatPerKugle.length - 1;
if (kugleGeneration < _dailyHeatPerKugle.length) {
index = kugleGeneration;
}
maxHeat = _dailyHeatPerKugle[index] * stakedTime / delayInHours;
}
}
function calculateMaxRewards(uint256[] memory ids)
public
view
returns (uint256 heat, uint256 carbon)
{
uint256 totalMaxHeatReward = 0;
uint256 totalMaxCarbonReward = 0;
// for each KugleId
for (uint16 i = 0; i < ids.length; i++) {
// If token is not staked, no rewards
if (_stakedKugles[ids[i]].owner == address(0)) {
continue;
}
// check if kugleId is staked by current user
require(_stakedKugles[ids[i]].owner == msg.sender, NotStaked(ids[i]));
(uint256 maxHeat, uint256 maxCarbon) = calculateMaxRewardOfKugle(_stakedKugles[ids[i]]);
maxHeat = maxHeat > _maxHeatRewards ? _maxHeatRewards : maxHeat;
maxCarbon = maxCarbon > _maxCarbonRewards ? _maxCarbonRewards : maxCarbon;
totalMaxHeatReward += maxHeat;
totalMaxCarbonReward += maxCarbon;
}
return (totalMaxHeatReward, totalMaxCarbonReward);
}
// Ajout d'une fonction publique pour exposer le calcul des rewards max pour les tests
function getMaxRewards(uint256[] memory ids)
public
view
returns (uint256 heat, uint256 carbon)
{
return calculateMaxRewards(ids);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;
interface IBoosterSeller {
struct Booster {
uint256 id;
uint256[] kugleIds;
address buyer;
}
struct Edition {
string uniqueName;
// NOTE: The name is not unique, it's just a name to display on the website + noted in the NFT Metadata
string displayedName;
uint256 price;
uint256[2] kuglesIds;
uint256[2] boosterIds;
bool available;
bool cancelled;
bool visible;
bool boostersToKeepSent;
uint8 percentageToKeepForOwner;
uint256 heatToSendOnSale;
uint256 carbonToSendOnSale;
}
// function createBoosters(uint256[] memory kugleIds) external;
function createEdition(
string calldata uniqueName,
uint256 price,
string calldata displayedName,
uint256 kuglesLength,
uint8 percentageToKeepForOwner,
uint256 heatToSendOnSale,
uint256 carbonToSendOnSale
) external;
// function addBoostersToEdition(uint16 editionId, uint256[] memory boosterIds) external;
function getBooster(uint256 boosterId) external returns (Booster memory);
function getEdition(uint16 editionId) external returns (Edition memory);
function renameEdition(uint16 editionId, string memory newName) external;
function changeEditionPrice(uint16 editionId, uint256 newPrice) external;
function setEditionAvailability(uint16 editionId, bool available) external;
function setEditionVisibility(uint16 editionId, bool visible) external;
function cancelEdition(uint16 editionId) external;
function buyBoosters(uint16 editionId, uint16 boostersAmount, bool stake, address to)
external;
function getKugleCount() external view returns (uint256);
function incrementKugleCount() external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;
/**
* KugleFactory
* |
* v
* Rewards
* |
* v
* Stacking
* | |
* v v
* Breeding Hatch
* | |
* v v
* KugleNFT
*/
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721RoyaltyUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721URIStorageUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "../Tokens/interfaces/IRessourcesTokens.sol";
import "../Tokens/interfaces/IReactor.sol";
import "../Seller/interfaces/IBoosterSeller.sol";
import "./interfaces/IKugleNFT.sol";
// KBS errors
error NotOwned(uint256 kugleId, address account);
error NotStaked(uint256 kugleId);
error AlreadyHatch(uint256 kugleId);
error NoEnoughHeatToClaim(uint256 maxHeatToClaim, uint256 heatToClaim);
error AddressCannotBeZero(address account);
abstract contract KugleFactory is
IKugleNFT,
Initializable,
ERC721EnumerableUpgradeable,
ERC721URIStorageUpgradeable,
ERC721RoyaltyUpgradeable,
UUPSUpgradeable,
OwnableUpgradeable
{
uint256 internal constant GENESIS_AMOUNT = 2000;
address payable public _royaltiesReceiver;
uint16 internal _totalStakedKugles;
uint256 internal _totalKugles; // total of NFT minted (egg + kugle)
uint256 internal _breedPrice;
uint256 internal _hatchPrice;
uint256 internal _priceMulplier;
uint256 public _multiplierDecimals;
uint256[] internal _dailyHeatPerKugle;
uint256[] internal _dailyCarbonPerKugle;
GuRewardTier[] internal _guRewardTiers;
uint256 public _maxHeatRewards;
uint256 public _maxCarbonRewards;
string internal constant URI = "https://api.kugle.app/eth-api-dev/kugles/"; // TODO : FOR MAINNET DELETE -dev
IReactor internal guHeldContract;
IRessourcesTokens internal heatContract;
IRessourcesTokens internal carbonContract;
address internal potionsContract;
IBoosterSeller internal boosterSellerContract;
// IRessources internal ressourcesContract;
mapping(uint256 => uint8) internal _kugleLevel; // id of Kugle to level of Kugle
mapping(uint256 => uint8) internal _kugleGeneration; // id of Kugle to generation of Kugle
mapping(uint256 => StakeInfo) internal _stakedKugles; // id of Kugle to its stake info
mapping(address => uint16) internal _nbStakedKugles; // address of owner to nb Of stakedKugle
mapping(address => uint256[]) userStakedKugleId; // address of owner to stakedKugleId
uint16 internal _royaltiesRate;
address internal _royaltyReceiver;
// in hours
uint256 internal _delayBetweenRewards;
mapping(uint256 => SpecialSeries) internal _specialSeries;
uint256 internal _totalSpecialSeries;
modifier onlyPotContractOrOwner() {
require(msg.sender == potionsContract || msg.sender == owner());
_;
}
modifier onlyBoosterSellerContractOrOwner() {
require(msg.sender == address(boosterSellerContract) || msg.sender == owner());
_;
}
function initialize() public initializer {
__ERC721_init("Kugle Genesis", "KGEN");
__ERC721Enumerable_init();
__ERC721Royalty_init();
__ERC721URIStorage_init();
__Ownable_init(msg.sender);
__UUPSUpgradeable_init();
_totalSpecialSeries = 0;
_totalKugles = 0;
_breedPrice = 200 ether; // 200 carbon
_hatchPrice = 200 ether; // 200 heat
_priceMulplier = 12; // 12 = 1.2
_multiplierDecimals = 1;
_dailyCarbonPerKugle.push(19.2 * 1e18); // ref: https://docs.kugle.app/docs/Tokenomic/NFT%20Eggs%20&%20Kugles
_dailyCarbonPerKugle.push(16 * 1e18);
_dailyCarbonPerKugle.push(10 * 1e18);
_dailyCarbonPerKugle.push(8.33 * 1e18);
_dailyCarbonPerKugle.push(6.94 * 1e18);
_dailyCarbonPerKugle.push(5.79 * 1e18);
_dailyCarbonPerKugle.push(4.82 * 1e18);
_dailyCarbonPerKugle.push(4.02 * 1e18);
_dailyCarbonPerKugle.push(3.34 * 1e18);
_dailyCarbonPerKugle.push(2.79 * 1e18);
_dailyHeatPerKugle.push(14.4 * 1e18);
_dailyHeatPerKugle.push(12 * 1e18);
_dailyHeatPerKugle.push(7.5 * 1e18);
_dailyHeatPerKugle.push(6.25 * 1e18);
_dailyHeatPerKugle.push(5.2 * 1e18);
_dailyHeatPerKugle.push(4.34 * 1e18);
_dailyHeatPerKugle.push(3.62 * 1e18);
_dailyHeatPerKugle.push(3.01 * 1e18);
_dailyHeatPerKugle.push(2.51 * 1e18);
_dailyHeatPerKugle.push(2.09 * 1e18);
_delayBetweenRewards = 24;
_royaltiesRate = 750;
_royaltyReceiver = msg.sender;
_maxHeatRewards = 500e18;
_maxCarbonRewards = 500e18;
}
function setNewDailyCarbonPerKugle(uint256[] calldata newArray) public onlyOwner {
_dailyCarbonPerKugle = newArray;
}
function setNewDailyHeatPerKugle(uint256[] calldata newArray) public onlyOwner {
_dailyHeatPerKugle = newArray;
}
function setDelayBetweenRewards(uint256 _delay) external onlyOwner {
_delayBetweenRewards = _delay;
}
function setRoyaltiesRate(uint16 _rate) external onlyOwner {
_royaltiesRate = _rate;
_setDefaultRoyalty(_royaltyReceiver, _rate);
}
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() initializer { }
function _increaseBalance(address account, uint128 amount)
internal
override(ERC721Upgradeable, ERC721EnumerableUpgradeable)
{
super._increaseBalance(account, amount);
}
function _update(address to, uint256 tokenId, address auth)
internal
override(ERC721Upgradeable, ERC721EnumerableUpgradeable)
returns (address)
{
return super._update(to, tokenId, auth);
}
function _authorizeUpgrade(address) internal override onlyOwner { }
function supportsInterface(bytes4 interfaceId)
public
view
override(ERC721EnumerableUpgradeable, ERC721URIStorageUpgradeable, ERC721RoyaltyUpgradeable)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
function setContracts(
address _guHeldContract,
address _heatAddress,
address _carbonAddress,
address _potionsContract,
address _boosterSellerAddress
) external onlyOwner {
require(_guHeldContract != address(0), AddressCannotBeZero(_guHeldContract));
require(_heatAddress != address(0), AddressCannotBeZero(_heatAddress));
require(_carbonAddress != address(0), AddressCannotBeZero(_carbonAddress));
require(_potionsContract != address(0), AddressCannotBeZero(_potionsContract));
require(_boosterSellerAddress != address(0), AddressCannotBeZero(_boosterSellerAddress));
guHeldContract = IReactor(_guHeldContract);
heatContract = IRessourcesTokens(_heatAddress);
carbonContract = IRessourcesTokens(_carbonAddress);
potionsContract = _potionsContract;
boosterSellerContract = IBoosterSeller(_boosterSellerAddress);
}
function setRoyaltiesReceiverAddress(address payable _royaltiesReceiverAddress)
external
onlyOwner
{
require(
_royaltiesReceiverAddress != address(0), AddressCannotBeZero(_royaltiesReceiverAddress)
);
_royaltyReceiver = _royaltiesReceiverAddress;
_setDefaultRoyalty(_royaltiesReceiverAddress, _royaltiesRate); // 250 amount of royalties in % / 100
}
function tokenURI(uint256 _kugleId)
public
pure
override(ERC721Upgradeable, ERC721URIStorageUpgradeable)
returns (string memory)
{
return string(abi.encodePacked(URI, Strings.toString(_kugleId), "/os_vals"));
}
function circulatingSupply() external view returns (uint256) {
return _totalKugles;
}
function setPrices(uint256 _newBreedPrice, uint256 _newHatchPrice, uint256 _newPriceMulplier)
external
onlyOwner
{
_breedPrice = _newBreedPrice;
_hatchPrice = _newHatchPrice;
_priceMulplier = _newPriceMulplier;
}
function getPrices() external view returns (uint256, uint256, uint256) {
return (_breedPrice, _hatchPrice, _priceMulplier);
}
/**
* @dev Get the next available token ID for breeding by getting the total count from BoosterSeller
*/
function getNextAvailableTokenId() public view returns (uint256) {
return boosterSellerContract.getKugleCount();
}
function setMultiplierDecimals(uint256 newValue) external onlyOwner {
_multiplierDecimals = newValue;
}
function setMaxRewards(uint256 maxHeatRewards, uint256 maxCarbonRewards) public onlyOwner {
_maxHeatRewards = maxHeatRewards;
_maxCarbonRewards = maxCarbonRewards;
}
function addOrDeleteGuRewardTier(uint256 index, uint256 _guHeld, uint256 _popCap)
external
onlyOwner
{
if (_popCap == 0) {
require(index < _guRewardTiers.length);
for (uint256 i = index; i < _guRewardTiers.length - 1; i++) {
_guRewardTiers[i] = _guRewardTiers[i + 1];
}
_guRewardTiers.pop();
} else {
GuRewardTier memory newTier = GuRewardTier(_guHeld, _popCap);
uint256 length = _guRewardTiers.length;
if (length == 0 || _guHeld > _guRewardTiers[length - 1].guHeld) {
_guRewardTiers.push(newTier);
} else {
uint256 i;
for (i = 0; i < length; i++) {
if (_guHeld <= _guRewardTiers[i].guHeld) {
break;
}
}
_guRewardTiers.push(_guRewardTiers[length - 1]);
for (uint256 j = length - 1; j > i; j--) {
_guRewardTiers[j] = _guRewardTiers[j - 1];
}
_guRewardTiers[i] = newTier;
}
}
}
function getGuRewardTiers() external view returns (GuRewardTier[] memory) {
return _guRewardTiers;
}
function ownerOf(uint256 tokenId)
public
view
virtual
override(ERC721Upgradeable, IERC721, IKugleNFT)
returns (address)
{
return super.ownerOf(tokenId);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (utils/Strings.sol)
pragma solidity ^0.8.20;
import {Math} from "./math/Math.sol";
import {SafeCast} from "./math/SafeCast.sol";
import {SignedMath} from "./math/SignedMath.sol";
/**
* @dev String operations.
*/
library Strings {
using SafeCast for *;
bytes16 private constant HEX_DIGITS = "0123456789abcdef";
uint8 private constant ADDRESS_LENGTH = 20;
/**
* @dev The `value` string doesn't fit in the specified `length`.
*/
error StringsInsufficientHexLength(uint256 value, uint256 length);
/**
* @dev The string being parsed contains characters that are not in scope of the given base.
*/
error StringsInvalidChar();
/**
* @dev The string being parsed is not a properly formatted address.
*/
error StringsInvalidAddressFormat();
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
assembly ("memory-safe") {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
assembly ("memory-safe") {
mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toStringSigned(int256 value) internal pure returns (string memory) {
return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
uint256 localValue = value;
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = HEX_DIGITS[localValue & 0xf];
localValue >>= 4;
}
if (localValue != 0) {
revert StringsInsufficientHexLength(value, length);
}
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal
* representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its checksummed ASCII `string` hexadecimal
* representation, according to EIP-55.
*/
function toChecksumHexString(address addr) internal pure returns (string memory) {
bytes memory buffer = bytes(toHexString(addr));
// hash the hex part of buffer (skip length + 2 bytes, length 40)
uint256 hashValue;
assembly ("memory-safe") {
hashValue := shr(96, keccak256(add(buffer, 0x22), 40))
}
for (uint256 i = 41; i > 1; --i) {
// possible values for buffer[i] are 48 (0) to 57 (9) and 97 (a) to 102 (f)
if (hashValue & 0xf > 7 && uint8(buffer[i]) > 96) {
// case shift by xoring with 0x20
buffer[i] ^= 0x20;
}
hashValue >>= 4;
}
return string(buffer);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
}
/**
* @dev Parse a decimal string and returns the value as a `uint256`.
*
* Requirements:
* - The string must be formatted as `[0-9]*`
* - The result must fit into an `uint256` type
*/
function parseUint(string memory input) internal pure returns (uint256) {
return parseUint(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseUint} that parses a substring of `input` located between position `begin` (included) and
* `end` (excluded).
*
* Requirements:
* - The substring must be formatted as `[0-9]*`
* - The result must fit into an `uint256` type
*/
function parseUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) {
(bool success, uint256 value) = tryParseUint(input, begin, end);
if (!success) revert StringsInvalidChar();
return value;
}
/**
* @dev Variant of {parseUint-string} that returns false if the parsing fails because of an invalid character.
*
* NOTE: This function will revert if the result does not fit in a `uint256`.
*/
function tryParseUint(string memory input) internal pure returns (bool success, uint256 value) {
return _tryParseUintUncheckedBounds(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseUint-string-uint256-uint256} that returns false if the parsing fails because of an invalid
* character.
*
* NOTE: This function will revert if the result does not fit in a `uint256`.
*/
function tryParseUint(
string memory input,
uint256 begin,
uint256 end
) internal pure returns (bool success, uint256 value) {
if (end > bytes(input).length || begin > end) return (false, 0);
return _tryParseUintUncheckedBounds(input, begin, end);
}
/**
* @dev Implementation of {tryParseUint} that does not check bounds. Caller should make sure that
* `begin <= end <= input.length`. Other inputs would result in undefined behavior.
*/
function _tryParseUintUncheckedBounds(
string memory input,
uint256 begin,
uint256 end
) private pure returns (bool success, uint256 value) {
bytes memory buffer = bytes(input);
uint256 result = 0;
for (uint256 i = begin; i < end; ++i) {
uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i)));
if (chr > 9) return (false, 0);
result *= 10;
result += chr;
}
return (true, result);
}
/**
* @dev Parse a decimal string and returns the value as a `int256`.
*
* Requirements:
* - The string must be formatted as `[-+]?[0-9]*`
* - The result must fit in an `int256` type.
*/
function parseInt(string memory input) internal pure returns (int256) {
return parseInt(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseInt-string} that parses a substring of `input` located between position `begin` (included) and
* `end` (excluded).
*
* Requirements:
* - The substring must be formatted as `[-+]?[0-9]*`
* - The result must fit in an `int256` type.
*/
function parseInt(string memory input, uint256 begin, uint256 end) internal pure returns (int256) {
(bool success, int256 value) = tryParseInt(input, begin, end);
if (!success) revert StringsInvalidChar();
return value;
}
/**
* @dev Variant of {parseInt-string} that returns false if the parsing fails because of an invalid character or if
* the result does not fit in a `int256`.
*
* NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`.
*/
function tryParseInt(string memory input) internal pure returns (bool success, int256 value) {
return _tryParseIntUncheckedBounds(input, 0, bytes(input).length);
}
uint256 private constant ABS_MIN_INT256 = 2 ** 255;
/**
* @dev Variant of {parseInt-string-uint256-uint256} that returns false if the parsing fails because of an invalid
* character or if the result does not fit in a `int256`.
*
* NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`.
*/
function tryParseInt(
string memory input,
uint256 begin,
uint256 end
) internal pure returns (bool success, int256 value) {
if (end > bytes(input).length || begin > end) return (false, 0);
return _tryParseIntUncheckedBounds(input, begin, end);
}
/**
* @dev Implementation of {tryParseInt} that does not check bounds. Caller should make sure that
* `begin <= end <= input.length`. Other inputs would result in undefined behavior.
*/
function _tryParseIntUncheckedBounds(
string memory input,
uint256 begin,
uint256 end
) private pure returns (bool success, int256 value) {
bytes memory buffer = bytes(input);
// Check presence of a negative sign.
bytes1 sign = begin == end ? bytes1(0) : bytes1(_unsafeReadBytesOffset(buffer, begin)); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
bool positiveSign = sign == bytes1("+");
bool negativeSign = sign == bytes1("-");
uint256 offset = (positiveSign || negativeSign).toUint();
(bool absSuccess, uint256 absValue) = tryParseUint(input, begin + offset, end);
if (absSuccess && absValue < ABS_MIN_INT256) {
return (true, negativeSign ? -int256(absValue) : int256(absValue));
} else if (absSuccess && negativeSign && absValue == ABS_MIN_INT256) {
return (true, type(int256).min);
} else return (false, 0);
}
/**
* @dev Parse a hexadecimal string (with or without "0x" prefix), and returns the value as a `uint256`.
*
* Requirements:
* - The string must be formatted as `(0x)?[0-9a-fA-F]*`
* - The result must fit in an `uint256` type.
*/
function parseHexUint(string memory input) internal pure returns (uint256) {
return parseHexUint(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseHexUint} that parses a substring of `input` located between position `begin` (included) and
* `end` (excluded).
*
* Requirements:
* - The substring must be formatted as `(0x)?[0-9a-fA-F]*`
* - The result must fit in an `uint256` type.
*/
function parseHexUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) {
(bool success, uint256 value) = tryParseHexUint(input, begin, end);
if (!success) revert StringsInvalidChar();
return value;
}
/**
* @dev Variant of {parseHexUint-string} that returns false if the parsing fails because of an invalid character.
*
* NOTE: This function will revert if the result does not fit in a `uint256`.
*/
function tryParseHexUint(string memory input) internal pure returns (bool success, uint256 value) {
return _tryParseHexUintUncheckedBounds(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseHexUint-string-uint256-uint256} that returns false if the parsing fails because of an
* invalid character.
*
* NOTE: This function will revert if the result does not fit in a `uint256`.
*/
function tryParseHexUint(
string memory input,
uint256 begin,
uint256 end
) internal pure returns (bool success, uint256 value) {
if (end > bytes(input).length || begin > end) return (false, 0);
return _tryParseHexUintUncheckedBounds(input, begin, end);
}
/**
* @dev Implementation of {tryParseHexUint} that does not check bounds. Caller should make sure that
* `begin <= end <= input.length`. Other inputs would result in undefined behavior.
*/
function _tryParseHexUintUncheckedBounds(
string memory input,
uint256 begin,
uint256 end
) private pure returns (bool success, uint256 value) {
bytes memory buffer = bytes(input);
// skip 0x prefix if present
bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(buffer, begin)) == bytes2("0x"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
uint256 offset = hasPrefix.toUint() * 2;
uint256 result = 0;
for (uint256 i = begin + offset; i < end; ++i) {
uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i)));
if (chr > 15) return (false, 0);
result *= 16;
unchecked {
// Multiplying by 16 is equivalent to a shift of 4 bits (with additional overflow check).
// This guaratees that adding a value < 16 will not cause an overflow, hence the unchecked.
result += chr;
}
}
return (true, result);
}
/**
* @dev Parse a hexadecimal string (with or without "0x" prefix), and returns the value as an `address`.
*
* Requirements:
* - The string must be formatted as `(0x)?[0-9a-fA-F]{40}`
*/
function parseAddress(string memory input) internal pure returns (address) {
return parseAddress(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseAddress} that parses a substring of `input` located between position `begin` (included) and
* `end` (excluded).
*
* Requirements:
* - The substring must be formatted as `(0x)?[0-9a-fA-F]{40}`
*/
function parseAddress(string memory input, uint256 begin, uint256 end) internal pure returns (address) {
(bool success, address value) = tryParseAddress(input, begin, end);
if (!success) revert StringsInvalidAddressFormat();
return value;
}
/**
* @dev Variant of {parseAddress-string} that returns false if the parsing fails because the input is not a properly
* formatted address. See {parseAddress} requirements.
*/
function tryParseAddress(string memory input) internal pure returns (bool success, address value) {
return tryParseAddress(input, 0, bytes(input).length);
}
/**
* @dev Variant of {parseAddress-string-uint256-uint256} that returns false if the parsing fails because input is not a properly
* formatted address. See {parseAddress} requirements.
*/
function tryParseAddress(
string memory input,
uint256 begin,
uint256 end
) internal pure returns (bool success, address value) {
if (end > bytes(input).length || begin > end) return (false, address(0));
bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(bytes(input), begin)) == bytes2("0x"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty
uint256 expectedLength = 40 + hasPrefix.toUint() * 2;
// check that input is the correct length
if (end - begin == expectedLength) {
// length guarantees that this does not overflow, and value is at most type(uint160).max
(bool s, uint256 v) = _tryParseHexUintUncheckedBounds(input, begin, end);
return (s, address(uint160(v)));
} else {
return (false, address(0));
}
}
function _tryParseChr(bytes1 chr) private pure returns (uint8) {
uint8 value = uint8(chr);
// Try to parse `chr`:
// - Case 1: [0-9]
// - Case 2: [a-f]
// - Case 3: [A-F]
// - otherwise not supported
unchecked {
if (value > 47 && value < 58) value -= 48;
else if (value > 96 && value < 103) value -= 87;
else if (value > 64 && value < 71) value -= 55;
else return type(uint8).max;
}
return value;
}
/**
* @dev Reads a bytes32 from a bytes array without bounds checking.
*
* NOTE: making this function internal would mean it could be used with memory unsafe offset, and marking the
* assembly block as such would prevent some optimizations.
*/
function _unsafeReadBytesOffset(bytes memory buffer, uint256 offset) private pure returns (bytes32 value) {
// This is not memory safe in the general case, but all calls to this private function are within bounds.
assembly ("memory-safe") {
value := mload(add(buffer, add(0x20, offset)))
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC-721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
* a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC-721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or
* {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
* a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC-721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the address zero.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.20;
/**
* @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]
* ```solidity
* 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 Storage of the initializable contract.
*
* It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
* when using with upgradeable contracts.
*
* @custom:storage-location erc7201:openzeppelin.storage.Initializable
*/
struct InitializableStorage {
/**
* @dev Indicates that the contract has been initialized.
*/
uint64 _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool _initializing;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
/**
* @dev The contract is already initialized.
*/
error InvalidInitialization();
/**
* @dev The contract is not initializing.
*/
error NotInitializing();
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint64 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.
*
* Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
* number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
* production.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
// Cache values to avoid duplicated sloads
bool isTopLevelCall = !$._initializing;
uint64 initialized = $._initialized;
// Allowed calls:
// - initialSetup: the contract is not in the initializing state and no previous version was
// initialized
// - construction: the contract is initialized at version 1 (no reininitialization) and the
// current contract is just being deployed
bool initialSetup = initialized == 0 && isTopLevelCall;
bool construction = initialized == 1 && address(this).code.length == 0;
if (!initialSetup && !construction) {
revert InvalidInitialization();
}
$._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.
*
* 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.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* 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.
*
* WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint64 version) {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing || $._initialized >= version) {
revert InvalidInitialization();
}
$._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() {
_checkInitializing();
_;
}
/**
* @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
*/
function _checkInitializing() internal view virtual {
if (!_isInitializing()) {
revert NotInitializing();
}
}
/**
* @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.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing) {
revert InvalidInitialization();
}
if ($._initialized != type(uint64).max) {
$._initialized = type(uint64).max;
emit Initialized(type(uint64).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint64) {
return _getInitializableStorage()._initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _getInitializableStorage()._initializing;
}
/**
* @dev Returns a pointer to the storage namespace.
*/
// solhint-disable-next-line var-name-mixedcase
function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
assembly {
$.slot := INITIALIZABLE_STORAGE
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/extensions/ERC721Royalty.sol)
pragma solidity ^0.8.20;
import {ERC721Upgradeable} from "../ERC721Upgradeable.sol";
import {ERC2981Upgradeable} from "../../common/ERC2981Upgradeable.sol";
import {Initializable} from "../../../proxy/utils/Initializable.sol";
/**
* @dev Extension of ERC-721 with the ERC-2981 NFT Royalty Standard, a standardized way to retrieve royalty payment
* information.
*
* Royalty information can be specified globally for all token ids via {ERC2981-_setDefaultRoyalty}, and/or individually
* for specific token ids via {ERC2981-_setTokenRoyalty}. The latter takes precedence over the first.
*
* IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See
* https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the ERC. Marketplaces are expected to
* voluntarily pay royalties together with sales, but note that this standard is not yet widely supported.
*/
abstract contract ERC721RoyaltyUpgradeable is Initializable, ERC2981Upgradeable, ERC721Upgradeable {
function __ERC721Royalty_init() internal onlyInitializing {
}
function __ERC721Royalty_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Upgradeable, ERC2981Upgradeable) returns (bool) {
return super.supportsInterface(interfaceId);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/extensions/ERC721URIStorage.sol)
pragma solidity ^0.8.20;
import {ERC721Upgradeable} from "../ERC721Upgradeable.sol";
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
import {IERC4906} from "@openzeppelin/contracts/interfaces/IERC4906.sol";
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {Initializable} from "../../../proxy/utils/Initializable.sol";
/**
* @dev ERC-721 token with storage based token URI management.
*/
abstract contract ERC721URIStorageUpgradeable is Initializable, IERC4906, ERC721Upgradeable {
using Strings for uint256;
// Interface ID as defined in ERC-4906. This does not correspond to a traditional interface ID as ERC-4906 only
// defines events and does not include any external function.
bytes4 private constant ERC4906_INTERFACE_ID = bytes4(0x49064906);
/// @custom:storage-location erc7201:openzeppelin.storage.ERC721URIStorage
struct ERC721URIStorageStorage {
// Optional mapping for token URIs
mapping(uint256 tokenId => string) _tokenURIs;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC721URIStorage")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant ERC721URIStorageStorageLocation = 0x0542a41881ee128a365a727b282c86fa859579490b9bb45aab8503648c8e7900;
function _getERC721URIStorageStorage() private pure returns (ERC721URIStorageStorage storage $) {
assembly {
$.slot := ERC721URIStorageStorageLocation
}
}
function __ERC721URIStorage_init() internal onlyInitializing {
}
function __ERC721URIStorage_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Upgradeable, IERC165) returns (bool) {
return interfaceId == ERC4906_INTERFACE_ID || super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
ERC721URIStorageStorage storage $ = _getERC721URIStorageStorage();
_requireOwned(tokenId);
string memory _tokenURI = $._tokenURIs[tokenId];
string memory base = _baseURI();
// If there is no base URI, return the token URI.
if (bytes(base).length == 0) {
return _tokenURI;
}
// If both are set, concatenate the baseURI and tokenURI (via string.concat).
if (bytes(_tokenURI).length > 0) {
return string.concat(base, _tokenURI);
}
return super.tokenURI(tokenId);
}
/**
* @dev Sets `_tokenURI` as the tokenURI of `tokenId`.
*
* Emits {MetadataUpdate}.
*/
function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {
ERC721URIStorageStorage storage $ = _getERC721URIStorageStorage();
$._tokenURIs[tokenId] = _tokenURI;
emit MetadataUpdate(tokenId);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/extensions/ERC721Enumerable.sol)
pragma solidity ^0.8.20;
import {ERC721Upgradeable} from "../ERC721Upgradeable.sol";
import {IERC721Enumerable} from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {Initializable} from "../../../proxy/utils/Initializable.sol";
/**
* @dev This implements an optional extension of {ERC721} defined in the ERC that adds enumerability
* of all the token ids in the contract as well as all token ids owned by each account.
*
* CAUTION: {ERC721} extensions that implement custom `balanceOf` logic, such as {ERC721Consecutive},
* interfere with enumerability and should not be used together with {ERC721Enumerable}.
*/
abstract contract ERC721EnumerableUpgradeable is Initializable, ERC721Upgradeable, IERC721Enumerable {
/// @custom:storage-location erc7201:openzeppelin.storage.ERC721Enumerable
struct ERC721EnumerableStorage {
mapping(address owner => mapping(uint256 index => uint256)) _ownedTokens;
mapping(uint256 tokenId => uint256) _ownedTokensIndex;
uint256[] _allTokens;
mapping(uint256 tokenId => uint256) _allTokensIndex;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC721Enumerable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant ERC721EnumerableStorageLocation = 0x645e039705490088daad89bae25049a34f4a9072d398537b1ab2425f24cbed00;
function _getERC721EnumerableStorage() private pure returns (ERC721EnumerableStorage storage $) {
assembly {
$.slot := ERC721EnumerableStorageLocation
}
}
/**
* @dev An `owner`'s token query was out of bounds for `index`.
*
* NOTE: The owner being `address(0)` indicates a global out of bounds index.
*/
error ERC721OutOfBoundsIndex(address owner, uint256 index);
/**
* @dev Batch mint is not allowed.
*/
error ERC721EnumerableForbiddenBatchMint();
function __ERC721Enumerable_init() internal onlyInitializing {
}
function __ERC721Enumerable_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721Upgradeable) returns (bool) {
return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256) {
ERC721EnumerableStorage storage $ = _getERC721EnumerableStorage();
if (index >= balanceOf(owner)) {
revert ERC721OutOfBoundsIndex(owner, index);
}
return $._ownedTokens[owner][index];
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view virtual returns (uint256) {
ERC721EnumerableStorage storage $ = _getERC721EnumerableStorage();
return $._allTokens.length;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view virtual returns (uint256) {
ERC721EnumerableStorage storage $ = _getERC721EnumerableStorage();
if (index >= totalSupply()) {
revert ERC721OutOfBoundsIndex(address(0), index);
}
return $._allTokens[index];
}
/**
* @dev See {ERC721-_update}.
*/
function _update(address to, uint256 tokenId, address auth) internal virtual override returns (address) {
address previousOwner = super._update(to, tokenId, auth);
if (previousOwner == address(0)) {
_addTokenToAllTokensEnumeration(tokenId);
} else if (previousOwner != to) {
_removeTokenFromOwnerEnumeration(previousOwner, tokenId);
}
if (to == address(0)) {
_removeTokenFromAllTokensEnumeration(tokenId);
} else if (previousOwner != to) {
_addTokenToOwnerEnumeration(to, tokenId);
}
return previousOwner;
}
/**
* @dev Private function to add a token to this extension's ownership-tracking data structures.
* @param to address representing the new owner of the given token ID
* @param tokenId uint256 ID of the token to be added to the tokens list of the given address
*/
function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
ERC721EnumerableStorage storage $ = _getERC721EnumerableStorage();
uint256 length = balanceOf(to) - 1;
$._ownedTokens[to][length] = tokenId;
$._ownedTokensIndex[tokenId] = length;
}
/**
* @dev Private function to add a token to this extension's token tracking data structures.
* @param tokenId uint256 ID of the token to be added to the tokens list
*/
function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
ERC721EnumerableStorage storage $ = _getERC721EnumerableStorage();
$._allTokensIndex[tokenId] = $._allTokens.length;
$._allTokens.push(tokenId);
}
/**
* @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
* while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
* gas optimizations e.g. when performing a transfer operation (avoiding double writes).
* This has O(1) time complexity, but alters the order of the _ownedTokens array.
* @param from address representing the previous owner of the given token ID
* @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
*/
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
ERC721EnumerableStorage storage $ = _getERC721EnumerableStorage();
// To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = balanceOf(from);
uint256 tokenIndex = $._ownedTokensIndex[tokenId];
mapping(uint256 index => uint256) storage _ownedTokensByOwner = $._ownedTokens[from];
// When the token to delete is the last token, the swap operation is unnecessary
if (tokenIndex != lastTokenIndex) {
uint256 lastTokenId = _ownedTokensByOwner[lastTokenIndex];
_ownedTokensByOwner[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
$._ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
}
// This also deletes the contents at the last position of the array
delete $._ownedTokensIndex[tokenId];
delete _ownedTokensByOwner[lastTokenIndex];
}
/**
* @dev Private function to remove a token from this extension's token tracking data structures.
* This has O(1) time complexity, but alters the order of the _allTokens array.
* @param tokenId uint256 ID of the token to be removed from the tokens list
*/
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
ERC721EnumerableStorage storage $ = _getERC721EnumerableStorage();
// To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = $._allTokens.length - 1;
uint256 tokenIndex = $._allTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
// rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
// an 'if' statement (like in _removeTokenFromOwnerEnumeration)
uint256 lastTokenId = $._allTokens[lastTokenIndex];
$._allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
$._allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
// This also deletes the contents at the last position of the array
delete $._allTokensIndex[tokenId];
$._allTokens.pop();
}
/**
* See {ERC721-_increaseBalance}. We need that to account tokens that were minted in batch
*/
function _increaseBalance(address account, uint128 amount) internal virtual override {
if (amount > 0) {
revert ERC721EnumerableForbiddenBatchMint();
}
super._increaseBalance(account, amount);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.22;
import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
import {Initializable} from "./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.
*/
abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable {
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
address private immutable __self = address(this);
/**
* @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)`
* and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,
* while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string.
* If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must
* be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
* during an upgrade.
*/
string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";
/**
* @dev The call is from an unauthorized context.
*/
error UUPSUnauthorizedCallContext();
/**
* @dev The storage `slot` is unsupported as a UUID.
*/
error UUPSUnsupportedProxiableUUID(bytes32 slot);
/**
* @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 ERC-1967) 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 ERC-1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
* fail.
*/
modifier onlyProxy() {
_checkProxy();
_;
}
/**
* @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() {
_checkNotDelegated();
_;
}
function __UUPSUpgradeable_init() internal onlyInitializing {
}
function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
}
/**
* @dev Implementation of the ERC-1822 {proxiableUUID} function. This returns the storage slot used by the
* implementation. It is used to validate the implementation's compatibility when performing 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 notDelegated returns (bytes32) {
return ERC1967Utils.IMPLEMENTATION_SLOT;
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, data);
}
/**
* @dev Reverts if the execution is not performed via delegatecall or the execution
* context is not of a proxy with an ERC-1967 compliant implementation pointing to self.
* See {_onlyProxy}.
*/
function _checkProxy() internal view virtual {
if (
address(this) == __self || // Must be called through delegatecall
ERC1967Utils.getImplementation() != __self // Must be called through an active proxy
) {
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Reverts if the execution is performed via delegatecall.
* See {notDelegated}.
*/
function _checkNotDelegated() internal view virtual {
if (address(this) != __self) {
// Must not be called through delegatecall
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
/**
* @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call.
*
* As a security check, {proxiableUUID} is invoked in the new implementation, and the return value
* is expected to be the implementation slot in ERC-1967.
*
* Emits an {IERC1967-Upgraded} event.
*/
function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private {
try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) {
revert UUPSUnsupportedProxiableUUID(slot);
}
ERC1967Utils.upgradeToAndCall(newImplementation, data);
} catch {
// The implementation is not UUPS
revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../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.
*
* The initial owner is set to the address provided by the deployer. 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 {
/// @custom:storage-location erc7201:openzeppelin.storage.Ownable
struct OwnableStorage {
address _owner;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300;
function _getOwnableStorage() private pure returns (OwnableStorage storage $) {
assembly {
$.slot := OwnableStorageLocation
}
}
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
function __Ownable_init(address initialOwner) internal onlyInitializing {
__Ownable_init_unchained(initialOwner);
}
function __Ownable_init_unchained(address initialOwner) internal onlyInitializing {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @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) {
OwnableStorage storage $ = _getOwnableStorage();
return $._owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
OwnableStorage storage $ = _getOwnableStorage();
address oldOwner = $._owner;
$._owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;
import "./IKugleToken.sol";
// Interface for Heat and Carbon tokens
interface IRessourcesTokens is IKugleToken {
function mint(address _to, uint256 _amount) external;
function burn(address _from, uint256 _amount) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;
interface IReactor {
function initialize(address _guAddress, address _kugleNFT) external;
function blockGu(uint256 _amount) external;
function unblockGu(uint256 _amount) external;
function getBlockedGuByAddress(address _address) external view returns (uint256);
function PopCapNotReached(uint256 _amount) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
import {Panic} from "../Panic.sol";
import {SafeCast} from "./SafeCast.sol";
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Returns the addition of two unsigned integers, with an success flag (no overflow).
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an success flag (no overflow).
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an success flag (no overflow).
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
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 success flag (no division by zero).
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
*
* IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
* However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
* one branch when needed, making this function more expensive.
*/
function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {
unchecked {
// branchless ternary works because:
// b ^ (a ^ b) == a
// b ^ 0 == b
return b ^ ((a ^ b) * SafeCast.toUint(condition));
}
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a > b, a, b);
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(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 towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
Panic.panic(Panic.DIVISION_BY_ZERO);
}
// The following calculation ensures accurate ceiling division without overflow.
// Since a is non-zero, (a - 1) / b will not overflow.
// The largest possible result occurs when (a - 1) / b is type(uint256).max,
// but the largest value we can obtain is type(uint256).max - 1, which happens
// when a = type(uint256).max and b = 1.
unchecked {
return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);
}
}
/**
* @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
*
* 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²⁵⁶ and mod 2²⁵⁶ - 1, then use
// the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2²⁵⁶ + prod0.
uint256 prod0 = x * y; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0.
if (denominator <= prod1) {
Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
uint256 twos = denominator & (0 - denominator);
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²⁵⁶ / 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²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such
// that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv ≡ 1 mod 2⁴.
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⁸
inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶
inverse *= 2 - denominator * inverse; // inverse mod 2³²
inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴
inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸
inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶
// 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²⁵⁶. Since the preconditions guarantee that the outcome is
// less than 2²⁵⁶, 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;
}
}
/**
* @dev 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) {
return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);
}
/**
* @dev Calculate the modular multiplicative inverse of a number in Z/nZ.
*
* If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.
* If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.
*
* If the input value is not inversible, 0 is returned.
*
* NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the
* inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.
*/
function invMod(uint256 a, uint256 n) internal pure returns (uint256) {
unchecked {
if (n == 0) return 0;
// The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)
// Used to compute integers x and y such that: ax + ny = gcd(a, n).
// When the gcd is 1, then the inverse of a modulo n exists and it's x.
// ax + ny = 1
// ax = 1 + (-y)n
// ax ≡ 1 (mod n) # x is the inverse of a modulo n
// If the remainder is 0 the gcd is n right away.
uint256 remainder = a % n;
uint256 gcd = n;
// Therefore the initial coefficients are:
// ax + ny = gcd(a, n) = n
// 0a + 1n = n
int256 x = 0;
int256 y = 1;
while (remainder != 0) {
uint256 quotient = gcd / remainder;
(gcd, remainder) = (
// The old remainder is the next gcd to try.
remainder,
// Compute the next remainder.
// Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd
// where gcd is at most n (capped to type(uint256).max)
gcd - remainder * quotient
);
(x, y) = (
// Increment the coefficient of a.
y,
// Decrement the coefficient of n.
// Can overflow, but the result is casted to uint256 so that the
// next value of y is "wrapped around" to a value between 0 and n - 1.
x - y * int256(quotient)
);
}
if (gcd != 1) return 0; // No inverse exists.
return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.
}
}
/**
* @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.
*
* From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is
* prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that
* `a**(p-2)` is the modular multiplicative inverse of a in Fp.
*
* NOTE: this function does NOT check that `p` is a prime greater than `2`.
*/
function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {
unchecked {
return Math.modExp(a, p - 2, p);
}
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)
*
* Requirements:
* - modulus can't be zero
* - underlying staticcall to precompile must succeed
*
* IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make
* sure the chain you're using it on supports the precompiled contract for modular exponentiation
* at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,
* the underlying function will succeed given the lack of a revert, but the result may be incorrectly
* interpreted as 0.
*/
function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {
(bool success, uint256 result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).
* It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying
* to operate modulo 0 or if the underlying precompile reverted.
*
* IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain
* you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in
* https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack
* of a revert, but the result may be incorrectly interpreted as 0.
*/
function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {
if (m == 0) return (false, 0);
assembly ("memory-safe") {
let ptr := mload(0x40)
// | Offset | Content | Content (Hex) |
// |-----------|------------|--------------------------------------------------------------------|
// | 0x00:0x1f | size of b | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x20:0x3f | size of e | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x40:0x5f | size of m | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x60:0x7f | value of b | 0x<.............................................................b> |
// | 0x80:0x9f | value of e | 0x<.............................................................e> |
// | 0xa0:0xbf | value of m | 0x<.............................................................m> |
mstore(ptr, 0x20)
mstore(add(ptr, 0x20), 0x20)
mstore(add(ptr, 0x40), 0x20)
mstore(add(ptr, 0x60), b)
mstore(add(ptr, 0x80), e)
mstore(add(ptr, 0xa0), m)
// Given the result < m, it's guaranteed to fit in 32 bytes,
// so we can use the memory scratch space located at offset 0.
success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)
result := mload(0x00)
}
}
/**
* @dev Variant of {modExp} that supports inputs of arbitrary length.
*/
function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {
(bool success, bytes memory result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Variant of {tryModExp} that supports inputs of arbitrary length.
*/
function tryModExp(
bytes memory b,
bytes memory e,
bytes memory m
) internal view returns (bool success, bytes memory result) {
if (_zeroBytes(m)) return (false, new bytes(0));
uint256 mLen = m.length;
// Encode call args in result and move the free memory pointer
result = abi.encodePacked(b.length, e.length, mLen, b, e, m);
assembly ("memory-safe") {
let dataPtr := add(result, 0x20)
// Write result on top of args to avoid allocating extra memory.
success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)
// Overwrite the length.
// result.length > returndatasize() is guaranteed because returndatasize() == m.length
mstore(result, mLen)
// Set the memory pointer after the returned data.
mstore(0x40, add(dataPtr, mLen))
}
}
/**
* @dev Returns whether the provided byte array is zero.
*/
function _zeroBytes(bytes memory byteArray) private pure returns (bool) {
for (uint256 i = 0; i < byteArray.length; ++i) {
if (byteArray[i] != 0) {
return false;
}
}
return true;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* This method is based on Newton's method for computing square roots; the algorithm is restricted to only
* using integer operations.
*/
function sqrt(uint256 a) internal pure returns (uint256) {
unchecked {
// Take care of easy edge cases when a == 0 or a == 1
if (a <= 1) {
return a;
}
// In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a
// sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between
// the current value as `ε_n = | x_n - sqrt(a) |`.
//
// For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root
// of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is
// bigger than any uint256.
//
// By noticing that
// `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)`
// we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar
// to the msb function.
uint256 aa = a;
uint256 xn = 1;
if (aa >= (1 << 128)) {
aa >>= 128;
xn <<= 64;
}
if (aa >= (1 << 64)) {
aa >>= 64;
xn <<= 32;
}
if (aa >= (1 << 32)) {
aa >>= 32;
xn <<= 16;
}
if (aa >= (1 << 16)) {
aa >>= 16;
xn <<= 8;
}
if (aa >= (1 << 8)) {
aa >>= 8;
xn <<= 4;
}
if (aa >= (1 << 4)) {
aa >>= 4;
xn <<= 2;
}
if (aa >= (1 << 2)) {
xn <<= 1;
}
// We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1).
//
// We can refine our estimation by noticing that the middle of that interval minimizes the error.
// If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2).
// This is going to be our x_0 (and ε_0)
xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2)
// From here, Newton's method give us:
// x_{n+1} = (x_n + a / x_n) / 2
//
// One should note that:
// x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a
// = ((x_n² + a) / (2 * x_n))² - a
// = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a
// = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)
// = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²)
// = (x_n² - a)² / (2 * x_n)²
// = ((x_n² - a) / (2 * x_n))²
// ≥ 0
// Which proves that for all n ≥ 1, sqrt(a) ≤ x_n
//
// This gives us the proof of quadratic convergence of the sequence:
// ε_{n+1} = | x_{n+1} - sqrt(a) |
// = | (x_n + a / x_n) / 2 - sqrt(a) |
// = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |
// = | (x_n - sqrt(a))² / (2 * x_n) |
// = | ε_n² / (2 * x_n) |
// = ε_n² / | (2 * x_n) |
//
// For the first iteration, we have a special case where x_0 is known:
// ε_1 = ε_0² / | (2 * x_0) |
// ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))
// ≤ 2**(2*e-4) / (3 * 2**(e-1))
// ≤ 2**(e-3) / 3
// ≤ 2**(e-3-log2(3))
// ≤ 2**(e-4.5)
//
// For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n:
// ε_{n+1} = ε_n² / | (2 * x_n) |
// ≤ (2**(e-k))² / (2 * 2**(e-1))
// ≤ 2**(2*e-2*k) / 2**e
// ≤ 2**(e-2*k)
xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5) -- special case, see above
xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9) -- general case with k = 4.5
xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18) -- general case with k = 9
xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36) -- general case with k = 18
xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72) -- general case with k = 36
xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144) -- general case with k = 72
// Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision
// ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either
// sqrt(a) or sqrt(a) + 1.
return xn - SafeCast.toUint(xn > a / xn);
}
}
/**
* @dev Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
uint256 exp;
unchecked {
exp = 128 * SafeCast.toUint(value > (1 << 128) - 1);
value >>= exp;
result += exp;
exp = 64 * SafeCast.toUint(value > (1 << 64) - 1);
value >>= exp;
result += exp;
exp = 32 * SafeCast.toUint(value > (1 << 32) - 1);
value >>= exp;
result += exp;
exp = 16 * SafeCast.toUint(value > (1 << 16) - 1);
value >>= exp;
result += exp;
exp = 8 * SafeCast.toUint(value > (1 << 8) - 1);
value >>= exp;
result += exp;
exp = 4 * SafeCast.toUint(value > (1 << 4) - 1);
value >>= exp;
result += exp;
exp = 2 * SafeCast.toUint(value > (1 << 2) - 1);
value >>= exp;
result += exp;
result += SafeCast.toUint(value > 1);
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
uint256 isGt;
unchecked {
isGt = SafeCast.toUint(value > (1 << 128) - 1);
value >>= isGt * 128;
result += isGt * 16;
isGt = SafeCast.toUint(value > (1 << 64) - 1);
value >>= isGt * 64;
result += isGt * 8;
isGt = SafeCast.toUint(value > (1 << 32) - 1);
value >>= isGt * 32;
result += isGt * 4;
isGt = SafeCast.toUint(value > (1 << 16) - 1);
value >>= isGt * 16;
result += isGt * 2;
result += SafeCast.toUint(value > (1 << 8) - 1);
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.20;
/**
* @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeCast {
/**
* @dev Value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);
/**
* @dev An int value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedIntToUint(int256 value);
/**
* @dev Value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);
/**
* @dev An uint value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedUintToInt(uint256 value);
/**
* @dev Returns the downcasted uint248 from uint256, reverting on
* overflow (when the input is greater than largest uint248).
*
* Counterpart to Solidity's `uint248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toUint248(uint256 value) internal pure returns (uint248) {
if (value > type(uint248).max) {
revert SafeCastOverflowedUintDowncast(248, value);
}
return uint248(value);
}
/**
* @dev Returns the downcasted uint240 from uint256, reverting on
* overflow (when the input is greater than largest uint240).
*
* Counterpart to Solidity's `uint240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toUint240(uint256 value) internal pure returns (uint240) {
if (value > type(uint240).max) {
revert SafeCastOverflowedUintDowncast(240, value);
}
return uint240(value);
}
/**
* @dev Returns the downcasted uint232 from uint256, reverting on
* overflow (when the input is greater than largest uint232).
*
* Counterpart to Solidity's `uint232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toUint232(uint256 value) internal pure returns (uint232) {
if (value > type(uint232).max) {
revert SafeCastOverflowedUintDowncast(232, value);
}
return uint232(value);
}
/**
* @dev Returns the downcasted uint224 from uint256, reverting on
* overflow (when the input is greater than largest uint224).
*
* Counterpart to Solidity's `uint224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toUint224(uint256 value) internal pure returns (uint224) {
if (value > type(uint224).max) {
revert SafeCastOverflowedUintDowncast(224, value);
}
return uint224(value);
}
/**
* @dev Returns the downcasted uint216 from uint256, reverting on
* overflow (when the input is greater than largest uint216).
*
* Counterpart to Solidity's `uint216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toUint216(uint256 value) internal pure returns (uint216) {
if (value > type(uint216).max) {
revert SafeCastOverflowedUintDowncast(216, value);
}
return uint216(value);
}
/**
* @dev Returns the downcasted uint208 from uint256, reverting on
* overflow (when the input is greater than largest uint208).
*
* Counterpart to Solidity's `uint208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toUint208(uint256 value) internal pure returns (uint208) {
if (value > type(uint208).max) {
revert SafeCastOverflowedUintDowncast(208, value);
}
return uint208(value);
}
/**
* @dev Returns the downcasted uint200 from uint256, reverting on
* overflow (when the input is greater than largest uint200).
*
* Counterpart to Solidity's `uint200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toUint200(uint256 value) internal pure returns (uint200) {
if (value > type(uint200).max) {
revert SafeCastOverflowedUintDowncast(200, value);
}
return uint200(value);
}
/**
* @dev Returns the downcasted uint192 from uint256, reverting on
* overflow (when the input is greater than largest uint192).
*
* Counterpart to Solidity's `uint192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toUint192(uint256 value) internal pure returns (uint192) {
if (value > type(uint192).max) {
revert SafeCastOverflowedUintDowncast(192, value);
}
return uint192(value);
}
/**
* @dev Returns the downcasted uint184 from uint256, reverting on
* overflow (when the input is greater than largest uint184).
*
* Counterpart to Solidity's `uint184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toUint184(uint256 value) internal pure returns (uint184) {
if (value > type(uint184).max) {
revert SafeCastOverflowedUintDowncast(184, value);
}
return uint184(value);
}
/**
* @dev Returns the downcasted uint176 from uint256, reverting on
* overflow (when the input is greater than largest uint176).
*
* Counterpart to Solidity's `uint176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toUint176(uint256 value) internal pure returns (uint176) {
if (value > type(uint176).max) {
revert SafeCastOverflowedUintDowncast(176, value);
}
return uint176(value);
}
/**
* @dev Returns the downcasted uint168 from uint256, reverting on
* overflow (when the input is greater than largest uint168).
*
* Counterpart to Solidity's `uint168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toUint168(uint256 value) internal pure returns (uint168) {
if (value > type(uint168).max) {
revert SafeCastOverflowedUintDowncast(168, value);
}
return uint168(value);
}
/**
* @dev Returns the downcasted uint160 from uint256, reverting on
* overflow (when the input is greater than largest uint160).
*
* Counterpart to Solidity's `uint160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toUint160(uint256 value) internal pure returns (uint160) {
if (value > type(uint160).max) {
revert SafeCastOverflowedUintDowncast(160, value);
}
return uint160(value);
}
/**
* @dev Returns the downcasted uint152 from uint256, reverting on
* overflow (when the input is greater than largest uint152).
*
* Counterpart to Solidity's `uint152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toUint152(uint256 value) internal pure returns (uint152) {
if (value > type(uint152).max) {
revert SafeCastOverflowedUintDowncast(152, value);
}
return uint152(value);
}
/**
* @dev Returns the downcasted uint144 from uint256, reverting on
* overflow (when the input is greater than largest uint144).
*
* Counterpart to Solidity's `uint144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toUint144(uint256 value) internal pure returns (uint144) {
if (value > type(uint144).max) {
revert SafeCastOverflowedUintDowncast(144, value);
}
return uint144(value);
}
/**
* @dev Returns the downcasted uint136 from uint256, reverting on
* overflow (when the input is greater than largest uint136).
*
* Counterpart to Solidity's `uint136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toUint136(uint256 value) internal pure returns (uint136) {
if (value > type(uint136).max) {
revert SafeCastOverflowedUintDowncast(136, value);
}
return uint136(value);
}
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toUint128(uint256 value) internal pure returns (uint128) {
if (value > type(uint128).max) {
revert SafeCastOverflowedUintDowncast(128, value);
}
return uint128(value);
}
/**
* @dev Returns the downcasted uint120 from uint256, reverting on
* overflow (when the input is greater than largest uint120).
*
* Counterpart to Solidity's `uint120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toUint120(uint256 value) internal pure returns (uint120) {
if (value > type(uint120).max) {
revert SafeCastOverflowedUintDowncast(120, value);
}
return uint120(value);
}
/**
* @dev Returns the downcasted uint112 from uint256, reverting on
* overflow (when the input is greater than largest uint112).
*
* Counterpart to Solidity's `uint112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toUint112(uint256 value) internal pure returns (uint112) {
if (value > type(uint112).max) {
revert SafeCastOverflowedUintDowncast(112, value);
}
return uint112(value);
}
/**
* @dev Returns the downcasted uint104 from uint256, reverting on
* overflow (when the input is greater than largest uint104).
*
* Counterpart to Solidity's `uint104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toUint104(uint256 value) internal pure returns (uint104) {
if (value > type(uint104).max) {
revert SafeCastOverflowedUintDowncast(104, value);
}
return uint104(value);
}
/**
* @dev Returns the downcasted uint96 from uint256, reverting on
* overflow (when the input is greater than largest uint96).
*
* Counterpart to Solidity's `uint96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toUint96(uint256 value) internal pure returns (uint96) {
if (value > type(uint96).max) {
revert SafeCastOverflowedUintDowncast(96, value);
}
return uint96(value);
}
/**
* @dev Returns the downcasted uint88 from uint256, reverting on
* overflow (when the input is greater than largest uint88).
*
* Counterpart to Solidity's `uint88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toUint88(uint256 value) internal pure returns (uint88) {
if (value > type(uint88).max) {
revert SafeCastOverflowedUintDowncast(88, value);
}
return uint88(value);
}
/**
* @dev Returns the downcasted uint80 from uint256, reverting on
* overflow (when the input is greater than largest uint80).
*
* Counterpart to Solidity's `uint80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toUint80(uint256 value) internal pure returns (uint80) {
if (value > type(uint80).max) {
revert SafeCastOverflowedUintDowncast(80, value);
}
return uint80(value);
}
/**
* @dev Returns the downcasted uint72 from uint256, reverting on
* overflow (when the input is greater than largest uint72).
*
* Counterpart to Solidity's `uint72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toUint72(uint256 value) internal pure returns (uint72) {
if (value > type(uint72).max) {
revert SafeCastOverflowedUintDowncast(72, value);
}
return uint72(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toUint64(uint256 value) internal pure returns (uint64) {
if (value > type(uint64).max) {
revert SafeCastOverflowedUintDowncast(64, value);
}
return uint64(value);
}
/**
* @dev Returns the downcasted uint56 from uint256, reverting on
* overflow (when the input is greater than largest uint56).
*
* Counterpart to Solidity's `uint56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toUint56(uint256 value) internal pure returns (uint56) {
if (value > type(uint56).max) {
revert SafeCastOverflowedUintDowncast(56, value);
}
return uint56(value);
}
/**
* @dev Returns the downcasted uint48 from uint256, reverting on
* overflow (when the input is greater than largest uint48).
*
* Counterpart to Solidity's `uint48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toUint48(uint256 value) internal pure returns (uint48) {
if (value > type(uint48).max) {
revert SafeCastOverflowedUintDowncast(48, value);
}
return uint48(value);
}
/**
* @dev Returns the downcasted uint40 from uint256, reverting on
* overflow (when the input is greater than largest uint40).
*
* Counterpart to Solidity's `uint40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toUint40(uint256 value) internal pure returns (uint40) {
if (value > type(uint40).max) {
revert SafeCastOverflowedUintDowncast(40, value);
}
return uint40(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toUint32(uint256 value) internal pure returns (uint32) {
if (value > type(uint32).max) {
revert SafeCastOverflowedUintDowncast(32, value);
}
return uint32(value);
}
/**
* @dev Returns the downcasted uint24 from uint256, reverting on
* overflow (when the input is greater than largest uint24).
*
* Counterpart to Solidity's `uint24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toUint24(uint256 value) internal pure returns (uint24) {
if (value > type(uint24).max) {
revert SafeCastOverflowedUintDowncast(24, value);
}
return uint24(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toUint16(uint256 value) internal pure returns (uint16) {
if (value > type(uint16).max) {
revert SafeCastOverflowedUintDowncast(16, value);
}
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toUint8(uint256 value) internal pure returns (uint8) {
if (value > type(uint8).max) {
revert SafeCastOverflowedUintDowncast(8, value);
}
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*/
function toUint256(int256 value) internal pure returns (uint256) {
if (value < 0) {
revert SafeCastOverflowedIntToUint(value);
}
return uint256(value);
}
/**
* @dev Returns the downcasted int248 from int256, reverting on
* overflow (when the input is less than smallest int248 or
* greater than largest int248).
*
* Counterpart to Solidity's `int248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(248, value);
}
}
/**
* @dev Returns the downcasted int240 from int256, reverting on
* overflow (when the input is less than smallest int240 or
* greater than largest int240).
*
* Counterpart to Solidity's `int240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(240, value);
}
}
/**
* @dev Returns the downcasted int232 from int256, reverting on
* overflow (when the input is less than smallest int232 or
* greater than largest int232).
*
* Counterpart to Solidity's `int232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(232, value);
}
}
/**
* @dev Returns the downcasted int224 from int256, reverting on
* overflow (when the input is less than smallest int224 or
* greater than largest int224).
*
* Counterpart to Solidity's `int224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(224, value);
}
}
/**
* @dev Returns the downcasted int216 from int256, reverting on
* overflow (when the input is less than smallest int216 or
* greater than largest int216).
*
* Counterpart to Solidity's `int216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(216, value);
}
}
/**
* @dev Returns the downcasted int208 from int256, reverting on
* overflow (when the input is less than smallest int208 or
* greater than largest int208).
*
* Counterpart to Solidity's `int208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(208, value);
}
}
/**
* @dev Returns the downcasted int200 from int256, reverting on
* overflow (when the input is less than smallest int200 or
* greater than largest int200).
*
* Counterpart to Solidity's `int200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(200, value);
}
}
/**
* @dev Returns the downcasted int192 from int256, reverting on
* overflow (when the input is less than smallest int192 or
* greater than largest int192).
*
* Counterpart to Solidity's `int192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(192, value);
}
}
/**
* @dev Returns the downcasted int184 from int256, reverting on
* overflow (when the input is less than smallest int184 or
* greater than largest int184).
*
* Counterpart to Solidity's `int184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(184, value);
}
}
/**
* @dev Returns the downcasted int176 from int256, reverting on
* overflow (when the input is less than smallest int176 or
* greater than largest int176).
*
* Counterpart to Solidity's `int176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(176, value);
}
}
/**
* @dev Returns the downcasted int168 from int256, reverting on
* overflow (when the input is less than smallest int168 or
* greater than largest int168).
*
* Counterpart to Solidity's `int168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(168, value);
}
}
/**
* @dev Returns the downcasted int160 from int256, reverting on
* overflow (when the input is less than smallest int160 or
* greater than largest int160).
*
* Counterpart to Solidity's `int160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(160, value);
}
}
/**
* @dev Returns the downcasted int152 from int256, reverting on
* overflow (when the input is less than smallest int152 or
* greater than largest int152).
*
* Counterpart to Solidity's `int152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(152, value);
}
}
/**
* @dev Returns the downcasted int144 from int256, reverting on
* overflow (when the input is less than smallest int144 or
* greater than largest int144).
*
* Counterpart to Solidity's `int144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(144, value);
}
}
/**
* @dev Returns the downcasted int136 from int256, reverting on
* overflow (when the input is less than smallest int136 or
* greater than largest int136).
*
* Counterpart to Solidity's `int136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(136, value);
}
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(128, value);
}
}
/**
* @dev Returns the downcasted int120 from int256, reverting on
* overflow (when the input is less than smallest int120 or
* greater than largest int120).
*
* Counterpart to Solidity's `int120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(120, value);
}
}
/**
* @dev Returns the downcasted int112 from int256, reverting on
* overflow (when the input is less than smallest int112 or
* greater than largest int112).
*
* Counterpart to Solidity's `int112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(112, value);
}
}
/**
* @dev Returns the downcasted int104 from int256, reverting on
* overflow (when the input is less than smallest int104 or
* greater than largest int104).
*
* Counterpart to Solidity's `int104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(104, value);
}
}
/**
* @dev Returns the downcasted int96 from int256, reverting on
* overflow (when the input is less than smallest int96 or
* greater than largest int96).
*
* Counterpart to Solidity's `int96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(96, value);
}
}
/**
* @dev Returns the downcasted int88 from int256, reverting on
* overflow (when the input is less than smallest int88 or
* greater than largest int88).
*
* Counterpart to Solidity's `int88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(88, value);
}
}
/**
* @dev Returns the downcasted int80 from int256, reverting on
* overflow (when the input is less than smallest int80 or
* greater than largest int80).
*
* Counterpart to Solidity's `int80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(80, value);
}
}
/**
* @dev Returns the downcasted int72 from int256, reverting on
* overflow (when the input is less than smallest int72 or
* greater than largest int72).
*
* Counterpart to Solidity's `int72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(72, value);
}
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(64, value);
}
}
/**
* @dev Returns the downcasted int56 from int256, reverting on
* overflow (when the input is less than smallest int56 or
* greater than largest int56).
*
* Counterpart to Solidity's `int56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(56, value);
}
}
/**
* @dev Returns the downcasted int48 from int256, reverting on
* overflow (when the input is less than smallest int48 or
* greater than largest int48).
*
* Counterpart to Solidity's `int48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(48, value);
}
}
/**
* @dev Returns the downcasted int40 from int256, reverting on
* overflow (when the input is less than smallest int40 or
* greater than largest int40).
*
* Counterpart to Solidity's `int40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(40, value);
}
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(32, value);
}
}
/**
* @dev Returns the downcasted int24 from int256, reverting on
* overflow (when the input is less than smallest int24 or
* greater than largest int24).
*
* Counterpart to Solidity's `int24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(24, value);
}
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(16, value);
}
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(8, value);
}
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
if (value > uint256(type(int256).max)) {
revert SafeCastOverflowedUintToInt(value);
}
return int256(value);
}
/**
* @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
*/
function toUint(bool b) internal pure returns (uint256 u) {
assembly ("memory-safe") {
u := iszero(iszero(b))
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.20;
import {SafeCast} from "./SafeCast.sol";
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
*
* IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
* However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
* one branch when needed, making this function more expensive.
*/
function ternary(bool condition, int256 a, int256 b) internal pure returns (int256) {
unchecked {
// branchless ternary works because:
// b ^ (a ^ b) == a
// b ^ 0 == b
return b ^ ((a ^ b) * int256(SafeCast.toUint(condition)));
}
}
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return ternary(a > b, a, b);
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return ternary(a < b, a, b);
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// Formula from the "Bit Twiddling Hacks" by Sean Eron Anderson.
// Since `n` is a signed integer, the generated bytecode will use the SAR opcode to perform the right shift,
// taking advantage of the most significant (or "sign" bit) in two's complement representation.
// This opcode adds new most significant bits set to the value of the previous most significant bit. As a result,
// the mask will either be `bytes32(0)` (if n is positive) or `~bytes32(0)` (if n is negative).
int256 mask = n >> 255;
// A `bytes32(0)` mask leaves the input unchanged, while a `~bytes32(0)` mask complements it.
return uint256((n + mask) ^ mask);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/ERC721.sol)
pragma solidity ^0.8.20;
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import {IERC721Metadata} from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import {ERC721Utils} from "@openzeppelin/contracts/token/ERC721/utils/ERC721Utils.sol";
import {ContextUpgradeable} from "../../utils/ContextUpgradeable.sol";
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {ERC165Upgradeable} from "../../utils/introspection/ERC165Upgradeable.sol";
import {IERC721Errors} from "@openzeppelin/contracts/interfaces/draft-IERC6093.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC-721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
abstract contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721, IERC721Metadata, IERC721Errors {
using Strings for uint256;
/// @custom:storage-location erc7201:openzeppelin.storage.ERC721
struct ERC721Storage {
// Token name
string _name;
// Token symbol
string _symbol;
mapping(uint256 tokenId => address) _owners;
mapping(address owner => uint256) _balances;
mapping(uint256 tokenId => address) _tokenApprovals;
mapping(address owner => mapping(address operator => bool)) _operatorApprovals;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC721")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant ERC721StorageLocation = 0x80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab0079300;
function _getERC721Storage() private pure returns (ERC721Storage storage $) {
assembly {
$.slot := ERC721StorageLocation
}
}
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing {
__ERC721_init_unchained(name_, symbol_);
}
function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {
ERC721Storage storage $ = _getERC721Storage();
$._name = name_;
$._symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual returns (uint256) {
ERC721Storage storage $ = _getERC721Storage();
if (owner == address(0)) {
revert ERC721InvalidOwner(address(0));
}
return $._balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual returns (address) {
return _requireOwned(tokenId);
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual returns (string memory) {
ERC721Storage storage $ = _getERC721Storage();
return $._name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual returns (string memory) {
ERC721Storage storage $ = _getERC721Storage();
return $._symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual returns (string memory) {
_requireOwned(tokenId);
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string.concat(baseURI, tokenId.toString()) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overridden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual {
_approve(to, tokenId, _msgSender());
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual returns (address) {
_requireOwned(tokenId);
return _getApproved(tokenId);
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
ERC721Storage storage $ = _getERC721Storage();
return $._operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(address from, address to, uint256 tokenId) public virtual {
if (to == address(0)) {
revert ERC721InvalidReceiver(address(0));
}
// Setting an "auth" arguments enables the `_isAuthorized` check which verifies that the token exists
// (from != 0). Therefore, it is not needed to verify that the return value is not 0 here.
address previousOwner = _update(to, tokenId, _msgSender());
if (previousOwner != from) {
revert ERC721IncorrectOwner(from, tokenId, previousOwner);
}
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) public {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual {
transferFrom(from, to, tokenId);
ERC721Utils.checkOnERC721Received(_msgSender(), from, to, tokenId, data);
}
/**
* @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist
*
* IMPORTANT: Any overrides to this function that add ownership of tokens not tracked by the
* core ERC-721 logic MUST be matched with the use of {_increaseBalance} to keep balances
* consistent with ownership. The invariant to preserve is that for any address `a` the value returned by
* `balanceOf(a)` must be equal to the number of tokens such that `_ownerOf(tokenId)` is `a`.
*/
function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
ERC721Storage storage $ = _getERC721Storage();
return $._owners[tokenId];
}
/**
* @dev Returns the approved address for `tokenId`. Returns 0 if `tokenId` is not minted.
*/
function _getApproved(uint256 tokenId) internal view virtual returns (address) {
ERC721Storage storage $ = _getERC721Storage();
return $._tokenApprovals[tokenId];
}
/**
* @dev Returns whether `spender` is allowed to manage `owner`'s tokens, or `tokenId` in
* particular (ignoring whether it is owned by `owner`).
*
* WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this
* assumption.
*/
function _isAuthorized(address owner, address spender, uint256 tokenId) internal view virtual returns (bool) {
return
spender != address(0) &&
(owner == spender || isApprovedForAll(owner, spender) || _getApproved(tokenId) == spender);
}
/**
* @dev Checks if `spender` can operate on `tokenId`, assuming the provided `owner` is the actual owner.
* Reverts if:
* - `spender` does not have approval from `owner` for `tokenId`.
* - `spender` does not have approval to manage all of `owner`'s assets.
*
* WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this
* assumption.
*/
function _checkAuthorized(address owner, address spender, uint256 tokenId) internal view virtual {
if (!_isAuthorized(owner, spender, tokenId)) {
if (owner == address(0)) {
revert ERC721NonexistentToken(tokenId);
} else {
revert ERC721InsufficientApproval(spender, tokenId);
}
}
}
/**
* @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override.
*
* NOTE: the value is limited to type(uint128).max. This protect against _balance overflow. It is unrealistic that
* a uint256 would ever overflow from increments when these increments are bounded to uint128 values.
*
* WARNING: Increasing an account's balance using this function tends to be paired with an override of the
* {_ownerOf} function to resolve the ownership of the corresponding tokens so that balances and ownership
* remain consistent with one another.
*/
function _increaseBalance(address account, uint128 value) internal virtual {
ERC721Storage storage $ = _getERC721Storage();
unchecked {
$._balances[account] += value;
}
}
/**
* @dev Transfers `tokenId` from its current owner to `to`, or alternatively mints (or burns) if the current owner
* (or `to`) is the zero address. Returns the owner of the `tokenId` before the update.
*
* The `auth` argument is optional. If the value passed is non 0, then this function will check that
* `auth` is either the owner of the token, or approved to operate on the token (by the owner).
*
* Emits a {Transfer} event.
*
* NOTE: If overriding this function in a way that tracks balances, see also {_increaseBalance}.
*/
function _update(address to, uint256 tokenId, address auth) internal virtual returns (address) {
ERC721Storage storage $ = _getERC721Storage();
address from = _ownerOf(tokenId);
// Perform (optional) operator check
if (auth != address(0)) {
_checkAuthorized(from, auth, tokenId);
}
// Execute the update
if (from != address(0)) {
// Clear approval. No need to re-authorize or emit the Approval event
_approve(address(0), tokenId, address(0), false);
unchecked {
$._balances[from] -= 1;
}
}
if (to != address(0)) {
unchecked {
$._balances[to] += 1;
}
}
$._owners[tokenId] = to;
emit Transfer(from, to, tokenId);
return from;
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal {
if (to == address(0)) {
revert ERC721InvalidReceiver(address(0));
}
address previousOwner = _update(to, tokenId, address(0));
if (previousOwner != address(0)) {
revert ERC721InvalidSender(address(0));
}
}
/**
* @dev Mints `tokenId`, transfers it to `to` and checks for `to` acceptance.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual {
_mint(to, tokenId);
ERC721Utils.checkOnERC721Received(_msgSender(), address(0), to, tokenId, data);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
* This is an internal function that does not check if the sender is authorized to operate on the token.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal {
address previousOwner = _update(address(0), tokenId, address(0));
if (previousOwner == address(0)) {
revert ERC721NonexistentToken(tokenId);
}
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(address from, address to, uint256 tokenId) internal {
if (to == address(0)) {
revert ERC721InvalidReceiver(address(0));
}
address previousOwner = _update(to, tokenId, address(0));
if (previousOwner == address(0)) {
revert ERC721NonexistentToken(tokenId);
} else if (previousOwner != from) {
revert ERC721IncorrectOwner(from, tokenId, previousOwner);
}
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking that contract recipients
* are aware of the ERC-721 standard to prevent tokens from being forever locked.
*
* `data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is like {safeTransferFrom} in the sense that it invokes
* {IERC721Receiver-onERC721Received} on the receiver, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `tokenId` token must exist and be owned by `from`.
* - `to` cannot be the zero address.
* - `from` cannot be the zero address.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(address from, address to, uint256 tokenId) internal {
_safeTransfer(from, to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeTransfer-address-address-uint256-}[`_safeTransfer`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual {
_transfer(from, to, tokenId);
ERC721Utils.checkOnERC721Received(_msgSender(), from, to, tokenId, data);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* The `auth` argument is optional. If the value passed is non 0, then this function will check that `auth` is
* either the owner of the token, or approved to operate on all tokens held by this owner.
*
* Emits an {Approval} event.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address to, uint256 tokenId, address auth) internal {
_approve(to, tokenId, auth, true);
}
/**
* @dev Variant of `_approve` with an optional flag to enable or disable the {Approval} event. The event is not
* emitted in the context of transfers.
*/
function _approve(address to, uint256 tokenId, address auth, bool emitEvent) internal virtual {
ERC721Storage storage $ = _getERC721Storage();
// Avoid reading the owner unless necessary
if (emitEvent || auth != address(0)) {
address owner = _requireOwned(tokenId);
// We do not use _isAuthorized because single-token approvals should not be able to call approve
if (auth != address(0) && owner != auth && !isApprovedForAll(owner, auth)) {
revert ERC721InvalidApprover(auth);
}
if (emitEvent) {
emit Approval(owner, to, tokenId);
}
}
$._tokenApprovals[tokenId] = to;
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Requirements:
* - operator can't be the address zero.
*
* Emits an {ApprovalForAll} event.
*/
function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
ERC721Storage storage $ = _getERC721Storage();
if (operator == address(0)) {
revert ERC721InvalidOperator(operator);
}
$._operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Reverts if the `tokenId` doesn't have a current owner (it hasn't been minted, or it has been burned).
* Returns the owner.
*
* Overrides to ownership logic should be done to {_ownerOf}.
*/
function _requireOwned(uint256 tokenId) internal view returns (address) {
address owner = _ownerOf(tokenId);
if (owner == address(0)) {
revert ERC721NonexistentToken(tokenId);
}
return owner;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/common/ERC2981.sol)
pragma solidity ^0.8.20;
import {IERC2981} from "@openzeppelin/contracts/interfaces/IERC2981.sol";
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {ERC165Upgradeable} from "../../utils/introspection/ERC165Upgradeable.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the NFT Royalty Standard, a standardized way to retrieve royalty payment information.
*
* Royalty information can be specified globally for all token ids via {_setDefaultRoyalty}, and/or individually for
* specific token ids via {_setTokenRoyalty}. The latter takes precedence over the first.
*
* Royalty is specified as a fraction of sale price. {_feeDenominator} is overridable but defaults to 10000, meaning the
* fee is specified in basis points by default.
*
* IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See
* https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the ERC. Marketplaces are expected to
* voluntarily pay royalties together with sales, but note that this standard is not yet widely supported.
*/
abstract contract ERC2981Upgradeable is Initializable, IERC2981, ERC165Upgradeable {
struct RoyaltyInfo {
address receiver;
uint96 royaltyFraction;
}
/// @custom:storage-location erc7201:openzeppelin.storage.ERC2981
struct ERC2981Storage {
RoyaltyInfo _defaultRoyaltyInfo;
mapping(uint256 tokenId => RoyaltyInfo) _tokenRoyaltyInfo;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC2981")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant ERC2981StorageLocation = 0xdaedc9ab023613a7caf35e703657e986ccfad7e3eb0af93a2853f8d65dd86b00;
function _getERC2981Storage() private pure returns (ERC2981Storage storage $) {
assembly {
$.slot := ERC2981StorageLocation
}
}
/**
* @dev The default royalty set is invalid (eg. (numerator / denominator) >= 1).
*/
error ERC2981InvalidDefaultRoyalty(uint256 numerator, uint256 denominator);
/**
* @dev The default royalty receiver is invalid.
*/
error ERC2981InvalidDefaultRoyaltyReceiver(address receiver);
/**
* @dev The royalty set for an specific `tokenId` is invalid (eg. (numerator / denominator) >= 1).
*/
error ERC2981InvalidTokenRoyalty(uint256 tokenId, uint256 numerator, uint256 denominator);
/**
* @dev The royalty receiver for `tokenId` is invalid.
*/
error ERC2981InvalidTokenRoyaltyReceiver(uint256 tokenId, address receiver);
function __ERC2981_init() internal onlyInitializing {
}
function __ERC2981_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC165Upgradeable) returns (bool) {
return interfaceId == type(IERC2981).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @inheritdoc IERC2981
*/
function royaltyInfo(
uint256 tokenId,
uint256 salePrice
) public view virtual returns (address receiver, uint256 amount) {
ERC2981Storage storage $ = _getERC2981Storage();
RoyaltyInfo storage _royaltyInfo = $._tokenRoyaltyInfo[tokenId];
address royaltyReceiver = _royaltyInfo.receiver;
uint96 royaltyFraction = _royaltyInfo.royaltyFraction;
if (royaltyReceiver == address(0)) {
royaltyReceiver = $._defaultRoyaltyInfo.receiver;
royaltyFraction = $._defaultRoyaltyInfo.royaltyFraction;
}
uint256 royaltyAmount = (salePrice * royaltyFraction) / _feeDenominator();
return (royaltyReceiver, royaltyAmount);
}
/**
* @dev The denominator with which to interpret the fee set in {_setTokenRoyalty} and {_setDefaultRoyalty} as a
* fraction of the sale price. Defaults to 10000 so fees are expressed in basis points, but may be customized by an
* override.
*/
function _feeDenominator() internal pure virtual returns (uint96) {
return 10000;
}
/**
* @dev Sets the royalty information that all ids in this contract will default to.
*
* Requirements:
*
* - `receiver` cannot be the zero address.
* - `feeNumerator` cannot be greater than the fee denominator.
*/
function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual {
ERC2981Storage storage $ = _getERC2981Storage();
uint256 denominator = _feeDenominator();
if (feeNumerator > denominator) {
// Royalty fee will exceed the sale price
revert ERC2981InvalidDefaultRoyalty(feeNumerator, denominator);
}
if (receiver == address(0)) {
revert ERC2981InvalidDefaultRoyaltyReceiver(address(0));
}
$._defaultRoyaltyInfo = RoyaltyInfo(receiver, feeNumerator);
}
/**
* @dev Removes default royalty information.
*/
function _deleteDefaultRoyalty() internal virtual {
ERC2981Storage storage $ = _getERC2981Storage();
delete $._defaultRoyaltyInfo;
}
/**
* @dev Sets the royalty information for a specific token id, overriding the global default.
*
* Requirements:
*
* - `receiver` cannot be the zero address.
* - `feeNumerator` cannot be greater than the fee denominator.
*/
function _setTokenRoyalty(uint256 tokenId, address receiver, uint96 feeNumerator) internal virtual {
ERC2981Storage storage $ = _getERC2981Storage();
uint256 denominator = _feeDenominator();
if (feeNumerator > denominator) {
// Royalty fee will exceed the sale price
revert ERC2981InvalidTokenRoyalty(tokenId, feeNumerator, denominator);
}
if (receiver == address(0)) {
revert ERC2981InvalidTokenRoyaltyReceiver(tokenId, address(0));
}
$._tokenRoyaltyInfo[tokenId] = RoyaltyInfo(receiver, feeNumerator);
}
/**
* @dev Resets royalty information for the token id back to the global default.
*/
function _resetTokenRoyalty(uint256 tokenId) internal virtual {
ERC2981Storage storage $ = _getERC2981Storage();
delete $._tokenRoyaltyInfo[tokenId];
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC4906.sol)
pragma solidity ^0.8.20;
import {IERC165} from "./IERC165.sol";
import {IERC721} from "./IERC721.sol";
/// @title ERC-721 Metadata Update Extension
interface IERC4906 is IERC165, IERC721 {
/// @dev This event emits when the metadata of a token is changed.
/// So that the third-party platforms such as NFT market could
/// timely update the images and related attributes of the NFT.
event MetadataUpdate(uint256 _tokenId);
/// @dev This event emits when the metadata of a range of tokens is changed.
/// So that the third-party platforms such as NFT market could
/// timely update the images and related attributes of the NFTs.
event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Enumerable.sol)
pragma solidity ^0.8.20;
import {IERC721} from "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC1822.sol)
pragma solidity ^0.8.20;
/**
* @dev ERC-1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822Proxiable {
/**
* @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);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (proxy/ERC1967/ERC1967Utils.sol)
pragma solidity ^0.8.22;
import {IBeacon} from "../beacon/IBeacon.sol";
import {IERC1967} from "../../interfaces/IERC1967.sol";
import {Address} from "../../utils/Address.sol";
import {StorageSlot} from "../../utils/StorageSlot.sol";
/**
* @dev This library provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] slots.
*/
library ERC1967Utils {
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev The `implementation` of the proxy is invalid.
*/
error ERC1967InvalidImplementation(address implementation);
/**
* @dev The `admin` of the proxy is invalid.
*/
error ERC1967InvalidAdmin(address admin);
/**
* @dev The `beacon` of the proxy is invalid.
*/
error ERC1967InvalidBeacon(address beacon);
/**
* @dev An upgrade function sees `msg.value > 0` that may be lost.
*/
error ERC1967NonPayable();
/**
* @dev Returns the current implementation address.
*/
function getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the ERC-1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
if (newImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(newImplementation);
}
StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Performs implementation upgrade with additional setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-Upgraded} event.
*/
function upgradeToAndCall(address newImplementation, bytes memory data) internal {
_setImplementation(newImplementation);
emit IERC1967.Upgraded(newImplementation);
if (data.length > 0) {
Address.functionDelegateCall(newImplementation, data);
} else {
_checkNonPayable();
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using
* the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
*/
function getAdmin() internal view returns (address) {
return StorageSlot.getAddressSlot(ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the ERC-1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
if (newAdmin == address(0)) {
revert ERC1967InvalidAdmin(address(0));
}
StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {IERC1967-AdminChanged} event.
*/
function changeAdmin(address newAdmin) internal {
emit IERC1967.AdminChanged(getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Returns the current beacon.
*/
function getBeacon() internal view returns (address) {
return StorageSlot.getAddressSlot(BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the ERC-1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
if (newBeacon.code.length == 0) {
revert ERC1967InvalidBeacon(newBeacon);
}
StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;
address beaconImplementation = IBeacon(newBeacon).implementation();
if (beaconImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(beaconImplementation);
}
}
/**
* @dev Change the beacon and trigger a setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-BeaconUpgraded} event.
*
* CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since
* it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
* efficiency.
*/
function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {
_setBeacon(newBeacon);
emit IERC1967.BeaconUpgraded(newBeacon);
if (data.length > 0) {
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
} else {
_checkNonPayable();
}
}
/**
* @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract
* if an upgrade doesn't perform an initialization call.
*/
function _checkNonPayable() private {
if (msg.value > 0) {
revert ERC1967NonPayable();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../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;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;
interface IKugleToken {
function transferToUser(address _to, uint256 _amount) external;
function setAuthorizeContract(address _contract, bool _authorized) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol)
pragma solidity ^0.8.20;
/**
* @dev Helper library for emitting standardized panic codes.
*
* ```solidity
* contract Example {
* using Panic for uint256;
*
* // Use any of the declared internal constants
* function foo() { Panic.GENERIC.panic(); }
*
* // Alternatively
* function foo() { Panic.panic(Panic.GENERIC); }
* }
* ```
*
* Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].
*
* _Available since v5.1._
*/
// slither-disable-next-line unused-state
library Panic {
/// @dev generic / unspecified error
uint256 internal constant GENERIC = 0x00;
/// @dev used by the assert() builtin
uint256 internal constant ASSERT = 0x01;
/// @dev arithmetic underflow or overflow
uint256 internal constant UNDER_OVERFLOW = 0x11;
/// @dev division or modulo by zero
uint256 internal constant DIVISION_BY_ZERO = 0x12;
/// @dev enum conversion error
uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;
/// @dev invalid encoding in storage
uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;
/// @dev empty array pop
uint256 internal constant EMPTY_ARRAY_POP = 0x31;
/// @dev array out of bounds access
uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;
/// @dev resource error (too large allocation or too large array)
uint256 internal constant RESOURCE_ERROR = 0x41;
/// @dev calling invalid internal function
uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;
/// @dev Reverts with a panic code. Recommended to use with
/// the internal constants with predefined codes.
function panic(uint256 code) internal pure {
assembly ("memory-safe") {
mstore(0x00, 0x4e487b71)
mstore(0x20, code)
revert(0x1c, 0x24)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.20;
import {IERC721} from "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/utils/ERC721Utils.sol)
pragma solidity ^0.8.20;
import {IERC721Receiver} from "../IERC721Receiver.sol";
import {IERC721Errors} from "../../../interfaces/draft-IERC6093.sol";
/**
* @dev Library that provide common ERC-721 utility functions.
*
* See https://eips.ethereum.org/EIPS/eip-721[ERC-721].
*
* _Available since v5.1._
*/
library ERC721Utils {
/**
* @dev Performs an acceptance check for the provided `operator` by calling {IERC721-onERC721Received}
* on the `to` address. The `operator` is generally the address that initiated the token transfer (i.e. `msg.sender`).
*
* The acceptance call is not executed and treated as a no-op if the target address doesn't contain code (i.e. an EOA).
* Otherwise, the recipient must implement {IERC721Receiver-onERC721Received} and return the acceptance magic value to accept
* the transfer.
*/
function checkOnERC721Received(
address operator,
address from,
address to,
uint256 tokenId,
bytes memory data
) internal {
if (to.code.length > 0) {
try IERC721Receiver(to).onERC721Received(operator, from, tokenId, data) returns (bytes4 retval) {
if (retval != IERC721Receiver.onERC721Received.selector) {
// Token rejected
revert IERC721Errors.ERC721InvalidReceiver(to);
}
} catch (bytes memory reason) {
if (reason.length == 0) {
// non-IERC721Receiver implementer
revert IERC721Errors.ERC721InvalidReceiver(to);
} else {
assembly ("memory-safe") {
revert(add(32, reason), mload(reason))
}
}
}
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*/
abstract contract ERC165Upgradeable is Initializable, IERC165 {
function __ERC165_init() internal onlyInitializing {
}
function __ERC165_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard ERC-20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC20InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC20InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
* @param spender Address that may be allowed to operate on tokens without being their owner.
* @param allowance Amount of tokens a `spender` is allowed to operate with.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC20InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `spender` to be approved. Used in approvals.
* @param spender Address that may be allowed to operate on tokens without being their owner.
*/
error ERC20InvalidSpender(address spender);
}
/**
* @dev Standard ERC-721 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.
*/
interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC721NonexistentToken(uint256 tokenId);
/**
* @dev Indicates an error related to the ownership over a particular token. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param tokenId Identifier number of a token.
* @param owner Address of the current owner of a token.
*/
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC721InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param tokenId Identifier number of a token.
*/
error ERC721InsufficientApproval(address operator, uint256 tokenId);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC721InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC721InvalidOperator(address operator);
}
/**
* @dev Standard ERC-1155 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.
*/
interface IERC1155Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
* @param tokenId Identifier number of a token.
*/
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC1155InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC1155InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param owner Address of the current owner of a token.
*/
error ERC1155MissingApprovalForAll(address operator, address owner);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC1155InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC1155InvalidOperator(address operator);
/**
* @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
* Used in batch transfers.
* @param idsLength Length of the array of token identifiers
* @param valuesLength Length of the array of token amounts
*/
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC2981.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../utils/introspection/IERC165.sol";
/**
* @dev Interface for the NFT Royalty Standard.
*
* A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal
* support for royalty payments across all NFT marketplaces and ecosystem participants.
*/
interface IERC2981 is IERC165 {
/**
* @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of
* exchange. The royalty amount is denominated and should be paid in that same unit of exchange.
*
* NOTE: ERC-2981 allows setting the royalty to 100% of the price. In that case all the price would be sent to the
* royalty receiver and 0 tokens to the seller. Contracts dealing with royalty should consider empty transfers.
*/
function royaltyInfo(
uint256 tokenId,
uint256 salePrice
) external view returns (address receiver, uint256 royaltyAmount);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../utils/introspection/IERC165.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC721.sol)
pragma solidity ^0.8.20;
import {IERC721} from "../token/ERC721/IERC721.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.20;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeacon {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {UpgradeableBeacon} will check that this address is a contract.
*/
function implementation() external view returns (address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1967.sol)
pragma solidity ^0.8.20;
/**
* @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
*/
interface IERC1967 {
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Emitted when the beacon is changed.
*/
event BeaconUpgraded(address indexed beacon);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (utils/Address.sol)
pragma solidity ^0.8.20;
import {Errors} from "./Errors.sol";
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @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://consensys.net/diligence/blog/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.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert Errors.InsufficientBalance(address(this).balance, amount);
}
(bool success, bytes memory returndata) = recipient.call{value: amount}("");
if (!success) {
_revert(returndata);
}
}
/**
* @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 or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {Errors.FailedCall} error.
*
* 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.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @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`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert Errors.InsufficientBalance(address(this).balance, value);
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case
* of an unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {Errors.FailedCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}.
*/
function _revert(bytes memory returndata) private pure {
// 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
assembly ("memory-safe") {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert Errors.FailedCall();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.20;
/**
* @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 ERC-1967 implementation slot:
* ```solidity
* contract ERC1967 {
* // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(newImplementation.code.length > 0);
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* TIP: Consider using this library along with {SlotDerivation}.
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct Int256Slot {
int256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Int256Slot` with member `value` located at `slot`.
*/
function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
/**
* @dev Returns a `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.20;
/**
* @title ERC-721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC-721 asset contracts.
*/
interface IERC721Receiver {
/**
* @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);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of common custom errors used in multiple contracts
*
* IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.
* It is recommended to avoid relying on the error API for critical functionality.
*
* _Available since v5.1._
*/
library Errors {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error InsufficientBalance(uint256 balance, uint256 needed);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedCall();
/**
* @dev The deployment failed.
*/
error FailedDeployment();
/**
* @dev A necessary precompile is missing.
*/
error MissingPrecompile(address);
}{
"remappings": [
"forge-std/=dependencies/forge-std-1.9.5/src/",
"@openzeppelin/contracts/=dependencies/@openzeppelin-contracts-5.2.0/",
"@openzeppelin/contracts-upgradeable/=dependencies/@openzeppelin-contracts-upgradeable-5.2.0/",
"solmate/=dependencies/solmate-6.8.0/src/",
"@openzeppelin-contracts-5.2.0/=dependencies/@openzeppelin-contracts-5.2.0/",
"@openzeppelin-contracts-upgradeable-5.2.0/=dependencies/@openzeppelin-contracts-upgradeable-5.2.0/",
"forge-std-1.9.5/=dependencies/forge-std-1.9.5/src/",
"solmate-6.8.0/=dependencies/solmate-6.8.0/src/"
],
"optimizer": {
"enabled": true,
"runs": 200,
"details": {
"constantOptimizer": true,
"yul": true,
"yulDetails": {
"stackAllocation": true,
"optimizerSteps": "dhfoDgvulfnTcCejUtnSiIf"
}
}
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "prague",
"viaIR": false
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressCannotBeZero","type":"error"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"uint256","name":"kugleId","type":"uint256"}],"name":"AlreadyHatch","type":"error"},{"inputs":[],"name":"BreedingPaused","type":"error"},{"inputs":[{"internalType":"address","name":"implementation","type":"address"}],"name":"ERC1967InvalidImplementation","type":"error"},{"inputs":[],"name":"ERC1967NonPayable","type":"error"},{"inputs":[{"internalType":"uint256","name":"numerator","type":"uint256"},{"internalType":"uint256","name":"denominator","type":"uint256"}],"name":"ERC2981InvalidDefaultRoyalty","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC2981InvalidDefaultRoyaltyReceiver","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"numerator","type":"uint256"},{"internalType":"uint256","name":"denominator","type":"uint256"}],"name":"ERC2981InvalidTokenRoyalty","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC2981InvalidTokenRoyaltyReceiver","type":"error"},{"inputs":[],"name":"ERC721EnumerableForbiddenBatchMint","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"owner","type":"address"}],"name":"ERC721IncorrectOwner","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ERC721InsufficientApproval","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC721InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"ERC721InvalidOperator","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"ERC721InvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC721InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC721InvalidSender","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ERC721NonexistentToken","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"ERC721OutOfBoundsIndex","type":"error"},{"inputs":[],"name":"FailedCall","type":"error"},{"inputs":[{"internalType":"uint256","name":"maxHeat","type":"uint256"},{"internalType":"uint256","name":"claimedHeat","type":"uint256"},{"internalType":"uint256","name":"maxCarbon","type":"uint256"},{"internalType":"uint256","name":"claimedCarbon","type":"uint256"}],"name":"InsufficientRewards","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[{"internalType":"uint256","name":"kugleId","type":"uint256"}],"name":"KugleNotFertile","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[{"internalType":"uint256","name":"kugleId","type":"uint256"},{"internalType":"address","name":"account","type":"address"}],"name":"NotOwned","type":"error"},{"inputs":[{"internalType":"uint256","name":"kugleId","type":"uint256"}],"name":"NotOwnerOrStaked","type":"error"},{"inputs":[{"internalType":"uint256","name":"kugleId","type":"uint256"}],"name":"NotStaked","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"SameKugle","type":"error"},{"inputs":[],"name":"UUPSUnauthorizedCallContext","type":"error"},{"inputs":[{"internalType":"bytes32","name":"slot","type":"bytes32"}],"name":"UUPSUnsupportedProxiableUUID","type":"error"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"UserCanNotStake","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_fromTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_toTokenId","type":"uint256"}],"name":"BatchMetadataUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"kugleId","type":"uint256"}],"name":"EndStaking","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"MetadataUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"itemId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"parent1","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"parent2","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"pricePaid","type":"uint256"}],"name":"NewBreeding","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"itemId","type":"uint256"}],"name":"NewHatching","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"itemId","type":"uint256"}],"name":"NewNFTMinted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"kugleId","type":"uint256"}],"name":"StartStaking","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"UPGRADE_INTERFACE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_maxCarbonRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_maxHeatRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_multiplierDecimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_royaltiesReceiver","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"uint256","name":"_guHeld","type":"uint256"},{"internalType":"uint256","name":"_popCap","type":"uint256"}],"name":"addOrDeleteGuRewardTier","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_kugleId1","type":"uint256"},{"internalType":"uint256","name":"_kugleId2","type":"uint256"},{"internalType":"bool","name":"_stakeKugle","type":"bool"},{"internalType":"uint256","name":"_priceAdditionnalCarbon","type":"uint256"},{"internalType":"uint256","name":"_carbonRewardsClaimed","type":"uint256"}],"name":"breed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"calculateMaxRewards","outputs":[{"internalType":"uint256","name":"heat","type":"uint256"},{"internalType":"uint256","name":"carbon","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"circulatingSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_heatRewardsClaimed","type":"uint256"},{"internalType":"uint256","name":"_carbonRewardsClaimed","type":"uint256"},{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"}],"name":"claimReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_fromTokenId","type":"uint256"},{"internalType":"uint256","name":"_toTokenId","type":"uint256"}],"name":"emitBatchMetadataUpdate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBreedingPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getGuRewardTiers","outputs":[{"components":[{"internalType":"uint256","name":"guHeld","type":"uint256"},{"internalType":"uint256","name":"popCap","type":"uint256"}],"internalType":"struct IKugleNFT.GuRewardTier[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_kugleId","type":"uint256"}],"name":"getKugleGeneration","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_kugleId","type":"uint256"}],"name":"getKugleLevel","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_kuglesIds","type":"uint256[]"}],"name":"getKuglesLevels","outputs":[{"internalType":"uint8[]","name":"","type":"uint8[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"getMaxRewards","outputs":[{"internalType":"uint256","name":"heat","type":"uint256"},{"internalType":"uint256","name":"carbon","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNextAvailableTokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"getPopCapFromAmount","outputs":[{"internalType":"uint256","name":"popCap","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrices","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_kugleId","type":"uint256"}],"name":"getStakedKugleInfos","outputs":[{"components":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"stakingDate","type":"uint256"},{"internalType":"uint256","name":"lastRewardClaimDate","type":"uint256"},{"internalType":"uint256","name":"kugleId","type":"uint256"}],"internalType":"struct IKugleNFT.StakeInfo","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getUserPopCap","outputs":[{"internalType":"uint256","name":"popCap","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_kugleIds","type":"uint256[]"},{"internalType":"bool","name":"_stakeKugle","type":"bool"},{"internalType":"uint256","name":"_heatRewardsClaimed","type":"uint256"}],"name":"hatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_toMint","type":"uint256[]"},{"internalType":"address","name":"_to","type":"address"}],"name":"mintKuglesTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_paused","type":"bool"}],"name":"setBreedingPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_guHeldContract","type":"address"},{"internalType":"address","name":"_heatAddress","type":"address"},{"internalType":"address","name":"_carbonAddress","type":"address"},{"internalType":"address","name":"_potionsContract","type":"address"},{"internalType":"address","name":"_boosterSellerAddress","type":"address"}],"name":"setContracts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_delay","type":"uint256"}],"name":"setDelayBetweenRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_kugleId","type":"uint256"},{"internalType":"uint8","name":"_generation","type":"uint8"}],"name":"setKugleGeneration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_kugleId","type":"uint256"},{"internalType":"uint8","name":"_level","type":"uint8"}],"name":"setKugleLevel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"maxHeatRewards","type":"uint256"},{"internalType":"uint256","name":"maxCarbonRewards","type":"uint256"}],"name":"setMaxRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newValue","type":"uint256"}],"name":"setMultiplierDecimals","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"newArray","type":"uint256[]"}],"name":"setNewDailyCarbonPerKugle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"newArray","type":"uint256[]"}],"name":"setNewDailyHeatPerKugle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newBreedPrice","type":"uint256"},{"internalType":"uint256","name":"_newHatchPrice","type":"uint256"},{"internalType":"uint256","name":"_newPriceMulplier","type":"uint256"}],"name":"setPrices","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_rate","type":"uint16"}],"name":"setRoyaltiesRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"_royaltiesReceiverAddress","type":"address"}],"name":"setRoyaltiesReceiverAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_kugleIds","type":"uint256[]"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_kugleIds","type":"uint256[]"},{"internalType":"address","name":"_owner","type":"address"}],"name":"stakeFromBoosterContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"stakedTokenOfOwner","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"tokenOfOwner","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_kugleId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_kugleIds","type":"uint256[]"},{"internalType":"uint256","name":"_heatRewardsClaimed","type":"uint256"},{"internalType":"uint256","name":"_carbonRewardsClaimed","type":"uint256"}],"name":"unstake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"}]Contract Creation Code
60a060405230608052348015610013575f5ffd5b507ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff1615906001600160401b03165f8115801561005d5750825b90505f826001600160401b031660011480156100785750303b155b905081158015610086575080155b156100a45760405163f92ee8a960e01b815260040160405180910390fd5b84546001600160401b031916600117855583156100d257845460ff60401b1916680100000000000000001785555b831561011857845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050506080516154c66101435f395f81816135150152818161353e015261367301526154c65ff3fe6080604052600436106103b3575f3560e01c80636352211e116101e9578063ad3cb1cc11610108578063e8b9cdd41161009d578063f2fde38b1161006d578063f2fde38b14610b36578063f63bf8bd14610b55578063f94d8e5114610b74578063f9de234314610b93575f5ffd5b8063e8b9cdd414610aad578063e985e9c514610acc578063ed8a896114610aeb578063f0d7169314610b0a575f5ffd5b8063c8d32fd4116100d8578063c8d32fd414610a31578063d12ecd0e14610a50578063d1c7231e14610a6f578063e53b278e14610a8e575f5ffd5b8063ad3cb1cc1461099f578063b88d4fde146109cf578063bd9a548b146109ee578063c87b56dd14610a12575f5ffd5b806391a837111161017e578063a22cb4651161014e578063a22cb46514610923578063a483011414610942578063a88fe42d14610961578063a916db4b14610980575f5ffd5b806391a83711146108be5780639358928b146108dc57806395d89b41146108f057806395d9cae314610904575f5ffd5b806380af7de1116101b957806380af7de1146108625780638129fc1c1461088157806382d5bf35146108955780638da5cb5b146108aa575f5ffd5b80636352211e146107f15780636493bfe41461081057806370a082311461082f578063715018a61461084e575f5ffd5b80632f745c59116102d55780634d5d24131161026a578063566af4451161023a578063566af445146107645780635740c30b1461079257806357f6a941146107b15780635c8f5338146107d2575f5ffd5b80634d5d2413146107095780634f1ef2861461071e5780634f6ccce71461073157806352d1902d14610750575f5ffd5b806341b72f71116102a557806341b72f711461068957806342842e0e146106a857806342ce797c146106c7578063492b5c57146106f4575f5ffd5b80632f745c591461061557806330c018c91461063457806333d4f31e146106535780633ba61fe914610672575f5ffd5b806318160ddd1161034b57806327477f121161031b57806327477f121461057157806328d3174014610590578063294cdf0d146105bc5780632a55205a146105e8575f5ffd5b806318160ddd146104d8578063221939ec146104f8578063233be5ba1461051757806323b872dd14610552575f5ffd5b8063095ea7b311610386578063095ea7b31461045a5780630a32645c1461047b5780630fbf0a931461049a5780630ff06aaf146104b9575f5ffd5b806301ffc9a7146103b757806303d0d9ce146103ec57806306fdde031461040d578063081812fc1461042e575b5f5ffd5b3480156103c2575f5ffd5b506103d66103d13660046145bd565b610bb2565b6040516103e391906145d7565b60405180910390f35b3480156103f7575f5ffd5b50610400610bc2565b6040516103e391906145e5565b348015610418575f5ffd5b50610421610c32565b6040516103e391906145fc565b348015610439575f5ffd5b5061044d61044836600461463d565b610cd3565b6040516103e39190614657565b348015610465575f5ffd5b50610479610474366004614682565b610ce7565b005b348015610486575f5ffd5b506104796104953660046146b5565b610cf6565b3480156104a5575f5ffd5b506104796104b436600461470c565b610d6d565b3480156104c4575f5ffd5b506104796104d336600461475b565b610e18565b3480156104e3575f5ffd5b505f5160206154485f395f51905f5254610400565b348015610503575f5ffd5b50610479610512366004614775565b610e4e565b348015610522575f5ffd5b5061054561053136600461463d565b5f9081526011602052604090205460ff1690565b6040516103e391906147b8565b34801561055d575f5ffd5b5061047961056c3660046147c7565b611119565b34801561057c575f5ffd5b5061047961058b36600461470c565b61118e565b34801561059b575f5ffd5b506105af6105aa36600461470c565b6111a2565b6040516103e391906147f2565b3480156105c7575f5ffd5b506105db6105d63660046146b5565b61126d565b6040516103e39190614838565b3480156105f3575f5ffd5b5061060761060236600461486f565b6112f9565b6040516103e392919061488a565b348015610620575f5ffd5b5061040061062f366004614682565b6113be565b34801561063f575f5ffd5b5061047961064e3660046148b7565b611421565b34801561065e575f5ffd5b5061047961066d3660046149be565b61147b565b34801561067d575f5ffd5b5060195460ff166103d6565b348015610694575f5ffd5b506104796106a3366004614a19565b6116ca565b3480156106b3575f5ffd5b506104796106c23660046147c7565b611930565b3480156106d2575f5ffd5b506106e66106e1366004614a79565b61194a565b6040516103e3929190614aaa565b3480156106ff575f5ffd5b5061040060055481565b348015610714575f5ffd5b5061040060095481565b61047961072c366004614b32565b611b18565b34801561073c575f5ffd5b5061040061074b36600461463d565b611b33565b34801561075b575f5ffd5b50610400611ba0565b34801561076f575f5ffd5b5061054561077e36600461463d565b5f9081526010602052604090205460ff1690565b34801561079d575f5ffd5b506104796107ac366004614b8c565b611bbb565b3480156107bc575f5ffd5b506107c56120e2565b6040516103e39190614bf2565b3480156107dd575f5ffd5b506106e66107ec366004614a79565b612151565b3480156107fc575f5ffd5b5061044d61080b36600461463d565b612165565b34801561081b575f5ffd5b5061040061082a36600461463d565b61216f565b34801561083a575f5ffd5b506104006108493660046146b5565b61224e565b348015610859575f5ffd5b506104796122a6565b34801561086d575f5ffd5b5061047961087c36600461470c565b6122b9565b34801561088c575f5ffd5b506104796122cd565b3480156108a0575f5ffd5b50610400600a5481565b3480156108b5575f5ffd5b5061044d61267d565b3480156108c9575f5ffd5b505f5461044d906001600160a01b031681565b3480156108e7575f5ffd5b50600154610400565b3480156108fb575f5ffd5b506104216126ab565b34801561090f575f5ffd5b5061047961091e366004614c35565b6126e9565b34801561092e575f5ffd5b5061047961093d366004614c7b565b612a7d565b34801561094d575f5ffd5b5061047961095c36600461486f565b612a88565b34801561096c575f5ffd5b5061047961097b366004614775565b612acd565b34801561098b575f5ffd5b5061047961099a3660046148b7565b612ae3565b3480156109aa575f5ffd5b50610421604051806040016040528060058152602001640352e302e360dc1b81525081565b3480156109da575f5ffd5b506104796109e9366004614ca5565b612b0c565b3480156109f9575f5ffd5b506002546003546004546040516103e393929190614d12565b348015610a1d575f5ffd5b50610421610a2c36600461463d565b612b24565b348015610a3c575f5ffd5b50610400610a4b3660046146b5565b612b6f565b348015610a5b575f5ffd5b50610479610a6a36600461463d565b612bf4565b348015610a7a575f5ffd5b506105db610a893660046146b5565b612c01565b348015610a99575f5ffd5b50610479610aa836600461486f565b612c6a565b348015610ab8575f5ffd5b50610479610ac736600461463d565b612c7d565b348015610ad7575f5ffd5b506103d6610ae6366004614d31565b612c8a565b348015610af6575f5ffd5b50610479610b05366004614d5b565b612cd6565b348015610b15575f5ffd5b50610b29610b2436600461463d565b612d5c565b6040516103e39190614da0565b348015610b41575f5ffd5b50610479610b503660046146b5565b612df8565b348015610b60575f5ffd5b50610479610b6f366004614dd4565b612e32565b348015610b7f575f5ffd5b50610479610b8e366004614e2e565b612f6b565b348015610b9e575f5ffd5b50610479610bad366004614e48565b612f86565b5f610bbc82613007565b92915050565b600f54604080516396484af560e01b815290515f926001600160a01b0316916396484af59160048083019260209291908290030181865afa158015610c09573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c2d9190614e91565b905090565b5f5160206154085f395f51905f528054606091908190610c5190614eab565b80601f0160208091040260200160405190810160405280929190818152602001828054610c7d90614eab565b8015610cc85780601f10610c9f57610100808354040283529160200191610cc8565b820191905f5260205f20905b815481529060010190602001808311610cab57829003601f168201915b505050505091505090565b5f610cdd82613011565b50610bbc82613047565b610cf2828233613080565b5050565b610cfe61308d565b806001600160a01b038116610d305760405163084c41ef60e01b8152600401610d279190614657565b60405180910390fd5b50601580546001600160a01b038316620100000262010000600160b01b031982168117909255610d6a91839161ffff9182169116176130bf565b50565b5f5b61ffff8116821115610e135733610da1848461ffff8516818110610d9557610d95614ee3565b90506020020135612165565b6001600160a01b031614610ddb5760405162461bcd60e51b81526020600482015260016024820152606f60f81b6044820152606401610d27565b610e0183838361ffff16818110610df457610df4614ee3565b9050602002013533613173565b80610e0b81614f0b565b915050610d6f565b505050565b610e2061308d565b6015805461ffff191661ffff831690811791829055610d6a916201000090046001600160a01b0316906130bf565b610e5661308d565b805f03610f15576008548310610e6a575f5ffd5b825b600854610e7b90600190614f29565b811015610ee2576008610e8f826001614f3c565b81548110610e9f57610e9f614ee3565b905f5260205f20906002020160088281548110610ebe57610ebe614ee3565b5f918252602090912082546002909202019081556001918201549082015501610e6c565b506008805480610ef457610ef4614f4f565b5f8281526020812060025f1990930192830201818155600101559055505050565b6040805180820190915282815260208101829052600854801580610f6357506008610f41600183614f29565b81548110610f5157610f51614ee3565b905f5260205f2090600202015f015484115b15610fd257600880546001810182555f9190915282517ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee360029092029182015560208301517ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee490910155611112565b5f5b8181101561100d5760088181548110610fef57610fef614ee3565b905f5260205f2090600202015f015485111561100d57600101610fd4565b60088061101b600185614f29565b8154811061102b5761102b614ee3565b5f918252602080832084546001808201875595855291842060029384029091018054939092020191825583015490830155906110679084614f29565b90505b818111156110dd57600861107f600183614f29565b8154811061108f5761108f614ee3565b905f5260205f209060020201600882815481106110ae576110ae614ee3565b5f91825260209091208254600290920201908155600191820154910155806110d581614f63565b91505061106a565b5082600882815481106110f2576110f2614ee3565b5f9182526020918290208351600290920201908155910151600190910155505b5050505050565b6001600160a01b038216611142575f604051633250574960e11b8152600401610d279190614657565b5f61114e8383336132ef565b9050836001600160a01b0316816001600160a01b031614611188578382826040516364283d7b60e01b8152600401610d2793929190614f78565b50505050565b61119661308d565b610e1360068383614540565b60605f826001600160401b038111156111bd576111bd6148e1565b6040519080825280602002602001820160405280156111e6578160200160208202803683370190505b5090505f5b61ffff81168411156112655761122b85858361ffff1681811061121057611210614ee3565b905060200201355f9081526010602052604090205460ff1690565b828261ffff168151811061124157611241614ee3565b60ff909216602092830291909101909101528061125d81614f0b565b9150506111eb565b509392505050565b60605f6112798361224e565b90505f816001600160401b03811115611294576112946148e1565b6040519080825280602002602001820160405280156112bd578160200160208202803683370190505b5090505f5b82811015611265576112d485826113be565b8282815181106112e6576112e6614ee3565b60209081029190910101526001016112c2565b5f8281527fdaedc9ab023613a7caf35e703657e986ccfad7e3eb0af93a2853f8d65dd86b0160205260408120805482917fdaedc9ab023613a7caf35e703657e986ccfad7e3eb0af93a2853f8d65dd86b00916001600160a01b03811690600160a01b90046001600160601b03168161138b57505081546001600160a01b03811690600160a01b90046001600160601b03165b5f6127106113a26001600160601b0384168a614fa8565b6113ac9190614fbf565b929650919450505050505b9250929050565b5f5f5160206153e85f395f51905f526113d68461224e565b83106113f957838360405163295f44f760e21b8152600401610d2792919061488a565b6001600160a01b0384165f908152602091825260408082208583529092522054905092915050565b600e546001600160a01b0316331480611452575061143d61267d565b6001600160a01b0316336001600160a01b0316145b61145a575f5ffd5b5f91825260106020526040909120805460ff191660ff909216919091179055565b5f5f6114868361194a565b9150915084821015801561149a5750838110155b82868387909192936114c35760405163f90ee78960e01b8152600401610d279493929190614fde565b505050505f8511156115c657600c546040516340c10f1960e01b81526001600160a01b03909116906340c10f1990611501903390899060040161488a565b5f604051808303815f87803b158015611518575f5ffd5b505af115801561152a573d5f5f3e3d5ffd5b505f925050505b83518161ffff1610156115c45760105f858361ffff168151811061155757611557614ee3565b60209081029190910181015182528101919091526040015f205460ff166001036115b2574260125f868461ffff168151811061159557611595614ee3565b602002602001015181526020019081526020015f20600201819055505b806115bc81614f0b565b915050611531565b505b831561111257600d546040516340c10f1960e01b81526001600160a01b03909116906340c10f19906115fe903390889060040161488a565b5f604051808303815f87803b158015611615575f5ffd5b505af1158015611627573d5f5f3e3d5ffd5b505f925050505b83518161ffff1610156116c257600160105f868461ffff168151811061165657611656614ee3565b60209081029190910181015182528101919091526040015f205460ff1611156116b0574260125f868461ffff168151811061169357611693614ee3565b602002602001015181526020019081526020015f20600201819055505b806116ba81614f0b565b91505061162e565b505050505050565b8383808060200260200160405190810160405280939291908181526020018383602002808284375f920182905250925050505b81518161ffff16101561176b57336001600160a01b031660125f848461ffff168151811061172d5761172d614ee3565b60209081029190910181015182528101919091526040015f20546001600160a01b031614611759575f5ffd5b8061176381614f0b565b9150506116fd565b506117a983838787808060200260200160405190810160405280939291908181526020018383602002808284375f9201919091525061147b92505050565b5f5b61ffff81168511156116c2576117de303388888561ffff168181106117d2576117d2614ee3565b90506020020135613303565b60125f87878461ffff168181106117f7576117f7614ee3565b602090810292909201358352508181019290925260409081015f90812080546001600160a01b0319168155600181018290556002810182905560030181905533815260139092528120805461ffff169161185083615009565b91906101000a81548161ffff021916908361ffff160217905550505f601481819054906101000a900461ffff168092919061188a90615009565b91906101000a81548161ffff021916908361ffff160217905550506118ca86868361ffff168181106118be576118be614ee3565b9050602002013561331d565b337f9aa4e3402f7cbf239c25434981b7bb0801469216348fd608239d2f748743993a878761ffff851681811061190257611902614ee3565b9050602002013560405161191691906145e5565b60405180910390a28061192881614f0b565b9150506117ab565b610e1383838360405180602001604052805f815250612b0c565b5f808080805b85518161ffff161015611b0d575f6001600160a01b031660125f888461ffff168151811061198057611980614ee3565b60209081029190910181015182528101919091526040015f20546001600160a01b031614611afb57336001600160a01b031660125f888461ffff16815181106119cb576119cb614ee3565b602002602001015181526020019081526020015f205f015f9054906101000a90046001600160a01b03166001600160a01b031614868261ffff1681518110611a1557611a15614ee3565b602002602001015190611a3c57604051631c5220e760e21b8152600401610d2791906145e5565b505f5f611ab260125f8a8661ffff1681518110611a5b57611a5b614ee3565b60209081029190910181015182528181019290925260409081015f20815160808101835281546001600160a01b031681526001820154938101939093526002810154918301919091526003015460608201526133ce565b915091506009548211611ac55781611ac9565b6009545b9150600a548111611ada5780611ade565b600a545b9050611aea8286614f3c565b9450611af68185614f3c565b935050505b80611b0581614f0b565b915050611950565b509094909350915050565b611b2061350a565b611b29826135ae565b610cf282826135b6565b5f5f5160206153e85f395f51905f52611b575f5160206154485f395f51905f525490565b8310611b7a575f8360405163295f44f760e21b8152600401610d2792919061488a565b806002018381548110611b8f57611b8f614ee3565b905f5260205f200154915050919050565b5f611ba9613668565b505f5160206154285f395f51905f5290565b60195460ff1615611bdf57604051634b51d40f60e01b815260040160405180910390fd5b838503611bff57604051630980c2ef60e21b815260040160405180910390fd5b5f6107d0861115611c11576004611c14565b60065b90505f6107d0861115611c28576004611c2b565b60065b5f88815260106020526040902054909150600160ff909116118015611c6257505f8781526010602052604090205460ff8084169116105b8790611c8257604051630cc243f960e11b8152600401610d2791906145e5565b505f86815260106020526040902054600160ff909116118015611cb757505f8681526010602052604090205460ff8083169116105b8690611cd757604051630cc243f960e11b8152600401610d2791906145e5565b5033611ce288612165565b6001600160a01b03161480611d0c57505f878152601260205260409020546001600160a01b031633145b8790611d2c576040516302e41c0f60e01b8152600401610d2791906145e5565b5033611d3787612165565b6001600160a01b03161480611d6157505f868152601260205260409020546001600160a01b031633145b8690611d81576040516302e41c0f60e01b8152600401610d2791906145e5565b506040805160028082526060820183525f9260208301908036833701905050905087815f81518110611db557611db5614ee3565b6020026020010181815250508681600181518110611dd557611dd5614ee3565b602002602001018181525050611dec5f858361147b565b5f88815260116020526040808220548983529082205460ff91821692911690818311611e185781611e1a565b825b611e2590600161501b565b90505f600554600183611e389190615038565b60ff16611e459190614fa8565b611e5090600a615157565b89611e5c600185615038565b600454611e699190615164565b600254611e769190614fa8565b611e809190614f3c565b611e8a9190614fbf565b600d54604051632770a7eb60e21b81529192506001600160a01b031690639dc29fac90611ebd903390859060040161488a565b5f604051808303815f87803b158015611ed4575f5ffd5b505af1158015611ee6573d5f5f3e3d5ffd5b5050505f8d815260126020526040902054336001600160a01b03909116039050611f1f575f8c8152601260205260409020426002909101555b5f8b815260126020526040902054336001600160a01b0390911603611f53575f8b8152601260205260409020426002909101555b5f8c8152601060205260408120805460ff1691611f6f83615177565b82546101009290920a60ff8181021990931691831602179091555f8d815260106020526040812080549092169250611fa683615177565b91906101000a81548160ff021916908360ff160217905550505f611fc8610bc2565b9050611fd433826136b1565b5f8181526010602090815260408083208054600160ff19918216179091556011909252909120805490911660ff85161790558a15612016576120168133613173565b336001600160a01b03167fb44e8a10ee72d4a392dd220584e16927886f8db9f16add3c7538317fff8e555b828f8f866040516120559493929190614fde565b60405180910390a260018054905f61206c8361518c565b9190505550600f5f9054906101000a90046001600160a01b03166001600160a01b03166323ae0b086040518163ffffffff1660e01b81526004015f604051808303815f87803b1580156120bd575f5ffd5b505af11580156120cf573d5f5f3e3d5ffd5b5050505050505050505050505050505050565b60606008805480602002602001604051908101604052809291908181526020015f905b82821015612148578382905f5260205f2090600202016040518060400160405290815f820154815260200160018201548152505081526020019060010190612105565b50505050905090565b5f5f61215c8361194a565b91509150915091565b5f610bbc826136ca565b5f5f6008805480602002602001604051908101604052809291908181526020015f905b828210156121d5578382905f5260205f2090600202016040518060400160405290815f820154815260200160018201548152505081526020019060010190612192565b5050505090505f600182516121ea9190614f29565b90505b6008818154811061220057612200614ee3565b905f5260205f2090600202015f0154841061223c5781818151811061222757612227614ee3565b60200260200101516020015192505050919050565b8061224681614f63565b9150506121ed565b5f5f5160206154085f395f51905f526001600160a01b038316612286575f6040516322718ad960e21b8152600401610d279190614657565b6001600160a01b039092165f908152600390920160205250604090205490565b6122ae61308d565b6122b75f6136d4565b565b6122c161308d565b610e1360078383614540565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff1615906001600160401b03165f811580156123115750825b90505f826001600160401b0316600114801561232c5750303b155b90508115801561233a575080155b156123585760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561238257845460ff60401b1916600160401b1785555b6123cd6040518060400160405280600d81526020016c4b75676c652047656e6573697360981b8152506040518060400160405280600481526020016325a3a2a760e11b815250613744565b6123d5613756565b6123dd613756565b6123e5613756565b6123ee3361375e565b6123f6613756565b5f60188181556001828155680ad78ebc5ac62000006002819055600355600c600455600581905560078054808301825568010a741a46278000007fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688918201558154808401835567de0b6b3a764000009082015581548084018355678ac7230489e80000908201558154808401835567739a1adda3010000908201558154808401835567604fd53af5360000908201558154808401835567505a3652c183000090820155815480840183556742e414766962000090820155815480840183556737c9e8b37d1200009082015581548084018355672e5a104dcdce00009082015581548084019092556726b81237cb5700009101556006805480830182559381905267c7d713b49da000007ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f948501558054808301825567a688906bd8b0000090850155805480830182556768155a43676e000090850155805480830182556756bc75e2d6310000908501558054808301825567482a1c73000800009085015580548083018255673c3ac70175320000908501558054808301825567323cd2d206ea000090850155805480830182556729c5ab0d65ed000090850155805480830182556722d54fb3923b00009085015580549182019055671d012bed3c910000920191909155601655601580546201000033026001600160b01b0319909116176102ee179055681b1ae4d6e2ef5000006009819055600a55831561111257845460ff60401b191685556040517fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29061266e9060019061519d565b60405180910390a15050505050565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b031690565b7f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab007930180546060915f5160206154085f395f51905f5291610c5190614eab565b612726815f8686808060200260200160405190810160405280939291908181526020018383602002808284375f9201919091525061147b92505050565b5f805b84811015612a165760105f87878481811061274657612746614ee3565b602090810292909201358352508101919091526040015f205460ff1660011486868381811061277757612777614ee3565b905060200201359061279d5760405163761c47fd60e11b8152600401610d2791906145e5565b50336127b4878784818110610d9557610d95614ee3565b6001600160a01b031614806127fe57503360125f8888858181106127da576127da614ee3565b602090810292909201358352508101919091526040015f20546001600160a01b0316145b86868381811061281057612810614ee3565b9050602002013533909161283957604051631063106b60e21b8152600401610d279291906151b2565b505060055460115f88888581811061285357612853614ee3565b602090810292909201358352508101919091526040015f2054612879919060ff16614fa8565b61288490600a615157565b60115f88888581811061289957612899614ee3565b602090810292909201358352508101919091526040015f20546004546128c29160ff1690615164565b6003546128cf9190614fa8565b6128d99190614fbf565b6128e39083614f3c565b91503360125f8888858181106128fb576128fb614ee3565b602090810292909201358352508101919091526040015f20546001600160a01b031603612958574260125f88888581811061293857612938614ee3565b9050602002013581526020019081526020015f2060020181905550612973565b831561297357612973868683818110610df457610df4614ee3565b600260105f88888581811061298a5761298a614ee3565b9050602002013581526020019081526020015f205f6101000a81548160ff021916908360ff160217905550336001600160a01b03167f2543a938ecc43171e33b9d441b0a6aa9baad7260ea2ff859e0b12fc3273527fa8787848181106129f2576129f2614ee3565b90506020020135604051612a0691906145e5565b60405180910390a2600101612729565b50600c54604051632770a7eb60e21b81526001600160a01b0390911690639dc29fac90612a49903390859060040161488a565b5f604051808303815f87803b158015612a60575f5ffd5b505af1158015612a72573d5f5f3e3d5ffd5b505050505050505050565b610cf233838361376f565b612a9061308d565b7f6bd5c950a8d8df17f772f5af37cb3655737899cbf903264b9795592da439661c8282604051612ac1929190614aaa565b60405180910390a15050565b612ad561308d565b600292909255600355600455565b612aeb61308d565b5f91825260116020526040909120805460ff191660ff909216919091179055565b612b17848484611119565b6111883385858585613819565b606060405180606001604052806029815260200161546860299139612b4883613926565b604051602001612b599291906151cd565b6040516020818303038152906040529050919050565b600b546040516309ea1cff60e31b81525f9182916001600160a01b0390911690634f50e7f890612ba3908690600401614657565b602060405180830381865afa158015612bbe573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612be29190614e91565b9050612bed8161216f565b9392505050565b612bfc61308d565b600555565b6001600160a01b0381165f90815260146020908152604091829020805483518184028101840190945280845260609392830182828015612c5e57602002820191905f5260205f20905b815481526020019060010190808311612c4a575b50505050509050919050565b612c7261308d565b600991909155600a55565b612c8561308d565b601655565b6001600160a01b039182165f9081527f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab00793056020908152604080832093909416825291909152205460ff1690565b600f546001600160a01b03163314612cec575f5ffd5b612cf5816139b5565b8190612d155760405163d452055760e01b8152600401610d279190614657565b505f5b61ffff811683111561118857612d4a84848361ffff16818110612d3d57612d3d614ee3565b9050602002013583613173565b80612d5481614f0b565b915050612d18565b612d8c60405180608001604052805f6001600160a01b031681526020015f81526020015f81526020015f81525090565b5f828152601260205260409020546001600160a01b0316612dab575f5ffd5b505f90815260126020908152604091829020825160808101845281546001600160a01b03168152600182015492810192909252600281015492820192909252600390910154606082015290565b612e0061308d565b6001600160a01b038116612e29575f604051631e4fbdf760e01b8152600401610d279190614657565b610d6a816136d4565b612e3a61308d565b846001600160a01b038116612e635760405163084c41ef60e01b8152600401610d279190614657565b50836001600160a01b038116612e8d5760405163084c41ef60e01b8152600401610d279190614657565b50826001600160a01b038116612eb75760405163084c41ef60e01b8152600401610d279190614657565b50816001600160a01b038116612ee15760405163084c41ef60e01b8152600401610d279190614657565b50806001600160a01b038116612f0b5760405163084c41ef60e01b8152600401610d279190614657565b50600b80546001600160a01b03199081166001600160a01b0397881617909155600c8054821695871695909517909455600d8054851693861693909317909255600e80548416918516919091179055600f80549092169216919091179055565b612f7361308d565b6019805460ff1916911515919091179055565b600f546001600160a01b0316331480612fb75750612fa261267d565b6001600160a01b0316336001600160a01b0316145b612fbf575f5ffd5b5f5b82518161ffff161015610e1357612ff582848361ffff1681518110612fe857612fe8614ee3565b60200260200101516139e5565b80612fff81614f0b565b915050612fc1565b5f610bbc82613a9c565b5f5f61301c83613ac0565b90506001600160a01b038116610bbc5782604051637e27328960e01b8152600401610d2791906145e5565b5f9081527f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab007930460205260409020546001600160a01b031690565b610e138383836001613af9565b3361309661267d565b6001600160a01b0316146122b7573360405163118cdaa760e01b8152600401610d279190614657565b7fdaedc9ab023613a7caf35e703657e986ccfad7e3eb0af93a2853f8d65dd86b006127106001600160601b038316811015613111578281604051636f483d0960e01b8152600401610d2792919061521c565b6001600160a01b03841661313a575f604051635b6cc80560e11b8152600401610d279190614657565b50604080518082019091526001600160a01b039093168084526001600160601b039092166020909301839052600160a01b909202179055565b61317c816139b5565b819061319c5760405163d452055760e01b8152600401610d279190614657565b506131a8333084611119565b604080516080810182526001600160a01b03838116808352426020808501828152858701928352606086018981525f8a815260128452888120885181546001600160a01b03191698169790971787559151600187015592516002860155915160039094019390935590815260139091529182208054919261ffff9092169161322f83614f0b565b91906101000a81548161ffff021916908361ffff160217905550505f601481819054906101000a900461ffff168092919061326990614f0b565b825461ffff9182166101009390930a9283029190920219909116179055506001600160a01b0382165f81815260146020908152604080832080546001810182559084529190922001859055517f5a10b5f49dd8fad36b4ab1cbca7032df7337fdc475a5616c796b654fe12eedac906132e29086906145e5565b60405180910390a2505050565b5f6132fb848484613c03565b949350505050565b610e1383838360405180602001604052805f815250613cf9565b335f908152601460205260408120905b8154811015610e13578282828154811061334957613349614ee3565b905f5260205f200154036133c6578154829061336790600190614f29565b8154811061337757613377614ee3565b905f5260205f20015482828154811061339257613392614ee3565b905f5260205f200181905550818054806133ae576133ae614f4f565b600190038181905f5260205f20015f90559055505050565b60010161332d565b5f5f5f601654610e106133e19190614fa8565b90505f8460200151426133f49190614f29565b90505f8560200151866040015161340b9190614f29565b90505f6134188284614f29565b6060880180515f9081526011602090815260408083205493518352601090915290205491925060ff908116916001911611156134a9576007545f9061345f90600190614f29565b60075490915082101561346f5750805b85836007838154811061348457613484614ee3565b905f5260205f2001546134979190614fa8565b6134a19190614fbf565b965050613500565b6006545f906134ba90600190614f29565b6006549091508210156134ca5750805b8583600683815481106134df576134df614ee3565b905f5260205f2001546134f29190614fa8565b6134fc9190614fbf565b9750505b5050505050915091565b306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016148061359057507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166135845f5160206154285f395f51905f52546001600160a01b031690565b6001600160a01b031614155b156122b75760405163703e46dd60e11b815260040160405180910390fd5b610d6a61308d565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015613610575060408051601f3d908101601f1916820190925261360d91810190614e91565b60015b61362f5781604051634c9c8ce360e01b8152600401610d279190614657565b5f5160206154285f395f51905f52811461365e5780604051632a87526960e21b8152600401610d2791906145e5565b610e138383613d04565b306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146122b75760405163703e46dd60e11b815260040160405180910390fd5b610cf2828260405180602001604052805f815250613d59565b5f610bbc82613d70565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a3505050565b61374c613d7a565b610cf28282613dc3565b6122b7613d7a565b613766613d7a565b610d6a81613df3565b5f5160206154085f395f51905f526001600160a01b0383166137a65782604051630b61174360e31b8152600401610d279190614657565b6001600160a01b038481165f81815260058401602090815260408083209488168084529490915290819020805460ff1916861515179055517f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c319061380b9086906145d7565b60405180910390a350505050565b6001600160a01b0383163b1561111257604051630a85bd0160e11b81526001600160a01b0384169063150b7a029061385b908890889087908790600401615231565b6020604051808303815f875af1925050508015613895575060408051601f3d908101601f19168201909252613892918101906152a5565b60015b6138f3573d8080156138c2576040519150601f19603f3d011682016040523d82523d5f602084013e6138c7565b606091505b5080515f036138eb5783604051633250574960e11b8152600401610d279190614657565b805181602001fd5b6001600160e01b03198116630a85bd0160e11b146116c25783604051633250574960e11b8152600401610d279190614657565b60605f61393283613dfb565b60010190505f816001600160401b03811115613950576139506148e1565b6040519080825280601f01601f19166020018201604052801561397a576020820181803683370190505b5090508181016020015b5f19016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a850494508461398457509392505050565b5f6139bf82612b6f565b6001600160a01b039092165f9081526013602052604090205461ffff1691909110919050565b6139ef82826136b1565b5f818152601060205260409020805460ff191660011790556107d08111613a2a575f818152601160205260409020805460ff19169055613a43565b5f818152601160205260409020805460ff191660011790555b816001600160a01b03167f1c05098ed1ff38e6238d2b1b04b2c7977d4c94ce651bda6473f9dba8dbf01da082604051613a7c91906145e5565b60405180910390a260018054905f613a938361518c565b91905055505050565b5f6001600160e01b03198216632483248360e11b1480610bbc5750610bbc82613ed2565b5f9081527f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab007930260205260409020546001600160a01b031690565b5f5160206154085f395f51905f528180613b1b57506001600160a01b03831615155b15613bd3575f613b2a85613011565b90506001600160a01b03841615801590613b565750836001600160a01b0316816001600160a01b031614155b8015613b695750613b678185612c8a565b155b15613b89578360405163a9fbf51f60e01b8152600401610d279190614657565b8215613bd15784866001600160a01b0316826001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45b505b5f93845260040160205250506040902080546001600160a01b0319166001600160a01b0392909216919091179055565b5f5f613c10858585613ef6565b90506001600160a01b038116613c9757613c92845f5160206154485f395f51905f5280545f8381527f645e039705490088daad89bae25049a34f4a9072d398537b1ab2425f24cbed0360205260408120829055600182018355919091527fa42f15e5d656f8155fd7419d740a6073999f19cd6e061449ce4a257150545bf20155565b613cba565b846001600160a01b0316816001600160a01b031614613cba57613cba8185613ff8565b6001600160a01b038516613cd657613cd18461408f565b6132fb565b846001600160a01b0316816001600160a01b0316146132fb576132fb858561415c565b612b178484846141b4565b613d0d8261424c565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a2805115613d5157610e1382826142a6565b610cf2614318565b613d638383614337565b610e13335f858585613819565b5f610bbc82613011565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff166122b757604051631afcd79f60e31b815260040160405180910390fd5b613dcb613d7a565b5f5160206154085f395f51905f5280613de4848261530c565b5060018101611188838261530c565b612e00613d7a565b5f8072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8310613e395772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310613e65576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310613e8357662386f26fc10000830492506010015b6305f5e1008310613e9b576305f5e100830492506008015b6127108310613eaf57612710830492506004015b60648310613ec1576064830492506002015b600a8310610bbc5760010192915050565b5f6001600160e01b0319821663780e9d6360e01b1480610bbc5750610bbc82614398565b5f5f5160206154085f395f51905f5281613f0f85613ac0565b90506001600160a01b03841615613f2b57613f2b8185876143d7565b6001600160a01b03811615613f6757613f465f865f5f613af9565b6001600160a01b0381165f908152600383016020526040902080545f190190555b6001600160a01b03861615613f97576001600160a01b0386165f9081526003830160205260409020805460010190555b5f85815260028301602052604080822080546001600160a01b0319166001600160a01b038a811691821790925591518893918516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a495945050505050565b5f5160206153e85f395f51905f525f6140108461224e565b5f8481526001840160209081526040808320546001600160a01b03891684529186905290912091925090818314614068575f838152602082815260408083205485845281842081905583526001870190915290208290555b5f948552600190930160209081526040808620869055928552929092528220919091555050565b5f5160206154485f395f51905f52545f5160206153e85f395f51905f52905f906140bb90600190614f29565b5f8481526003840160205260408120546002850180549394509092849081106140e6576140e6614ee3565b905f5260205f20015490508084600201838154811061410757614107614ee3565b5f9182526020808320909101929092558281526003860190915260408082208490558682528120556002840180548061414257614142614f4f565b600190038181905f5260205f20015f905590555050505050565b5f5160206153e85f395f51905f525f60016141768561224e565b6141809190614f29565b6001600160a01b039094165f9081526020838152604080832087845282528083208690559482526001909301909252502055565b6001600160a01b0382166141dd575f604051633250574960e11b8152600401610d279190614657565b5f6141e983835f6132ef565b90506001600160a01b0381166142145781604051637e27328960e01b8152600401610d2791906145e5565b836001600160a01b0316816001600160a01b031614611188578382826040516364283d7b60e01b8152600401610d2793929190614f78565b806001600160a01b03163b5f036142785780604051634c9c8ce360e01b8152600401610d279190614657565b5f5160206154285f395f51905f5280546001600160a01b0319166001600160a01b0392909216919091179055565b60605f5f846001600160a01b0316846040516142c291906153c5565b5f60405180830381855af49150503d805f81146142fa576040519150601f19603f3d011682016040523d82523d5f602084013e6142ff565b606091505b509150915061430f85838361442c565b95945050505050565b34156122b75760405163b398979f60e01b815260040160405180910390fd5b6001600160a01b038216614360575f604051633250574960e11b8152600401610d279190614657565b5f61436c83835f6132ef565b90506001600160a01b03811615610e13575f6040516339e3563760e11b8152600401610d279190614657565b5f6001600160e01b031982166380ac58cd60e01b14806143c857506001600160e01b03198216635b5e139f60e01b145b80610bbc5750610bbc8261447f565b6143e28383836144b3565b610e13576001600160a01b03831661440f5780604051637e27328960e01b8152600401610d2791906145e5565b818160405163177e802f60e01b8152600401610d2792919061488a565b6060826144415761443c82614517565b612bed565b815115801561445857506001600160a01b0384163b155b156144785783604051639996b31560e01b8152600401610d279190614657565b5080612bed565b5f6001600160e01b0319821663152a902d60e11b1480610bbc57506301ffc9a760e01b6001600160e01b0319831614610bbc565b5f6001600160a01b038316158015906132fb5750826001600160a01b0316846001600160a01b031614806144ec57506144ec8484612c8a565b806132fb5750826001600160a01b031661450583613047565b6001600160a01b031614949350505050565b8051156145275780518082602001fd5b60405163d6bda27560e01b815260040160405180910390fd5b828054828255905f5260205f20908101928215614579579160200282015b8281111561457957823582559160200191906001019061455e565b50614585929150614589565b5090565b5b80821115614585575f815560010161458a565b6001600160e01b031981168114610d6a575f5ffd5b8035610bbc8161459d565b5f602082840312156145cd575f5ffd5b612bed83836145b2565b811515815260208101610bbc565b81815260208101610bbc565b8281835e505f910152565b602080825282518282018181529160408401915f91839061462290839083908a016145f1565b601f91909101601f19160195945050505050565b8035610bbc565b5f6020828403121561464d575f5ffd5b612bed8383614636565b6001600160a01b038216815260208101610bbc565b80356001600160a01b0381168114610bbc575f5ffd5b5f5f60408385031215614693575f5ffd5b61469d848461466c565b91506146ac8460208501614636565b90509250929050565b5f602082840312156146c5575f5ffd5b612bed838361466c565b5f5f83601f8401126146df575f5ffd5b5081356001600160401b038111156146f5575f5ffd5b6020830191508360208202830111156113b7575f5ffd5b5f5f6020838503121561471d575f5ffd5b82356001600160401b03811115614732575f5ffd5b61473e858286016146cf565b92509250509250929050565b803561ffff81168114610bbc575f5ffd5b5f6020828403121561476b575f5ffd5b612bed838361474a565b5f5f5f60608486031215614787575f5ffd5b6147918585614636565b92506147a08560208601614636565b91506147af8560408601614636565b90509250925092565b60ff8216815260208101610bbc565b5f5f5f606084860312156147d9575f5ffd5b6147e3858561466c565b92506147a0856020860161466c565b602080825282518282018181529160408401915f918601825b8281101561482c57815160ff1685526020948501949091019060010161480b565b50929695505050505050565b602080825282518282018181529160408401915f918601825b8281101561482c578151855260209485019490910190600101614851565b5f5f60408385031215614880575f5ffd5b61469d8484614636565b6001600160a01b0383168152604081015b612bed60208301849052565b803560ff81168114610bbc575f5ffd5b5f5f604083850312156148c8575f5ffd5b6148d28484614636565b91506146ac84602085016148a7565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f191681016001600160401b038111828210171561491d5761491d6148e1565b604052919050565b5f6001600160401b0382111561493d5761493d6148e1565b5060209081020190565b5f61495961495484614925565b6148f5565b83815290506020808201908402830185811115614974575f5ffd5b835b81811015614996576149888782614636565b835260209283019201614976565b5050509392505050565b5f82601f8301126149af575f5ffd5b612bed83833560208501614947565b5f5f5f606084860312156149d0575f5ffd5b6149da8585614636565b92506149e98560208601614636565b915060408401356001600160401b03811115614a03575f5ffd5b614a0f868287016149a0565b9150509250925092565b5f5f5f5f60608587031215614a2c575f5ffd5b84356001600160401b03811115614a41575f5ffd5b614a4d878288016146cf565b9450945050614a5f8660208701614636565b9150614a6e8660408701614636565b905092959194509250565b5f60208284031215614a89575f5ffd5b81356001600160401b03811115614a9e575f5ffd5b6132fb848285016149a0565b8281526040810161489b565b5f6001600160401b03821115614ace57614ace6148e1565b506020601f91909101601f19160190565b5f614aec61495484614ab6565b905082815260208101848484011115614b03575f5ffd5b838382375f84820152509392505050565b5f82601f830112614b23575f5ffd5b612bed83833560208501614adf565b5f5f60408385031215614b43575f5ffd5b614b4d848461466c565b915060208301356001600160401b03811115614b67575f5ffd5b614b7385828601614b14565b9150509250929050565b80358015158114610bbc575f5ffd5b5f5f5f5f5f60a08688031215614ba0575f5ffd5b614baa8787614636565b9450614bb98760208801614636565b9350614bc88760408801614b7d565b9250614bd78760608801614636565b9150614be68760808801614636565b90509295509295909350565b602080825282518282018181529160408401915f918601825b8281101561482c578151805186526020908101518187015260409095019490910190600101614c0b565b5f5f5f5f60608587031215614c48575f5ffd5b84356001600160401b03811115614c5d575f5ffd5b614c69878288016146cf565b9450945050614a5f8660208701614b7d565b5f5f60408385031215614c8c575f5ffd5b614c96848461466c565b91506146ac8460208501614b7d565b5f5f5f5f60808587031215614cb8575f5ffd5b614cc2868661466c565b9350614cd1866020870161466c565b9250614ce08660408701614636565b915060608501356001600160401b03811115614cfa575f5ffd5b614d0687828801614b14565b91505092959194509250565b83815260608101614d2560208301859052565b6132fb60408301849052565b5f5f60408385031215614d42575f5ffd5b614d4c848461466c565b91506146ac846020850161466c565b5f5f5f60408486031215614d6d575f5ffd5b83356001600160401b03811115614d82575f5ffd5b614d8e868287016146cf565b93509350506147af856020860161466c565b81516001600160a01b0316815260208083015190820152604080830151908201526060808301519082015260808101610bbc565b5f5f5f5f5f60a08688031215614de8575f5ffd5b614df2878761466c565b9450614e01876020880161466c565b9350614e10876040880161466c565b9250614e1f876060880161466c565b9150614be6876080880161466c565b5f60208284031215614e3e575f5ffd5b612bed8383614b7d565b5f5f60408385031215614e59575f5ffd5b82356001600160401b03811115614e6e575f5ffd5b614e7a858286016149a0565b9250506146ac846020850161466c565b8051610bbc565b5f60208284031215614ea1575f5ffd5b612bed8383614e8a565b600281046001821680614ebf57607f821691505b602082108103614edd57634e487b7160e01b5f52602260045260245ffd5b50919050565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b61ffff165f61fffe198201614f2257614f22614ef7565b5060010190565b81810381811115610bbc57610bbc614ef7565b80820180821115610bbc57610bbc614ef7565b634e487b7160e01b5f52603160045260245ffd5b5f81614f7157614f71614ef7565b505f190190565b6001600160a01b038416815260608101614f9460208301859052565b6001600160a01b03831660408301526132fb565b8082028115828204841417610bbc57610bbc614ef7565b5f82614fd957634e487b7160e01b5f52601260045260245ffd5b500490565b84815260808101614ff160208301869052565b614ffd60408301859052565b61430f60608301849052565b61ffff165f81614f7157614f71614ef7565b60ff918216919081169082820190811115610bbc57610bbc614ef7565b60ff918216919081169082820390811115610bbc57610bbc614ef7565b80825b600185111561508f5780860481111561507357615073614ef7565b600185161561508157908102905b60019490941c938002615058565b94509492505050565b5f826150a657506001612bed565b816150b257505f612bed565b81600181146150c857600281146150d2576150ff565b6001915050612bed565b60ff8411156150e3576150e3614ef7565b8360020a9150848211156150f9576150f9614ef7565b50612bed565b5060208310610133831016604e8410600b841016171561512d575081810a8381111561443c5761443c614ef7565b61513a8484846001615055565b9250905081840481111561515057615150614ef7565b0292915050565b5f612bed5f198484615098565b60ff821691505f612bed5f198484615098565b60ff165f60fe198201614f2257614f22614ef7565b5f60018201614f2257614f22614ef7565b6001600160401b038216815260208101610bbc565b828152604081016001600160a01b0383166020830152612bed565b5f815f85518492506151e3818660208a016145f1565b85519401938492508291505f906151fe818460208a016145f1565b672f6f735f76616c7360c01b92019182525060080195945050505050565b6001600160601b03831681526040810161489b565b6001600160a01b0385168152608081016001600160a01b038516602083015261525c60408301859052565b8181036060830152805f84515f818552602085019050809350615283828260208a016145f1565b601f91909101601f19160198975050505050505050565b8051610bbc8161459d565b5f602082840312156152b5575f5ffd5b612bed838361529a565b81811015610cf2575f81556001016152bf565b601f821115610e13575f81815260209081902090601f85018190048201908510156152fa5750805b6111126020601f8601048301826152bf565b81516001600160401b03811115615325576153256148e1565b615339816153338454614eab565b846152d2565b6020601f82116001811461536b575f83156153545750848201515b5f19600885021c1981166002850217855550611112565b5f84815260208120601f198516915b8281101561539a578785015182556020948501946001909201910161537a565b50848210156153b657838701515f19601f87166008021c191681555b50505050600202600101905550565b5f815f84518492506153db8186602089016145f1565b9390930194935050505056fe645e039705490088daad89bae25049a34f4a9072d398537b1ab2425f24cbed0080bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab0079300360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc645e039705490088daad89bae25049a34f4a9072d398537b1ab2425f24cbed0268747470733a2f2f6170692e6b75676c652e6170702f6574682d6170692d6465762f6b75676c65732fa2646970667358221220a5c9b41712c4800ee2b7d5eabe92284f26c8fb62b241fcce6e33ad42f48cb27464736f6c634300081c0033
Deployed Bytecode
0x6080604052600436106103b3575f3560e01c80636352211e116101e9578063ad3cb1cc11610108578063e8b9cdd41161009d578063f2fde38b1161006d578063f2fde38b14610b36578063f63bf8bd14610b55578063f94d8e5114610b74578063f9de234314610b93575f5ffd5b8063e8b9cdd414610aad578063e985e9c514610acc578063ed8a896114610aeb578063f0d7169314610b0a575f5ffd5b8063c8d32fd4116100d8578063c8d32fd414610a31578063d12ecd0e14610a50578063d1c7231e14610a6f578063e53b278e14610a8e575f5ffd5b8063ad3cb1cc1461099f578063b88d4fde146109cf578063bd9a548b146109ee578063c87b56dd14610a12575f5ffd5b806391a837111161017e578063a22cb4651161014e578063a22cb46514610923578063a483011414610942578063a88fe42d14610961578063a916db4b14610980575f5ffd5b806391a83711146108be5780639358928b146108dc57806395d89b41146108f057806395d9cae314610904575f5ffd5b806380af7de1116101b957806380af7de1146108625780638129fc1c1461088157806382d5bf35146108955780638da5cb5b146108aa575f5ffd5b80636352211e146107f15780636493bfe41461081057806370a082311461082f578063715018a61461084e575f5ffd5b80632f745c59116102d55780634d5d24131161026a578063566af4451161023a578063566af445146107645780635740c30b1461079257806357f6a941146107b15780635c8f5338146107d2575f5ffd5b80634d5d2413146107095780634f1ef2861461071e5780634f6ccce71461073157806352d1902d14610750575f5ffd5b806341b72f71116102a557806341b72f711461068957806342842e0e146106a857806342ce797c146106c7578063492b5c57146106f4575f5ffd5b80632f745c591461061557806330c018c91461063457806333d4f31e146106535780633ba61fe914610672575f5ffd5b806318160ddd1161034b57806327477f121161031b57806327477f121461057157806328d3174014610590578063294cdf0d146105bc5780632a55205a146105e8575f5ffd5b806318160ddd146104d8578063221939ec146104f8578063233be5ba1461051757806323b872dd14610552575f5ffd5b8063095ea7b311610386578063095ea7b31461045a5780630a32645c1461047b5780630fbf0a931461049a5780630ff06aaf146104b9575f5ffd5b806301ffc9a7146103b757806303d0d9ce146103ec57806306fdde031461040d578063081812fc1461042e575b5f5ffd5b3480156103c2575f5ffd5b506103d66103d13660046145bd565b610bb2565b6040516103e391906145d7565b60405180910390f35b3480156103f7575f5ffd5b50610400610bc2565b6040516103e391906145e5565b348015610418575f5ffd5b50610421610c32565b6040516103e391906145fc565b348015610439575f5ffd5b5061044d61044836600461463d565b610cd3565b6040516103e39190614657565b348015610465575f5ffd5b50610479610474366004614682565b610ce7565b005b348015610486575f5ffd5b506104796104953660046146b5565b610cf6565b3480156104a5575f5ffd5b506104796104b436600461470c565b610d6d565b3480156104c4575f5ffd5b506104796104d336600461475b565b610e18565b3480156104e3575f5ffd5b505f5160206154485f395f51905f5254610400565b348015610503575f5ffd5b50610479610512366004614775565b610e4e565b348015610522575f5ffd5b5061054561053136600461463d565b5f9081526011602052604090205460ff1690565b6040516103e391906147b8565b34801561055d575f5ffd5b5061047961056c3660046147c7565b611119565b34801561057c575f5ffd5b5061047961058b36600461470c565b61118e565b34801561059b575f5ffd5b506105af6105aa36600461470c565b6111a2565b6040516103e391906147f2565b3480156105c7575f5ffd5b506105db6105d63660046146b5565b61126d565b6040516103e39190614838565b3480156105f3575f5ffd5b5061060761060236600461486f565b6112f9565b6040516103e392919061488a565b348015610620575f5ffd5b5061040061062f366004614682565b6113be565b34801561063f575f5ffd5b5061047961064e3660046148b7565b611421565b34801561065e575f5ffd5b5061047961066d3660046149be565b61147b565b34801561067d575f5ffd5b5060195460ff166103d6565b348015610694575f5ffd5b506104796106a3366004614a19565b6116ca565b3480156106b3575f5ffd5b506104796106c23660046147c7565b611930565b3480156106d2575f5ffd5b506106e66106e1366004614a79565b61194a565b6040516103e3929190614aaa565b3480156106ff575f5ffd5b5061040060055481565b348015610714575f5ffd5b5061040060095481565b61047961072c366004614b32565b611b18565b34801561073c575f5ffd5b5061040061074b36600461463d565b611b33565b34801561075b575f5ffd5b50610400611ba0565b34801561076f575f5ffd5b5061054561077e36600461463d565b5f9081526010602052604090205460ff1690565b34801561079d575f5ffd5b506104796107ac366004614b8c565b611bbb565b3480156107bc575f5ffd5b506107c56120e2565b6040516103e39190614bf2565b3480156107dd575f5ffd5b506106e66107ec366004614a79565b612151565b3480156107fc575f5ffd5b5061044d61080b36600461463d565b612165565b34801561081b575f5ffd5b5061040061082a36600461463d565b61216f565b34801561083a575f5ffd5b506104006108493660046146b5565b61224e565b348015610859575f5ffd5b506104796122a6565b34801561086d575f5ffd5b5061047961087c36600461470c565b6122b9565b34801561088c575f5ffd5b506104796122cd565b3480156108a0575f5ffd5b50610400600a5481565b3480156108b5575f5ffd5b5061044d61267d565b3480156108c9575f5ffd5b505f5461044d906001600160a01b031681565b3480156108e7575f5ffd5b50600154610400565b3480156108fb575f5ffd5b506104216126ab565b34801561090f575f5ffd5b5061047961091e366004614c35565b6126e9565b34801561092e575f5ffd5b5061047961093d366004614c7b565b612a7d565b34801561094d575f5ffd5b5061047961095c36600461486f565b612a88565b34801561096c575f5ffd5b5061047961097b366004614775565b612acd565b34801561098b575f5ffd5b5061047961099a3660046148b7565b612ae3565b3480156109aa575f5ffd5b50610421604051806040016040528060058152602001640352e302e360dc1b81525081565b3480156109da575f5ffd5b506104796109e9366004614ca5565b612b0c565b3480156109f9575f5ffd5b506002546003546004546040516103e393929190614d12565b348015610a1d575f5ffd5b50610421610a2c36600461463d565b612b24565b348015610a3c575f5ffd5b50610400610a4b3660046146b5565b612b6f565b348015610a5b575f5ffd5b50610479610a6a36600461463d565b612bf4565b348015610a7a575f5ffd5b506105db610a893660046146b5565b612c01565b348015610a99575f5ffd5b50610479610aa836600461486f565b612c6a565b348015610ab8575f5ffd5b50610479610ac736600461463d565b612c7d565b348015610ad7575f5ffd5b506103d6610ae6366004614d31565b612c8a565b348015610af6575f5ffd5b50610479610b05366004614d5b565b612cd6565b348015610b15575f5ffd5b50610b29610b2436600461463d565b612d5c565b6040516103e39190614da0565b348015610b41575f5ffd5b50610479610b503660046146b5565b612df8565b348015610b60575f5ffd5b50610479610b6f366004614dd4565b612e32565b348015610b7f575f5ffd5b50610479610b8e366004614e2e565b612f6b565b348015610b9e575f5ffd5b50610479610bad366004614e48565b612f86565b5f610bbc82613007565b92915050565b600f54604080516396484af560e01b815290515f926001600160a01b0316916396484af59160048083019260209291908290030181865afa158015610c09573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c2d9190614e91565b905090565b5f5160206154085f395f51905f528054606091908190610c5190614eab565b80601f0160208091040260200160405190810160405280929190818152602001828054610c7d90614eab565b8015610cc85780601f10610c9f57610100808354040283529160200191610cc8565b820191905f5260205f20905b815481529060010190602001808311610cab57829003601f168201915b505050505091505090565b5f610cdd82613011565b50610bbc82613047565b610cf2828233613080565b5050565b610cfe61308d565b806001600160a01b038116610d305760405163084c41ef60e01b8152600401610d279190614657565b60405180910390fd5b50601580546001600160a01b038316620100000262010000600160b01b031982168117909255610d6a91839161ffff9182169116176130bf565b50565b5f5b61ffff8116821115610e135733610da1848461ffff8516818110610d9557610d95614ee3565b90506020020135612165565b6001600160a01b031614610ddb5760405162461bcd60e51b81526020600482015260016024820152606f60f81b6044820152606401610d27565b610e0183838361ffff16818110610df457610df4614ee3565b9050602002013533613173565b80610e0b81614f0b565b915050610d6f565b505050565b610e2061308d565b6015805461ffff191661ffff831690811791829055610d6a916201000090046001600160a01b0316906130bf565b610e5661308d565b805f03610f15576008548310610e6a575f5ffd5b825b600854610e7b90600190614f29565b811015610ee2576008610e8f826001614f3c565b81548110610e9f57610e9f614ee3565b905f5260205f20906002020160088281548110610ebe57610ebe614ee3565b5f918252602090912082546002909202019081556001918201549082015501610e6c565b506008805480610ef457610ef4614f4f565b5f8281526020812060025f1990930192830201818155600101559055505050565b6040805180820190915282815260208101829052600854801580610f6357506008610f41600183614f29565b81548110610f5157610f51614ee3565b905f5260205f2090600202015f015484115b15610fd257600880546001810182555f9190915282517ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee360029092029182015560208301517ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee490910155611112565b5f5b8181101561100d5760088181548110610fef57610fef614ee3565b905f5260205f2090600202015f015485111561100d57600101610fd4565b60088061101b600185614f29565b8154811061102b5761102b614ee3565b5f918252602080832084546001808201875595855291842060029384029091018054939092020191825583015490830155906110679084614f29565b90505b818111156110dd57600861107f600183614f29565b8154811061108f5761108f614ee3565b905f5260205f209060020201600882815481106110ae576110ae614ee3565b5f91825260209091208254600290920201908155600191820154910155806110d581614f63565b91505061106a565b5082600882815481106110f2576110f2614ee3565b5f9182526020918290208351600290920201908155910151600190910155505b5050505050565b6001600160a01b038216611142575f604051633250574960e11b8152600401610d279190614657565b5f61114e8383336132ef565b9050836001600160a01b0316816001600160a01b031614611188578382826040516364283d7b60e01b8152600401610d2793929190614f78565b50505050565b61119661308d565b610e1360068383614540565b60605f826001600160401b038111156111bd576111bd6148e1565b6040519080825280602002602001820160405280156111e6578160200160208202803683370190505b5090505f5b61ffff81168411156112655761122b85858361ffff1681811061121057611210614ee3565b905060200201355f9081526010602052604090205460ff1690565b828261ffff168151811061124157611241614ee3565b60ff909216602092830291909101909101528061125d81614f0b565b9150506111eb565b509392505050565b60605f6112798361224e565b90505f816001600160401b03811115611294576112946148e1565b6040519080825280602002602001820160405280156112bd578160200160208202803683370190505b5090505f5b82811015611265576112d485826113be565b8282815181106112e6576112e6614ee3565b60209081029190910101526001016112c2565b5f8281527fdaedc9ab023613a7caf35e703657e986ccfad7e3eb0af93a2853f8d65dd86b0160205260408120805482917fdaedc9ab023613a7caf35e703657e986ccfad7e3eb0af93a2853f8d65dd86b00916001600160a01b03811690600160a01b90046001600160601b03168161138b57505081546001600160a01b03811690600160a01b90046001600160601b03165b5f6127106113a26001600160601b0384168a614fa8565b6113ac9190614fbf565b929650919450505050505b9250929050565b5f5f5160206153e85f395f51905f526113d68461224e565b83106113f957838360405163295f44f760e21b8152600401610d2792919061488a565b6001600160a01b0384165f908152602091825260408082208583529092522054905092915050565b600e546001600160a01b0316331480611452575061143d61267d565b6001600160a01b0316336001600160a01b0316145b61145a575f5ffd5b5f91825260106020526040909120805460ff191660ff909216919091179055565b5f5f6114868361194a565b9150915084821015801561149a5750838110155b82868387909192936114c35760405163f90ee78960e01b8152600401610d279493929190614fde565b505050505f8511156115c657600c546040516340c10f1960e01b81526001600160a01b03909116906340c10f1990611501903390899060040161488a565b5f604051808303815f87803b158015611518575f5ffd5b505af115801561152a573d5f5f3e3d5ffd5b505f925050505b83518161ffff1610156115c45760105f858361ffff168151811061155757611557614ee3565b60209081029190910181015182528101919091526040015f205460ff166001036115b2574260125f868461ffff168151811061159557611595614ee3565b602002602001015181526020019081526020015f20600201819055505b806115bc81614f0b565b915050611531565b505b831561111257600d546040516340c10f1960e01b81526001600160a01b03909116906340c10f19906115fe903390889060040161488a565b5f604051808303815f87803b158015611615575f5ffd5b505af1158015611627573d5f5f3e3d5ffd5b505f925050505b83518161ffff1610156116c257600160105f868461ffff168151811061165657611656614ee3565b60209081029190910181015182528101919091526040015f205460ff1611156116b0574260125f868461ffff168151811061169357611693614ee3565b602002602001015181526020019081526020015f20600201819055505b806116ba81614f0b565b91505061162e565b505050505050565b8383808060200260200160405190810160405280939291908181526020018383602002808284375f920182905250925050505b81518161ffff16101561176b57336001600160a01b031660125f848461ffff168151811061172d5761172d614ee3565b60209081029190910181015182528101919091526040015f20546001600160a01b031614611759575f5ffd5b8061176381614f0b565b9150506116fd565b506117a983838787808060200260200160405190810160405280939291908181526020018383602002808284375f9201919091525061147b92505050565b5f5b61ffff81168511156116c2576117de303388888561ffff168181106117d2576117d2614ee3565b90506020020135613303565b60125f87878461ffff168181106117f7576117f7614ee3565b602090810292909201358352508181019290925260409081015f90812080546001600160a01b0319168155600181018290556002810182905560030181905533815260139092528120805461ffff169161185083615009565b91906101000a81548161ffff021916908361ffff160217905550505f601481819054906101000a900461ffff168092919061188a90615009565b91906101000a81548161ffff021916908361ffff160217905550506118ca86868361ffff168181106118be576118be614ee3565b9050602002013561331d565b337f9aa4e3402f7cbf239c25434981b7bb0801469216348fd608239d2f748743993a878761ffff851681811061190257611902614ee3565b9050602002013560405161191691906145e5565b60405180910390a28061192881614f0b565b9150506117ab565b610e1383838360405180602001604052805f815250612b0c565b5f808080805b85518161ffff161015611b0d575f6001600160a01b031660125f888461ffff168151811061198057611980614ee3565b60209081029190910181015182528101919091526040015f20546001600160a01b031614611afb57336001600160a01b031660125f888461ffff16815181106119cb576119cb614ee3565b602002602001015181526020019081526020015f205f015f9054906101000a90046001600160a01b03166001600160a01b031614868261ffff1681518110611a1557611a15614ee3565b602002602001015190611a3c57604051631c5220e760e21b8152600401610d2791906145e5565b505f5f611ab260125f8a8661ffff1681518110611a5b57611a5b614ee3565b60209081029190910181015182528181019290925260409081015f20815160808101835281546001600160a01b031681526001820154938101939093526002810154918301919091526003015460608201526133ce565b915091506009548211611ac55781611ac9565b6009545b9150600a548111611ada5780611ade565b600a545b9050611aea8286614f3c565b9450611af68185614f3c565b935050505b80611b0581614f0b565b915050611950565b509094909350915050565b611b2061350a565b611b29826135ae565b610cf282826135b6565b5f5f5160206153e85f395f51905f52611b575f5160206154485f395f51905f525490565b8310611b7a575f8360405163295f44f760e21b8152600401610d2792919061488a565b806002018381548110611b8f57611b8f614ee3565b905f5260205f200154915050919050565b5f611ba9613668565b505f5160206154285f395f51905f5290565b60195460ff1615611bdf57604051634b51d40f60e01b815260040160405180910390fd5b838503611bff57604051630980c2ef60e21b815260040160405180910390fd5b5f6107d0861115611c11576004611c14565b60065b90505f6107d0861115611c28576004611c2b565b60065b5f88815260106020526040902054909150600160ff909116118015611c6257505f8781526010602052604090205460ff8084169116105b8790611c8257604051630cc243f960e11b8152600401610d2791906145e5565b505f86815260106020526040902054600160ff909116118015611cb757505f8681526010602052604090205460ff8083169116105b8690611cd757604051630cc243f960e11b8152600401610d2791906145e5565b5033611ce288612165565b6001600160a01b03161480611d0c57505f878152601260205260409020546001600160a01b031633145b8790611d2c576040516302e41c0f60e01b8152600401610d2791906145e5565b5033611d3787612165565b6001600160a01b03161480611d6157505f868152601260205260409020546001600160a01b031633145b8690611d81576040516302e41c0f60e01b8152600401610d2791906145e5565b506040805160028082526060820183525f9260208301908036833701905050905087815f81518110611db557611db5614ee3565b6020026020010181815250508681600181518110611dd557611dd5614ee3565b602002602001018181525050611dec5f858361147b565b5f88815260116020526040808220548983529082205460ff91821692911690818311611e185781611e1a565b825b611e2590600161501b565b90505f600554600183611e389190615038565b60ff16611e459190614fa8565b611e5090600a615157565b89611e5c600185615038565b600454611e699190615164565b600254611e769190614fa8565b611e809190614f3c565b611e8a9190614fbf565b600d54604051632770a7eb60e21b81529192506001600160a01b031690639dc29fac90611ebd903390859060040161488a565b5f604051808303815f87803b158015611ed4575f5ffd5b505af1158015611ee6573d5f5f3e3d5ffd5b5050505f8d815260126020526040902054336001600160a01b03909116039050611f1f575f8c8152601260205260409020426002909101555b5f8b815260126020526040902054336001600160a01b0390911603611f53575f8b8152601260205260409020426002909101555b5f8c8152601060205260408120805460ff1691611f6f83615177565b82546101009290920a60ff8181021990931691831602179091555f8d815260106020526040812080549092169250611fa683615177565b91906101000a81548160ff021916908360ff160217905550505f611fc8610bc2565b9050611fd433826136b1565b5f8181526010602090815260408083208054600160ff19918216179091556011909252909120805490911660ff85161790558a15612016576120168133613173565b336001600160a01b03167fb44e8a10ee72d4a392dd220584e16927886f8db9f16add3c7538317fff8e555b828f8f866040516120559493929190614fde565b60405180910390a260018054905f61206c8361518c565b9190505550600f5f9054906101000a90046001600160a01b03166001600160a01b03166323ae0b086040518163ffffffff1660e01b81526004015f604051808303815f87803b1580156120bd575f5ffd5b505af11580156120cf573d5f5f3e3d5ffd5b5050505050505050505050505050505050565b60606008805480602002602001604051908101604052809291908181526020015f905b82821015612148578382905f5260205f2090600202016040518060400160405290815f820154815260200160018201548152505081526020019060010190612105565b50505050905090565b5f5f61215c8361194a565b91509150915091565b5f610bbc826136ca565b5f5f6008805480602002602001604051908101604052809291908181526020015f905b828210156121d5578382905f5260205f2090600202016040518060400160405290815f820154815260200160018201548152505081526020019060010190612192565b5050505090505f600182516121ea9190614f29565b90505b6008818154811061220057612200614ee3565b905f5260205f2090600202015f0154841061223c5781818151811061222757612227614ee3565b60200260200101516020015192505050919050565b8061224681614f63565b9150506121ed565b5f5f5160206154085f395f51905f526001600160a01b038316612286575f6040516322718ad960e21b8152600401610d279190614657565b6001600160a01b039092165f908152600390920160205250604090205490565b6122ae61308d565b6122b75f6136d4565b565b6122c161308d565b610e1360078383614540565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff1615906001600160401b03165f811580156123115750825b90505f826001600160401b0316600114801561232c5750303b155b90508115801561233a575080155b156123585760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561238257845460ff60401b1916600160401b1785555b6123cd6040518060400160405280600d81526020016c4b75676c652047656e6573697360981b8152506040518060400160405280600481526020016325a3a2a760e11b815250613744565b6123d5613756565b6123dd613756565b6123e5613756565b6123ee3361375e565b6123f6613756565b5f60188181556001828155680ad78ebc5ac62000006002819055600355600c600455600581905560078054808301825568010a741a46278000007fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688918201558154808401835567de0b6b3a764000009082015581548084018355678ac7230489e80000908201558154808401835567739a1adda3010000908201558154808401835567604fd53af5360000908201558154808401835567505a3652c183000090820155815480840183556742e414766962000090820155815480840183556737c9e8b37d1200009082015581548084018355672e5a104dcdce00009082015581548084019092556726b81237cb5700009101556006805480830182559381905267c7d713b49da000007ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f948501558054808301825567a688906bd8b0000090850155805480830182556768155a43676e000090850155805480830182556756bc75e2d6310000908501558054808301825567482a1c73000800009085015580548083018255673c3ac70175320000908501558054808301825567323cd2d206ea000090850155805480830182556729c5ab0d65ed000090850155805480830182556722d54fb3923b00009085015580549182019055671d012bed3c910000920191909155601655601580546201000033026001600160b01b0319909116176102ee179055681b1ae4d6e2ef5000006009819055600a55831561111257845460ff60401b191685556040517fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29061266e9060019061519d565b60405180910390a15050505050565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b031690565b7f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab007930180546060915f5160206154085f395f51905f5291610c5190614eab565b612726815f8686808060200260200160405190810160405280939291908181526020018383602002808284375f9201919091525061147b92505050565b5f805b84811015612a165760105f87878481811061274657612746614ee3565b602090810292909201358352508101919091526040015f205460ff1660011486868381811061277757612777614ee3565b905060200201359061279d5760405163761c47fd60e11b8152600401610d2791906145e5565b50336127b4878784818110610d9557610d95614ee3565b6001600160a01b031614806127fe57503360125f8888858181106127da576127da614ee3565b602090810292909201358352508101919091526040015f20546001600160a01b0316145b86868381811061281057612810614ee3565b9050602002013533909161283957604051631063106b60e21b8152600401610d279291906151b2565b505060055460115f88888581811061285357612853614ee3565b602090810292909201358352508101919091526040015f2054612879919060ff16614fa8565b61288490600a615157565b60115f88888581811061289957612899614ee3565b602090810292909201358352508101919091526040015f20546004546128c29160ff1690615164565b6003546128cf9190614fa8565b6128d99190614fbf565b6128e39083614f3c565b91503360125f8888858181106128fb576128fb614ee3565b602090810292909201358352508101919091526040015f20546001600160a01b031603612958574260125f88888581811061293857612938614ee3565b9050602002013581526020019081526020015f2060020181905550612973565b831561297357612973868683818110610df457610df4614ee3565b600260105f88888581811061298a5761298a614ee3565b9050602002013581526020019081526020015f205f6101000a81548160ff021916908360ff160217905550336001600160a01b03167f2543a938ecc43171e33b9d441b0a6aa9baad7260ea2ff859e0b12fc3273527fa8787848181106129f2576129f2614ee3565b90506020020135604051612a0691906145e5565b60405180910390a2600101612729565b50600c54604051632770a7eb60e21b81526001600160a01b0390911690639dc29fac90612a49903390859060040161488a565b5f604051808303815f87803b158015612a60575f5ffd5b505af1158015612a72573d5f5f3e3d5ffd5b505050505050505050565b610cf233838361376f565b612a9061308d565b7f6bd5c950a8d8df17f772f5af37cb3655737899cbf903264b9795592da439661c8282604051612ac1929190614aaa565b60405180910390a15050565b612ad561308d565b600292909255600355600455565b612aeb61308d565b5f91825260116020526040909120805460ff191660ff909216919091179055565b612b17848484611119565b6111883385858585613819565b606060405180606001604052806029815260200161546860299139612b4883613926565b604051602001612b599291906151cd565b6040516020818303038152906040529050919050565b600b546040516309ea1cff60e31b81525f9182916001600160a01b0390911690634f50e7f890612ba3908690600401614657565b602060405180830381865afa158015612bbe573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612be29190614e91565b9050612bed8161216f565b9392505050565b612bfc61308d565b600555565b6001600160a01b0381165f90815260146020908152604091829020805483518184028101840190945280845260609392830182828015612c5e57602002820191905f5260205f20905b815481526020019060010190808311612c4a575b50505050509050919050565b612c7261308d565b600991909155600a55565b612c8561308d565b601655565b6001600160a01b039182165f9081527f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab00793056020908152604080832093909416825291909152205460ff1690565b600f546001600160a01b03163314612cec575f5ffd5b612cf5816139b5565b8190612d155760405163d452055760e01b8152600401610d279190614657565b505f5b61ffff811683111561118857612d4a84848361ffff16818110612d3d57612d3d614ee3565b9050602002013583613173565b80612d5481614f0b565b915050612d18565b612d8c60405180608001604052805f6001600160a01b031681526020015f81526020015f81526020015f81525090565b5f828152601260205260409020546001600160a01b0316612dab575f5ffd5b505f90815260126020908152604091829020825160808101845281546001600160a01b03168152600182015492810192909252600281015492820192909252600390910154606082015290565b612e0061308d565b6001600160a01b038116612e29575f604051631e4fbdf760e01b8152600401610d279190614657565b610d6a816136d4565b612e3a61308d565b846001600160a01b038116612e635760405163084c41ef60e01b8152600401610d279190614657565b50836001600160a01b038116612e8d5760405163084c41ef60e01b8152600401610d279190614657565b50826001600160a01b038116612eb75760405163084c41ef60e01b8152600401610d279190614657565b50816001600160a01b038116612ee15760405163084c41ef60e01b8152600401610d279190614657565b50806001600160a01b038116612f0b5760405163084c41ef60e01b8152600401610d279190614657565b50600b80546001600160a01b03199081166001600160a01b0397881617909155600c8054821695871695909517909455600d8054851693861693909317909255600e80548416918516919091179055600f80549092169216919091179055565b612f7361308d565b6019805460ff1916911515919091179055565b600f546001600160a01b0316331480612fb75750612fa261267d565b6001600160a01b0316336001600160a01b0316145b612fbf575f5ffd5b5f5b82518161ffff161015610e1357612ff582848361ffff1681518110612fe857612fe8614ee3565b60200260200101516139e5565b80612fff81614f0b565b915050612fc1565b5f610bbc82613a9c565b5f5f61301c83613ac0565b90506001600160a01b038116610bbc5782604051637e27328960e01b8152600401610d2791906145e5565b5f9081527f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab007930460205260409020546001600160a01b031690565b610e138383836001613af9565b3361309661267d565b6001600160a01b0316146122b7573360405163118cdaa760e01b8152600401610d279190614657565b7fdaedc9ab023613a7caf35e703657e986ccfad7e3eb0af93a2853f8d65dd86b006127106001600160601b038316811015613111578281604051636f483d0960e01b8152600401610d2792919061521c565b6001600160a01b03841661313a575f604051635b6cc80560e11b8152600401610d279190614657565b50604080518082019091526001600160a01b039093168084526001600160601b039092166020909301839052600160a01b909202179055565b61317c816139b5565b819061319c5760405163d452055760e01b8152600401610d279190614657565b506131a8333084611119565b604080516080810182526001600160a01b03838116808352426020808501828152858701928352606086018981525f8a815260128452888120885181546001600160a01b03191698169790971787559151600187015592516002860155915160039094019390935590815260139091529182208054919261ffff9092169161322f83614f0b565b91906101000a81548161ffff021916908361ffff160217905550505f601481819054906101000a900461ffff168092919061326990614f0b565b825461ffff9182166101009390930a9283029190920219909116179055506001600160a01b0382165f81815260146020908152604080832080546001810182559084529190922001859055517f5a10b5f49dd8fad36b4ab1cbca7032df7337fdc475a5616c796b654fe12eedac906132e29086906145e5565b60405180910390a2505050565b5f6132fb848484613c03565b949350505050565b610e1383838360405180602001604052805f815250613cf9565b335f908152601460205260408120905b8154811015610e13578282828154811061334957613349614ee3565b905f5260205f200154036133c6578154829061336790600190614f29565b8154811061337757613377614ee3565b905f5260205f20015482828154811061339257613392614ee3565b905f5260205f200181905550818054806133ae576133ae614f4f565b600190038181905f5260205f20015f90559055505050565b60010161332d565b5f5f5f601654610e106133e19190614fa8565b90505f8460200151426133f49190614f29565b90505f8560200151866040015161340b9190614f29565b90505f6134188284614f29565b6060880180515f9081526011602090815260408083205493518352601090915290205491925060ff908116916001911611156134a9576007545f9061345f90600190614f29565b60075490915082101561346f5750805b85836007838154811061348457613484614ee3565b905f5260205f2001546134979190614fa8565b6134a19190614fbf565b965050613500565b6006545f906134ba90600190614f29565b6006549091508210156134ca5750805b8583600683815481106134df576134df614ee3565b905f5260205f2001546134f29190614fa8565b6134fc9190614fbf565b9750505b5050505050915091565b306001600160a01b037f000000000000000000000000519711c3137437ca583e07db5a954782fb2dbe9316148061359057507f000000000000000000000000519711c3137437ca583e07db5a954782fb2dbe936001600160a01b03166135845f5160206154285f395f51905f52546001600160a01b031690565b6001600160a01b031614155b156122b75760405163703e46dd60e11b815260040160405180910390fd5b610d6a61308d565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015613610575060408051601f3d908101601f1916820190925261360d91810190614e91565b60015b61362f5781604051634c9c8ce360e01b8152600401610d279190614657565b5f5160206154285f395f51905f52811461365e5780604051632a87526960e21b8152600401610d2791906145e5565b610e138383613d04565b306001600160a01b037f000000000000000000000000519711c3137437ca583e07db5a954782fb2dbe9316146122b75760405163703e46dd60e11b815260040160405180910390fd5b610cf2828260405180602001604052805f815250613d59565b5f610bbc82613d70565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a3505050565b61374c613d7a565b610cf28282613dc3565b6122b7613d7a565b613766613d7a565b610d6a81613df3565b5f5160206154085f395f51905f526001600160a01b0383166137a65782604051630b61174360e31b8152600401610d279190614657565b6001600160a01b038481165f81815260058401602090815260408083209488168084529490915290819020805460ff1916861515179055517f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c319061380b9086906145d7565b60405180910390a350505050565b6001600160a01b0383163b1561111257604051630a85bd0160e11b81526001600160a01b0384169063150b7a029061385b908890889087908790600401615231565b6020604051808303815f875af1925050508015613895575060408051601f3d908101601f19168201909252613892918101906152a5565b60015b6138f3573d8080156138c2576040519150601f19603f3d011682016040523d82523d5f602084013e6138c7565b606091505b5080515f036138eb5783604051633250574960e11b8152600401610d279190614657565b805181602001fd5b6001600160e01b03198116630a85bd0160e11b146116c25783604051633250574960e11b8152600401610d279190614657565b60605f61393283613dfb565b60010190505f816001600160401b03811115613950576139506148e1565b6040519080825280601f01601f19166020018201604052801561397a576020820181803683370190505b5090508181016020015b5f19016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a850494508461398457509392505050565b5f6139bf82612b6f565b6001600160a01b039092165f9081526013602052604090205461ffff1691909110919050565b6139ef82826136b1565b5f818152601060205260409020805460ff191660011790556107d08111613a2a575f818152601160205260409020805460ff19169055613a43565b5f818152601160205260409020805460ff191660011790555b816001600160a01b03167f1c05098ed1ff38e6238d2b1b04b2c7977d4c94ce651bda6473f9dba8dbf01da082604051613a7c91906145e5565b60405180910390a260018054905f613a938361518c565b91905055505050565b5f6001600160e01b03198216632483248360e11b1480610bbc5750610bbc82613ed2565b5f9081527f80bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab007930260205260409020546001600160a01b031690565b5f5160206154085f395f51905f528180613b1b57506001600160a01b03831615155b15613bd3575f613b2a85613011565b90506001600160a01b03841615801590613b565750836001600160a01b0316816001600160a01b031614155b8015613b695750613b678185612c8a565b155b15613b89578360405163a9fbf51f60e01b8152600401610d279190614657565b8215613bd15784866001600160a01b0316826001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45b505b5f93845260040160205250506040902080546001600160a01b0319166001600160a01b0392909216919091179055565b5f5f613c10858585613ef6565b90506001600160a01b038116613c9757613c92845f5160206154485f395f51905f5280545f8381527f645e039705490088daad89bae25049a34f4a9072d398537b1ab2425f24cbed0360205260408120829055600182018355919091527fa42f15e5d656f8155fd7419d740a6073999f19cd6e061449ce4a257150545bf20155565b613cba565b846001600160a01b0316816001600160a01b031614613cba57613cba8185613ff8565b6001600160a01b038516613cd657613cd18461408f565b6132fb565b846001600160a01b0316816001600160a01b0316146132fb576132fb858561415c565b612b178484846141b4565b613d0d8261424c565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a2805115613d5157610e1382826142a6565b610cf2614318565b613d638383614337565b610e13335f858585613819565b5f610bbc82613011565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff166122b757604051631afcd79f60e31b815260040160405180910390fd5b613dcb613d7a565b5f5160206154085f395f51905f5280613de4848261530c565b5060018101611188838261530c565b612e00613d7a565b5f8072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8310613e395772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310613e65576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310613e8357662386f26fc10000830492506010015b6305f5e1008310613e9b576305f5e100830492506008015b6127108310613eaf57612710830492506004015b60648310613ec1576064830492506002015b600a8310610bbc5760010192915050565b5f6001600160e01b0319821663780e9d6360e01b1480610bbc5750610bbc82614398565b5f5f5160206154085f395f51905f5281613f0f85613ac0565b90506001600160a01b03841615613f2b57613f2b8185876143d7565b6001600160a01b03811615613f6757613f465f865f5f613af9565b6001600160a01b0381165f908152600383016020526040902080545f190190555b6001600160a01b03861615613f97576001600160a01b0386165f9081526003830160205260409020805460010190555b5f85815260028301602052604080822080546001600160a01b0319166001600160a01b038a811691821790925591518893918516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a495945050505050565b5f5160206153e85f395f51905f525f6140108461224e565b5f8481526001840160209081526040808320546001600160a01b03891684529186905290912091925090818314614068575f838152602082815260408083205485845281842081905583526001870190915290208290555b5f948552600190930160209081526040808620869055928552929092528220919091555050565b5f5160206154485f395f51905f52545f5160206153e85f395f51905f52905f906140bb90600190614f29565b5f8481526003840160205260408120546002850180549394509092849081106140e6576140e6614ee3565b905f5260205f20015490508084600201838154811061410757614107614ee3565b5f9182526020808320909101929092558281526003860190915260408082208490558682528120556002840180548061414257614142614f4f565b600190038181905f5260205f20015f905590555050505050565b5f5160206153e85f395f51905f525f60016141768561224e565b6141809190614f29565b6001600160a01b039094165f9081526020838152604080832087845282528083208690559482526001909301909252502055565b6001600160a01b0382166141dd575f604051633250574960e11b8152600401610d279190614657565b5f6141e983835f6132ef565b90506001600160a01b0381166142145781604051637e27328960e01b8152600401610d2791906145e5565b836001600160a01b0316816001600160a01b031614611188578382826040516364283d7b60e01b8152600401610d2793929190614f78565b806001600160a01b03163b5f036142785780604051634c9c8ce360e01b8152600401610d279190614657565b5f5160206154285f395f51905f5280546001600160a01b0319166001600160a01b0392909216919091179055565b60605f5f846001600160a01b0316846040516142c291906153c5565b5f60405180830381855af49150503d805f81146142fa576040519150601f19603f3d011682016040523d82523d5f602084013e6142ff565b606091505b509150915061430f85838361442c565b95945050505050565b34156122b75760405163b398979f60e01b815260040160405180910390fd5b6001600160a01b038216614360575f604051633250574960e11b8152600401610d279190614657565b5f61436c83835f6132ef565b90506001600160a01b03811615610e13575f6040516339e3563760e11b8152600401610d279190614657565b5f6001600160e01b031982166380ac58cd60e01b14806143c857506001600160e01b03198216635b5e139f60e01b145b80610bbc5750610bbc8261447f565b6143e28383836144b3565b610e13576001600160a01b03831661440f5780604051637e27328960e01b8152600401610d2791906145e5565b818160405163177e802f60e01b8152600401610d2792919061488a565b6060826144415761443c82614517565b612bed565b815115801561445857506001600160a01b0384163b155b156144785783604051639996b31560e01b8152600401610d279190614657565b5080612bed565b5f6001600160e01b0319821663152a902d60e11b1480610bbc57506301ffc9a760e01b6001600160e01b0319831614610bbc565b5f6001600160a01b038316158015906132fb5750826001600160a01b0316846001600160a01b031614806144ec57506144ec8484612c8a565b806132fb5750826001600160a01b031661450583613047565b6001600160a01b031614949350505050565b8051156145275780518082602001fd5b60405163d6bda27560e01b815260040160405180910390fd5b828054828255905f5260205f20908101928215614579579160200282015b8281111561457957823582559160200191906001019061455e565b50614585929150614589565b5090565b5b80821115614585575f815560010161458a565b6001600160e01b031981168114610d6a575f5ffd5b8035610bbc8161459d565b5f602082840312156145cd575f5ffd5b612bed83836145b2565b811515815260208101610bbc565b81815260208101610bbc565b8281835e505f910152565b602080825282518282018181529160408401915f91839061462290839083908a016145f1565b601f91909101601f19160195945050505050565b8035610bbc565b5f6020828403121561464d575f5ffd5b612bed8383614636565b6001600160a01b038216815260208101610bbc565b80356001600160a01b0381168114610bbc575f5ffd5b5f5f60408385031215614693575f5ffd5b61469d848461466c565b91506146ac8460208501614636565b90509250929050565b5f602082840312156146c5575f5ffd5b612bed838361466c565b5f5f83601f8401126146df575f5ffd5b5081356001600160401b038111156146f5575f5ffd5b6020830191508360208202830111156113b7575f5ffd5b5f5f6020838503121561471d575f5ffd5b82356001600160401b03811115614732575f5ffd5b61473e858286016146cf565b92509250509250929050565b803561ffff81168114610bbc575f5ffd5b5f6020828403121561476b575f5ffd5b612bed838361474a565b5f5f5f60608486031215614787575f5ffd5b6147918585614636565b92506147a08560208601614636565b91506147af8560408601614636565b90509250925092565b60ff8216815260208101610bbc565b5f5f5f606084860312156147d9575f5ffd5b6147e3858561466c565b92506147a0856020860161466c565b602080825282518282018181529160408401915f918601825b8281101561482c57815160ff1685526020948501949091019060010161480b565b50929695505050505050565b602080825282518282018181529160408401915f918601825b8281101561482c578151855260209485019490910190600101614851565b5f5f60408385031215614880575f5ffd5b61469d8484614636565b6001600160a01b0383168152604081015b612bed60208301849052565b803560ff81168114610bbc575f5ffd5b5f5f604083850312156148c8575f5ffd5b6148d28484614636565b91506146ac84602085016148a7565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f191681016001600160401b038111828210171561491d5761491d6148e1565b604052919050565b5f6001600160401b0382111561493d5761493d6148e1565b5060209081020190565b5f61495961495484614925565b6148f5565b83815290506020808201908402830185811115614974575f5ffd5b835b81811015614996576149888782614636565b835260209283019201614976565b5050509392505050565b5f82601f8301126149af575f5ffd5b612bed83833560208501614947565b5f5f5f606084860312156149d0575f5ffd5b6149da8585614636565b92506149e98560208601614636565b915060408401356001600160401b03811115614a03575f5ffd5b614a0f868287016149a0565b9150509250925092565b5f5f5f5f60608587031215614a2c575f5ffd5b84356001600160401b03811115614a41575f5ffd5b614a4d878288016146cf565b9450945050614a5f8660208701614636565b9150614a6e8660408701614636565b905092959194509250565b5f60208284031215614a89575f5ffd5b81356001600160401b03811115614a9e575f5ffd5b6132fb848285016149a0565b8281526040810161489b565b5f6001600160401b03821115614ace57614ace6148e1565b506020601f91909101601f19160190565b5f614aec61495484614ab6565b905082815260208101848484011115614b03575f5ffd5b838382375f84820152509392505050565b5f82601f830112614b23575f5ffd5b612bed83833560208501614adf565b5f5f60408385031215614b43575f5ffd5b614b4d848461466c565b915060208301356001600160401b03811115614b67575f5ffd5b614b7385828601614b14565b9150509250929050565b80358015158114610bbc575f5ffd5b5f5f5f5f5f60a08688031215614ba0575f5ffd5b614baa8787614636565b9450614bb98760208801614636565b9350614bc88760408801614b7d565b9250614bd78760608801614636565b9150614be68760808801614636565b90509295509295909350565b602080825282518282018181529160408401915f918601825b8281101561482c578151805186526020908101518187015260409095019490910190600101614c0b565b5f5f5f5f60608587031215614c48575f5ffd5b84356001600160401b03811115614c5d575f5ffd5b614c69878288016146cf565b9450945050614a5f8660208701614b7d565b5f5f60408385031215614c8c575f5ffd5b614c96848461466c565b91506146ac8460208501614b7d565b5f5f5f5f60808587031215614cb8575f5ffd5b614cc2868661466c565b9350614cd1866020870161466c565b9250614ce08660408701614636565b915060608501356001600160401b03811115614cfa575f5ffd5b614d0687828801614b14565b91505092959194509250565b83815260608101614d2560208301859052565b6132fb60408301849052565b5f5f60408385031215614d42575f5ffd5b614d4c848461466c565b91506146ac846020850161466c565b5f5f5f60408486031215614d6d575f5ffd5b83356001600160401b03811115614d82575f5ffd5b614d8e868287016146cf565b93509350506147af856020860161466c565b81516001600160a01b0316815260208083015190820152604080830151908201526060808301519082015260808101610bbc565b5f5f5f5f5f60a08688031215614de8575f5ffd5b614df2878761466c565b9450614e01876020880161466c565b9350614e10876040880161466c565b9250614e1f876060880161466c565b9150614be6876080880161466c565b5f60208284031215614e3e575f5ffd5b612bed8383614b7d565b5f5f60408385031215614e59575f5ffd5b82356001600160401b03811115614e6e575f5ffd5b614e7a858286016149a0565b9250506146ac846020850161466c565b8051610bbc565b5f60208284031215614ea1575f5ffd5b612bed8383614e8a565b600281046001821680614ebf57607f821691505b602082108103614edd57634e487b7160e01b5f52602260045260245ffd5b50919050565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b61ffff165f61fffe198201614f2257614f22614ef7565b5060010190565b81810381811115610bbc57610bbc614ef7565b80820180821115610bbc57610bbc614ef7565b634e487b7160e01b5f52603160045260245ffd5b5f81614f7157614f71614ef7565b505f190190565b6001600160a01b038416815260608101614f9460208301859052565b6001600160a01b03831660408301526132fb565b8082028115828204841417610bbc57610bbc614ef7565b5f82614fd957634e487b7160e01b5f52601260045260245ffd5b500490565b84815260808101614ff160208301869052565b614ffd60408301859052565b61430f60608301849052565b61ffff165f81614f7157614f71614ef7565b60ff918216919081169082820190811115610bbc57610bbc614ef7565b60ff918216919081169082820390811115610bbc57610bbc614ef7565b80825b600185111561508f5780860481111561507357615073614ef7565b600185161561508157908102905b60019490941c938002615058565b94509492505050565b5f826150a657506001612bed565b816150b257505f612bed565b81600181146150c857600281146150d2576150ff565b6001915050612bed565b60ff8411156150e3576150e3614ef7565b8360020a9150848211156150f9576150f9614ef7565b50612bed565b5060208310610133831016604e8410600b841016171561512d575081810a8381111561443c5761443c614ef7565b61513a8484846001615055565b9250905081840481111561515057615150614ef7565b0292915050565b5f612bed5f198484615098565b60ff821691505f612bed5f198484615098565b60ff165f60fe198201614f2257614f22614ef7565b5f60018201614f2257614f22614ef7565b6001600160401b038216815260208101610bbc565b828152604081016001600160a01b0383166020830152612bed565b5f815f85518492506151e3818660208a016145f1565b85519401938492508291505f906151fe818460208a016145f1565b672f6f735f76616c7360c01b92019182525060080195945050505050565b6001600160601b03831681526040810161489b565b6001600160a01b0385168152608081016001600160a01b038516602083015261525c60408301859052565b8181036060830152805f84515f818552602085019050809350615283828260208a016145f1565b601f91909101601f19160198975050505050505050565b8051610bbc8161459d565b5f602082840312156152b5575f5ffd5b612bed838361529a565b81811015610cf2575f81556001016152bf565b601f821115610e13575f81815260209081902090601f85018190048201908510156152fa5750805b6111126020601f8601048301826152bf565b81516001600160401b03811115615325576153256148e1565b615339816153338454614eab565b846152d2565b6020601f82116001811461536b575f83156153545750848201515b5f19600885021c1981166002850217855550611112565b5f84815260208120601f198516915b8281101561539a578785015182556020948501946001909201910161537a565b50848210156153b657838701515f19601f87166008021c191681555b50505050600202600101905550565b5f815f84518492506153db8186602089016145f1565b9390930194935050505056fe645e039705490088daad89bae25049a34f4a9072d398537b1ab2425f24cbed0080bb2b638cc20bc4d0a60d66940f3ab4a00c1d7b313497ca82fb0b4ab0079300360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc645e039705490088daad89bae25049a34f4a9072d398537b1ab2425f24cbed0268747470733a2f2f6170692e6b75676c652e6170702f6574682d6170692d6465762f6b75676c65732fa2646970667358221220a5c9b41712c4800ee2b7d5eabe92284f26c8fb62b241fcce6e33ad42f48cb27464736f6c634300081c0033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in GLMR
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.