Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
TokenTracker
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Name:
LiquidityBonds
Compiler Version
v0.8.22+commit.4fc1097e
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// Copyright 2025 Energi Core
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not,
// see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
/// @title LiquidityBonds
/// @author Energi Core
pragma solidity 0.8.22;
import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import { ERC721Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
import { ILiquidityBondLocker } from "./interface/ILiquidityBondLocker.sol";
import { IOperatorRegistry } from "./interface/IOperatorRegistry.sol";
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
import { Base64 } from "@openzeppelin/contracts/utils/Base64.sol";
import { INonFungiblePositionManager } from "./interface/INonfungiblePositionManager.sol";
contract LiquidityBonds is ERC721Upgradeable, OwnableUpgradeable, PausableUpgradeable, ReentrancyGuardUpgradeable {
using Strings for uint256;
// ------------------------------------------------------------------------
// Events
// ------------------------------------------------------------------------
event MinterAdded(address indexed minter);
event MinterRemoved(address indexed minter);
event LiquidityBondLockerUpdated(address indexed oldLiquidityBondLocker, address indexed newLiquidityBondLocker);
event LiquidityBondMinted(address indexed to, uint256 indexed bondId, uint256 indexed uniswapV3PositionId);
event LiquidityBondBurned(uint256 indexed bondId);
event OperatorRegistryUpdated(address indexed oldOperatorRegistry, address indexed newOperatorRegistry);
// ------------------------------------------------------------------------
// Storage
// ------------------------------------------------------------------------
string public bondType; // Type of the bond, can be used for categorization
struct Bond {
uint256 bondId; // Bond ID
uint256 uniswapV3PositionId; // Uniswap V3 position ID
bool isRedemeed; // Whether the bond is locked
}
uint256 public currentIndex; // Current index for the next bond ID
mapping(uint256 => Bond) public bonds; // Mapping of bond ID to Bond struct
mapping(address => bool) public minters; // Mapping of minters
address public liquidityBondLocker; // Address of the liquidity bond locker
address public operatorRegistry; // Address of the operator registry
// ------------------------------------------------------------------------
// Modifiers
// ------------------------------------------------------------------------
/**
* @notice Modifier to check if the caller is a minter or the owner
*/
modifier onlyMinterOrOwner() {
require(minters[msg.sender] || msg.sender == owner(), "LiquidityBonds:: Not a minter or owner");
_;
}
/**
* @notice Internal function to validate a transfer, according to whether the calling address,
* from address and to address is an EOA or Whitelisted
* @param from the address of the from target to be validated
* @param to the address of the to target to be validated
*/
modifier validateTransfer(address from, address to) {
require(
msg.sender == tx.origin || IOperatorRegistry(operatorRegistry).isOperatorAllowed(address(this), msg.sender),
"LiquidityBonds: Sender is not whitelist"
);
uint256 codeLength;
assembly {
codeLength := extcodesize(to)
}
require(
codeLength == 0 || IOperatorRegistry(operatorRegistry).isOperatorAllowed(address(this), to),
"LiquidityBonds: Receiver not whitelist"
);
_;
}
/**
* @notice Internal function to validate a approve
* @param _operator the address of the from target to be validated
*/
modifier validateApprove(address _operator) {
uint256 codeLength;
assembly {
codeLength := extcodesize(_operator)
}
require(
codeLength == 0 || IOperatorRegistry(operatorRegistry).isOperatorAllowed(address(this), _operator),
"LiquidityBonds: Operator is not whitelisted"
);
_;
}
// ------------------------------------------------------------------------
// Initialization
// ------------------------------------------------------------------------
/**
* @notice Initializes the contract
* @dev Only callable once
* @param liquidityBondLocker_ ~ Address of the liquidity bond locker
*/
function initialize(
address liquidityBondLocker_,
address operatorRegistry_,
string memory bondType_
) external initializer {
__ERC721_init("ETH-GMI LP Bond L4", "ETH-GMI-BOND-L4");
__Ownable_init();
__Pausable_init();
__ReentrancyGuard_init();
liquidityBondLocker = liquidityBondLocker_;
operatorRegistry = operatorRegistry_;
bondType = bondType_;
minters[liquidityBondLocker_] = true; // Set the liquidity bond locker as a minter
}
// ------------------------------------------------------------------------
// Public Functions
// ------------------------------------------------------------------------
/**
* @notice Mints a new liquidity bond
* @dev Only callable by the minter or owner
* @param _to ~ Address to mint the bond to
* @param _uniswapV3PositionId ~ Uniswap V3 position ID
*/
function mint(address _to, uint256 _uniswapV3PositionId) external onlyMinterOrOwner whenNotPaused nonReentrant {
require(_to != address(0), "LiquidityBonds:: Address is zero");
require(_uniswapV3PositionId != 0, "LiquidityBonds:: Uniswap V3 position ID is zero");
ILiquidityBondLocker locker = ILiquidityBondLocker(liquidityBondLocker);
require(locker.locks(_uniswapV3PositionId).isLocked == false, "LiquidityBonds:: Position is already locked");
currentIndex++;
bonds[currentIndex] = Bond(currentIndex, _uniswapV3PositionId, false);
_mint(_to, currentIndex);
emit LiquidityBondMinted(_to, currentIndex, _uniswapV3PositionId);
}
/**
* @notice Burn liquidity bond
* @dev Only callable by the minter or owner
* @param _bondId ~ Token ID of the bond
*/
function burn(uint256 _bondId) external onlyMinterOrOwner whenNotPaused nonReentrant {
require(_bondId != 0, "LiquidityBonds:: Bond ID is zero");
require(_exists(_bondId), "LiquidityBonds:: Bond does not exist");
bonds[_bondId].isRedemeed = true;
_burn(_bondId);
emit LiquidityBondBurned(_bondId);
}
// ------------------------------------------------------------------------
// Owner Functions
// ------------------------------------------------------------------------
/**
* @notice Pauses contract
*/
function pause() external onlyOwner {
_pause();
}
/**
* @notice Unpauses contract
*/
function unpause() external onlyOwner {
_unpause();
}
/**
* @notice Adds a new minter
* @dev Only callable by the owner
* @param _minter ~ Address of the new minter
*/
function addMinter(address _minter) external onlyOwner {
require(_minter != address(0), "LiquidityBonds:: Address is zero");
require(!minters[_minter], "LiquidityBonds:: Address is already a minter");
minters[_minter] = true;
emit MinterAdded(_minter);
}
/**
* @notice Removes a minter
* @dev Only callable by the owner
* @param _minter ~ Address of the minter
*/
function removeMinter(address _minter) external onlyOwner {
require(_minter != address(0), "LiquidityBonds:: Address is zero");
require(minters[_minter], "LiquidityBonds:: Address is not a minter");
minters[_minter] = false;
emit MinterRemoved(_minter);
}
/**
* @notice Updates the liquidity bond locker address
* @dev Only callable by the owner
* @param _liquidityBondLocker ~ Address of the new liquidity bond locker
*/
function updateLiquidityBondLocker(address _liquidityBondLocker) external onlyOwner {
require(_liquidityBondLocker != address(0), "LiquidityBonds:: Address is zero");
require(_liquidityBondLocker != liquidityBondLocker, "LiquidityBonds:: Address is already set");
address oldLiquidityBondLocker = liquidityBondLocker;
liquidityBondLocker = _liquidityBondLocker;
emit LiquidityBondLockerUpdated(oldLiquidityBondLocker, _liquidityBondLocker);
}
/**
* @notice Updates the operator registry address
* @dev Only callable by the owner
* @param _operatorRegistry ~ Address of the new operator registry
*/
function updateOperatorRegistry(address _operatorRegistry) external onlyOwner {
require(_operatorRegistry != address(0), "LiquidityBonds:: Address is zero");
require(_operatorRegistry != operatorRegistry, "LiquidityBonds:: Address is already set");
address oldOperatorRegistry = operatorRegistry;
operatorRegistry = _operatorRegistry;
emit OperatorRegistryUpdated(oldOperatorRegistry, _operatorRegistry);
}
// ------------------------------------------------------------------------
// Internal
// ------------------------------------------------------------------------
/// @dev Gets current timestamp
function _currentTime() internal view virtual returns (uint256) {
return block.timestamp;
}
/**
* @notice Extracts a portion of a string
* @param str The input string to extract from
* @param startIndex The starting position to extract from
* @param endIndex The end position to extract to
* @return The extracted substring
*/
function substring(string memory str, uint256 startIndex, uint256 endIndex) internal pure returns (string memory) {
bytes memory strBytes = bytes(str);
bytes memory result = new bytes(endIndex - startIndex);
for (uint256 i = startIndex; i < endIndex; i++) {
result[i - startIndex] = strBytes[i];
}
return string(result);
}
/**
* @notice Formats a number from 18 decimals to a 4 decimal place string
* @param value The number to format (with 18 decimals)
* @return The formatted string with 4 decimal places
*/
function formatDecimals(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0.0000";
}
string memory str = value.toString();
uint256 length = bytes(str).length;
if (length <= 18) {
uint256 zeros = 18 - length;
string memory pad;
for (uint256 i = 0; i < zeros; i++) {
pad = string(abi.encodePacked("0", pad));
}
str = string(abi.encodePacked(pad, str));
length = 18;
}
uint256 decimalPosition = length - 18;
string memory wholeNumber = decimalPosition == 0 ? "0" : substring(str, 0, decimalPosition);
string memory decimals = substring(str, decimalPosition, decimalPosition + 4);
return string(abi.encodePacked(wholeNumber, ".", decimals));
}
/**
* @dev Note it will validate the from and to address in the allowlist
*/
function _transfer(address from, address to, uint256 tokenId) internal virtual override validateTransfer(from, to) {
super._transfer(from, to, tokenId);
}
/**
* @dev Note it will validate operator is allowed or not
*/
function _approve(address to, uint256 tokenId) internal virtual override validateApprove(to) {
super._approve(to, tokenId);
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual override validateApprove(operator) {
super._setApprovalForAll(owner, operator, approved);
}
// ------------------------------------------------------------------------
// View
// ------------------------------------------------------------------------
/**
* @notice Get bond information
* @param _bondId ID of the bond
* @return uniswapV3PositionId ID of the Uniswap V3 position
* @return startTime Start time of the bond
* @return duration Duration of the bond
* @return durationLeft Time left for the bond to unlock
* @return rewardsGMI GMI rewards for the bond
* @return rewardsWETH9 WETH9 rewards for the bond
*/
function getBondInfo(
uint256 _bondId
)
public
view
returns (
uint256 uniswapV3PositionId,
uint256 startTime,
uint256 duration,
uint256 durationLeft,
uint256 rewardsGMI,
uint256 rewardsWETH9
)
{
Bond memory bond = bonds[_bondId];
ILiquidityBondLocker locker = ILiquidityBondLocker(liquidityBondLocker);
ILiquidityBondLocker.Lock memory lock = locker.locks(bond.uniswapV3PositionId);
ILiquidityBondLocker.Bond memory currentBond = locker.bonds(lock.bondId);
uint256 timeLeft = _currentTime() >= lock.startTime + currentBond.lockDuration
? 0
: (currentBond.lockDuration + lock.startTime) - _currentTime();
(rewardsGMI) = locker.getRewards0(bond.uniswapV3PositionId);
(, , , , , , , , , , uint128 tokensOwed0, uint128 tokensOwed1) = INonFungiblePositionManager(
locker.uniswapPositionManager()
).positions(bond.uniswapV3PositionId);
return (
lock.uniswapV3PositionId,
lock.startTime,
currentBond.lockDuration,
timeLeft,
rewardsGMI + tokensOwed0,
tokensOwed1
);
}
/**
* @notice Get the token URI for a bond
* @param _tokenId ID of the bond
* @return Token URI for the bond
*/
function tokenURI(uint256 _tokenId) public view override returns (string memory) {
(
uint256 uniswapV3PositionId,
uint256 startTime,
uint256 duration,
uint256 durationLeft,
uint256 rewardsGMI,
uint256 rewardsWETH9
) = getBondInfo(_tokenId);
uint256 unlockTime = _currentTime() + durationLeft;
string memory svg = string(
abi.encodePacked(
'<svg width="290" height="500" viewBox="0 0 290 500" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><filter id="f1"><feImage result="p0" xlink:href="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0nMjkwJyBoZWlnaHQ9JzUwMCcgdmlld0JveD0nMCAwIDI5MCA1MDAnIHhtbG5zPSdodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2Zyc+PHJlY3Qgd2lkdGg9JzI5MHB4JyBoZWlnaHQ9JzUwMHB4JyBmaWxsPScjMWM3ZDRiJy8+PC9zdmc+"/> <feImage result="p1" xlink:href="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0nMjkwJyBoZWlnaHQ9JzUwMCcgdmlld0JveD0nMCAwIDI5MCA1MDAnIHhtbG5zPSdodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2Zyc+PGNpcmNsZSBjeD0nMjIyJyBjeT0nMjAyJyByPScxMjBweCcgZmlsbD0nI2ZmZjk5NycvPjwvc3ZnPg==" /> <feImage result="p2" xlink:href="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0nMjkwJyBoZWlnaHQ9JzUwMCcgdmlld0JveD0nMCAwIDI5MCA1MDAnIHhtbG5zPSdodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2Zyc+PGNpcmNsZSBjeD0nODQnIGN5PSczODEnIHI9JzEyMHB4JyBmaWxsPScjOWM3MjM4Jy8+PC9zdmc+" /> <feImage result="p3" xlink:href="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0nMjkwJyBoZWlnaHQ9JzUwMCcgdmlld0JveD0nMCAwIDI5MCA1MDAnIHhtbG5zPSdodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2Zyc+PGNpcmNsZSBjeD0nMjU2JyBjeT0nNDA3JyByPScxMDBweCcgZmlsbD0nIzRkNmIxNCcvPjwvc3ZnPg==" /> <feBlend mode="overlay" in="p0" in2="p1" /> <feBlend mode="exclusion" in2="p2" /> <feBlend mode="overlay" in2="p3" result="blendOut" /> <feGaussianBlur in="blendOut" stdDeviation="42" /> </filter> <clipPath id="corners"> <rect width="290" height="500" rx="42" ry="42" /> </clipPath> <path id="text-path-a" d="M40 12 H250 A28 28 0 0 1 278 40 V460 A28 28 0 0 1 250 488 H40 A28 28 0 0 1 12 460 V40 A28 28 0 0 1 40 12 z" /> <path id="minimap" d="M234 444C234 457.949 242.21 463 253 463" /> <filter id="top-region-blur"> <feGaussianBlur in="SourceGraphic" stdDeviation="24" /> </filter> <linearGradient id="grad-up" x1="1" x2="0" y1="1" y2="0"> <stop offset="0.0" stop-color="white" stop-opacity="1" /> <stop offset=".9" stop-color="white" stop-opacity="0" /> </linearGradient> <linearGradient id="grad-down" x1="0" x2="1" y1="0" y2="1"> <stop offset="0.0" stop-color="white" stop-opacity="1" /> <stop offset="0.9" stop-color="white" stop-opacity="0" /> </linearGradient> <mask id="fade-up" maskContentUnits="objectBoundingBox"> <rect width="1" height="1" fill="url(#grad-up)" /> </mask> <mask id="fade-down" maskContentUnits="objectBoundingBox"> <rect width="1" height="1" fill="url(#grad-down)" /> </mask> <mask id="none" maskContentUnits="objectBoundingBox"> <rect width="1" height="1" fill="white" /> </mask> <linearGradient id="grad-symbol"> <stop offset="0.7" stop-color="white" stop-opacity="1" /> <stop offset=".95" stop-color="white" stop-opacity="0" /> </linearGradient> <mask id="fade-symbol" maskContentUnits="userSpaceOnUse"> <rect width="290px" height="200px" fill="url(#grad-symbol)" /> </mask> </defs> <g clip-path="url(#corners)"> <rect fill="#1c7d4b" x="0px" y="0px" width="290px" height="500px" /> <rect style="filter: url(#f1)" x="0px" y="0px" width="290px" height="500px" /> <g style="filter:url(#top-region-blur); transform:scale(1.5); transform-origin:center top;"> <rect fill="none" x="0px" y="0px" width="290px" height="500px" /> <ellipse cx="50%" cy="0px" rx="180px" ry="120px" fill="#000" opacity="0.85" /> </g> <rect x="0" y="0" width="290" height="500" rx="42" ry="42" fill="rgba(0,0,0,0)" stroke="rgba(255,255,255,0.2)" /> </g> <text text-rendering="optimizeSpeed"> <textPath startOffset="-100%" fill="white" font-family="Verdana" font-size="10px" xlink:href="#text-path-a">',
"ETH-GMI-BOND-L4 #",
_tokenId.toString(),
'<animate additive="sum" attributeName="startOffset" from="0%" to="100%" begin="0s" dur="30s" repeatCount="indefinite" /> </textPath> <textPath startOffset="0%" fill="white" font-family="Verdana" font-size="10px" xlink:href="#text-path-a">',
"ETH-GMI-BOND-L4 #",
_tokenId.toString(),
'<animate additive="sum" attributeName="startOffset" from="0%" to="100%" begin="0s" dur="30s" repeatCount="indefinite" /> </textPath> <textPath startOffset="0%" fill="white" font-family="Verdana" font-size="10px" xlink:href="#text-path-a">',
"ETH-GMI-BOND-L4 #",
_tokenId.toString(),
'<animate additive="sum" attributeName="startOffset" from="0%" to="100%" begin="0s" dur="30s" repeatCount="indefinite" /> </textPath> <textPath startOffset="-50%" fill="white" font-family="Verdana" font-size="10px" xlink:href="#text-path-a">',
"ETH-GMI-BOND-L4 #",
_tokenId.toString(),
'<animate additive="sum" attributeName="startOffset" from="0%" to="100%" begin="0s" dur="30s" repeatCount="indefinite" /> </textPath> </text> <g mask="url(#fade-symbol)"> <rect fill="none" x="0px" y="0px" width="290px" height="200px" /> <text y="70px" x="32px" fill="white" font-family="Verdana" font-weight="200" font-size="36px">LP BOND</text> <text y="115px" x="32px" fill="white" font-family="Verdana" font-weight="200" font-size="36px">#',
_tokenId.toString(),
'</text> </g> <rect x="16" y="16" width="258" height="468" rx="26" ry="26" fill="rgba(0,0,0,0)" stroke="rgba(255,255,255,0.2)" /> <g style="transform:translate(29px, 384px)"> <rect width="230px" height="26px" rx="8px" ry="8px" fill="rgba(0,0,0,0.6)" /> <text x="12px" y="17px" font-family="Verdana" font-size="12px" fill="white"> <tspan fill="rgba(255,255,255,0.6)">Position Id: </tspan>',
uniswapV3PositionId.toString(),
'</text> </g> <g style="transform:translate(29px, 414px)"> <rect width="230px" height="26px" rx="8px" ry="8px" fill="rgba(0,0,0,0.6)" /> <text x="12px" y="17px" font-family="Verdana" font-size="12px" fill="white"> <tspan fill="rgba(255,255,255,0.6)">GMI Rewards: </tspan>',
formatDecimals(rewardsGMI),
'</text> </g> <g style="transform:translate(29px, 444px)"> <rect width="230px" height="26px" rx="8px" ry="8px" fill="rgba(0,0,0,0.6)" /> <text x="12px" y="17px" font-family="Verdana" font-size="12px" fill="white"> <tspan fill="rgba(255,255,255,0.6)">WETH Rewards: </tspan>',
formatDecimals(rewardsWETH9),
"</text> </g> </svg>"
)
);
string memory json = string(
abi.encodePacked(
'{"name": "ETH-GMI-BOND-L4 #',
_tokenId.toString(),
'", "description": "A locked Uniswap V3 liquidity bond with rewards.", "image": "data:image/svg+xml;base64,',
Base64.encode(bytes(svg)),
'", "attributes": [{"trait_type": "Uniswap V3 Position ID", "value": "',
uniswapV3PositionId.toString(),
'"}, {"trait_type": "Start Time", "value": "',
startTime.toString(),
'"}, {"trait_type": "Bond Duration", "value": "',
duration.toString(),
'"}, {"trait_type": "GMI Rewards", "value": "',
rewardsGMI.toString(),
'"}, {"trait_type": "WETH9 Rewards", "value": "',
rewardsWETH9.toString(),
'"}, {"display_type": "date", "trait_type": "Unlock Time", "value": ',
unlockTime.toString(),
"}]}"
)
);
return string(abi.encodePacked("data:application/json;base64,", Base64.encode(bytes(json))));
}
function name() public pure override returns (string memory) {
return "ETH-GMI LP Bond L4";
}
function symbol() public pure override returns (string memory) {
return "ETH-GMI-BOND-L4";
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
function __Ownable_init() internal onlyInitializing {
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal onlyInitializing {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
/**
* This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.0;
import "../../utils/AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* 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 initialize the implementation contract, you can either invoke the
* initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() initializer {}
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
*/
bool private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Modifier to protect an initializer function from being invoked twice.
*/
modifier initializer() {
// If the contract is initializing we ignore whether _initialized is set in order to support multiple
// inheritance patterns, but we only do this in the context of a constructor, because in other contexts the
// contract may have been reentered.
require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized");
bool isTopLevelCall = !_initializing;
if (isTopLevelCall) {
_initializing = true;
_initialized = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
}
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} modifier, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
function _isConstructor() private view returns (bool) {
return !AddressUpgradeable.isContract(address(this));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
function __Pausable_init() internal onlyInitializing {
__Pausable_init_unchained();
}
function __Pausable_init_unchained() internal onlyInitializing {
_paused = false;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
require(!paused(), "Pausable: paused");
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
require(paused(), "Pausable: not paused");
_;
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
/**
* This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuardUpgradeable is Initializable {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
function __ReentrancyGuard_init() internal onlyInitializing {
__ReentrancyGuard_init_unchained();
}
function __ReentrancyGuard_init_unchained() internal onlyInitializing {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/ERC721.sol)
pragma solidity ^0.8.0;
import "./IERC721Upgradeable.sol";
import "./IERC721ReceiverUpgradeable.sol";
import "./extensions/IERC721MetadataUpgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/ContextUpgradeable.sol";
import "../../utils/StringsUpgradeable.sol";
import "../../utils/introspection/ERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable {
using AddressUpgradeable for address;
using StringsUpgradeable for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @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 {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) {
return
interfaceId == type(IERC721Upgradeable).interfaceId ||
interfaceId == type(IERC721MetadataUpgradeable).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(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 overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721Upgradeable.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - 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,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721Upgradeable.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* 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 virtual {
_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);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @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 virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
_afterTokenTransfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721Upgradeable.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
_afterTokenTransfer(owner, address(0), 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 virtual {
require(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
_afterTokenTransfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits a {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC721: approve to caller");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721ReceiverUpgradeable.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
/**
* This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[44] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC721Upgradeable.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721MetadataUpgradeable is IERC721Upgradeable {
/**
* @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 v4.4.1 (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721ReceiverUpgradeable {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165Upgradeable.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721Upgradeable is IERC165Upgradeable {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns 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);
/**
* @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;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
/**
* This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
function __ERC165_init() internal onlyInitializing {
}
function __ERC165_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165Upgradeable).interfaceId;
}
/**
* This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165Upgradeable {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library StringsUpgradeable {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}// 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.1.0) (utils/Base64.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides a set of functions to operate with Base64 strings.
*/
library Base64 {
/**
* @dev Base64 Encoding/Decoding Table
* See sections 4 and 5 of https://datatracker.ietf.org/doc/html/rfc4648
*/
string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
string internal constant _TABLE_URL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
/**
* @dev Converts a `bytes` to its Bytes64 `string` representation.
*/
function encode(bytes memory data) internal pure returns (string memory) {
return _encode(data, _TABLE, true);
}
/**
* @dev Converts a `bytes` to its Bytes64Url `string` representation.
* Output is not padded with `=` as specified in https://www.rfc-editor.org/rfc/rfc4648[rfc4648].
*/
function encodeURL(bytes memory data) internal pure returns (string memory) {
return _encode(data, _TABLE_URL, false);
}
/**
* @dev Internal table-agnostic conversion
*/
function _encode(bytes memory data, string memory table, bool withPadding) private pure returns (string memory) {
/**
* Inspired by Brecht Devos (Brechtpd) implementation - MIT licence
* https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol
*/
if (data.length == 0) return "";
// If padding is enabled, the final length should be `bytes` data length divided by 3 rounded up and then
// multiplied by 4 so that it leaves room for padding the last chunk
// - `data.length + 2` -> Prepare for division rounding up
// - `/ 3` -> Number of 3-bytes chunks (rounded up)
// - `4 *` -> 4 characters for each chunk
// This is equivalent to: 4 * Math.ceil(data.length / 3)
//
// If padding is disabled, the final length should be `bytes` data length multiplied by 4/3 rounded up as
// opposed to when padding is required to fill the last chunk.
// - `4 * data.length` -> 4 characters for each chunk
// - ` + 2` -> Prepare for division rounding up
// - `/ 3` -> Number of 3-bytes chunks (rounded up)
// This is equivalent to: Math.ceil((4 * data.length) / 3)
uint256 resultLength = withPadding ? 4 * ((data.length + 2) / 3) : (4 * data.length + 2) / 3;
string memory result = new string(resultLength);
assembly ("memory-safe") {
// Prepare the lookup table (skip the first "length" byte)
let tablePtr := add(table, 1)
// Prepare result pointer, jump over length
let resultPtr := add(result, 0x20)
let dataPtr := data
let endPtr := add(data, mload(data))
// In some cases, the last iteration will read bytes after the end of the data. We cache the value, and
// set it to zero to make sure no dirty bytes are read in that section.
let afterPtr := add(endPtr, 0x20)
let afterCache := mload(afterPtr)
mstore(afterPtr, 0x00)
// Run over the input, 3 bytes at a time
for {
} lt(dataPtr, endPtr) {
} {
// Advance 3 bytes
dataPtr := add(dataPtr, 3)
let input := mload(dataPtr)
// To write each character, shift the 3 byte (24 bits) chunk
// 4 times in blocks of 6 bits for each character (18, 12, 6, 0)
// and apply logical AND with 0x3F to bitmask the least significant 6 bits.
// Use this as an index into the lookup table, mload an entire word
// so the desired character is in the least significant byte, and
// mstore8 this least significant byte into the result and continue.
mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))
resultPtr := add(resultPtr, 1) // Advance
mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))
resultPtr := add(resultPtr, 1) // Advance
mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))
resultPtr := add(resultPtr, 1) // Advance
mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))
resultPtr := add(resultPtr, 1) // Advance
}
// Reset the value that was cached
mstore(afterPtr, afterCache)
if withPadding {
// When data `bytes` is not exactly 3 bytes long
// it is padded with `=` characters at the end
switch mod(mload(data), 3)
case 1 {
mstore8(sub(resultPtr, 1), 0x3d)
mstore8(sub(resultPtr, 2), 0x3d)
}
case 2 {
mstore8(sub(resultPtr, 1), 0x3d)
}
}
}
return result;
}
}// 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.3.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 Return the 512-bit addition of two uint256.
*
* The result is stored in two 256 variables such that sum = high * 2²⁵⁶ + low.
*/
function add512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
assembly ("memory-safe") {
low := add(a, b)
high := lt(low, a)
}
}
/**
* @dev Return the 512-bit multiplication of two uint256.
*
* The result is stored in two 256 variables such that product = high * 2²⁵⁶ + low.
*/
function mul512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
// 512-bit multiply [high low] = 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 = high * 2²⁵⁶ + low.
assembly ("memory-safe") {
let mm := mulmod(a, b, not(0))
low := mul(a, b)
high := sub(sub(mm, low), lt(mm, low))
}
}
/**
* @dev Returns the addition of two unsigned integers, with a success flag (no overflow).
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a + b;
success = c >= a;
result = c * SafeCast.toUint(success);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with a success flag (no overflow).
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a - b;
success = c <= a;
result = c * SafeCast.toUint(success);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with a success flag (no overflow).
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a * b;
assembly ("memory-safe") {
// Only true when the multiplication doesn't overflow
// (c / a == b) || (a == 0)
success := or(eq(div(c, a), b), iszero(a))
}
// equivalent to: success ? c : 0
result = c * SafeCast.toUint(success);
}
}
/**
* @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 {
success = b > 0;
assembly ("memory-safe") {
// The `DIV` opcode returns zero when the denominator is 0.
result := div(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 {
success = b > 0;
assembly ("memory-safe") {
// The `MOD` opcode returns zero when the denominator is 0.
result := mod(a, b)
}
}
}
/**
* @dev Unsigned saturating addition, bounds to `2²⁵⁶ - 1` instead of overflowing.
*/
function saturatingAdd(uint256 a, uint256 b) internal pure returns (uint256) {
(bool success, uint256 result) = tryAdd(a, b);
return ternary(success, result, type(uint256).max);
}
/**
* @dev Unsigned saturating subtraction, bounds to zero instead of overflowing.
*/
function saturatingSub(uint256 a, uint256 b) internal pure returns (uint256) {
(, uint256 result) = trySub(a, b);
return result;
}
/**
* @dev Unsigned saturating multiplication, bounds to `2²⁵⁶ - 1` instead of overflowing.
*/
function saturatingMul(uint256 a, uint256 b) internal pure returns (uint256) {
(bool success, uint256 result) = tryMul(a, b);
return ternary(success, result, type(uint256).max);
}
/**
* @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 {
(uint256 high, uint256 low) = mul512(x, y);
// Handle non-overflow cases, 256 by 256 division.
if (high == 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 low / denominator;
}
// Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0.
if (denominator <= high) {
Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [high low].
uint256 remainder;
assembly ("memory-safe") {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
high := sub(high, gt(remainder, low))
low := sub(low, 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 ("memory-safe") {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [high low] by twos.
low := div(low, 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 high into low.
low |= high * 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 high
// is no longer required.
result = low * 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 Calculates floor(x * y >> n) with full precision. Throws if result overflows a uint256.
*/
function mulShr(uint256 x, uint256 y, uint8 n) internal pure returns (uint256 result) {
unchecked {
(uint256 high, uint256 low) = mul512(x, y);
if (high >= 1 << n) {
Panic.panic(Panic.UNDER_OVERFLOW);
}
return (high << (256 - n)) | (low >> n);
}
}
/**
* @dev Calculates x * y >> n with full precision, following the selected rounding direction.
*/
function mulShr(uint256 x, uint256 y, uint8 n, Rounding rounding) internal pure returns (uint256) {
return mulShr(x, y, n) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, 1 << n) > 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 x) internal pure returns (uint256 r) {
// If value has upper 128 bits set, log2 result is at least 128
r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
// If upper 64 bits of 128-bit half set, add 64 to result
r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
// If upper 32 bits of 64-bit half set, add 32 to result
r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
// If upper 16 bits of 32-bit half set, add 16 to result
r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
// If upper 8 bits of 16-bit half set, add 8 to result
r |= SafeCast.toUint((x >> r) > 0xff) << 3;
// If upper 4 bits of 8-bit half set, add 4 to result
r |= SafeCast.toUint((x >> r) > 0xf) << 2;
// Shifts value right by the current result and use it as an index into this lookup table:
//
// | x (4 bits) | index | table[index] = MSB position |
// |------------|---------|-----------------------------|
// | 0000 | 0 | table[0] = 0 |
// | 0001 | 1 | table[1] = 0 |
// | 0010 | 2 | table[2] = 1 |
// | 0011 | 3 | table[3] = 1 |
// | 0100 | 4 | table[4] = 2 |
// | 0101 | 5 | table[5] = 2 |
// | 0110 | 6 | table[6] = 2 |
// | 0111 | 7 | table[7] = 2 |
// | 1000 | 8 | table[8] = 3 |
// | 1001 | 9 | table[9] = 3 |
// | 1010 | 10 | table[10] = 3 |
// | 1011 | 11 | table[11] = 3 |
// | 1100 | 12 | table[12] = 3 |
// | 1101 | 13 | table[13] = 3 |
// | 1110 | 14 | table[14] = 3 |
// | 1111 | 15 | table[15] = 3 |
//
// The lookup table is represented as a 32-byte value with the MSB positions for 0-15 in the last 16 bytes.
assembly ("memory-safe") {
r := or(r, byte(shr(r, x), 0x0000010102020202030303030303030300000000000000000000000000000000))
}
}
/**
* @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 x) internal pure returns (uint256 r) {
// If value has upper 128 bits set, log2 result is at least 128
r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
// If upper 64 bits of 128-bit half set, add 64 to result
r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
// If upper 32 bits of 64-bit half set, add 32 to result
r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
// If upper 16 bits of 32-bit half set, add 16 to result
r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
// Add 1 if upper 8 bits of 16-bit half set, and divide accumulated result by 8
return (r >> 3) | SafeCast.toUint((x >> r) > 0xff);
}
/**
* @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/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.3.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;
uint256 private constant SPECIAL_CHARS_LOOKUP =
(1 << 0x08) | // backspace
(1 << 0x09) | // tab
(1 << 0x0a) | // newline
(1 << 0x0c) | // form feed
(1 << 0x0d) | // carriage return
(1 << 0x22) | // double quote
(1 << 0x5c); // backslash
/**
* @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-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 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-string-uint256-uint256} 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-string-uint256-uint256} 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-string} 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-string-uint256-uint256} 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 guarantees 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-string} 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-string} 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-string-uint256-uint256} 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 Escape special characters in JSON strings. This can be useful to prevent JSON injection in NFT metadata.
*
* WARNING: This function should only be used in double quoted JSON strings. Single quotes are not escaped.
*
* NOTE: This function escapes all unicode characters, and not just the ones in ranges defined in section 2.5 of
* RFC-4627 (U+0000 to U+001F, U+0022 and U+005C). ECMAScript's `JSON.parse` does recover escaped unicode
* characters that are not in this range, but other tooling may provide different results.
*/
function escapeJSON(string memory input) internal pure returns (string memory) {
bytes memory buffer = bytes(input);
bytes memory output = new bytes(2 * buffer.length); // worst case scenario
uint256 outputLength = 0;
for (uint256 i; i < buffer.length; ++i) {
bytes1 char = bytes1(_unsafeReadBytesOffset(buffer, i));
if (((SPECIAL_CHARS_LOOKUP & (1 << uint8(char))) != 0)) {
output[outputLength++] = "\\";
if (char == 0x08) output[outputLength++] = "b";
else if (char == 0x09) output[outputLength++] = "t";
else if (char == 0x0a) output[outputLength++] = "n";
else if (char == 0x0c) output[outputLength++] = "f";
else if (char == 0x0d) output[outputLength++] = "r";
else if (char == 0x5c) output[outputLength++] = "\\";
else if (char == 0x22) {
// solhint-disable-next-line quotes
output[outputLength++] = '"';
}
} else {
output[outputLength++] = char;
}
}
// write the actual length and deallocate unused memory
assembly ("memory-safe") {
mstore(output, outputLength)
mstore(0x40, add(output, shl(5, shr(5, add(outputLength, 63)))))
}
return string(output);
}
/**
* @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)))
}
}
}// Copyright 2025 Energi Core
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
/// @title ILiquidityBondLocker
/// @author Energi Core
pragma solidity 0.8.22;
interface ILiquidityBondLocker {
struct Lock {
uint256 uniswapV3PositionId;
uint256 lpBondId;
uint256 bondId;
uint256 startTime;
uint256 lockedAmount0;
uint256 lockedAmount1;
bool isLocked;
}
struct Bond {
uint256 bondId;
address collection;
address token0;
address token1;
uint256 requiredAmount1;
uint256 fee;
int24 tickLower;
int24 tickUpper;
uint256 amount0Min;
uint256 amount1Min;
uint256 bondType;
uint256 lockDuration;
uint256 multiplier;
bool isActive;
address pool;
bool isGMIPool;
}
function lockDuration() external view returns (uint256);
function locks(uint256 _uniswapV3PositionId) external view returns (Lock memory);
function bonds(uint256 _bondId) external view returns (Bond memory);
function lockPosition(uint256 _uniswapV3PositionId) external;
function unlockPosition(uint256 _uniswapV3PositionId) external;
function getRewards0(uint256 _uniswapV3PositionId) external view returns (uint256 rewardsGMI);
function uniswapPositionManager() external view returns (address);
function startTime(uint256 _bondId) external view returns (uint256);
}// Copyright 2025 Energi Core
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
/// @title INonFungiblePositionManager
/// @author Energi Core
pragma solidity 0.8.22;
import { IERC721 } from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
interface INonFungiblePositionManager is IERC721 {
/// @notice Emitted when liquidity is increased for a position NFT
/// @dev Also emitted when a token is minted
/// @param tokenId The ID of the token for which liquidity was increased
/// @param liquidity The amount by which liquidity for the NFT position was increased
/// @param amount0 The amount of token0 that was paid for the increase in liquidity
/// @param amount1 The amount of token1 that was paid for the increase in liquidity
event IncreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);
/// @notice Emitted when liquidity is decreased for a position NFT
/// @param tokenId The ID of the token for which liquidity was decreased
/// @param liquidity The amount by which liquidity for the NFT position was decreased
/// @param amount0 The amount of token0 that was accounted for the decrease in liquidity
/// @param amount1 The amount of token1 that was accounted for the decrease in liquidity
event DecreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);
/// @notice Emitted when tokens are collected for a position NFT
/// @dev The amounts reported may not be exactly equivalent to the amounts transferred, due to rounding behavior
/// @param tokenId The ID of the token for which underlying tokens were collected
/// @param recipient The address of the account that received the collected tokens
/// @param amount0 The amount of token0 owed to the position that was collected
/// @param amount1 The amount of token1 owed to the position that was collected
event Collect(uint256 indexed tokenId, address recipient, uint256 amount0, uint256 amount1);
/// @notice Returns the position information associated with a given token ID.
/// @dev Throws if the token ID is not valid.
/// @param tokenId The ID of the token that represents the position
/// @return nonce The nonce for permits
/// @return operator The address that is approved for spending
/// @return token0 The address of the token0 for a specific pool
/// @return token1 The address of the token1 for a specific pool
/// @return fee The fee associated with the pool
/// @return tickLower The lower end of the tick range for the position
/// @return tickUpper The higher end of the tick range for the position
/// @return liquidity The liquidity of the position
/// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position
/// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position
/// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation
/// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation
function positions(
uint256 tokenId
)
external
view
returns (
uint96 nonce,
address operator,
address token0,
address token1,
uint24 fee,
int24 tickLower,
int24 tickUpper,
uint128 liquidity,
uint256 feeGrowthInside0LastX128,
uint256 feeGrowthInside1LastX128,
uint128 tokensOwed0,
uint128 tokensOwed1
);
struct MintParams {
address token0;
address token1;
uint24 fee;
int24 tickLower;
int24 tickUpper;
uint256 amount0Desired;
uint256 amount1Desired;
uint256 amount0Min;
uint256 amount1Min;
address recipient;
uint256 deadline;
}
/// @notice Creates a new position wrapped in a NFT
/// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized
/// a method does not exist, i.e. the pool is assumed to be initialized.
/// @param params The params necessary to mint a position, encoded as `MintParams` in calldata
/// @return tokenId The ID of the token that represents the minted position
/// @return liquidity The amount of liquidity for this position
/// @return amount0 The amount of token0
/// @return amount1 The amount of token1
function mint(
MintParams calldata params
) external payable returns (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);
struct IncreaseLiquidityParams {
uint256 tokenId;
uint256 amount0Desired;
uint256 amount1Desired;
uint256 amount0Min;
uint256 amount1Min;
uint256 deadline;
}
/// @notice Increases the amount of liquidity in a position, with tokens paid by the `msg.sender`
/// @param params tokenId The ID of the token for which liquidity is being increased,
/// amount0Desired The desired amount of token0 to be spent,
/// amount1Desired The desired amount of token1 to be spent,
/// amount0Min The minimum amount of token0 to spend, which serves as a slippage check,
/// amount1Min The minimum amount of token1 to spend, which serves as a slippage check,
/// deadline The time by which the transaction must be included to effect the change
/// @return liquidity The new liquidity amount as a result of the increase
/// @return amount0 The amount of token0 to acheive resulting liquidity
/// @return amount1 The amount of token1 to acheive resulting liquidity
function increaseLiquidity(
IncreaseLiquidityParams calldata params
) external payable returns (uint128 liquidity, uint256 amount0, uint256 amount1);
struct DecreaseLiquidityParams {
uint256 tokenId;
uint128 liquidity;
uint256 amount0Min;
uint256 amount1Min;
uint256 deadline;
}
/// @notice Decreases the amount of liquidity in a position and accounts it to the position
/// @param params tokenId The ID of the token for which liquidity is being decreased,
/// amount The amount by which liquidity will be decreased,
/// amount0Min The minimum amount of token0 that should be accounted for the burned liquidity,
/// amount1Min The minimum amount of token1 that should be accounted for the burned liquidity,
/// deadline The time by which the transaction must be included to effect the change
/// @return amount0 The amount of token0 accounted to the position's tokens owed
/// @return amount1 The amount of token1 accounted to the position's tokens owed
function decreaseLiquidity(
DecreaseLiquidityParams calldata params
) external payable returns (uint256 amount0, uint256 amount1);
struct CollectParams {
uint256 tokenId;
address recipient;
uint128 amount0Max;
uint128 amount1Max;
}
/// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient
/// @param params tokenId The ID of the NFT for which tokens are being collected,
/// recipient The account that should receive the tokens,
/// amount0Max The maximum amount of token0 to collect,
/// amount1Max The maximum amount of token1 to collect
/// @return amount0 The amount of fees collected in token0
/// @return amount1 The amount of fees collected in token1
function collect(CollectParams calldata params) external payable returns (uint256 amount0, uint256 amount1);
/// @notice Burns a token ID, which deletes it from the NFT contract. The token must have 0 liquidity and all tokens
/// must be collected first.
/// @param tokenId The ID of the token that is being burned
function burn(uint256 tokenId) external payable;
}// Copyright 2025 Energi Core
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Energi Governance system is the fundamental part of Energi Core.
// NOTE: It's not allowed to change the compiler due to byte-to-byte
// match requirement.
/// @title IOperatorRegistry
/// @author Energi Core
pragma solidity 0.8.22;
interface IOperatorRegistry {
function isWhitelist(address _collection, address _operator) external view returns (bool);
function isOperatorAllowed(address _collection, address _operator) external view returns (bool);
function universalAllowedOperators(address _operator) external view returns (bool);
function fundReceiver() external view returns (address);
function sharePercentageBps() external view returns (uint256);
function addWhitelist(address _collection, address _operator) external;
function removeWhitelist(address _collection, address _operator) external;
function addUniversalOperator(address _operator) external;
function removeUniversalOperator(address _operator) external;
function changeFundReceiver(address _fundReceiver) external;
function changeSharePercentageBps(uint256 _sharePercentageBps) external;
function pause() external;
function unpause() external;
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"viaIR": true,
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"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":true,"internalType":"uint256","name":"bondId","type":"uint256"}],"name":"LiquidityBondBurned","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldLiquidityBondLocker","type":"address"},{"indexed":true,"internalType":"address","name":"newLiquidityBondLocker","type":"address"}],"name":"LiquidityBondLockerUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"bondId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"uniswapV3PositionId","type":"uint256"}],"name":"LiquidityBondMinted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"minter","type":"address"}],"name":"MinterAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"minter","type":"address"}],"name":"MinterRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldOperatorRegistry","type":"address"},{"indexed":true,"internalType":"address","name":"newOperatorRegistry","type":"address"}],"name":"OperatorRegistryUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","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":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[{"internalType":"address","name":"_minter","type":"address"}],"name":"addMinter","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":[],"name":"bondType","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"bonds","outputs":[{"internalType":"uint256","name":"bondId","type":"uint256"},{"internalType":"uint256","name":"uniswapV3PositionId","type":"uint256"},{"internalType":"bool","name":"isRedemeed","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_bondId","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"currentIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_bondId","type":"uint256"}],"name":"getBondInfo","outputs":[{"internalType":"uint256","name":"uniswapV3PositionId","type":"uint256"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"duration","type":"uint256"},{"internalType":"uint256","name":"durationLeft","type":"uint256"},{"internalType":"uint256","name":"rewardsGMI","type":"uint256"},{"internalType":"uint256","name":"rewardsWETH9","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"liquidityBondLocker_","type":"address"},{"internalType":"address","name":"operatorRegistry_","type":"address"},{"internalType":"string","name":"bondType_","type":"string"}],"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":[],"name":"liquidityBondLocker","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_uniswapV3PositionId","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"minters","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"operatorRegistry","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_minter","type":"address"}],"name":"removeMinter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","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":"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":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"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":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_liquidityBondLocker","type":"address"}],"name":"updateLiquidityBondLocker","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_operatorRegistry","type":"address"}],"name":"updateOperatorRegistry","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
608080604052346100175761561890816200001d8239f35b600080fdfe6080604052600436101561001257600080fd5b60003560e01c806301ffc9a71461022757806306fdde0314610222578063081812fc1461021d578063095ea7b3146102185780630989f2971461021357806323b872dd1461020e57806326987b60146102095780633092afd5146102045780633392bec8146101ff5780633f4ba83a146101fa57806340c10f19146101f557806342842e0e146101f057806342966c68146101eb5780634571e3a6146101e657806358c2225b146101e15780635c975abb146101dc5780635f1c17c0146101d75780636352211e146101d257806370a08231146101cd578063715018a6146101c857806374ec06bc146101c35780638456cb59146101be5780638da5cb5b146101b957806394c8636f146101b457806395d89b41146101af578063983b2d56146101aa578063a22cb465146101a5578063b5215aaa146101a0578063b88d4fde1461019b578063c87b56dd14610196578063e985e9c514610191578063f2fde38b1461018c5763f46eccc41461018757600080fd5b613274565b6131da565b613172565b6114b6565b61144f565b6113c0565b611302565b6111f2565b6111d6565b6110f2565b61108f565b611023565b610ff9565b610f95565b610eef565b610ed1565b610e88565b610e65565b610e3b565b610d0e565b610a7a565b610a52565b61089e565b6107fd565b6107ba565b6106c1565b6106a2565b610530565b610475565b610382565b610341565b61030d565b610243565b6001600160e01b031981160361023e57565b600080fd5b3461023e57602036600319011261023e5760206004356102628161022c565b63ffffffff60e01b166380ac58cd60e01b81149081156102a0575b811561028f575b506040519015158152f35b6301ffc9a760e01b14905038610284565b635b5e139f60e01b8114915061027d565b60005b8381106102c45750506000910152565b81810151838201526020016102b4565b906020916102ed815180928185528580860191016102b1565b601f01601f1916010190565b90602061030a9281815201906102d4565b90565b3461023e57600036600319011261023e5761033d6103296132ca565b6040519182916020835260208301906102d4565b0390f35b3461023e57602036600319011261023e57602061035f6004356132f8565b6040516001600160a01b039091168152f35b6001600160a01b0381160361023e57565b3461023e57604036600319011261023e5760043561039f81610371565b6024356103ab81614258565b916001600160a01b038084169082168114610426576103dd936103d89133149081156103df575b5061338a565b6146b6565b005b6001600160a01b03166000908152606a6020526040902061042091506104199033905b9060018060a01b0316600052602052604060002090565b5460ff1690565b386103d2565b60405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608490fd5b3461023e57602036600319011261023e5760043561049281610371565b6097546001600160a01b039182916104ad90831633146133fc565b16906104ba821515613447565b610132828154928316926104d084831415613492565b6001600160a01b0319161790557ff8b0ee9361a0f0225b39f58411465016adbd34abff194e6119b537fa8b063247600080a3005b606090600319011261023e5760043561051c81610371565b9060243561052981610371565b9060443590565b3461023e5761053e36610504565b9061055161054c833361479d565b6134ee565b323314801561062a575b61056490614888565b803b158015610580575b9261057b6103dd946148e4565b6150bd565b50610132546105a590610599906001600160a01b031681565b6001600160a01b031690565b604051633185c44d60e21b81523060048201526001600160a01b03831660248201529390602090859060449082905afa938415610625576103dd9461057b916000916105f6575b509194505061056e565b610618915060203d60201161061e575b6106108183610c6c565b81019061456d565b386105ec565b503d610606565b613611565b506101325461064390610599906001600160a01b031681565b604051633185c44d60e21b815230600482015233602482015290602090829060449082905afa80156106255761056491600091610683575b50905061055b565b61069c915060203d60201161061e576106108183610c6c565b3861067b565b3461023e57600036600319011261023e57602061012e54604051908152f35b3461023e57602036600319011261023e576004356106de81610371565b6097546001600160a01b03906106f790821633146133fc565b8116610704811515613447565b60009181835261013060205260ff60408420541615610764576001600160a01b0316600090815261013060205260409020805460ff191690557fe94479a9f7e1952cc78f2d6baab678adc1b772d936c6583def489e524cb666928280a280f35b60405162461bcd60e51b815260206004820152602860248201527f4c6971756964697479426f6e64733a3a2041646472657373206973206e6f7420604482015267309036b4b73a32b960c11b6064820152608490fd5b3461023e57602036600319011261023e5760c06107d86004356138a3565b93604093919351958652602086015260408501526060840152608083015260a0820152f35b3461023e57600036600319011261023e5761082360018060a01b036097541633146133fc565b60c95460ff8116156108625760ff191660c9557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b60405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606490fd5b3461023e57604036600319011261023e576004356108bb81610371565b60243560009133835261013060205260ff6040842054168015610a3e575b6108e290613b67565b6108f160ff60c9541615613bc2565b610900600260fb541415613c01565b600260fb556001600160a01b0381169061091b821515613447565b610926831515613c4d565b6101315461093e90610599906001600160a01b031681565b60405163f4dadc6160e01b8152600481018590529060e090829060249082905afa80156106255760c061097e91610984938891610a0f575b500151151590565b15613cb1565b6109dc61012e9161099e6109988454613d11565b61012e55565b6109d483546109cf6109ae610c8d565b9180835288602084015289604084015260005261012f602052604060002090565b613d20565b82549061493f565b54907f72970e8e667928f70b2da0ecfd32c52c589298ecc73c7c540586fb6003ba040f8480a4610a0c600160fb55565b80f35b610a31915060e03d60e011610a37575b610a298183610c6c565b81019061359c565b38610976565b503d610a1f565b506097546001600160a01b031633146108d9565b3461023e576103dd610a6336610504565b9060405192610a7184610c16565b600084526142d0565b3461023e57602036600319011261023e5760043560009033825261013060205260ff6040832054168015610bec575b610ab290613b67565b610ac160ff60c9541615613bc2565b610ad0600260fb541415613c01565b600260fb558015610ba8576000818152606760205260409020546001600160a01b031615610b5757610b206002610b128360005261012f602052604060002090565b01805460ff19166001179055565b610b2981614a79565b7f0d7a61e190b0f85b64fde8b74afceb2d1894072e7b5ee31e2295b51ad0d441bc8280a2610a0c600160fb55565b60405162461bcd60e51b8152602060048201526024808201527f4c6971756964697479426f6e64733a3a20426f6e6420646f6573206e6f7420656044820152631e1a5cdd60e21b6064820152608490fd5b606460405162461bcd60e51b815260206004820152602060248201527f4c6971756964697479426f6e64733a3a20426f6e64204944206973207a65726f6044820152fd5b506097546001600160a01b03163314610aa9565b634e487b7160e01b600052604160045260246000fd5b602081019081106001600160401b03821117610c3157604052565b610c00565b606081019081106001600160401b03821117610c3157604052565b604081019081106001600160401b03821117610c3157604052565b90601f801991011681019081106001600160401b03821117610c3157604052565b60405190610c9a82610c36565b565b6040519061020082018281106001600160401b03821117610c3157604052565b6001600160401b038111610c3157601f01601f191660200190565b929192610ce382610cbc565b91610cf16040519384610c6c565b82948184528183011161023e578281602093846000960137010152565b3461023e57606036600319011261023e57600435610d2b81610371565b602435610d3781610371565b6044356001600160401b03811161023e573660238201121561023e57610d67903690602481600401359101610cd7565b6000549160ff8360081c169283600014610e325750303b155b15610dd657610d9592159384610dab576140a7565b610d9b57005b6103dd61ff001960005416600055565b610dbf61010061ff00196000541617600055565b610dd1600160ff196000541617600055565b6140a7565b60405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b60ff1615610d80565b3461023e57600036600319011261023e57610132546040516001600160a01b039091168152602090f35b3461023e57600036600319011261023e57602060ff60c954166040519015158152f35b3461023e57602036600319011261023e5760043560005261012f6020526060604060002080549060ff600260018301549201541690604051928352602083015215156040820152f35b3461023e57602036600319011261023e57602061035f600435614258565b3461023e57602036600319011261023e57600435610f0c81610371565b6001600160a01b03168015610f3d57600052606860205261033d604060002054604051918291829190602083019252565b60405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608490fd5b3461023e57600080600319360112610ff65760975481906001600160a01b03811690610fc23383146133fc565b6001600160a01b0319166097557f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b80fd5b3461023e57600036600319011261023e57610131546040516001600160a01b039091168152602090f35b3461023e57600036600319011261023e5761104960018060a01b036097541633146133fc565b600160c95461105b60ff821615613bc2565b60ff19161760c9557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1005b3461023e57600036600319011261023e576097546040516001600160a01b039091168152602090f35b90600182811c921680156110e8575b60208310146110d257565b634e487b7160e01b600052602260045260246000fd5b91607f16916110c7565b3461023e57600080600319360112610ff657604051908061012d8054611117816110b8565b808652926020926001928084169081156111a75750600114611150575b61033d8761114481890382610c6c565b604051918291826102f9565b815293507f193a3ae4da5049eb74cee39e4cf5827f7ce7b1d1d1775ef1c6311eb60558e6d55b838510611194575050505081016020016111448261033d3880611134565b8054868601840152938201938101611176565b91505086955061033d9693506020925061114494915060ff191682840152151560051b82010192933880611134565b3461023e57600036600319011261023e5761033d610329613d4d565b3461023e57602036600319011261023e5760043561120f81610371565b6097546001600160a01b039061122890821633146133fc565b8116611235811515613447565b60009181835261013060205260ff60408420541661129e576001600160a01b0316600090815261013060205260409020611277905b805460ff19166001179055565b7f6ae172837ea30b801fbfcdd4108aa1d5bf8ff775444fd70256b44e6bf3dfc3f68280a280f35b60405162461bcd60e51b815260206004820152602c60248201527f4c6971756964697479426f6e64733a3a204164647265737320697320616c726560448201526b30b23c90309036b4b73a32b960a11b6064820152608490fd5b8015150361023e57565b3461023e57604036600319011261023e5760043561131f81610371565b60243561132b816112f8565b813b158015611348575b916113426103dd93614582565b336151d4565b5061013254604051633185c44d60e21b81523060048201526001600160a01b03848116602483015290939160209185916044918391165afa928315610625576103dd93611342916000916113a1575b5091935050611335565b6113ba915060203d60201161061e576106108183610c6c565b38611397565b3461023e57602036600319011261023e576004356113dd81610371565b6097546001600160a01b039182916113f890831633146133fc565b1690611405821515613447565b6101318281549283169261141b84831415613492565b6001600160a01b0319161790557f748f722ee0920121a4d9633c16ef2dd3a68219e5c44480aeb31ab9df22412424600080a3005b3461023e57608036600319011261023e5760043561146c81610371565b60243561147881610371565b606435916001600160401b03831161023e573660238401121561023e576114ac6103dd933690602481600401359101610cd7565b91604435916142d0565b3461023e57602036600319011261023e576004356114d3816138a3565b92939290916114e2904261376d565b916114ec87614d3d565b946114f688614d3d565b9561150089614d3d565b6115098a614d3d565b6115128b614d3d565b61151b8b614d3d565b9061152587614ec0565b9261152f89614ec0565b946040519c8d976020890161255890610d9a907f3c7376672077696474683d2232393022206865696768743d223530302220766981527f6577426f783d2230203020323930203530302220786d6c6e733d22687474703a60208201527f2f2f7777772e77332e6f72672f323030302f7376672220786d6c6e733a786c6960408201527f6e6b3d22687474703a2f2f7777772e77332e6f72672f313939392f786c696e6b60608201527f223e3c646566733e3c66696c7465722069643d226631223e3c6665496d61676560808201527f20726573756c743d2270302220786c696e6b3a687265663d22646174613a696d60a08201527f6167652f7376672b786d6c3b6261736536342c50484e325a794233615752306160c08201527f44306e4d6a6b774a79426f5a576c6e614851394a7a55774d436367646d6c6c6460e08201527f304a766544306e4d434177494449354d4341314d44416e494868746247357a506101008201527f53646f644852774f693876643364334c6e637a4c6d39795a7938794d4441774c6101208201527f334e325a79632b50484a6c5933516764326c6b644767394a7a49354d4842344a6101408201527f79426f5a576c6e614851394a7a55774d4842344a79426d615778735053636a4d6101608201527f574d335a4452694a79382b5043397a646d632b222f3e203c6665496d616765206101808201527f726573756c743d2270312220786c696e6b3a687265663d22646174613a696d616101a08201527f67652f7376672b786d6c3b6261736536342c50484e325a7942336157523061446101c08201527f306e4d6a6b774a79426f5a576c6e614851394a7a55774d436367646d6c6c64306101e08201527f4a766544306e4d434177494449354d4341314d44416e494868746247357a50536102008201527f646f644852774f693876643364334c6e637a4c6d39795a7938794d4441774c336102208201527f4e325a79632b50474e70636d4e735a53426a6544306e4d6a49794a79426a65546102408201527f306e4d6a41794a794279505363784d6a4277654363675a6d6c736244306e49326102608201527f5a6d5a6a6b354e796376506a777663335a6e50673d3d22202f3e203c6665496d6102808201527f61676520726573756c743d2270322220786c696e6b3a687265663d22646174616102a08201527f3a696d6167652f7376672b786d6c3b6261736536342c50484e325a7942336157806102c08301527f52306144306e4d6a6b774a79426f5a576c6e614851394a7a55774d436367646d806102e08401527f6c6c64304a766544306e4d434177494449354d4341314d44416e49486874624790816103008501527f357a5053646f644852774f693876643364334c6e637a4c6d39795a7938794d4492836103208601527f41774c334e325a79632b50474e70636d4e735a53426a6544306e4f44516e49476103408601527f4e355053637a4f44456e494849394a7a45794d4842344a79426d6157787350536103608601527f636a4f574d334d6a4d344a79382b5043397a646d632b22202f3e203c6665496d6103808601527f61676520726573756c743d2270332220786c696e6b3a687265663d22646174616103a08601526103c08501526103e08401526104008301526104208201527f41774c334e325a79632b50474e70636d4e735a53426a6544306e4d6a55324a796104408201527f426a6554306e4e4441334a794279505363784d444277654363675a6d6c7362446104608201527f306e497a526b4e6d49784e436376506a777663335a6e50673d3d22202f3e203c6104808201527f6665426c656e64206d6f64653d226f7665726c61792220696e3d2270302220696104a08201527f6e323d22703122202f3e203c6665426c656e64206d6f64653d226578636c75736104c08201527f696f6e2220696e323d22703222202f3e203c6665426c656e64206d6f64653d226104e08201527f6f7665726c61792220696e323d2270332220726573756c743d22626c656e644f6105008201527f757422202f3e203c6665476175737369616e426c757220696e3d22626c656e646105208201527f4f75742220737464446576696174696f6e3d22343222202f3e203c2f66696c746105408201527f65723e203c636c6970506174682069643d22636f726e657273223e203c7265636105608201527f742077696474683d2232393022206865696768743d22353030222072783d22346105808201527f32222072793d22343222202f3e203c2f636c6970506174683e203c70617468206105a08201527f69643d22746578742d706174682d612220643d224d34302031322048323530206105c08201527f41323820323820302030203120323738203430205634363020413238203238206105e08201527f30203020312032353020343838204834302041323820323820302030203120316106008201527f32203436302056343020413238203238203020302031203430203132207a22206106208201527f2f3e203c706174682069643d226d696e696d61702220643d224d3233342034346106408201527f3443323334203435372e393439203234322e32312034363320323533203436336106608201527f22202f3e203c66696c7465722069643d22746f702d726567696f6e2d626c75726106808201527f223e203c6665476175737369616e426c757220696e3d22536f757263654772616106a08201527f706869632220737464446576696174696f6e3d22323422202f3e203c2f66696c6106c08201527f7465723e203c6c696e6561724772616469656e742069643d22677261642d75706106e08201527f222078313d2231222078323d2230222079313d2231222079323d2230223e203c6107008201527f73746f70206f66667365743d22302e30222073746f702d636f6c6f723d2277686107208201527f697465222073746f702d6f7061636974793d223122202f3e203c73746f70206f6107408201527f66667365743d222e39222073746f702d636f6c6f723d227768697465222073746107608201527f6f702d6f7061636974793d223022202f3e203c2f6c696e6561724772616469656107808201527f6e743e203c6c696e6561724772616469656e742069643d22677261642d646f776107a08201527f6e222078313d2230222078323d2231222079313d2230222079323d2231223e206107c08201527f3c73746f70206f66667365743d22302e30222073746f702d636f6c6f723d22776107e08201527f68697465222073746f702d6f7061636974793d223122202f3e203c73746f70206108008201527f6f66667365743d22302e39222073746f702d636f6c6f723d22776869746522206108208201527f73746f702d6f7061636974793d223022202f3e203c2f6c696e656172477261646108408201527f69656e743e203c6d61736b2069643d22666164652d757022206d61736b436f6e6108608201527f74656e74556e6974733d226f626a656374426f756e64696e67426f78223e203c6108808201527f726563742077696474683d223122206865696768743d2231222066696c6c3d226108a08201527f75726c2823677261642d75702922202f3e203c2f6d61736b3e203c6d61736b206108c08201527f69643d22666164652d646f776e22206d61736b436f6e74656e74556e6974733d6108e08201527f226f626a656374426f756e64696e67426f78223e203c726563742077696474686109008201527f3d223122206865696768743d2231222066696c6c3d2275726c2823677261642d6109208201527f646f776e2922202f3e203c2f6d61736b3e203c6d61736b2069643d226e6f6e656109408201527f22206d61736b436f6e74656e74556e6974733d226f626a656374426f756e64696109608201527f6e67426f78223e203c726563742077696474683d223122206865696768743d226109808201527f31222066696c6c3d22776869746522202f3e203c2f6d61736b3e203c6c696e656109a08201527f61724772616469656e742069643d22677261642d73796d626f6c223e203c73746109c08201527f6f70206f66667365743d22302e37222073746f702d636f6c6f723d22776869746109e08201527f65222073746f702d6f7061636974793d223122202f3e203c73746f70206f6666610a008201527f7365743d222e3935222073746f702d636f6c6f723d227768697465222073746f610a208201527f702d6f7061636974793d223022202f3e203c2f6c696e6561724772616469656e610a408201527f743e203c6d61736b2069643d22666164652d73796d626f6c22206d61736b436f610a608201527f6e74656e74556e6974733d227573657253706163654f6e557365223e203c7265610a808201527f63742077696474683d22323930707822206865696768743d2232303070782220610aa08201527f66696c6c3d2275726c2823677261642d73796d626f6c2922202f3e203c2f6d61610ac08201527f736b3e203c2f646566733e203c6720636c69702d706174683d2275726c282363610ae08201527f6f726e65727329223e203c726563742066696c6c3d2223316337643462222078610b008201527f3d223070782220793d22307078222077696474683d2232393070782220686569610b208201527f6768743d22353030707822202f3e203c72656374207374796c653d2266696c74610b408201527f65723a2075726c28236631292220783d223070782220793d2230707822207769610b608201527f6474683d22323930707822206865696768743d22353030707822202f3e203c67610b808201527f207374796c653d2266696c7465723a75726c2823746f702d726567696f6e2d62610ba08201527f6c7572293b207472616e73666f726d3a7363616c6528312e35293b207472616e610bc08201527f73666f726d2d6f726967696e3a63656e74657220746f703b223e203c72656374610be08201527f2066696c6c3d226e6f6e652220783d223070782220793d223070782220776964610c008201527f74683d22323930707822206865696768743d22353030707822202f3e203c656c610c208201527f6c697073652063783d22353025222063793d22307078222072783d2231383070610c408201527f78222072793d223132307078222066696c6c3d222330303022206f7061636974610c608201527f793d22302e383522202f3e203c2f673e203c7265637420783d22302220793d22610c808201527f30222077696474683d2232393022206865696768743d22353030222072783d22610ca08201527f3432222072793d223432222066696c6c3d227267626128302c302c302c302922610cc08201527f207374726f6b653d2272676261283235352c3235352c3235352c302e32292220610ce08201527f2f3e203c2f673e203c7465787420746578742d72656e646572696e673d226f70610d008201527f74696d697a655370656564223e203c74657874506174682073746172744f6666610d208201527f7365743d222d31303025222066696c6c3d2277686974652220666f6e742d6661610d408201527f6d696c793d2256657264616e612220666f6e742d73697a653d22313070782220610d608201527f786c696e6b3a687265663d2223746578742d706174682d61223e000000000000610d808201520190565b704554482d474d492d424f4e442d4c34202360781b815260110161257b91614432565b61258490614449565b704554482d474d492d424f4e442d4c34202360781b81526011016125a791614432565b6125b090614449565b704554482d474d492d424f4e442d4c34202360781b81526011016125d391614432565b7f3c616e696d6174652061646469746976653d2273756d2220617474726962757481527f654e616d653d2273746172744f6666736574222066726f6d3d2230252220746f60208201527f3d22313030252220626567696e3d22307322206475723d22333073222072657060408201527f656174436f756e743d22696e646566696e69746522202f3e203c2f746578745060608201527f6174683e203c74657874506174682073746172744f66667365743d222d35302560808201527f222066696c6c3d2277686974652220666f6e742d66616d696c793d225665726460a08201527f616e612220666f6e742d73697a653d22313070782220786c696e6b3a6872656660c08201526f1e9111ba32bc3a16b830ba3416b0911f60811b60e082015260f001704554482d474d492d424f4e442d4c34202360781b815260110161271991614432565b7f3c616e696d6174652061646469746976653d2273756d2220617474726962757481527f654e616d653d2273746172744f6666736574222066726f6d3d2230252220746f60208201527f3d22313030252220626567696e3d22307322206475723d22333073222072657060408201527f656174436f756e743d22696e646566696e69746522202f3e203c2f746578745060608201527f6174683e203c2f746578743e203c67206d61736b3d2275726c2823666164652d60808201527f73796d626f6c29223e203c726563742066696c6c3d226e6f6e652220783d223060a08201527f70782220793d22307078222077696474683d223239307078222068656967687460c08201527f3d22323030707822202f3e203c7465787420793d22373070782220783d22333260e08201527f7078222066696c6c3d2277686974652220666f6e742d66616d696c793d2256656101008201527f7264616e612220666f6e742d7765696768743d223230302220666f6e742d73696101208201527f7a653d2233367078223e4c5020424f4e443c2f746578743e203c7465787420796101408201527f3d2231313570782220783d2233327078222066696c6c3d2277686974652220666101608201527f6f6e742d66616d696c793d2256657264616e612220666f6e742d7765696768746101808201527f3d223230302220666f6e742d73697a653d2233367078223e23000000000000006101a08201526101b90161293d91614432565b7f3c2f746578743e203c2f673e203c7265637420783d2231362220793d2231362281527f2077696474683d2232353822206865696768743d22343638222072783d22323660208201527f222072793d223236222066696c6c3d227267626128302c302c302c302922207360408201527f74726f6b653d2272676261283235352c3235352c3235352c302e322922202f3e60608201527f203c67207374796c653d227472616e73666f726d3a7472616e736c617465283260808201527f3970782c20333834707829223e203c726563742077696474683d22323330707860a08201527f22206865696768743d2232367078222072783d22387078222072793d2238707860c08201527f222066696c6c3d227267626128302c302c302c302e362922202f3e203c74657860e08201527f7420783d22313270782220793d22313770782220666f6e742d66616d696c793d6101008201527f2256657264616e612220666f6e742d73697a653d2231327078222066696c6c3d6101208201527f227768697465223e203c747370616e2066696c6c3d2272676261283235352c326101408201527f35352c3235352c302e3629223e506f736974696f6e2049643a203c2f7473706161016082015261371f60f11b61018082015261018201612b1f91614432565b7f3c2f746578743e203c2f673e203c67207374796c653d227472616e73666f726d81527f3a7472616e736c61746528323970782c20343134707829223e203c726563742060208201527f77696474683d22323330707822206865696768743d2232367078222072783d2260408201527f387078222072793d22387078222066696c6c3d227267626128302c302c302c3060608201527f2e362922202f3e203c7465787420783d22313270782220793d2231377078222060808201527f666f6e742d66616d696c793d2256657264616e612220666f6e742d73697a653d60a08201527f2231327078222066696c6c3d227768697465223e203c747370616e2066696c6c60c08201527f3d2272676261283235352c3235352c3235352c302e3629223e474d492052657760e08201526d30b932399d101e17ba39b830b71f60911b61010082015261010e01612c7191614432565b7f3c2f746578743e203c2f673e203c67207374796c653d227472616e73666f726d81527f3a7472616e736c61746528323970782c20343434707829223e203c726563742060208201527f77696474683d22323330707822206865696768743d2232367078222072783d2260408201527f387078222072793d22387078222066696c6c3d227267626128302c302c302c3060608201527f2e362922202f3e203c7465787420783d22313270782220793d2231377078222060808201527f666f6e742d66616d696c793d2256657264616e612220666f6e742d73697a653d60a08201527f2231327078222066696c6c3d227768697465223e203c747370616e2066696c6c60c08201527f3d2272676261283235352c3235352c3235352c302e3629223e5745544820526560e08201526e3bb0b932399d101e17ba39b830b71f60891b61010082015261010f01612dc491614432565b721e17ba32bc3a1f101e17b39f101e17b9bb339f60691b81526013010397601f19988981018852612df59088610c6c565b612dfe90614d3d565b95612e07614fd9565b612e1091615501565b96612e1a90614d3d565b94612e2490614d3d565b90612e2e90614d3d565b91612e3890614d3d565b92612e4290614d3d565b93612e4c90614d3d565b6040517f7b226e616d65223a20224554482d474d492d424f4e442d4c34202300000000006020820152978897919691603b8901612e8891614432565b7f222c20226465736372697074696f6e223a202241206c6f636b656420556e697381527f776170205633206c697175696469747920626f6e64207769746820726577617260208201527f64732e222c2022696d616765223a2022646174613a696d6167652f7376672b786040820152691b5b0ed8985cd94d8d0b60b21b6060820152606a01612f1691614432565b7f222c202261747472696275746573223a205b7b2274726169745f74797065223a81527f2022556e697377617020563320506f736974696f6e204944222c202276616c7560208201526432911d101160d91b6040820152604501612f7991614432565b7f227d2c207b2274726169745f74797065223a202253746172742054696d65222c81526a10113b30b63ab2911d101160a91b6020820152602b01612fbc91614432565b7f227d2c207b2274726169745f74797065223a2022426f6e64204475726174696f81526d37111610113b30b63ab2911d101160911b6020820152602e0161300291614432565b7f227d2c207b2274726169745f74797065223a2022474d4920526577617264732281526b1610113b30b63ab2911d101160a11b6020820152602c0161304691614432565b7f227d2c207b2274726169745f74797065223a202257455448392052657761726481526d39911610113b30b63ab2911d101160911b6020820152602e0161308c91614432565b7f227d2c207b22646973706c61795f74797065223a202264617465222c2022747281527f6169745f74797065223a2022556e6c6f636b2054696d65222c202276616c75656020820152620111d160ed1b60408201526043016130ed91614432565b627d5d7d60e81b81526003010382810182526131099082610c6c565b613111614fd9565b61311a91615501565b6040517f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000602082015291908290603d820161315491614432565b0390810182526131649082610c6c565b60405161033d8192826102f9565b3461023e57604036600319011261023e57602060ff6131ce60043561319681610371565b602435906131a382610371565b60018060a01b0316600052606a845260406000209060018060a01b0316600052602052604060002090565b54166040519015158152f35b3461023e57602036600319011261023e576004356131f781610371565b6097546001600160a01b039061321090821633146133fc565b811615613220576103dd90614c4b565b60405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608490fd5b3461023e57602036600319011261023e5760043561329181610371565b60018060a01b0316600052610130602052602060ff604060002054166040519015158152f35b604051906132c482610c16565b60008252565b604051906132d782610c51565b60128252711155120b51d35248131408109bdb9908130d60721b6020830152565b6000818152606760205260409020546001600160a01b031615613330576000908152606960205260409020546001600160a01b031690565b60405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608490fd5b1561339157565b60405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608490fd5b1561340357565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b1561344e57565b606460405162461bcd60e51b815260206004820152602060248201527f4c6971756964697479426f6e64733a3a2041646472657373206973207a65726f6044820152fd5b1561349957565b60405162461bcd60e51b815260206004820152602760248201527f4c6971756964697479426f6e64733a3a204164647265737320697320616c726560448201526618591e481cd95d60ca1b6064820152608490fd5b156134f557565b60405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6044820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b6064820152608490fd5b90604051606081018181106001600160401b03821117610c3157604052604060ff6002839580548552600181015460208601520154161515910152565b5190610c9a826112f8565b908160e091031261023e576040519060e08201908282106001600160401b03831117610c315760c091604052805183526020810151602084015260408101516040840152606081015160608401526080810151608084015260a081015160a08401520151613609816112f8565b60c082015290565b6040513d6000823e3d90fd5b5190610c9a82610371565b51908160020b820361023e57565b908161020091031261023e5761364a610c9c565b908051825261365b6020820161361d565b602083015261366c6040820161361d565b604083015261367d6060820161361d565b60608301526080810151608083015260a081015160a08301526136a260c08201613628565b60c08301526136b360e08201613628565b60e0830152610100808201519083015261012080820151908301526101408082015190830152610160808201519083015261018080820151908301526101a06136fd818301613591565b908301526101c061370f81830161361d565b908301526137216101e0809201613591565b9082015290565b634e487b7160e01b600052601160045260246000fd5b906001820180921161374c57565b613728565b906004820180921161374c57565b906002820180921161374c57565b9190820180921161374c57565b60001981019190821161374c57565b601203906012821161374c57565b60111981019190821161374c57565b9190820391821161374c57565b9081602091031261023e575190565b9081602091031261023e575161030a81610371565b519062ffffff8216820361023e57565b51906001600160801b038216820361023e57565b91908261018091031261023e5781516bffffffffffffffffffffffff8116810361023e579161382c6020820161361d565b916138396040830161361d565b916138466060820161361d565b91613853608083016137d7565b9161386060a08201613628565b9161386d60c08301613628565b9161387a60e082016137e7565b91610100820151916101208101519161030a61016061389c61014085016137e7565b93016137e7565b6138c36138be6139069260005261012f602052604060002090565b613554565b610131546138db90610599906001600160a01b031681565b90602080910180519160e060409384518097819263f4dadc61851b8352600483019190602083019252565b0381875afa94851561062557600095613b44575b5082850151835163017c705f60e61b81526004810191909152949561020095868180602481015b0381895afa96871561062557600097613b11575b505086606061399f9798019461397461016087519a01998a519061376d565b4210613af4576000965b8486518351809b8192634086b3ad60e11b8352600483019190602083019252565b0381845afa98891561062557600099613ac0575b5084600491835192838092630e5047b360e41b82525afa94851561062557600095613a8b575b50509351935163133f757160e31b8152600481019490945290916101809190829085908180602481015b03916001600160a01b03165afa93841561062557600092600095613a49575b5050613a3f905194519751966001600160801b038093169061376d565b9396959493921690565b613a6e929550613a3f9350803d10613a84575b613a668183610c6c565b8101906137fb565b9b9a509850505050505050505091939038613a22565b503d613a5c565b613a039495509081613ab192903d10613ab9575b613aa98183610c6c565b8101906137c2565b9392386139d9565b503d613a9f565b6004919950613ae58691823d8411613aed575b613add8183610c6c565b8101906137b3565b9991506139b3565b503d613ad3565b613b0b8951613b06429189519061376d565b6137a6565b9661397e565b61399f97509081613b3692903d10613b3d575b613b2e8183610c6c565b810190613636565b9538613955565b503d613b24565b6139419550613b619060e03d60e011610a3757610a298183610c6c565b9461391a565b15613b6e57565b60405162461bcd60e51b815260206004820152602660248201527f4c6971756964697479426f6e64733a3a204e6f742061206d696e746572206f726044820152651037bbb732b960d11b6064820152608490fd5b15613bc957565b60405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606490fd5b15613c0857565b60405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b15613c5457565b60405162461bcd60e51b815260206004820152602f60248201527f4c6971756964697479426f6e64733a3a20556e697377617020563320706f736960448201526e74696f6e204944206973207a65726f60881b6064820152608490fd5b15613cb857565b60405162461bcd60e51b815260206004820152602b60248201527f4c6971756964697479426f6e64733a3a20506f736974696f6e20697320616c7260448201526a1958591e481b1bd8dad95960aa1b6064820152608490fd5b600019811461374c5760010190565b60026040610c9a9380518455602081015160018501550151151591019060ff801983541691151516179055565b60405190613d5a82610c51565b600f82526e1155120b51d3524b5093d3910b530d608a1b6020830152565b601f8111613d84575050565b60009060656000527f8ff97419363ffd7000167f130ef7168fbea05faf9251824ca5043f113cc6a7c7906020601f850160051c83019410613de0575b601f0160051c01915b828110613dd557505050565b818155600101613dc9565b9092508290613dc0565b601f8111613df6575050565b60009060666000527f46501879b8ca8525e8c2fd519e2fbfcfa2ebea26501294aa02cbfcfb12e94354906020601f850160051c83019410613e52575b601f0160051c01915b828110613e4757505050565b818155600101613e3b565b9092508290613e32565b601f8111613e68575050565b60009061012d6000527f193a3ae4da5049eb74cee39e4cf5827f7ce7b1d1d1775ef1c6311eb60558e6d5906020601f850160051c83019410613ec5575b601f0160051c01915b828110613eba57505050565b818155600101613eae565b9092508290613ea5565b9081516001600160401b038111610c3157613ef481613eef6066546110b8565b613dea565b602080601f8311600114613f3757508190613f279394600092613f2c575b50508160011b916000199060031b1c19161790565b606655565b015190503880613f12565b90601f19831694613f6a60666000527f46501879b8ca8525e8c2fd519e2fbfcfa2ebea26501294aa02cbfcfb12e9435490565b926000905b878210613fa7575050836001959610613f8e575b505050811b01606655565b015160001960f88460031b161c19169055388080613f83565b80600185968294968601518155019501930190613f6f565b9081516001600160401b038111610c315761012d90613fe781613fe284546110b8565b613e5c565b602080601f831160011461401e5750819061401a939495600092613f2c5750508160011b916000199060031b1c19161790565b9055565b90601f1983169561405261012d6000527f193a3ae4da5049eb74cee39e4cf5827f7ce7b1d1d1775ef1c6311eb60558e6d590565b926000905b88821061408f57505083600195969710614076575b505050811b019055565b015160001960f88460031b161c1916905538808061406c565b80600185968294968601518155019501930190614057565b91906140b16132ca565b6140b9613d4d565b906140d460ff60005460081c166140cf81614b90565b614b90565b8051906001600160401b038211610c31576140f9826140f46065546110b8565b613d78565b602090816001601f8511146141bd5750936141476141a29461413f8561126a999661419d96610c9a9c9a600092613f2c5750508160011b916000199060031b1c19161790565b606555613ecf565b61414f614bf0565b614157614c0e565b61415f614c2f565b61013180546001600160a01b0319166001600160a01b03871617905561013280546001600160a01b0319166001600160a01b03909216919091179055565b613fbf565b6001600160a01b031660009081526101306020526040902090565b60656000529190601f1984167f8ff97419363ffd7000167f130ef7168fbea05faf9251824ca5043f113cc6a7c7936000905b8282106142405750509460018561419d95610c9a9b99956141479561126a9c996141a29b10614227575b505050811b01606555613ecf565b015160001960f88460031b161c19169055388080614219565b806001869782949787015181550196019401906141ef565b6000908152606760205260409020546001600160a01b031680156142795790565b60405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608490fd5b929190926142e161054c833361479d565b32331480156143ba575b6142f490614888565b833b158015614326575b93614321939291614311610c9a966148e4565b61431c8383836150bd565b615311565b614ce7565b50610132549092919061434390610599906001600160a01b031681565b604051633185c44d60e21b81523060048201526001600160a01b03861660248201529490602090869060449082905afa9384156106255761431161432195610c9a9760009161439b575b5092965050919293506142fe565b6143b4915060203d60201161061e576106108183610c6c565b3861438d565b50610132546143d390610599906001600160a01b031681565b604051633185c44d60e21b815230600482015233602482015290602090829060449082905afa8015610625576142f491600091614413575b5090506142eb565b61442c915060203d60201161061e576106108183610c6c565b3861440b565b90614445602092828151948592016102b1565b0190565b7f3c616e696d6174652061646469746976653d2273756d2220617474726962757481527f654e616d653d2273746172744f6666736574222066726f6d3d2230252220746f60208201527f3d22313030252220626567696e3d22307322206475723d22333073222072657060408201527f656174436f756e743d22696e646566696e69746522202f3e203c2f746578745060608201527f6174683e203c74657874506174682073746172744f66667365743d223025222060808201527f66696c6c3d2277686974652220666f6e742d66616d696c793d2256657264616e60a08201527f612220666f6e742d73697a653d22313070782220786c696e6b3a687265663d2260c08201526d11ba32bc3a16b830ba3416b0911f60911b60e082015260ee0190565b9081602091031261023e575161030a816112f8565b1561458957565b60405162461bcd60e51b815260206004820152602b60248201527f4c6971756964697479426f6e64733a204f70657261746f72206973206e6f742060448201526a1dda1a5d195b1a5cdd195960aa1b6064820152608490fd5b6000803b158015614649575b6145f790614582565b81815260696020526040812080546001600160a01b03191690556001600160a01b0361462283614258565b167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258280a4565b5061013254604051633185c44d60e21b81523060048201526024810183905290602090829060449082906001600160a01b03165afa8015610625576145f7918391614697575b5090506145ee565b6146b0915060203d60201161061e576106108183610c6c565b3861468f565b803b15801561472d575b6146c990614582565b600082815260696020526040902080546001600160a01b0319166001600160a01b0383161790556001600160a01b038061470284614258565b169116907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600080a4565b5061013254604051633185c44d60e21b81523060048201526001600160a01b038381166024830152909160209183916044918391165afa8015610625576146c99160009161477e575b5090506146c0565b614797915060203d60201161061e576106108183610c6c565b38614776565b6000828152606760205260409020546001600160a01b03161561482e576147c382614258565b6001600160a01b038281168282168114949091908515614816575b50505082156147ec57505090565b6001600160a01b03166000908152606a6020526040902060ff92506148119190610402565b541690565b61482391929395506132f8565b1614913880806147de565b60405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608490fd5b1561488f57565b60405162461bcd60e51b815260206004820152602760248201527f4c6971756964697479426f6e64733a2053656e646572206973206e6f742077686044820152661a5d195b1a5cdd60ca1b6064820152608490fd5b156148eb57565b60405162461bcd60e51b815260206004820152602660248201527f4c6971756964697479426f6e64733a205265636569766572206e6f74207768696044820152651d195b1a5cdd60d21b6064820152608490fd5b6001600160a01b038116908115614a35576000838152606760205260409020546001600160a01b03166149f0576001600160a01b03811660009081526068602052604090206149c89190614993815461373e565b90556149a9846000526067602052604060002090565b80546001600160a01b0319166001600160a01b03909216919091179055565b60007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a4565b60405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606490fd5b606460405162461bcd60e51b815260206004820152602060248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152fd5b614a8281614258565b60003b158015614b1c575b90614a99600092614582565b614aa283615038565b6001600160a01b0381166000908152606860205260409020614ac4815461377a565b9055614aed614add846000526067602052604060002090565b80546001600160a01b0319169055565b6001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8280a4565b5061013254604051633185c44d60e21b8152306004820152600060248201529190602090839060449082906001600160a01b03165afa91821561062557600092614a99918491614b71575b5091925050614a8d565b614b8a915060203d60201161061e576106108183610c6c565b38614b67565b15614b9757565b60405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608490fd5b614c0560ff60005460081c166140cf81614b90565b610c9a33614c4b565b614c2360ff60005460081c166140cf81614b90565b60ff1960c9541660c955565b614c4460ff60005460081c166140cf81614b90565b600160fb55565b609780546001600160a01b039283166001600160a01b0319821681179092559091167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b60809060208152603260208201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b60608201520190565b15614cee57565b60405162461bcd60e51b815280614d0760048201614c94565b0390fd5b90614d1582610cbc565b614d226040519182610c6c565b8281528092614d33601f1991610cbc565b0190602036910137565b806000917a184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000080821015614e73575b506d04ee2d6d415b85acef810000000080831015614e64575b50662386f26fc1000080831015614e55575b506305f5e10080831015614e46575b5061271080831015614e37575b506064821015614e27575b600a80921015614e1d575b600190816021614dd560018701614d0b565b95860101905b614de7575b5050505090565b600019019083906f181899199a1a9b1b9c1cb0b131b232b360811b8282061a835304918215614e1857919082614ddb565b614de0565b9160010191614dc3565b9190606460029104910191614db8565b60049193920491019138614dad565b60089193920491019138614da0565b60109193920491019138614d91565b60209193920491019138614d7f565b604093508104915038614d66565b60405190614e8e82610c51565b60068252650302e303030360d41b6020830152565b60405190614eb082610c51565b60018252600360fc1b6020830152565b8015614fd057614ecf90614d3d565b9081516012811115614f56575b614f259192614f38614f12614ef361030a94613797565b9283614f4657614f01614ea3565b935b614f0c81613751565b91615469565b614f326040519586946020860190614432565b601760f91b815260010190565b90614432565b03601f198101835282610c6c565b614f5084826153fc565b93614f03565b614f6290929192613789565b906060916000905b808210614fa0575050614f32614f94614f2593614f3861030a946040519485936020850190614432565b92915060129050614edc565b909392614f38614fc7600192604051928391614f3260208401600190600360fc1b81520190565b93940190614f6a565b5061030a614e81565b60405190614fe682610c36565b604082527f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f6040837f4142434445464748494a4b4c4d4e4f505152535455565758595a61626364656660208201520152565b600081815260696020526040812080546001600160a01b03191690556001600160a01b0361462283614258565b1561506c57565b60405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608490fd5b906150c783614258565b6001600160a01b0383811692909182168390036151815761511661515a928216946150f3861515615065565b6150fc876145e2565b6001600160a01b0316600090815260686020526040902090565b615120815461377a565b90556001600160a01b0381166000908152606860205260409020615144815461373e565b90556149a9856000526067602052604060002090565b7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600080a4565b60405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608490fd5b6001600160a01b0382811693911691828414615256578161524b7f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c319361523a60209487600052606a865260406000209060018060a01b0316600052602052604060002090565b9060ff801983541691151516179055565b6040519015158152a3565b60405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606490fd5b9081602091031261023e575161030a8161022c565b6001600160a01b03918216815291166020820152604081019190915260806060820181905261030a929101906102d4565b3d1561530c573d906152f282610cbc565b916153006040519384610c6c565b82523d6000602084013e565b606090565b92909190823b156153cc57615344926020926000604051809681958294630a85bd0160e11b9a8b855233600486016152b0565b03926001600160a01b03165af16000918161539b575b5061538d576153676152e1565b805190816153885760405162461bcd60e51b815280614d0760048201614c94565b602001fd5b6001600160e01b0319161490565b6153be91925060203d6020116153c5575b6153b68183610c6c565b81019061529b565b903861535a565b503d6153ac565b50505050600190565b9081518110156153e6570160200190565b634e487b7160e01b600052603260045260246000fd5b9061540681610cbc565b916154146040519384610c6c565b818352601f1961542383610cbc565b0136602085013760009060005b83811061543e575050505090565b6001906001600160f81b031961545482856153d5565b5116841a61546282886153d5565b5301615430565b918181039281841161374c5761547e84610cbc565b9361548c6040519586610c6c565b80855261549b601f1991610cbc565b01366020860137825b8281106154b2575050505090565b6001600160f81b03196154c582846153d5565b51169084810381811161374c576154e260019360001a91886153d5565b53016154a4565b600281901b91906001600160fe1b0381160361374c57565b908151156155d85761552d61552861552361551c855161375f565b6003900490565b6154e9565b614d0b565b91602083019181825183016020810191825193600084525b828210615586575050505251600390066001811461557357600214615568575090565b603d90600019015390565b50603d9081600019820153600119015390565b9091956004906003809401938451600190603f9082828260121c16880101518553828282600c1c16880101518386015382828260061c1688010151600286015316850101519082015301959190615545565b505061030a6132b756fea26469706673582212204872c4fbc879c7ff727a2339b4810cccef13dd093be157f490625d6387082e1f64736f6c63430008160033
Deployed Bytecode
0x6080604052600436101561001257600080fd5b60003560e01c806301ffc9a71461022757806306fdde0314610222578063081812fc1461021d578063095ea7b3146102185780630989f2971461021357806323b872dd1461020e57806326987b60146102095780633092afd5146102045780633392bec8146101ff5780633f4ba83a146101fa57806340c10f19146101f557806342842e0e146101f057806342966c68146101eb5780634571e3a6146101e657806358c2225b146101e15780635c975abb146101dc5780635f1c17c0146101d75780636352211e146101d257806370a08231146101cd578063715018a6146101c857806374ec06bc146101c35780638456cb59146101be5780638da5cb5b146101b957806394c8636f146101b457806395d89b41146101af578063983b2d56146101aa578063a22cb465146101a5578063b5215aaa146101a0578063b88d4fde1461019b578063c87b56dd14610196578063e985e9c514610191578063f2fde38b1461018c5763f46eccc41461018757600080fd5b613274565b6131da565b613172565b6114b6565b61144f565b6113c0565b611302565b6111f2565b6111d6565b6110f2565b61108f565b611023565b610ff9565b610f95565b610eef565b610ed1565b610e88565b610e65565b610e3b565b610d0e565b610a7a565b610a52565b61089e565b6107fd565b6107ba565b6106c1565b6106a2565b610530565b610475565b610382565b610341565b61030d565b610243565b6001600160e01b031981160361023e57565b600080fd5b3461023e57602036600319011261023e5760206004356102628161022c565b63ffffffff60e01b166380ac58cd60e01b81149081156102a0575b811561028f575b506040519015158152f35b6301ffc9a760e01b14905038610284565b635b5e139f60e01b8114915061027d565b60005b8381106102c45750506000910152565b81810151838201526020016102b4565b906020916102ed815180928185528580860191016102b1565b601f01601f1916010190565b90602061030a9281815201906102d4565b90565b3461023e57600036600319011261023e5761033d6103296132ca565b6040519182916020835260208301906102d4565b0390f35b3461023e57602036600319011261023e57602061035f6004356132f8565b6040516001600160a01b039091168152f35b6001600160a01b0381160361023e57565b3461023e57604036600319011261023e5760043561039f81610371565b6024356103ab81614258565b916001600160a01b038084169082168114610426576103dd936103d89133149081156103df575b5061338a565b6146b6565b005b6001600160a01b03166000908152606a6020526040902061042091506104199033905b9060018060a01b0316600052602052604060002090565b5460ff1690565b386103d2565b60405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608490fd5b3461023e57602036600319011261023e5760043561049281610371565b6097546001600160a01b039182916104ad90831633146133fc565b16906104ba821515613447565b610132828154928316926104d084831415613492565b6001600160a01b0319161790557ff8b0ee9361a0f0225b39f58411465016adbd34abff194e6119b537fa8b063247600080a3005b606090600319011261023e5760043561051c81610371565b9060243561052981610371565b9060443590565b3461023e5761053e36610504565b9061055161054c833361479d565b6134ee565b323314801561062a575b61056490614888565b803b158015610580575b9261057b6103dd946148e4565b6150bd565b50610132546105a590610599906001600160a01b031681565b6001600160a01b031690565b604051633185c44d60e21b81523060048201526001600160a01b03831660248201529390602090859060449082905afa938415610625576103dd9461057b916000916105f6575b509194505061056e565b610618915060203d60201161061e575b6106108183610c6c565b81019061456d565b386105ec565b503d610606565b613611565b506101325461064390610599906001600160a01b031681565b604051633185c44d60e21b815230600482015233602482015290602090829060449082905afa80156106255761056491600091610683575b50905061055b565b61069c915060203d60201161061e576106108183610c6c565b3861067b565b3461023e57600036600319011261023e57602061012e54604051908152f35b3461023e57602036600319011261023e576004356106de81610371565b6097546001600160a01b03906106f790821633146133fc565b8116610704811515613447565b60009181835261013060205260ff60408420541615610764576001600160a01b0316600090815261013060205260409020805460ff191690557fe94479a9f7e1952cc78f2d6baab678adc1b772d936c6583def489e524cb666928280a280f35b60405162461bcd60e51b815260206004820152602860248201527f4c6971756964697479426f6e64733a3a2041646472657373206973206e6f7420604482015267309036b4b73a32b960c11b6064820152608490fd5b3461023e57602036600319011261023e5760c06107d86004356138a3565b93604093919351958652602086015260408501526060840152608083015260a0820152f35b3461023e57600036600319011261023e5761082360018060a01b036097541633146133fc565b60c95460ff8116156108625760ff191660c9557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b60405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606490fd5b3461023e57604036600319011261023e576004356108bb81610371565b60243560009133835261013060205260ff6040842054168015610a3e575b6108e290613b67565b6108f160ff60c9541615613bc2565b610900600260fb541415613c01565b600260fb556001600160a01b0381169061091b821515613447565b610926831515613c4d565b6101315461093e90610599906001600160a01b031681565b60405163f4dadc6160e01b8152600481018590529060e090829060249082905afa80156106255760c061097e91610984938891610a0f575b500151151590565b15613cb1565b6109dc61012e9161099e6109988454613d11565b61012e55565b6109d483546109cf6109ae610c8d565b9180835288602084015289604084015260005261012f602052604060002090565b613d20565b82549061493f565b54907f72970e8e667928f70b2da0ecfd32c52c589298ecc73c7c540586fb6003ba040f8480a4610a0c600160fb55565b80f35b610a31915060e03d60e011610a37575b610a298183610c6c565b81019061359c565b38610976565b503d610a1f565b506097546001600160a01b031633146108d9565b3461023e576103dd610a6336610504565b9060405192610a7184610c16565b600084526142d0565b3461023e57602036600319011261023e5760043560009033825261013060205260ff6040832054168015610bec575b610ab290613b67565b610ac160ff60c9541615613bc2565b610ad0600260fb541415613c01565b600260fb558015610ba8576000818152606760205260409020546001600160a01b031615610b5757610b206002610b128360005261012f602052604060002090565b01805460ff19166001179055565b610b2981614a79565b7f0d7a61e190b0f85b64fde8b74afceb2d1894072e7b5ee31e2295b51ad0d441bc8280a2610a0c600160fb55565b60405162461bcd60e51b8152602060048201526024808201527f4c6971756964697479426f6e64733a3a20426f6e6420646f6573206e6f7420656044820152631e1a5cdd60e21b6064820152608490fd5b606460405162461bcd60e51b815260206004820152602060248201527f4c6971756964697479426f6e64733a3a20426f6e64204944206973207a65726f6044820152fd5b506097546001600160a01b03163314610aa9565b634e487b7160e01b600052604160045260246000fd5b602081019081106001600160401b03821117610c3157604052565b610c00565b606081019081106001600160401b03821117610c3157604052565b604081019081106001600160401b03821117610c3157604052565b90601f801991011681019081106001600160401b03821117610c3157604052565b60405190610c9a82610c36565b565b6040519061020082018281106001600160401b03821117610c3157604052565b6001600160401b038111610c3157601f01601f191660200190565b929192610ce382610cbc565b91610cf16040519384610c6c565b82948184528183011161023e578281602093846000960137010152565b3461023e57606036600319011261023e57600435610d2b81610371565b602435610d3781610371565b6044356001600160401b03811161023e573660238201121561023e57610d67903690602481600401359101610cd7565b6000549160ff8360081c169283600014610e325750303b155b15610dd657610d9592159384610dab576140a7565b610d9b57005b6103dd61ff001960005416600055565b610dbf61010061ff00196000541617600055565b610dd1600160ff196000541617600055565b6140a7565b60405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b60ff1615610d80565b3461023e57600036600319011261023e57610132546040516001600160a01b039091168152602090f35b3461023e57600036600319011261023e57602060ff60c954166040519015158152f35b3461023e57602036600319011261023e5760043560005261012f6020526060604060002080549060ff600260018301549201541690604051928352602083015215156040820152f35b3461023e57602036600319011261023e57602061035f600435614258565b3461023e57602036600319011261023e57600435610f0c81610371565b6001600160a01b03168015610f3d57600052606860205261033d604060002054604051918291829190602083019252565b60405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608490fd5b3461023e57600080600319360112610ff65760975481906001600160a01b03811690610fc23383146133fc565b6001600160a01b0319166097557f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b80fd5b3461023e57600036600319011261023e57610131546040516001600160a01b039091168152602090f35b3461023e57600036600319011261023e5761104960018060a01b036097541633146133fc565b600160c95461105b60ff821615613bc2565b60ff19161760c9557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1005b3461023e57600036600319011261023e576097546040516001600160a01b039091168152602090f35b90600182811c921680156110e8575b60208310146110d257565b634e487b7160e01b600052602260045260246000fd5b91607f16916110c7565b3461023e57600080600319360112610ff657604051908061012d8054611117816110b8565b808652926020926001928084169081156111a75750600114611150575b61033d8761114481890382610c6c565b604051918291826102f9565b815293507f193a3ae4da5049eb74cee39e4cf5827f7ce7b1d1d1775ef1c6311eb60558e6d55b838510611194575050505081016020016111448261033d3880611134565b8054868601840152938201938101611176565b91505086955061033d9693506020925061114494915060ff191682840152151560051b82010192933880611134565b3461023e57600036600319011261023e5761033d610329613d4d565b3461023e57602036600319011261023e5760043561120f81610371565b6097546001600160a01b039061122890821633146133fc565b8116611235811515613447565b60009181835261013060205260ff60408420541661129e576001600160a01b0316600090815261013060205260409020611277905b805460ff19166001179055565b7f6ae172837ea30b801fbfcdd4108aa1d5bf8ff775444fd70256b44e6bf3dfc3f68280a280f35b60405162461bcd60e51b815260206004820152602c60248201527f4c6971756964697479426f6e64733a3a204164647265737320697320616c726560448201526b30b23c90309036b4b73a32b960a11b6064820152608490fd5b8015150361023e57565b3461023e57604036600319011261023e5760043561131f81610371565b60243561132b816112f8565b813b158015611348575b916113426103dd93614582565b336151d4565b5061013254604051633185c44d60e21b81523060048201526001600160a01b03848116602483015290939160209185916044918391165afa928315610625576103dd93611342916000916113a1575b5091935050611335565b6113ba915060203d60201161061e576106108183610c6c565b38611397565b3461023e57602036600319011261023e576004356113dd81610371565b6097546001600160a01b039182916113f890831633146133fc565b1690611405821515613447565b6101318281549283169261141b84831415613492565b6001600160a01b0319161790557f748f722ee0920121a4d9633c16ef2dd3a68219e5c44480aeb31ab9df22412424600080a3005b3461023e57608036600319011261023e5760043561146c81610371565b60243561147881610371565b606435916001600160401b03831161023e573660238401121561023e576114ac6103dd933690602481600401359101610cd7565b91604435916142d0565b3461023e57602036600319011261023e576004356114d3816138a3565b92939290916114e2904261376d565b916114ec87614d3d565b946114f688614d3d565b9561150089614d3d565b6115098a614d3d565b6115128b614d3d565b61151b8b614d3d565b9061152587614ec0565b9261152f89614ec0565b946040519c8d976020890161255890610d9a907f3c7376672077696474683d2232393022206865696768743d223530302220766981527f6577426f783d2230203020323930203530302220786d6c6e733d22687474703a60208201527f2f2f7777772e77332e6f72672f323030302f7376672220786d6c6e733a786c6960408201527f6e6b3d22687474703a2f2f7777772e77332e6f72672f313939392f786c696e6b60608201527f223e3c646566733e3c66696c7465722069643d226631223e3c6665496d61676560808201527f20726573756c743d2270302220786c696e6b3a687265663d22646174613a696d60a08201527f6167652f7376672b786d6c3b6261736536342c50484e325a794233615752306160c08201527f44306e4d6a6b774a79426f5a576c6e614851394a7a55774d436367646d6c6c6460e08201527f304a766544306e4d434177494449354d4341314d44416e494868746247357a506101008201527f53646f644852774f693876643364334c6e637a4c6d39795a7938794d4441774c6101208201527f334e325a79632b50484a6c5933516764326c6b644767394a7a49354d4842344a6101408201527f79426f5a576c6e614851394a7a55774d4842344a79426d615778735053636a4d6101608201527f574d335a4452694a79382b5043397a646d632b222f3e203c6665496d616765206101808201527f726573756c743d2270312220786c696e6b3a687265663d22646174613a696d616101a08201527f67652f7376672b786d6c3b6261736536342c50484e325a7942336157523061446101c08201527f306e4d6a6b774a79426f5a576c6e614851394a7a55774d436367646d6c6c64306101e08201527f4a766544306e4d434177494449354d4341314d44416e494868746247357a50536102008201527f646f644852774f693876643364334c6e637a4c6d39795a7938794d4441774c336102208201527f4e325a79632b50474e70636d4e735a53426a6544306e4d6a49794a79426a65546102408201527f306e4d6a41794a794279505363784d6a4277654363675a6d6c736244306e49326102608201527f5a6d5a6a6b354e796376506a777663335a6e50673d3d22202f3e203c6665496d6102808201527f61676520726573756c743d2270322220786c696e6b3a687265663d22646174616102a08201527f3a696d6167652f7376672b786d6c3b6261736536342c50484e325a7942336157806102c08301527f52306144306e4d6a6b774a79426f5a576c6e614851394a7a55774d436367646d806102e08401527f6c6c64304a766544306e4d434177494449354d4341314d44416e49486874624790816103008501527f357a5053646f644852774f693876643364334c6e637a4c6d39795a7938794d4492836103208601527f41774c334e325a79632b50474e70636d4e735a53426a6544306e4f44516e49476103408601527f4e355053637a4f44456e494849394a7a45794d4842344a79426d6157787350536103608601527f636a4f574d334d6a4d344a79382b5043397a646d632b22202f3e203c6665496d6103808601527f61676520726573756c743d2270332220786c696e6b3a687265663d22646174616103a08601526103c08501526103e08401526104008301526104208201527f41774c334e325a79632b50474e70636d4e735a53426a6544306e4d6a55324a796104408201527f426a6554306e4e4441334a794279505363784d444277654363675a6d6c7362446104608201527f306e497a526b4e6d49784e436376506a777663335a6e50673d3d22202f3e203c6104808201527f6665426c656e64206d6f64653d226f7665726c61792220696e3d2270302220696104a08201527f6e323d22703122202f3e203c6665426c656e64206d6f64653d226578636c75736104c08201527f696f6e2220696e323d22703222202f3e203c6665426c656e64206d6f64653d226104e08201527f6f7665726c61792220696e323d2270332220726573756c743d22626c656e644f6105008201527f757422202f3e203c6665476175737369616e426c757220696e3d22626c656e646105208201527f4f75742220737464446576696174696f6e3d22343222202f3e203c2f66696c746105408201527f65723e203c636c6970506174682069643d22636f726e657273223e203c7265636105608201527f742077696474683d2232393022206865696768743d22353030222072783d22346105808201527f32222072793d22343222202f3e203c2f636c6970506174683e203c70617468206105a08201527f69643d22746578742d706174682d612220643d224d34302031322048323530206105c08201527f41323820323820302030203120323738203430205634363020413238203238206105e08201527f30203020312032353020343838204834302041323820323820302030203120316106008201527f32203436302056343020413238203238203020302031203430203132207a22206106208201527f2f3e203c706174682069643d226d696e696d61702220643d224d3233342034346106408201527f3443323334203435372e393439203234322e32312034363320323533203436336106608201527f22202f3e203c66696c7465722069643d22746f702d726567696f6e2d626c75726106808201527f223e203c6665476175737369616e426c757220696e3d22536f757263654772616106a08201527f706869632220737464446576696174696f6e3d22323422202f3e203c2f66696c6106c08201527f7465723e203c6c696e6561724772616469656e742069643d22677261642d75706106e08201527f222078313d2231222078323d2230222079313d2231222079323d2230223e203c6107008201527f73746f70206f66667365743d22302e30222073746f702d636f6c6f723d2277686107208201527f697465222073746f702d6f7061636974793d223122202f3e203c73746f70206f6107408201527f66667365743d222e39222073746f702d636f6c6f723d227768697465222073746107608201527f6f702d6f7061636974793d223022202f3e203c2f6c696e6561724772616469656107808201527f6e743e203c6c696e6561724772616469656e742069643d22677261642d646f776107a08201527f6e222078313d2230222078323d2231222079313d2230222079323d2231223e206107c08201527f3c73746f70206f66667365743d22302e30222073746f702d636f6c6f723d22776107e08201527f68697465222073746f702d6f7061636974793d223122202f3e203c73746f70206108008201527f6f66667365743d22302e39222073746f702d636f6c6f723d22776869746522206108208201527f73746f702d6f7061636974793d223022202f3e203c2f6c696e656172477261646108408201527f69656e743e203c6d61736b2069643d22666164652d757022206d61736b436f6e6108608201527f74656e74556e6974733d226f626a656374426f756e64696e67426f78223e203c6108808201527f726563742077696474683d223122206865696768743d2231222066696c6c3d226108a08201527f75726c2823677261642d75702922202f3e203c2f6d61736b3e203c6d61736b206108c08201527f69643d22666164652d646f776e22206d61736b436f6e74656e74556e6974733d6108e08201527f226f626a656374426f756e64696e67426f78223e203c726563742077696474686109008201527f3d223122206865696768743d2231222066696c6c3d2275726c2823677261642d6109208201527f646f776e2922202f3e203c2f6d61736b3e203c6d61736b2069643d226e6f6e656109408201527f22206d61736b436f6e74656e74556e6974733d226f626a656374426f756e64696109608201527f6e67426f78223e203c726563742077696474683d223122206865696768743d226109808201527f31222066696c6c3d22776869746522202f3e203c2f6d61736b3e203c6c696e656109a08201527f61724772616469656e742069643d22677261642d73796d626f6c223e203c73746109c08201527f6f70206f66667365743d22302e37222073746f702d636f6c6f723d22776869746109e08201527f65222073746f702d6f7061636974793d223122202f3e203c73746f70206f6666610a008201527f7365743d222e3935222073746f702d636f6c6f723d227768697465222073746f610a208201527f702d6f7061636974793d223022202f3e203c2f6c696e6561724772616469656e610a408201527f743e203c6d61736b2069643d22666164652d73796d626f6c22206d61736b436f610a608201527f6e74656e74556e6974733d227573657253706163654f6e557365223e203c7265610a808201527f63742077696474683d22323930707822206865696768743d2232303070782220610aa08201527f66696c6c3d2275726c2823677261642d73796d626f6c2922202f3e203c2f6d61610ac08201527f736b3e203c2f646566733e203c6720636c69702d706174683d2275726c282363610ae08201527f6f726e65727329223e203c726563742066696c6c3d2223316337643462222078610b008201527f3d223070782220793d22307078222077696474683d2232393070782220686569610b208201527f6768743d22353030707822202f3e203c72656374207374796c653d2266696c74610b408201527f65723a2075726c28236631292220783d223070782220793d2230707822207769610b608201527f6474683d22323930707822206865696768743d22353030707822202f3e203c67610b808201527f207374796c653d2266696c7465723a75726c2823746f702d726567696f6e2d62610ba08201527f6c7572293b207472616e73666f726d3a7363616c6528312e35293b207472616e610bc08201527f73666f726d2d6f726967696e3a63656e74657220746f703b223e203c72656374610be08201527f2066696c6c3d226e6f6e652220783d223070782220793d223070782220776964610c008201527f74683d22323930707822206865696768743d22353030707822202f3e203c656c610c208201527f6c697073652063783d22353025222063793d22307078222072783d2231383070610c408201527f78222072793d223132307078222066696c6c3d222330303022206f7061636974610c608201527f793d22302e383522202f3e203c2f673e203c7265637420783d22302220793d22610c808201527f30222077696474683d2232393022206865696768743d22353030222072783d22610ca08201527f3432222072793d223432222066696c6c3d227267626128302c302c302c302922610cc08201527f207374726f6b653d2272676261283235352c3235352c3235352c302e32292220610ce08201527f2f3e203c2f673e203c7465787420746578742d72656e646572696e673d226f70610d008201527f74696d697a655370656564223e203c74657874506174682073746172744f6666610d208201527f7365743d222d31303025222066696c6c3d2277686974652220666f6e742d6661610d408201527f6d696c793d2256657264616e612220666f6e742d73697a653d22313070782220610d608201527f786c696e6b3a687265663d2223746578742d706174682d61223e000000000000610d808201520190565b704554482d474d492d424f4e442d4c34202360781b815260110161257b91614432565b61258490614449565b704554482d474d492d424f4e442d4c34202360781b81526011016125a791614432565b6125b090614449565b704554482d474d492d424f4e442d4c34202360781b81526011016125d391614432565b7f3c616e696d6174652061646469746976653d2273756d2220617474726962757481527f654e616d653d2273746172744f6666736574222066726f6d3d2230252220746f60208201527f3d22313030252220626567696e3d22307322206475723d22333073222072657060408201527f656174436f756e743d22696e646566696e69746522202f3e203c2f746578745060608201527f6174683e203c74657874506174682073746172744f66667365743d222d35302560808201527f222066696c6c3d2277686974652220666f6e742d66616d696c793d225665726460a08201527f616e612220666f6e742d73697a653d22313070782220786c696e6b3a6872656660c08201526f1e9111ba32bc3a16b830ba3416b0911f60811b60e082015260f001704554482d474d492d424f4e442d4c34202360781b815260110161271991614432565b7f3c616e696d6174652061646469746976653d2273756d2220617474726962757481527f654e616d653d2273746172744f6666736574222066726f6d3d2230252220746f60208201527f3d22313030252220626567696e3d22307322206475723d22333073222072657060408201527f656174436f756e743d22696e646566696e69746522202f3e203c2f746578745060608201527f6174683e203c2f746578743e203c67206d61736b3d2275726c2823666164652d60808201527f73796d626f6c29223e203c726563742066696c6c3d226e6f6e652220783d223060a08201527f70782220793d22307078222077696474683d223239307078222068656967687460c08201527f3d22323030707822202f3e203c7465787420793d22373070782220783d22333260e08201527f7078222066696c6c3d2277686974652220666f6e742d66616d696c793d2256656101008201527f7264616e612220666f6e742d7765696768743d223230302220666f6e742d73696101208201527f7a653d2233367078223e4c5020424f4e443c2f746578743e203c7465787420796101408201527f3d2231313570782220783d2233327078222066696c6c3d2277686974652220666101608201527f6f6e742d66616d696c793d2256657264616e612220666f6e742d7765696768746101808201527f3d223230302220666f6e742d73697a653d2233367078223e23000000000000006101a08201526101b90161293d91614432565b7f3c2f746578743e203c2f673e203c7265637420783d2231362220793d2231362281527f2077696474683d2232353822206865696768743d22343638222072783d22323660208201527f222072793d223236222066696c6c3d227267626128302c302c302c302922207360408201527f74726f6b653d2272676261283235352c3235352c3235352c302e322922202f3e60608201527f203c67207374796c653d227472616e73666f726d3a7472616e736c617465283260808201527f3970782c20333834707829223e203c726563742077696474683d22323330707860a08201527f22206865696768743d2232367078222072783d22387078222072793d2238707860c08201527f222066696c6c3d227267626128302c302c302c302e362922202f3e203c74657860e08201527f7420783d22313270782220793d22313770782220666f6e742d66616d696c793d6101008201527f2256657264616e612220666f6e742d73697a653d2231327078222066696c6c3d6101208201527f227768697465223e203c747370616e2066696c6c3d2272676261283235352c326101408201527f35352c3235352c302e3629223e506f736974696f6e2049643a203c2f7473706161016082015261371f60f11b61018082015261018201612b1f91614432565b7f3c2f746578743e203c2f673e203c67207374796c653d227472616e73666f726d81527f3a7472616e736c61746528323970782c20343134707829223e203c726563742060208201527f77696474683d22323330707822206865696768743d2232367078222072783d2260408201527f387078222072793d22387078222066696c6c3d227267626128302c302c302c3060608201527f2e362922202f3e203c7465787420783d22313270782220793d2231377078222060808201527f666f6e742d66616d696c793d2256657264616e612220666f6e742d73697a653d60a08201527f2231327078222066696c6c3d227768697465223e203c747370616e2066696c6c60c08201527f3d2272676261283235352c3235352c3235352c302e3629223e474d492052657760e08201526d30b932399d101e17ba39b830b71f60911b61010082015261010e01612c7191614432565b7f3c2f746578743e203c2f673e203c67207374796c653d227472616e73666f726d81527f3a7472616e736c61746528323970782c20343434707829223e203c726563742060208201527f77696474683d22323330707822206865696768743d2232367078222072783d2260408201527f387078222072793d22387078222066696c6c3d227267626128302c302c302c3060608201527f2e362922202f3e203c7465787420783d22313270782220793d2231377078222060808201527f666f6e742d66616d696c793d2256657264616e612220666f6e742d73697a653d60a08201527f2231327078222066696c6c3d227768697465223e203c747370616e2066696c6c60c08201527f3d2272676261283235352c3235352c3235352c302e3629223e5745544820526560e08201526e3bb0b932399d101e17ba39b830b71f60891b61010082015261010f01612dc491614432565b721e17ba32bc3a1f101e17b39f101e17b9bb339f60691b81526013010397601f19988981018852612df59088610c6c565b612dfe90614d3d565b95612e07614fd9565b612e1091615501565b96612e1a90614d3d565b94612e2490614d3d565b90612e2e90614d3d565b91612e3890614d3d565b92612e4290614d3d565b93612e4c90614d3d565b6040517f7b226e616d65223a20224554482d474d492d424f4e442d4c34202300000000006020820152978897919691603b8901612e8891614432565b7f222c20226465736372697074696f6e223a202241206c6f636b656420556e697381527f776170205633206c697175696469747920626f6e64207769746820726577617260208201527f64732e222c2022696d616765223a2022646174613a696d6167652f7376672b786040820152691b5b0ed8985cd94d8d0b60b21b6060820152606a01612f1691614432565b7f222c202261747472696275746573223a205b7b2274726169745f74797065223a81527f2022556e697377617020563320506f736974696f6e204944222c202276616c7560208201526432911d101160d91b6040820152604501612f7991614432565b7f227d2c207b2274726169745f74797065223a202253746172742054696d65222c81526a10113b30b63ab2911d101160a91b6020820152602b01612fbc91614432565b7f227d2c207b2274726169745f74797065223a2022426f6e64204475726174696f81526d37111610113b30b63ab2911d101160911b6020820152602e0161300291614432565b7f227d2c207b2274726169745f74797065223a2022474d4920526577617264732281526b1610113b30b63ab2911d101160a11b6020820152602c0161304691614432565b7f227d2c207b2274726169745f74797065223a202257455448392052657761726481526d39911610113b30b63ab2911d101160911b6020820152602e0161308c91614432565b7f227d2c207b22646973706c61795f74797065223a202264617465222c2022747281527f6169745f74797065223a2022556e6c6f636b2054696d65222c202276616c75656020820152620111d160ed1b60408201526043016130ed91614432565b627d5d7d60e81b81526003010382810182526131099082610c6c565b613111614fd9565b61311a91615501565b6040517f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000602082015291908290603d820161315491614432565b0390810182526131649082610c6c565b60405161033d8192826102f9565b3461023e57604036600319011261023e57602060ff6131ce60043561319681610371565b602435906131a382610371565b60018060a01b0316600052606a845260406000209060018060a01b0316600052602052604060002090565b54166040519015158152f35b3461023e57602036600319011261023e576004356131f781610371565b6097546001600160a01b039061321090821633146133fc565b811615613220576103dd90614c4b565b60405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608490fd5b3461023e57602036600319011261023e5760043561329181610371565b60018060a01b0316600052610130602052602060ff604060002054166040519015158152f35b604051906132c482610c16565b60008252565b604051906132d782610c51565b60128252711155120b51d35248131408109bdb9908130d60721b6020830152565b6000818152606760205260409020546001600160a01b031615613330576000908152606960205260409020546001600160a01b031690565b60405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608490fd5b1561339157565b60405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608490fd5b1561340357565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b1561344e57565b606460405162461bcd60e51b815260206004820152602060248201527f4c6971756964697479426f6e64733a3a2041646472657373206973207a65726f6044820152fd5b1561349957565b60405162461bcd60e51b815260206004820152602760248201527f4c6971756964697479426f6e64733a3a204164647265737320697320616c726560448201526618591e481cd95d60ca1b6064820152608490fd5b156134f557565b60405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6044820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b6064820152608490fd5b90604051606081018181106001600160401b03821117610c3157604052604060ff6002839580548552600181015460208601520154161515910152565b5190610c9a826112f8565b908160e091031261023e576040519060e08201908282106001600160401b03831117610c315760c091604052805183526020810151602084015260408101516040840152606081015160608401526080810151608084015260a081015160a08401520151613609816112f8565b60c082015290565b6040513d6000823e3d90fd5b5190610c9a82610371565b51908160020b820361023e57565b908161020091031261023e5761364a610c9c565b908051825261365b6020820161361d565b602083015261366c6040820161361d565b604083015261367d6060820161361d565b60608301526080810151608083015260a081015160a08301526136a260c08201613628565b60c08301526136b360e08201613628565b60e0830152610100808201519083015261012080820151908301526101408082015190830152610160808201519083015261018080820151908301526101a06136fd818301613591565b908301526101c061370f81830161361d565b908301526137216101e0809201613591565b9082015290565b634e487b7160e01b600052601160045260246000fd5b906001820180921161374c57565b613728565b906004820180921161374c57565b906002820180921161374c57565b9190820180921161374c57565b60001981019190821161374c57565b601203906012821161374c57565b60111981019190821161374c57565b9190820391821161374c57565b9081602091031261023e575190565b9081602091031261023e575161030a81610371565b519062ffffff8216820361023e57565b51906001600160801b038216820361023e57565b91908261018091031261023e5781516bffffffffffffffffffffffff8116810361023e579161382c6020820161361d565b916138396040830161361d565b916138466060820161361d565b91613853608083016137d7565b9161386060a08201613628565b9161386d60c08301613628565b9161387a60e082016137e7565b91610100820151916101208101519161030a61016061389c61014085016137e7565b93016137e7565b6138c36138be6139069260005261012f602052604060002090565b613554565b610131546138db90610599906001600160a01b031681565b90602080910180519160e060409384518097819263f4dadc61851b8352600483019190602083019252565b0381875afa94851561062557600095613b44575b5082850151835163017c705f60e61b81526004810191909152949561020095868180602481015b0381895afa96871561062557600097613b11575b505086606061399f9798019461397461016087519a01998a519061376d565b4210613af4576000965b8486518351809b8192634086b3ad60e11b8352600483019190602083019252565b0381845afa98891561062557600099613ac0575b5084600491835192838092630e5047b360e41b82525afa94851561062557600095613a8b575b50509351935163133f757160e31b8152600481019490945290916101809190829085908180602481015b03916001600160a01b03165afa93841561062557600092600095613a49575b5050613a3f905194519751966001600160801b038093169061376d565b9396959493921690565b613a6e929550613a3f9350803d10613a84575b613a668183610c6c565b8101906137fb565b9b9a509850505050505050505091939038613a22565b503d613a5c565b613a039495509081613ab192903d10613ab9575b613aa98183610c6c565b8101906137c2565b9392386139d9565b503d613a9f565b6004919950613ae58691823d8411613aed575b613add8183610c6c565b8101906137b3565b9991506139b3565b503d613ad3565b613b0b8951613b06429189519061376d565b6137a6565b9661397e565b61399f97509081613b3692903d10613b3d575b613b2e8183610c6c565b810190613636565b9538613955565b503d613b24565b6139419550613b619060e03d60e011610a3757610a298183610c6c565b9461391a565b15613b6e57565b60405162461bcd60e51b815260206004820152602660248201527f4c6971756964697479426f6e64733a3a204e6f742061206d696e746572206f726044820152651037bbb732b960d11b6064820152608490fd5b15613bc957565b60405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606490fd5b15613c0857565b60405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606490fd5b15613c5457565b60405162461bcd60e51b815260206004820152602f60248201527f4c6971756964697479426f6e64733a3a20556e697377617020563320706f736960448201526e74696f6e204944206973207a65726f60881b6064820152608490fd5b15613cb857565b60405162461bcd60e51b815260206004820152602b60248201527f4c6971756964697479426f6e64733a3a20506f736974696f6e20697320616c7260448201526a1958591e481b1bd8dad95960aa1b6064820152608490fd5b600019811461374c5760010190565b60026040610c9a9380518455602081015160018501550151151591019060ff801983541691151516179055565b60405190613d5a82610c51565b600f82526e1155120b51d3524b5093d3910b530d608a1b6020830152565b601f8111613d84575050565b60009060656000527f8ff97419363ffd7000167f130ef7168fbea05faf9251824ca5043f113cc6a7c7906020601f850160051c83019410613de0575b601f0160051c01915b828110613dd557505050565b818155600101613dc9565b9092508290613dc0565b601f8111613df6575050565b60009060666000527f46501879b8ca8525e8c2fd519e2fbfcfa2ebea26501294aa02cbfcfb12e94354906020601f850160051c83019410613e52575b601f0160051c01915b828110613e4757505050565b818155600101613e3b565b9092508290613e32565b601f8111613e68575050565b60009061012d6000527f193a3ae4da5049eb74cee39e4cf5827f7ce7b1d1d1775ef1c6311eb60558e6d5906020601f850160051c83019410613ec5575b601f0160051c01915b828110613eba57505050565b818155600101613eae565b9092508290613ea5565b9081516001600160401b038111610c3157613ef481613eef6066546110b8565b613dea565b602080601f8311600114613f3757508190613f279394600092613f2c575b50508160011b916000199060031b1c19161790565b606655565b015190503880613f12565b90601f19831694613f6a60666000527f46501879b8ca8525e8c2fd519e2fbfcfa2ebea26501294aa02cbfcfb12e9435490565b926000905b878210613fa7575050836001959610613f8e575b505050811b01606655565b015160001960f88460031b161c19169055388080613f83565b80600185968294968601518155019501930190613f6f565b9081516001600160401b038111610c315761012d90613fe781613fe284546110b8565b613e5c565b602080601f831160011461401e5750819061401a939495600092613f2c5750508160011b916000199060031b1c19161790565b9055565b90601f1983169561405261012d6000527f193a3ae4da5049eb74cee39e4cf5827f7ce7b1d1d1775ef1c6311eb60558e6d590565b926000905b88821061408f57505083600195969710614076575b505050811b019055565b015160001960f88460031b161c1916905538808061406c565b80600185968294968601518155019501930190614057565b91906140b16132ca565b6140b9613d4d565b906140d460ff60005460081c166140cf81614b90565b614b90565b8051906001600160401b038211610c31576140f9826140f46065546110b8565b613d78565b602090816001601f8511146141bd5750936141476141a29461413f8561126a999661419d96610c9a9c9a600092613f2c5750508160011b916000199060031b1c19161790565b606555613ecf565b61414f614bf0565b614157614c0e565b61415f614c2f565b61013180546001600160a01b0319166001600160a01b03871617905561013280546001600160a01b0319166001600160a01b03909216919091179055565b613fbf565b6001600160a01b031660009081526101306020526040902090565b60656000529190601f1984167f8ff97419363ffd7000167f130ef7168fbea05faf9251824ca5043f113cc6a7c7936000905b8282106142405750509460018561419d95610c9a9b99956141479561126a9c996141a29b10614227575b505050811b01606555613ecf565b015160001960f88460031b161c19169055388080614219565b806001869782949787015181550196019401906141ef565b6000908152606760205260409020546001600160a01b031680156142795790565b60405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608490fd5b929190926142e161054c833361479d565b32331480156143ba575b6142f490614888565b833b158015614326575b93614321939291614311610c9a966148e4565b61431c8383836150bd565b615311565b614ce7565b50610132549092919061434390610599906001600160a01b031681565b604051633185c44d60e21b81523060048201526001600160a01b03861660248201529490602090869060449082905afa9384156106255761431161432195610c9a9760009161439b575b5092965050919293506142fe565b6143b4915060203d60201161061e576106108183610c6c565b3861438d565b50610132546143d390610599906001600160a01b031681565b604051633185c44d60e21b815230600482015233602482015290602090829060449082905afa8015610625576142f491600091614413575b5090506142eb565b61442c915060203d60201161061e576106108183610c6c565b3861440b565b90614445602092828151948592016102b1565b0190565b7f3c616e696d6174652061646469746976653d2273756d2220617474726962757481527f654e616d653d2273746172744f6666736574222066726f6d3d2230252220746f60208201527f3d22313030252220626567696e3d22307322206475723d22333073222072657060408201527f656174436f756e743d22696e646566696e69746522202f3e203c2f746578745060608201527f6174683e203c74657874506174682073746172744f66667365743d223025222060808201527f66696c6c3d2277686974652220666f6e742d66616d696c793d2256657264616e60a08201527f612220666f6e742d73697a653d22313070782220786c696e6b3a687265663d2260c08201526d11ba32bc3a16b830ba3416b0911f60911b60e082015260ee0190565b9081602091031261023e575161030a816112f8565b1561458957565b60405162461bcd60e51b815260206004820152602b60248201527f4c6971756964697479426f6e64733a204f70657261746f72206973206e6f742060448201526a1dda1a5d195b1a5cdd195960aa1b6064820152608490fd5b6000803b158015614649575b6145f790614582565b81815260696020526040812080546001600160a01b03191690556001600160a01b0361462283614258565b167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258280a4565b5061013254604051633185c44d60e21b81523060048201526024810183905290602090829060449082906001600160a01b03165afa8015610625576145f7918391614697575b5090506145ee565b6146b0915060203d60201161061e576106108183610c6c565b3861468f565b803b15801561472d575b6146c990614582565b600082815260696020526040902080546001600160a01b0319166001600160a01b0383161790556001600160a01b038061470284614258565b169116907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600080a4565b5061013254604051633185c44d60e21b81523060048201526001600160a01b038381166024830152909160209183916044918391165afa8015610625576146c99160009161477e575b5090506146c0565b614797915060203d60201161061e576106108183610c6c565b38614776565b6000828152606760205260409020546001600160a01b03161561482e576147c382614258565b6001600160a01b038281168282168114949091908515614816575b50505082156147ec57505090565b6001600160a01b03166000908152606a6020526040902060ff92506148119190610402565b541690565b61482391929395506132f8565b1614913880806147de565b60405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608490fd5b1561488f57565b60405162461bcd60e51b815260206004820152602760248201527f4c6971756964697479426f6e64733a2053656e646572206973206e6f742077686044820152661a5d195b1a5cdd60ca1b6064820152608490fd5b156148eb57565b60405162461bcd60e51b815260206004820152602660248201527f4c6971756964697479426f6e64733a205265636569766572206e6f74207768696044820152651d195b1a5cdd60d21b6064820152608490fd5b6001600160a01b038116908115614a35576000838152606760205260409020546001600160a01b03166149f0576001600160a01b03811660009081526068602052604090206149c89190614993815461373e565b90556149a9846000526067602052604060002090565b80546001600160a01b0319166001600160a01b03909216919091179055565b60007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a4565b60405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606490fd5b606460405162461bcd60e51b815260206004820152602060248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152fd5b614a8281614258565b60003b158015614b1c575b90614a99600092614582565b614aa283615038565b6001600160a01b0381166000908152606860205260409020614ac4815461377a565b9055614aed614add846000526067602052604060002090565b80546001600160a01b0319169055565b6001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8280a4565b5061013254604051633185c44d60e21b8152306004820152600060248201529190602090839060449082906001600160a01b03165afa91821561062557600092614a99918491614b71575b5091925050614a8d565b614b8a915060203d60201161061e576106108183610c6c565b38614b67565b15614b9757565b60405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608490fd5b614c0560ff60005460081c166140cf81614b90565b610c9a33614c4b565b614c2360ff60005460081c166140cf81614b90565b60ff1960c9541660c955565b614c4460ff60005460081c166140cf81614b90565b600160fb55565b609780546001600160a01b039283166001600160a01b0319821681179092559091167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b60809060208152603260208201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b60608201520190565b15614cee57565b60405162461bcd60e51b815280614d0760048201614c94565b0390fd5b90614d1582610cbc565b614d226040519182610c6c565b8281528092614d33601f1991610cbc565b0190602036910137565b806000917a184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000080821015614e73575b506d04ee2d6d415b85acef810000000080831015614e64575b50662386f26fc1000080831015614e55575b506305f5e10080831015614e46575b5061271080831015614e37575b506064821015614e27575b600a80921015614e1d575b600190816021614dd560018701614d0b565b95860101905b614de7575b5050505090565b600019019083906f181899199a1a9b1b9c1cb0b131b232b360811b8282061a835304918215614e1857919082614ddb565b614de0565b9160010191614dc3565b9190606460029104910191614db8565b60049193920491019138614dad565b60089193920491019138614da0565b60109193920491019138614d91565b60209193920491019138614d7f565b604093508104915038614d66565b60405190614e8e82610c51565b60068252650302e303030360d41b6020830152565b60405190614eb082610c51565b60018252600360fc1b6020830152565b8015614fd057614ecf90614d3d565b9081516012811115614f56575b614f259192614f38614f12614ef361030a94613797565b9283614f4657614f01614ea3565b935b614f0c81613751565b91615469565b614f326040519586946020860190614432565b601760f91b815260010190565b90614432565b03601f198101835282610c6c565b614f5084826153fc565b93614f03565b614f6290929192613789565b906060916000905b808210614fa0575050614f32614f94614f2593614f3861030a946040519485936020850190614432565b92915060129050614edc565b909392614f38614fc7600192604051928391614f3260208401600190600360fc1b81520190565b93940190614f6a565b5061030a614e81565b60405190614fe682610c36565b604082527f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f6040837f4142434445464748494a4b4c4d4e4f505152535455565758595a61626364656660208201520152565b600081815260696020526040812080546001600160a01b03191690556001600160a01b0361462283614258565b1561506c57565b60405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608490fd5b906150c783614258565b6001600160a01b0383811692909182168390036151815761511661515a928216946150f3861515615065565b6150fc876145e2565b6001600160a01b0316600090815260686020526040902090565b615120815461377a565b90556001600160a01b0381166000908152606860205260409020615144815461373e565b90556149a9856000526067602052604060002090565b7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600080a4565b60405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608490fd5b6001600160a01b0382811693911691828414615256578161524b7f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c319361523a60209487600052606a865260406000209060018060a01b0316600052602052604060002090565b9060ff801983541691151516179055565b6040519015158152a3565b60405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606490fd5b9081602091031261023e575161030a8161022c565b6001600160a01b03918216815291166020820152604081019190915260806060820181905261030a929101906102d4565b3d1561530c573d906152f282610cbc565b916153006040519384610c6c565b82523d6000602084013e565b606090565b92909190823b156153cc57615344926020926000604051809681958294630a85bd0160e11b9a8b855233600486016152b0565b03926001600160a01b03165af16000918161539b575b5061538d576153676152e1565b805190816153885760405162461bcd60e51b815280614d0760048201614c94565b602001fd5b6001600160e01b0319161490565b6153be91925060203d6020116153c5575b6153b68183610c6c565b81019061529b565b903861535a565b503d6153ac565b50505050600190565b9081518110156153e6570160200190565b634e487b7160e01b600052603260045260246000fd5b9061540681610cbc565b916154146040519384610c6c565b818352601f1961542383610cbc565b0136602085013760009060005b83811061543e575050505090565b6001906001600160f81b031961545482856153d5565b5116841a61546282886153d5565b5301615430565b918181039281841161374c5761547e84610cbc565b9361548c6040519586610c6c565b80855261549b601f1991610cbc565b01366020860137825b8281106154b2575050505090565b6001600160f81b03196154c582846153d5565b51169084810381811161374c576154e260019360001a91886153d5565b53016154a4565b600281901b91906001600160fe1b0381160361374c57565b908151156155d85761552d61552861552361551c855161375f565b6003900490565b6154e9565b614d0b565b91602083019181825183016020810191825193600084525b828210615586575050505251600390066001811461557357600214615568575090565b603d90600019015390565b50603d9081600019820153600119015390565b9091956004906003809401938451600190603f9082828260121c16880101518553828282600c1c16880101518386015382828260061c1688010151600286015316850101519082015301959190615545565b505061030a6132b756fea26469706673582212204872c4fbc879c7ff727a2339b4810cccef13dd093be157f490625d6387082e1f64736f6c63430008160033
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
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.