Source Code
Overview
HYPE Balance
HYPE Value
$0.00View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Cross-Chain Transactions
Loading...
Loading
This contract contains unverified libraries: RoleCheckerLib
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
HyperpiePair
Compiler Version
v0.8.21+commit.d9974bed
Optimization Enabled:
Yes with 10000 runs
Other Settings:
shanghai EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import { IHyperpieFactory } from "./interfaces/factories/IHyperpieFactory.sol";
import { IHyperpieConfig } from "../interfaces/IHyperpieConfig.sol";
import { PoolFees } from "../memedex/rewards/PoolFees.sol";
import { IHyperpiePair } from "./interfaces/IHyperpiePair.sol";
import { IPoolFees } from "./interfaces/IPoolFees.sol";
import { HyperpieConstants } from "../utils/HyperpieConstants.sol";
import { UtilLib } from "../utils/UtilLib.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { ERC20Permit } from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol";
import { Pausable } from "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/utils/Create2.sol";
import { BeaconProxy } from "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol";
import { RoleCheckerLib } from "../libraries/RoleCheckerLib.sol";
contract HyperpiePair is
IHyperpiePair,
ERC20Permit,
ReentrancyGuard
{
using SafeERC20 for IERC20;
/*//////////////////////////////////////////////////////////////
STATE VARIABLES
//////////////////////////////////////////////////////////////*/
uint256 internal constant MINIMUM_LIQUIDITY = 10 ** 3;
uint256 internal constant MINIMUM_K = 10 ** 10;
// LP token metadata
string private _name;
string private _symbol;
bool public stable;
// Token addresses for the pair (e.g., MEME and mHYPE)
address public token0;
address public token1;
address public factory;
address public poolFees;
uint256 internal decimals0;
uint256 internal decimals1;
// Reserves of each token
uint256 private reserve0;
uint256 private reserve1;
uint256 private blockTimestampLast;
uint public reserve0CumulativeLast;
uint public reserve1CumulativeLast;
uint256 public index0 = 0;
uint256 public index1 = 0;
mapping(address => uint256) public claimable0;
mapping(address => uint256) public claimable1;
mapping(address => uint256) public supplyIndex0;
mapping(address => uint256) public supplyIndex1;
IHyperpieConfig public hyperpieConfig;
/*//////////////////////////////////////////////////////////////
CONSTRUCTOR & INITIALIZER
//////////////////////////////////////////////////////////////*/
modifier whenNotPaused() {
if (hyperpieConfig.isDexV2Paused()) revert IHyperpieConfig.DexV2Locked();
_;
}
constructor(
) ERC20("", "") ERC20Permit("") {}
// Initialize the pair with token addresses (can only be done once)
function initialize(address _token0, address _token1, address _hyperpieConfig, bool _stable) external {
if (factory != address(0)) revert FactoryAlreadySet();
factory = msg.sender;
UtilLib.checkNonZeroAddress(_token0);
UtilLib.checkNonZeroAddress(_token1);
token0 = _token0;
token1 = _token1;
stable = _stable;
hyperpieConfig = IHyperpieConfig(_hyperpieConfig);
address _poolFeesBeacon = hyperpieConfig.getAddress(HyperpieConstants.POOL_FEES_BEACON);
PoolFees _poolFees = PoolFees(
Create2.deploy(
0,
bytes32(uint256(uint160(address(this)))),
// set the beacon address to the poolFeesBeacon and initialize it
abi.encodePacked(type(BeaconProxy).creationCode, abi.encode(_poolFeesBeacon, ""))
)
);
_poolFees.initialize(_token0, _token1, _hyperpieConfig);
poolFees = address(_poolFees);
decimals0 = 10 ** ERC20(_token0).decimals();
decimals1 = 10 ** ERC20(_token1).decimals();
string memory _tokenA = ERC20(_token0).symbol();
string memory _tokenB = ERC20(_token1).symbol();
if (stable) {
_name = string.concat(_tokenA, "/", _tokenB, " Stable LP");
_symbol = string.concat(HyperpieConstants.STABLE_PREFIX, _tokenA, "-", _tokenB, "-LP");
} else {
_name = string.concat(_tokenA, "/", _tokenB, " V2 LP");
_symbol = string.concat(HyperpieConstants.V2_PREFIX, _tokenA, "-", _tokenB, "-LP");
}
}
/*//////////////////////////////////////////////////////////////
VIEW FUNCTIONS
//////////////////////////////////////////////////////////////*/
// Return current reserves and last timestamp
function getReserves() public view returns (uint256, uint256, uint256) {
return (reserve0, reserve1, blockTimestampLast);
}
function name() public view override returns (string memory) {
return _name;
}
function symbol() public view override returns (string memory) {
return _symbol;
}
function getAmountOut(uint256 amountIn, address tokenIn) external view returns (uint256) {
(uint256 _reserve0, uint256 _reserve1, ) = getReserves();
amountIn -= (amountIn * IHyperpieFactory(factory).getFee(address(this), stable)) / HyperpieConstants.DENOMINATOR; // remove fee from amount received
return _getAmountOut(amountIn, tokenIn, _reserve0, _reserve1);
}
function tokens() external view returns (address, address) {
return (token0, token1);
}
function getK() external view returns (uint256) {
return _k(reserve0, reserve1);
}
function currentCumulativePrices() public view
returns (uint256 reserve0Cumulative, uint256 reserve1Cumulative, uint256 blockTimestamp)
{
blockTimestamp = block.timestamp;
reserve0Cumulative = reserve0CumulativeLast;
reserve1Cumulative = reserve1CumulativeLast;
// if time has elapsed since the last update on the pool, mock the accumulated price values
(uint256 _reserve0, uint256 _reserve1, uint256 _blockTimestampLast) = getReserves();
if (_blockTimestampLast != blockTimestamp) {
// subtraction overflow is desired
uint256 timeElapsed = blockTimestamp - _blockTimestampLast;
reserve0Cumulative += _reserve0 * timeElapsed;
reserve1Cumulative += _reserve1 * timeElapsed;
}
}
/*//////////////////////////////////////////////////////////////
EXTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/
// Mint LP tokens when liquidity is added
function mint(address to) external whenNotPaused nonReentrant returns (uint256 liquidity) {
(uint256 _reserve0, uint256 _reserve1, ) = getReserves();
uint256 balance0 = IERC20(token0).balanceOf(address(this));
uint256 balance1 = IERC20(token1).balanceOf(address(this));
uint256 amount0 = balance0 - _reserve0;
uint256 amount1 = balance1 - _reserve1;
uint256 _totalSupply = totalSupply();
if (_totalSupply == 0) {
liquidity = Math.sqrt(amount0 * amount1) - MINIMUM_LIQUIDITY;
_mint(address(1), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens
if (stable) {
if ((amount0 * 1e18) / decimals0 != (amount1 * 1e18) / decimals1) revert DepositsNotEqual();
if (_k(amount0, amount1) <= MINIMUM_K) revert BelowMinimumK();
}
} else {
liquidity = Math.min((amount0 * _totalSupply) / _reserve0, (amount1 * _totalSupply) / _reserve1);
}
if (liquidity == 0) revert InsufficientLiquidityMinted();
_mint(to, liquidity);
_update(balance0, balance1, _reserve0, _reserve1);
emit Mint(msg.sender, amount0, amount1);
}
// Burn LP tokens to remove liquidity and return underlying tokens
function burn(address to) external whenNotPaused nonReentrant returns (uint256 amount0, uint256 amount1) {
UtilLib.checkNonZeroAddress(to);
(uint256 _reserve0, uint256 _reserve1, ) = getReserves();
uint256 balance0 = IERC20(token0).balanceOf(address(this));
uint256 balance1 = IERC20(token1).balanceOf(address(this));
uint256 liquidity = balanceOf(address(this));
uint256 _totalSupply = totalSupply();
amount0 = (liquidity * balance0) / _totalSupply;
amount1 = (liquidity * balance1) / _totalSupply;
if (amount0 == 0 || amount1 == 0) revert InsufficientLiquidityBurned();
_burn(address(this), liquidity);
IERC20(token0).safeTransfer(to, amount0);
IERC20(token1).safeTransfer(to, amount1);
_update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), _reserve0, _reserve1);
emit Burn(msg.sender, amount0, amount1, to);
}
// Swap tokens, applying fee and transferring fees to the PoolFees contract
function swap(uint256 amount0Out, uint256 amount1Out, address to) external whenNotPaused nonReentrant {
UtilLib.checkNonZeroAddress(to);
if (amount0Out == 0 && amount1Out == 0) revert InsufficientOutputAmount();
(uint256 _reserve0, uint256 _reserve1, ) = getReserves();
if (amount0Out >= _reserve0 || amount1Out >= _reserve1) revert InsufficientLiquidity();
uint256 _balance0;
uint256 _balance1;
{
(address _token0, address _token1) = (token0, token1);
if (to == _token0 || to == _token1) revert InvalidTo();
if (amount0Out > 0) IERC20(_token0).safeTransfer(to, amount0Out);
if (amount1Out > 0) IERC20(_token1).safeTransfer(to, amount1Out);
_balance0 = IERC20(_token0).balanceOf(address(this));
_balance1 = IERC20(_token1).balanceOf(address(this));
}
uint256 amount0In = _balance0 > _reserve0 - amount0Out ? _balance0 - (_reserve0 - amount0Out) : 0;
uint256 amount1In = _balance1 > _reserve1 - amount1Out ? _balance1 - (_reserve1 - amount1Out) : 0;
if (amount0In == 0 && amount1In == 0) revert InsufficientInputAmount();
{
(address _token0, address _token1) = (token0, token1);
uint256 fees = IHyperpieFactory(factory).getFee(address(this), stable);
if (amount0In > 0) _update0((amount0In * fees) / HyperpieConstants.DENOMINATOR); // accrue fees for token0 and move them out of pool
if (amount1In > 0) _update1((amount1In * fees) / HyperpieConstants.DENOMINATOR); // accrue fees for token1 and move them out of pool
_balance0 = IERC20(_token0).balanceOf(address(this)); // since we removed tokens, we need to reconfirm balances, can also simply use previous balance - amountIn/ 10000, but doing balanceOf again as safety check
_balance1 = IERC20(_token1).balanceOf(address(this));
if (_k(_balance0, _balance1) < _k(_reserve0, _reserve1)) revert K();
}
// Update reserves based on new balances after fee transfers
_update(_balance0, _balance1, _reserve0, _reserve1);
emit Swap(to, amount0In, amount1In, amount0Out, amount1Out);
}
function sync() external nonReentrant {
if (totalSupply() == 0) revert InsufficientLiquidity();
_update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1);
}
function claimFees() external nonReentrant whenNotPaused returns (uint256 claimed0, uint256 claimed1) {
address sender = _msgSender();
_updateFor(sender);
claimed0 = claimable0[sender];
claimed1 = claimable1[sender];
if (claimed0 > 0 || claimed1 > 0) {
claimable0[sender] = 0;
claimable1[sender] = 0;
PoolFees(poolFees).claimFeesFor(sender, claimed0, claimed1);
emit Claim(sender, sender, claimed0, claimed1);
}
}
function lpRevShareBPS() external view returns (uint256 lpRevBps) {
lpRevBps = PoolFees(poolFees).lpRevShareBPS();
}
/*//////////////////////////////////////////////////////////////
ADMIN AND BOT FUNCTIONS
//////////////////////////////////////////////////////////////*/
function setName(string calldata __name) external {
RoleCheckerLib.onlyMetaConfigRole(address(hyperpieConfig));
_name = __name;
emit SetName(__name);
}
function setSymbol(string calldata __symbol) external {
RoleCheckerLib.onlyMetaConfigRole(address(hyperpieConfig));
_symbol = __symbol;
emit SetSymbol(__symbol);
}
function updateConfig(address _hyperpieConfig) external {
UtilLib.checkNonZeroAddress(_hyperpieConfig);
RoleCheckerLib.onlyDefaultAdmin(address(hyperpieConfig));
hyperpieConfig = IHyperpieConfig(_hyperpieConfig);
emit UpdatedHyperpieConfig(_hyperpieConfig);
}
/*//////////////////////////////////////////////////////////////
INTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/
function _getAmountOut(
uint256 amountIn,
address tokenIn,
uint256 _reserve0,
uint256 _reserve1
) internal view returns (uint256) {
if (stable) {
uint256 xy = _k(_reserve0, _reserve1);
_reserve0 = (_reserve0 * 1e18) / decimals0;
_reserve1 = (_reserve1 * 1e18) / decimals1;
(uint256 reserveA, uint256 reserveB) = tokenIn == token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0);
amountIn = tokenIn == token0 ? (amountIn * 1e18) / decimals0 : (amountIn * 1e18) / decimals1;
uint256 y = reserveB - _get_y(amountIn + reserveA, xy, reserveB);
return (y * (tokenIn == token0 ? decimals1 : decimals0)) / 1e18;
} else {
(uint256 reserveA, uint256 reserveB) = tokenIn == token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0);
return (amountIn * reserveB) / (reserveA + amountIn);
}
}
function _get_y(uint256 x0, uint256 xy, uint256 y) internal view returns (uint256) {
for (uint256 i = 0; i < 255; i++) {
uint256 k = _f(x0, y);
if (k < xy) {
// there are two cases where dy == 0
// case 1: The y is converged and we find the correct answer
// case 2: _d(x0, y) is too large compare to (xy - k) and the rounding error
// screwed us.
// In this case, we need to increase y by 1
uint256 dy = ((xy - k) * 1e18) / _d(x0, y);
if (dy == 0) {
if (k == xy) {
// We found the correct answer. Return y
return y;
}
if (_k(x0, y + 1) > xy) {
// If _k(x0, y + 1) > xy, then we are close to the correct answer.
// There's no closer answer than y + 1
return y + 1;
}
dy = 1;
}
y = y + dy;
} else {
uint256 dy = ((k - xy) * 1e18) / _d(x0, y);
if (dy == 0) {
if (k == xy || _f(x0, y - 1) < xy) {
// Likewise, if k == xy, we found the correct answer.
// If _f(x0, y - 1) < xy, then we are close to the correct answer.
// There's no closer answer than "y"
// It's worth mentioning that we need to find y where f(x0, y) >= xy
// As a result, we can't return y - 1 even it's closer to the correct answer
return y;
}
dy = 1;
}
y = y - dy;
}
}
revert Y();
}
function _f(uint256 x0, uint256 y) internal pure returns (uint256) {
uint256 _a = (x0 * y) / 1e18;
uint256 _b = ((x0 * x0) / 1e18 + (y * y) / 1e18);
return (_a * _b) / 1e18;
}
function _d(uint256 x0, uint256 y) internal pure returns (uint256) {
return (3 * x0 * ((y * y) / 1e18)) / 1e18 + ((((x0 * x0) / 1e18) * x0) / 1e18);
}
// Internal function to update reserves
// update reserves and, on the first call per block, price accumulators
function _update(uint256 balance0, uint256 balance1, uint256 _reserve0, uint256 _reserve1) private {
uint256 blockTimestamp = block.timestamp;
uint256 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {
// * never overflows, and + overflow is desired
reserve0CumulativeLast += _reserve0 * timeElapsed;
reserve1CumulativeLast += _reserve1 * timeElapsed;
}
reserve0 = uint256(balance0);
reserve1 = uint256(balance1);
blockTimestampLast = blockTimestamp;
emit Sync(reserve0, reserve1);
}
function _k(uint256 x, uint256 y) internal view returns (uint256) {
if (stable) {
uint256 _x = (x * 1e18) / decimals0;
uint256 _y = (y * 1e18) / decimals1;
uint256 _a = (_x * _y) / 1e18;
uint256 _b = ((_x * _x) / 1e18 + (_y * _y) / 1e18);
return (_a * _b) / 1e18; // x3y+y3x >= k
} else {
return x * y; // xy >= k
}
}
/// @dev Accrue fees on token0
function _update0(uint256 amount) internal {
// Only update on this pool if there is a fee
if (amount == 0) return;
_distributeFees(token0, amount);
uint256 _ratio = (amount * 1e18) / totalSupply(); // 1e18 adjustment is removed during claim
if (_ratio > 0) {
index0 += _ratio;
}
emit Fees(_msgSender(), amount, 0);
}
/// @dev Accrue fees on token1
function _update1(uint256 amount) internal {
// Only update on this pool if there is a fee
if (amount == 0) return;
_distributeFees(token1, amount);
uint256 _ratio = (amount * 1e18) / totalSupply();
if (_ratio > 0) {
index1 += _ratio;
}
emit Fees(_msgSender(), 0, amount);
}
function _distributeFees(address _token, uint256 _amount) internal {
IERC20(_token).safeApprove(address(poolFees), _amount);
IPoolFees(poolFees).collectFee(_token, _amount);
}
function _updateFor(address recipient) internal {
uint256 _supplied = balanceOf(recipient); // get LP balance of `recipient`
if (_supplied > 0) {
uint256 _supplyIndex0 = supplyIndex0[recipient]; // get last adjusted index0 for recipient
uint256 _supplyIndex1 = supplyIndex1[recipient];
uint256 _index0 = index0; // get global index0 for accumulated fees
uint256 _index1 = index1;
supplyIndex0[recipient] = _index0; // update user current position to global position
supplyIndex1[recipient] = _index1;
uint256 _delta0 = _index0 - _supplyIndex0; // see if there is any difference that need to be accrued
uint256 _delta1 = _index1 - _supplyIndex1;
if (_delta0 > 0) {
uint256 _share = (_supplied * _delta0) / 1e18; // add accrued difference for each supplied token
claimable0[recipient] += _share * PoolFees(poolFees).lpRevShareBPS() / HyperpieConstants.DENOMINATOR;
}
if (_delta1 > 0) {
uint256 _share = (_supplied * _delta1) / 1e18;
claimable1[recipient] += _share * PoolFees(poolFees).lpRevShareBPS() / HyperpieConstants.DENOMINATOR;
}
} else {
supplyIndex0[recipient] = index0; // new users are set to the default global state
supplyIndex1[recipient] = index1;
}
}
function _beforeTokenTransfer(address from, address to, uint256) internal override {
_updateFor(from);
_updateFor(to);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
* - the caller must have allowance for ``from``'s tokens of at least
* `amount`.
*/
function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(address from, address to, uint256 amount) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
// decrementing then incrementing.
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
// Overflow not possible: amount <= accountBalance <= totalSupply.
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens 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 amount) 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, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been 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 _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1, "Math: mulDiv overflow");
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (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() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IHyperpieFactory {
error IdenticalTokenAddresses();
error PairAlreadyExists();
error NotAuthorized();
error FeeTooHigh();
error ZeroFee();
error InvalidPair();
error FeeInvalid();
event PairCreated(address indexed token0, address indexed token1, bool stable, address pair, uint256 index);
event SetCustomFee(address indexed pair, uint256 fee);
event SetFee(bool stable, uint256 fee);
event SetHyperpiePairImp(address indexed hyperpiePairImp);
event UpdatedHyperpieConfig(address indexed hyperpieConfig);
function getPair(address tokenA, address tokenB, bool stable) external view returns (address);
function createPair(address tokenA, address tokenB, bool stable) external returns (address pair);
function setFee(bool stable, uint256 fee) external;
function setCustomFee(address pair, uint256 fee) external;
function getFee(address pair, bool stable) external view returns (uint256);
function isPair(address pair) external view returns (bool);
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.21;
interface IHyperpieConfig {
/*//////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/
error CallerNotHyperpieConfigAllowedRole(string role);
error CallerNotHyperpieConfigPriceProvider();
error CallerNotHyperpieConfigOracleAdmin();
error CallerNotHyperpieConfigOracle();
error CallerNotHyperpiePauser();
error CallerNotHyperpieConfigAllowedBot();
error CallerNotHyperpieConfigAdmin();
error CallerNotHyperpieConfigManager();
error CallerNotHyperpieConfigMinter();
error CallerNotHyperpieConfigBurner();
error CallerNotHyperpieFactory();
error CallerNotHyperpieConfigFeeManager();
error CallerNotHyperpieConfigMetaConfig();
error EmergencyPaused();
error InvalidFeeValue();
error DexV2Locked();
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event SetAddress(bytes32 key, address indexed addr);
event MHypeFeeValueUpdated(uint256 mHypeFeeValue);
event SetUintValue(bytes32 key, uint256 value);
event SetWhitelistedFactory(address indexed factory, bool isApproved);
event DexV2Paused(address account);
event DexV2Unpaused(address account);
/*//////////////////////////////////////////////////////////////
VIEW FUNCTIONS
//////////////////////////////////////////////////////////////*/
function getAddress(bytes32 addressId) external view returns (address);
function getMHypeFeeValue() external view returns (uint256);
function setAddress(bytes32 key, address addr) external;
function getUint256Value(bytes32 valueId) external view returns (uint256);
function whitelistedFactories(address factory) external view returns (bool);
function isDexV2Paused() external view returns (bool);
}
interface IPausable {
function paused() external view returns (bool);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { IHyperpieConfig } from "../../interfaces/IHyperpieConfig.sol";
import { IPoolFees } from "../interfaces/IPoolFees.sol";
import { HyperpieConstants } from "../../utils/HyperpieConstants.sol";
import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import { RoleCheckerLib } from "../../libraries/RoleCheckerLib.sol";
import { UtilLib } from "../../utils/UtilLib.sol";
/// @title PoolFees
/// @notice Contract used as 1:1 pool relationship to split out fees.
/// @notice Ensures curve does not need to be modified for LP shares.
contract PoolFees is IPoolFees, ReentrancyGuardUpgradeable {
using SafeERC20 for IERC20;
address internal pool; // The pool it is bonded to
address internal token0; // token0 of pool, saved localy and statically for gas optimization
address internal token1; // Token1 of pool, saved localy and statically for gas optimization
address public poolCreator;
bool public meme; // if not core, then it's a meme pool, which creator can earn fees, only pair created by launchpad can be meme pool
IHyperpieConfig public hyperpieConfig;
constructor() {
_disableInitializers();
}
function initialize(
address _token0,
address _token1,
address _hyperpieConfig
)
external
initializer
{
__ReentrancyGuard_init();
pool = msg.sender;
token0 = _token0;
token1 = _token1;
hyperpieConfig = IHyperpieConfig(_hyperpieConfig);
}
modifier onlyPool() {
if (msg.sender != pool) revert NotPool();
_;
}
modifier onlyLaunchpad() {
address launchpad = hyperpieConfig.getAddress(HyperpieConstants.MEME_LAUNCHPAD);
if (msg.sender != launchpad ) revert NotLaunchpad();
_;
}
function collectFee(address _token, uint256 _amount) onlyPool nonReentrant override external {
if (_amount > 0) {
IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);
uint256 teamAmount = _amount * hyperpieConfig.getUint256Value(HyperpieConstants.FEE_TEAM_COLLECTOR) / HyperpieConstants.DENOMINATOR;
uint256 veHPPAmount = _amount * hyperpieConfig.getUint256Value(HyperpieConstants.FEE_VEHPP_COLLECTOR) / HyperpieConstants.DENOMINATOR; // veHPP fee only charged for core pools
uint256 lpAmount = _amount * lpRevShareBPS() / HyperpieConstants.DENOMINATOR;
uint256 creatorAmount = 0;
// If (non-meme) pool,creator fee is added to the LP amount, If meme pool, the creator fee goes to the creator.
if (meme) {
creatorAmount = _amount * hyperpieConfig.getUint256Value(HyperpieConstants.FEE_POOL_CREATOR) / HyperpieConstants.DENOMINATOR;
}
if ((teamAmount + creatorAmount + lpAmount + veHPPAmount) > _amount)
revert InvalidFees();
if (teamAmount > 0) {
IERC20(_token).safeTransfer(hyperpieConfig.getAddress(HyperpieConstants.FEE_TEAM_COLLECTOR), teamAmount);
}
if (creatorAmount > 0) {
IERC20(_token).safeTransfer(poolCreator, creatorAmount);
}
if (veHPPAmount > 0) {
IERC20(_token).safeTransfer(hyperpieConfig.getAddress(HyperpieConstants.FEE_VEHPP_COLLECTOR), veHPPAmount);
}
// lp amount will be left to be claimed by lp holders
}
}
/// @notice Allow the pool to transfer fees to users, mainly called by lp holders
function claimFeesFor(address _recipient, uint256 _amount0, uint256 _amount1) onlyPool nonReentrant override external {
if (_amount0 > 0) IERC20(token0).safeTransfer(_recipient, _amount0);
if (_amount1 > 0) IERC20(token1).safeTransfer(_recipient, _amount1);
}
function setCreatorAndMeme(bool _meme, address _creator) onlyLaunchpad nonReentrant override external {
meme = _meme;
poolCreator = _creator;
}
function updateConfig(address _hyperpieConfig) external {
UtilLib.checkNonZeroAddress(_hyperpieConfig);
RoleCheckerLib.onlyDefaultAdmin(address(hyperpieConfig));
hyperpieConfig = IHyperpieConfig(_hyperpieConfig);
emit UpdatedHyperpieConfig(_hyperpieConfig);
}
function lpRevShareBPS() public view returns (uint256 lpRevBps) {
if (!meme) {
lpRevBps = hyperpieConfig.getUint256Value(HyperpieConstants.FEE_V2_STABLE_LP);
lpRevBps += hyperpieConfig.getUint256Value(HyperpieConstants.FEE_POOL_CREATOR);
} else {
lpRevBps = hyperpieConfig.getUint256Value(HyperpieConstants.FEE_V2_STABLE_LP);
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IHyperpiePair {
/*//////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/
error InsufficientLiquidityMinted();
error InsufficientLiquidityBurned();
error InsufficientLiquidity();
error InvalidTo();
error Overflow();
error InvariantKViolated();
error InsufficientInputAmount();
error InsufficientOutputAmount();
error FactoryAlreadySet();
error IsNotFactory();
error DepositsNotEqual();
error BelowMinimumK();
error K();
error Y();
event Mint(address indexed sender, uint256 amount0, uint256 amount1);
event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to);
event Swap(
address indexed swappedFor,
uint256 amount0In,
uint256 amount1In,
uint256 amount0Out,
uint256 amount1Out
);
event Sync(uint256 reserve0, uint256 reserve1);
event Claim(address indexed sender, address indexed recipient, uint256 amount0, uint256 amount1);
event Fees(address indexed sender, uint256 amount0, uint256 amount1);
event SetName(string name);
event SetSymbol(string symbol);
event UpdatedHyperpieConfig(address indexed hyperpieConfig);
// Struct to capture time period obervations every 30 minutes, used for local oracles
struct Observation {
uint256 timestamp;
uint256 reserve0Cumulative;
uint256 reserve1Cumulative;
}
function getAmountOut(uint256 amountIn, address tokenIn) external view returns (uint256);
function getReserves() external view returns (uint256 reserve0, uint256 reserve1, uint256 blockTimestampLast);
function mint(address to) external returns (uint256 liquidity);
function burn(address to) external returns (uint256 amount0, uint256 amount1);
function swap(uint256 amount0Out, uint256 amount1Out, address to) external;
function token0() external view returns (address);
function token1() external view returns (address);
function initialize(address _token0, address _token1, address _hyperpieConfig, bool _stable) external;
function claimFees() external returns (uint256, uint256);
function tokens() external view returns (address, address);
function poolFees() external view returns (address);
function lpRevShareBPS() external view returns (uint256);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IPoolFees {
event UpdatedHyperpieConfig(address indexed hyperpieConfig);
error NotPool();
error InvalidFees();
error NotLaunchpad();
error TransferFailed();
error InvalidToken();
function collectFee(address _token, uint256 _amount) external;
/// @notice Address of Minter.sol
function claimFeesFor(address _recipient, uint256 _amount0, uint256 _amount1) external;
function lpRevShareBPS() external view returns (uint256 lpRevBps);
function setCreatorAndMeme(bool _meme, address _creator) external;
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.21;
library HyperpieConstants {
//contracts
bytes32 public constant HYPERPIE_STAKING = keccak256("HYPERPIE_STAKING");
bytes32 public constant PRICE_PROVIDER = keccak256("PRICE_PROVIDER");
bytes32 public constant HYPERPIE_WITHDRAW_MANAGER = keccak256("HYPERPIE_WITHDRAW_MANAGER");
bytes32 public constant MHYPE_TOKEN = keccak256("MHYPE_TOKEN");
bytes32 public constant FACTORY = keccak256("FACTORY");
bytes32 public constant MEME_LAUNCHPAD = keccak256("MEME_LAUNCHPAD");
bytes32 public constant HYPERPIE_ROUTER = keccak256("HYPERPIE_ROUTER");
//Roles
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
bytes32 public constant MANAGER = keccak256("MANAGER");
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE");
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
bytes32 public constant ORACLE_ROLE = keccak256("ORACLE_ROLE");
bytes32 public constant ORACLE_ADMIN_ROLE = keccak256("ORACLE_ADMIN_ROLE");
bytes32 public constant PRICE_PROVIDER_ROLE = keccak256("PRICE_PROVIDER_ROLE");
bytes32 public constant ALLOWED_BOT_ROLE = keccak256("ALLOWED_BOT_ROLE");
bytes32 public constant FEE_MANAGER_ROLE = keccak256("FEE_MANAGER_ROLE");
bytes32 public constant HYPERPIE_V2_META_CONFIG_ROLE = keccak256("HYPERPIE_V2_META_CONFIG_ROLE");
address public constant PLATFORM_TOKEN_ADDRESS = 0x0000000000000000000000000000000000000000; // HYPERPIE Token
address public constant WHYPE = 0x5555555555555555555555555555555555555555; // Wrapped HYPE
bytes32 public constant HYPE_STAKE_DESTINTATION = keccak256("HYPE_STAKE_DESTINTATION");
bytes32 public constant HYPERPIE_DELEGATOR = keccak256("HYPERPIE_DELEGATOR");
bytes32 public constant HYPERPIE_FEE_DESTINATION = keccak256("HYPERPIE_FEE_DESTINATION");
// HyperEVM L1 Read Precompile Addresses
address public constant SPOT_BALANCE_PRECOMPILE = 0x0000000000000000000000000000000000000801;
address public constant DELEGATOR_SUMMARY_PRECOMPILE = 0x0000000000000000000000000000000000000805;
// HYPE Token ID on Hyperliquid
uint64 public constant HYPE_TOKEN_ID = 150;
bytes32 public constant LAUNCHPAD_FEE_DESTINATION = keccak256("MEME_LAUNCHPAD_FEE_DESTINATION");
// For Native Restaking
uint256 constant GWEI_TO_WEI = 1e9;
uint256 public constant DENOMINATOR = 10_000;
uint256 public constant MHYPE_FEE_DENOMINATOR = 1_000_000;
uint256 public constant MHYPE_FEE_MAX_VALUE = 5_000; // Maximum ~0.5% inflation to prevent extreme inflation
uint256 public constant ONE_WEEK = 7 days;
uint256 public constant DECAY_RATE = 9900;
// For DEX
string public constant STABLE_PREFIX = "STABLE-";
string public constant V2_PREFIX = "V2-";
// FOR V2, SS FEE structure
bytes32 public constant FEE_V2_STABLE_LP = keccak256("FEE_V2_STABLE_LP");
bytes32 public constant FEE_TEAM_COLLECTOR = keccak256("FEE_TEAM_COLLECTOR");
bytes32 public constant FEE_VEHPP_COLLECTOR = keccak256("FEE_VEHPP_COLLECTOR");
bytes32 public constant FEE_POOL_CREATOR = keccak256("FEE_POOL_CREATOR");
bytes32 public constant POOL_FEES_BEACON = keccak256("POOL_FEES_BEACON");
uint256 public constant MEME_TOKEN_DECIMAL = 18;
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.21;
import { HyperpieConstants } from "./HyperpieConstants.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
/// @title UtilLib - Utility library
/// @notice Utility functions for Hyperpie protocol
library UtilLib {
/*//////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/
error ZeroAddressNotAllowed();
error TransferHYPEFailed();
/*//////////////////////////////////////////////////////////////
UTILITY FUNCTIONS
//////////////////////////////////////////////////////////////*/
/// @dev zero address check modifier
/// @param address_ address to check
function checkNonZeroAddress(address address_) internal pure {
if (address_ == address(0)) revert ZeroAddressNotAllowed();
}
/// @dev Safe transfer of HYPE (native token)
/// @param to recipient address
/// @param value amount to transfer
function safeTransferHYPE(address to, uint256 value) internal {
UtilLib.checkNonZeroAddress(to);
(bool success,) = address(to).call{ value: value }("");
if (!success) revert TransferHYPEFailed();
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return
success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/ERC20Permit.sol)
pragma solidity ^0.8.0;
import "./IERC20Permit.sol";
import "../ERC20.sol";
import "../../../utils/cryptography/ECDSA.sol";
import "../../../utils/cryptography/EIP712.sol";
import "../../../utils/Counters.sol";
/**
* @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* _Available since v3.4._
*/
abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {
using Counters for Counters.Counter;
mapping(address => Counters.Counter) private _nonces;
// solhint-disable-next-line var-name-mixedcase
bytes32 private constant _PERMIT_TYPEHASH =
keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
/**
* @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.
* However, to ensure consistency with the upgradeable transpiler, we will continue
* to reserve a slot.
* @custom:oz-renamed-from _PERMIT_TYPEHASH
*/
// solhint-disable-next-line var-name-mixedcase
bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;
/**
* @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`.
*
* It's a good idea to use the same `name` that is defined as the ERC20 token name.
*/
constructor(string memory name) EIP712(name, "1") {}
/**
* @dev See {IERC20Permit-permit}.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) public virtual override {
require(block.timestamp <= deadline, "ERC20Permit: expired deadline");
bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));
bytes32 hash = _hashTypedDataV4(structHash);
address signer = ECDSA.recover(hash, v, r, s);
require(signer == owner, "ERC20Permit: invalid signature");
_approve(owner, spender, value);
}
/**
* @dev See {IERC20Permit-nonces}.
*/
function nonces(address owner) public view virtual override returns (uint256) {
return _nonces[owner].current();
}
/**
* @dev See {IERC20Permit-DOMAIN_SEPARATOR}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view override returns (bytes32) {
return _domainSeparatorV4();
}
/**
* @dev "Consume a nonce": return the current value and increment.
*
* _Available since v4.1._
*/
function _useNonce(address owner) internal virtual returns (uint256 current) {
Counters.Counter storage nonce = _nonces[owner];
current = nonce.current();
nonce.increment();
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.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 Pausable is Context {
/**
* @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.
*/
constructor() {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Create2.sol)
pragma solidity ^0.8.0;
/**
* @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.
* `CREATE2` can be used to compute in advance the address where a smart
* contract will be deployed, which allows for interesting new mechanisms known
* as 'counterfactual interactions'.
*
* See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more
* information.
*/
library Create2 {
/**
* @dev Deploys a contract using `CREATE2`. The address where the contract
* will be deployed can be known in advance via {computeAddress}.
*
* The bytecode for a contract can be obtained from Solidity with
* `type(contractName).creationCode`.
*
* Requirements:
*
* - `bytecode` must not be empty.
* - `salt` must have not been used for `bytecode` already.
* - the factory must have a balance of at least `amount`.
* - if `amount` is non-zero, `bytecode` must have a `payable` constructor.
*/
function deploy(uint256 amount, bytes32 salt, bytes memory bytecode) internal returns (address addr) {
require(address(this).balance >= amount, "Create2: insufficient balance");
require(bytecode.length != 0, "Create2: bytecode length is zero");
/// @solidity memory-safe-assembly
assembly {
addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)
}
require(addr != address(0), "Create2: Failed on deploy");
}
/**
* @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the
* `bytecodeHash` or `salt` will result in a new destination address.
*/
function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {
return computeAddress(salt, bytecodeHash, address(this));
}
/**
* @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at
* `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.
*/
function computeAddress(bytes32 salt, bytes32 bytecodeHash, address deployer) internal pure returns (address addr) {
/// @solidity memory-safe-assembly
assembly {
let ptr := mload(0x40) // Get free memory pointer
// | | ↓ ptr ... ↓ ptr + 0x0B (start) ... ↓ ptr + 0x20 ... ↓ ptr + 0x40 ... |
// |-------------------|---------------------------------------------------------------------------|
// | bytecodeHash | CCCCCCCCCCCCC...CC |
// | salt | BBBBBBBBBBBBB...BB |
// | deployer | 000000...0000AAAAAAAAAAAAAAAAAAA...AA |
// | 0xFF | FF |
// |-------------------|---------------------------------------------------------------------------|
// | memory | 000000...00FFAAAAAAAAAAAAAAAAAAA...AABBBBBBBBBBBBB...BBCCCCCCCCCCCCC...CC |
// | keccak(start, 85) | ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ |
mstore(add(ptr, 0x40), bytecodeHash)
mstore(add(ptr, 0x20), salt)
mstore(ptr, deployer) // Right-aligned with 12 preceding garbage bytes
let start := add(ptr, 0x0b) // The hashed data starts at the final garbage byte which we will set to 0xff
mstore8(start, 0xff)
addr := keccak256(start, 85)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/beacon/BeaconProxy.sol)
pragma solidity ^0.8.0;
import "./IBeacon.sol";
import "../Proxy.sol";
import "../ERC1967/ERC1967Upgrade.sol";
/**
* @dev This contract implements a proxy that gets the implementation address for each call from an {UpgradeableBeacon}.
*
* The beacon address is stored in storage slot `uint256(keccak256('eip1967.proxy.beacon')) - 1`, so that it doesn't
* conflict with the storage layout of the implementation behind the proxy.
*
* _Available since v3.4._
*/
contract BeaconProxy is Proxy, ERC1967Upgrade {
/**
* @dev Initializes the proxy with `beacon`.
*
* If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This
* will typically be an encoded function call, and allows initializing the storage of the proxy like a Solidity
* constructor.
*
* Requirements:
*
* - `beacon` must be a contract with the interface {IBeacon}.
*/
constructor(address beacon, bytes memory data) payable {
_upgradeBeaconToAndCall(beacon, data, false);
}
/**
* @dev Returns the current beacon address.
*/
function _beacon() internal view virtual returns (address) {
return _getBeacon();
}
/**
* @dev Returns the current implementation address of the associated beacon.
*/
function _implementation() internal view virtual override returns (address) {
return IBeacon(_getBeacon()).implementation();
}
/**
* @dev Changes the proxy to use a new beacon. Deprecated: see {_upgradeBeaconToAndCall}.
*
* If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon.
*
* Requirements:
*
* - `beacon` must be a contract.
* - The implementation returned by `beacon` must be a contract.
*/
function _setBeacon(address beacon, bytes memory data) internal virtual {
_upgradeBeaconToAndCall(beacon, data, false);
}
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.21;
import { IHyperpieConfig } from "../utils/HyperpieConfigRoleChecker.sol";
import { HyperpieConstants } from "../utils/HyperpieConstants.sol";
import { IAccessControl } from "@openzeppelin/contracts/access/IAccessControl.sol";
library RoleCheckerLib {
/*//////////////////////////////////////////////////////////////
MODIFIERS
//////////////////////////////////////////////////////////////*/
function onlyRole(bytes32 role, address hyperpieConfig) external view {
if (!IAccessControl(hyperpieConfig).hasRole(role, msg.sender)) {
string memory roleStr = string(abi.encodePacked(role));
revert IHyperpieConfig.CallerNotHyperpieConfigAllowedRole(roleStr);
}
}
function onlyPriceProvider(address hyperpieConfig) external view {
if (!IAccessControl(hyperpieConfig).hasRole(HyperpieConstants.PRICE_PROVIDER_ROLE, msg.sender)) {
revert IHyperpieConfig.CallerNotHyperpieConfigPriceProvider();
}
}
function onlyHyperpieManager(address hyperpieConfig) external view {
if (!IAccessControl(hyperpieConfig).hasRole(HyperpieConstants.MANAGER, msg.sender)) {
revert IHyperpieConfig.CallerNotHyperpieConfigManager();
}
}
function onlyDefaultAdmin(address hyperpieConfig) external view {
if (!IAccessControl(hyperpieConfig).hasRole(HyperpieConstants.DEFAULT_ADMIN_ROLE, msg.sender)) {
revert IHyperpieConfig.CallerNotHyperpieConfigAdmin();
}
}
function onlyMinter(address hyperpieConfig) external view {
if (!IAccessControl(hyperpieConfig).hasRole(HyperpieConstants.MINTER_ROLE, msg.sender)) {
revert IHyperpieConfig.CallerNotHyperpieConfigMinter();
}
}
function onlyBurner(address hyperpieConfig) external view {
if (!IAccessControl(hyperpieConfig).hasRole(HyperpieConstants.BURNER_ROLE, msg.sender)) {
revert IHyperpieConfig.CallerNotHyperpieConfigBurner();
}
}
function onlyOracleAdmin(address hyperpieConfig) external view {
if (!IAccessControl(hyperpieConfig).hasRole(HyperpieConstants.ORACLE_ADMIN_ROLE, msg.sender)) {
revert IHyperpieConfig.CallerNotHyperpieConfigOracleAdmin();
}
}
function onlyOracle(address hyperpieConfig) external view {
if (!IAccessControl(hyperpieConfig).hasRole(HyperpieConstants.ORACLE_ROLE, msg.sender)) {
revert IHyperpieConfig.CallerNotHyperpieConfigOracle();
}
}
function onlyPauser(address hyperpieConfig) external view {
if (!IAccessControl(hyperpieConfig).hasRole(HyperpieConstants.PAUSER_ROLE, msg.sender)) {
revert IHyperpieConfig.CallerNotHyperpiePauser();
}
}
function onlyAllowedBot(address hyperpieConfig) external view {
if (!IAccessControl(hyperpieConfig).hasRole(HyperpieConstants.ALLOWED_BOT_ROLE, msg.sender)) {
revert IHyperpieConfig.CallerNotHyperpieConfigAllowedBot();
}
}
function onlyFeeManager(address hyperpieConfig) external view {
if (!IAccessControl(hyperpieConfig).hasRole(HyperpieConstants.FEE_MANAGER_ROLE, msg.sender)) {
revert IHyperpieConfig.CallerNotHyperpieConfigFeeManager();
}
}
function onlyMetaConfigRole(address hyperpieConfig) external view {
if (!IAccessControl(hyperpieConfig).hasRole(HyperpieConstants.HYPERPIE_V2_META_CONFIG_ROLE, msg.sender)) {
revert IHyperpieConfig.CallerNotHyperpieConfigMetaConfig();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
* constructor.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: setting the version to 255 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized != type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint8) {
return _initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _initializing;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @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
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/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 functionCallWithValue(target, data, 0, "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");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, 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) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or 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 {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.0;
import "../Strings.sol";
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV // Deprecated in v4.8
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
/// @solidity memory-safe-assembly
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/
function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, "\x19Ethereum Signed Message:\n32")
mstore(0x1c, hash)
message := keccak256(0x00, 0x3c)
}
}
/**
* @dev Returns an Ethereum Signed Message, created from `s`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) {
/// @solidity memory-safe-assembly
assembly {
let ptr := mload(0x40)
mstore(ptr, "\x19\x01")
mstore(add(ptr, 0x02), domainSeparator)
mstore(add(ptr, 0x22), structHash)
data := keccak256(ptr, 0x42)
}
}
/**
* @dev Returns an Ethereum Signed Data with intended validator, created from a
* `validator` and `data` according to the version 0 of EIP-191.
*
* See {recover}.
*/
function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x00", validator, data));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/EIP712.sol)
pragma solidity ^0.8.8;
import "./ECDSA.sol";
import "../ShortStrings.sol";
import "../../interfaces/IERC5267.sol";
/**
* @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
*
* The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,
* thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding
* they need in their contracts using a combination of `abi.encode` and `keccak256`.
*
* This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
* scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
* ({_hashTypedDataV4}).
*
* The implementation of the domain separator was designed to be as efficient as possible while still properly updating
* the chain id to protect against replay attacks on an eventual fork of the chain.
*
* NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
* https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
*
* NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain
* separator of the implementation contract. This will cause the `_domainSeparatorV4` function to always rebuild the
* separator from the immutable values, which is cheaper than accessing a cached version in cold storage.
*
* _Available since v3.4._
*
* @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
*/
abstract contract EIP712 is IERC5267 {
using ShortStrings for *;
bytes32 private constant _TYPE_HASH =
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
// Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
// invalidate the cached domain separator if the chain id changes.
bytes32 private immutable _cachedDomainSeparator;
uint256 private immutable _cachedChainId;
address private immutable _cachedThis;
bytes32 private immutable _hashedName;
bytes32 private immutable _hashedVersion;
ShortString private immutable _name;
ShortString private immutable _version;
string private _nameFallback;
string private _versionFallback;
/**
* @dev Initializes the domain separator and parameter caches.
*
* The meaning of `name` and `version` is specified in
* https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
*
* - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
* - `version`: the current major version of the signing domain.
*
* NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
* contract upgrade].
*/
constructor(string memory name, string memory version) {
_name = name.toShortStringWithFallback(_nameFallback);
_version = version.toShortStringWithFallback(_versionFallback);
_hashedName = keccak256(bytes(name));
_hashedVersion = keccak256(bytes(version));
_cachedChainId = block.chainid;
_cachedDomainSeparator = _buildDomainSeparator();
_cachedThis = address(this);
}
/**
* @dev Returns the domain separator for the current chain.
*/
function _domainSeparatorV4() internal view returns (bytes32) {
if (address(this) == _cachedThis && block.chainid == _cachedChainId) {
return _cachedDomainSeparator;
} else {
return _buildDomainSeparator();
}
}
function _buildDomainSeparator() private view returns (bytes32) {
return keccak256(abi.encode(_TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this)));
}
/**
* @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
* function returns the hash of the fully encoded EIP712 message for this domain.
*
* This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
*
* ```solidity
* bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
* keccak256("Mail(address to,string contents)"),
* mailTo,
* keccak256(bytes(mailContents))
* )));
* address signer = ECDSA.recover(digest, signature);
* ```
*/
function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);
}
/**
* @dev See {EIP-5267}.
*
* _Available since v4.9._
*/
function eip712Domain()
public
view
virtual
override
returns (
bytes1 fields,
string memory name,
string memory version,
uint256 chainId,
address verifyingContract,
bytes32 salt,
uint256[] memory extensions
)
{
return (
hex"0f", // 01111
_name.toStringWithFallback(_nameFallback),
_version.toStringWithFallback(_versionFallback),
block.chainid,
address(this),
bytes32(0),
new uint256[](0)
);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)
pragma solidity ^0.8.0;
/**
* @title Counters
* @author Matt Condon (@shrugs)
* @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
* of elements in a mapping, issuing ERC721 ids, or counting request ids.
*
* Include with `using Counters for Counters.Counter;`
*/
library Counters {
struct Counter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/ethereum/solidity/issues/4637
uint256 _value; // default: 0
}
function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
unchecked {
counter._value += 1;
}
}
function decrement(Counter storage counter) internal {
uint256 value = counter._value;
require(value > 0, "Counter: decrement overflow");
unchecked {
counter._value = value - 1;
}
}
function reset(Counter storage counter) internal {
counter._value = 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.0;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeacon {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {BeaconProxy} will check that this address is a contract.
*/
function implementation() external view returns (address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)
pragma solidity ^0.8.0;
/**
* @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
* instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
* be specified by overriding the virtual {_implementation} function.
*
* Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
* different contract through the {_delegate} function.
*
* The success and return data of the delegated call will be returned back to the caller of the proxy.
*/
abstract contract Proxy {
/**
* @dev Delegates the current call to `implementation`.
*
* This function does not return to its internal call site, it will return directly to the external caller.
*/
function _delegate(address implementation) internal virtual {
assembly {
// Copy msg.data. We take full control of memory in this inline assembly
// block because it will not return to Solidity code. We overwrite the
// Solidity scratch pad at memory position 0.
calldatacopy(0, 0, calldatasize())
// Call the implementation.
// out and outsize are 0 because we don't know the size yet.
let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
// Copy the returned data.
returndatacopy(0, 0, returndatasize())
switch result
// delegatecall returns 0 on error.
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
/**
* @dev This is a virtual function that should be overridden so it returns the address to which the fallback function
* and {_fallback} should delegate.
*/
function _implementation() internal view virtual returns (address);
/**
* @dev Delegates the current call to the address returned by `_implementation()`.
*
* This function does not return to its internal call site, it will return directly to the external caller.
*/
function _fallback() internal virtual {
_beforeFallback();
_delegate(_implementation());
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
* function in the contract matches the call data.
*/
fallback() external payable virtual {
_fallback();
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
* is empty.
*/
receive() external payable virtual {
_fallback();
}
/**
* @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
* call, or as part of the Solidity `fallback` or `receive` functions.
*
* If overridden should call `super._beforeFallback()`.
*/
function _beforeFallback() internal virtual {}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/ERC1967/ERC1967Upgrade.sol)
pragma solidity ^0.8.2;
import "../beacon/IBeacon.sol";
import "../../interfaces/IERC1967.sol";
import "../../interfaces/draft-IERC1822.sol";
import "../../utils/Address.sol";
import "../../utils/StorageSlot.sol";
/**
* @dev This abstract contract provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
*
* _Available since v4.1._
*/
abstract contract ERC1967Upgrade is IERC1967 {
// This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev Returns the current implementation address.
*/
function _getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Perform implementation upgrade
*
* Emits an {Upgraded} event.
*/
function _upgradeTo(address newImplementation) internal {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
}
/**
* @dev Perform implementation upgrade with additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {
_upgradeTo(newImplementation);
if (data.length > 0 || forceCall) {
Address.functionDelegateCall(newImplementation, data);
}
}
/**
* @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal {
// Upgrades from old implementations will perform a rollback test. This test requires the new
// implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
// this special case will break upgrade paths from old UUPS implementation to new ones.
if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {
_setImplementation(newImplementation);
} else {
try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
} catch {
revert("ERC1967Upgrade: new implementation is not UUPS");
}
_upgradeToAndCall(newImplementation, data, forceCall);
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*/
function _getAdmin() internal view returns (address) {
return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
require(newAdmin != address(0), "ERC1967: new admin is the zero address");
StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {AdminChanged} event.
*/
function _changeAdmin(address newAdmin) internal {
emit AdminChanged(_getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
*/
bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Returns the current beacon.
*/
function _getBeacon() internal view returns (address) {
return StorageSlot.getAddressSlot(_BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the EIP1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract");
require(
Address.isContract(IBeacon(newBeacon).implementation()),
"ERC1967: beacon implementation is not a contract"
);
StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;
}
/**
* @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
* not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
*
* Emits a {BeaconUpgraded} event.
*/
function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {
_setBeacon(newBeacon);
emit BeaconUpgraded(newBeacon);
if (data.length > 0 || forceCall) {
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
}
}
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.21;
import { UtilLib } from "./UtilLib.sol";
import { HyperpieConstants } from "./HyperpieConstants.sol";
import { IHyperpieConfig } from "../interfaces/IHyperpieConfig.sol";
import { IAccessControl } from "@openzeppelin/contracts/access/IAccessControl.sol";
/// @title HyperpieConfigRoleChecker - Role checker for Hyperpie Config
/// @notice Provides role checking functionality for Hyperpie Config
abstract contract HyperpieConfigRoleChecker {
/*//////////////////////////////////////////////////////////////
STATE VARIABLES
//////////////////////////////////////////////////////////////*/
IHyperpieConfig public hyperpieConfig;
uint256[49] private __gap; // reserve for upgrade
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event UpdatedHyperpieConfig(address indexed hyperpieConfig);
/*//////////////////////////////////////////////////////////////
MODIFIERS
//////////////////////////////////////////////////////////////*/
modifier onlyRole(bytes32 role) {
if (!IAccessControl(address(hyperpieConfig)).hasRole(role, msg.sender)) {
string memory roleStr = string(abi.encodePacked(role));
revert IHyperpieConfig.CallerNotHyperpieConfigAllowedRole(roleStr);
}
_;
}
modifier onlyPriceProvider() {
if (!IAccessControl(address(hyperpieConfig)).hasRole(HyperpieConstants.PRICE_PROVIDER_ROLE, msg.sender)) {
revert IHyperpieConfig.CallerNotHyperpieConfigPriceProvider();
}
_;
}
modifier onlyHyperpieManager() {
if (!IAccessControl(address(hyperpieConfig)).hasRole(HyperpieConstants.MANAGER, msg.sender)) {
revert IHyperpieConfig.CallerNotHyperpieConfigManager();
}
_;
}
modifier onlyDefaultAdmin() {
if (!IAccessControl(address(hyperpieConfig)).hasRole(HyperpieConstants.DEFAULT_ADMIN_ROLE, msg.sender)) {
revert IHyperpieConfig.CallerNotHyperpieConfigAdmin();
}
_;
}
modifier onlyMinter() {
if (!IAccessControl(address(hyperpieConfig)).hasRole(HyperpieConstants.MINTER_ROLE, msg.sender)) {
revert IHyperpieConfig.CallerNotHyperpieConfigMinter();
}
_;
}
modifier onlyBurner() {
if (!IAccessControl(address(hyperpieConfig)).hasRole(HyperpieConstants.BURNER_ROLE, msg.sender)) {
revert IHyperpieConfig.CallerNotHyperpieConfigBurner();
}
_;
}
modifier onlyOracleAdmin() {
if (!IAccessControl(address(hyperpieConfig)).hasRole(HyperpieConstants.ORACLE_ADMIN_ROLE, msg.sender)) {
revert IHyperpieConfig.CallerNotHyperpieConfigOracleAdmin();
}
_;
}
modifier onlyOracle() {
if (!IAccessControl(address(hyperpieConfig)).hasRole(HyperpieConstants.ORACLE_ROLE, msg.sender)) {
revert IHyperpieConfig.CallerNotHyperpieConfigOracle();
}
_;
}
modifier onlyPauser() {
if (!IAccessControl(address(hyperpieConfig)).hasRole(HyperpieConstants.PAUSER_ROLE, msg.sender)) {
revert IHyperpieConfig.CallerNotHyperpiePauser();
}
_;
}
modifier onlyAllowedBot() {
if (!IAccessControl(address(hyperpieConfig)).hasRole(HyperpieConstants.ALLOWED_BOT_ROLE, msg.sender)) {
revert IHyperpieConfig.CallerNotHyperpieConfigAllowedBot();
}
_;
}
modifier onlyOracleOrHyperpieStaking() {
address hyperpieStaking = hyperpieConfig.getAddress(HyperpieConstants.HYPERPIE_STAKING);
bool isOracle = IAccessControl(address(hyperpieConfig)).hasRole(HyperpieConstants.ORACLE_ROLE, msg.sender);
bool isHyperpieStaking = msg.sender == hyperpieStaking;
if (!isOracle && !isHyperpieStaking) {
revert IHyperpieConfig.CallerNotHyperpieConfigOracle();
}
_;
}
/*//////////////////////////////////////////////////////////////
ADMIN FUNCTIONS
//////////////////////////////////////////////////////////////*/
/// @notice Updates the Hyperpie config contract
/// @dev only callable by Hyperpie default
/// @param hyperpieConfigAddr the new Hyperpie config contract Address
function updateHyperpieConfig(address hyperpieConfigAddr) external virtual onlyDefaultAdmin {
UtilLib.checkNonZeroAddress(hyperpieConfigAddr);
hyperpieConfig = IHyperpieConfig(hyperpieConfigAddr);
emit UpdatedHyperpieConfig(hyperpieConfigAddr);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (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
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/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 functionCallWithValue(target, data, 0, "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");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, 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) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or 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 {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/Math.sol";
import "./math/SignedMath.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toString(int256 value) internal pure returns (string memory) {
return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return keccak256(bytes(a)) == keccak256(bytes(b));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/ShortStrings.sol)
pragma solidity ^0.8.8;
import "./StorageSlot.sol";
// | string | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
// | length | 0x BB |
type ShortString is bytes32;
/**
* @dev This library provides functions to convert short memory strings
* into a `ShortString` type that can be used as an immutable variable.
*
* Strings of arbitrary length can be optimized using this library if
* they are short enough (up to 31 bytes) by packing them with their
* length (1 byte) in a single EVM word (32 bytes). Additionally, a
* fallback mechanism can be used for every other case.
*
* Usage example:
*
* ```solidity
* contract Named {
* using ShortStrings for *;
*
* ShortString private immutable _name;
* string private _nameFallback;
*
* constructor(string memory contractName) {
* _name = contractName.toShortStringWithFallback(_nameFallback);
* }
*
* function name() external view returns (string memory) {
* return _name.toStringWithFallback(_nameFallback);
* }
* }
* ```
*/
library ShortStrings {
// Used as an identifier for strings longer than 31 bytes.
bytes32 private constant _FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;
error StringTooLong(string str);
error InvalidShortString();
/**
* @dev Encode a string of at most 31 chars into a `ShortString`.
*
* This will trigger a `StringTooLong` error is the input string is too long.
*/
function toShortString(string memory str) internal pure returns (ShortString) {
bytes memory bstr = bytes(str);
if (bstr.length > 31) {
revert StringTooLong(str);
}
return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length));
}
/**
* @dev Decode a `ShortString` back to a "normal" string.
*/
function toString(ShortString sstr) internal pure returns (string memory) {
uint256 len = byteLength(sstr);
// using `new string(len)` would work locally but is not memory safe.
string memory str = new string(32);
/// @solidity memory-safe-assembly
assembly {
mstore(str, len)
mstore(add(str, 0x20), sstr)
}
return str;
}
/**
* @dev Return the length of a `ShortString`.
*/
function byteLength(ShortString sstr) internal pure returns (uint256) {
uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF;
if (result > 31) {
revert InvalidShortString();
}
return result;
}
/**
* @dev Encode a string into a `ShortString`, or write it to storage if it is too long.
*/
function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) {
if (bytes(value).length < 32) {
return toShortString(value);
} else {
StorageSlot.getStringSlot(store).value = value;
return ShortString.wrap(_FALLBACK_SENTINEL);
}
}
/**
* @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}.
*/
function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) {
if (ShortString.unwrap(value) != _FALLBACK_SENTINEL) {
return toString(value);
} else {
return store;
}
}
/**
* @dev Return the length of a string that was encoded to `ShortString` or written to storage using {setWithFallback}.
*
* WARNING: This will return the "byte length" of the string. This may not reflect the actual length in terms of
* actual characters as the UTF-8 encoding of a single character can span over multiple bytes.
*/
function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) {
if (ShortString.unwrap(value) != _FALLBACK_SENTINEL) {
return byteLength(value);
} else {
return bytes(store).length;
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC5267.sol)
pragma solidity ^0.8.0;
interface IERC5267 {
/**
* @dev MAY be emitted to signal that the domain could have changed.
*/
event EIP712DomainChanged();
/**
* @dev returns the fields and values that describe the domain separator used by this contract for EIP-712
* signature.
*/
function eip712Domain()
external
view
returns (
bytes1 fields,
string memory name,
string memory version,
uint256 chainId,
address verifyingContract,
bytes32 salt,
uint256[] memory extensions
);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC1967.sol)
pragma solidity ^0.8.0;
/**
* @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
*
* _Available since v4.8.3._
*/
interface IERC1967 {
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Emitted when the beacon is changed.
*/
event BeaconUpgraded(address indexed beacon);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)
pragma solidity ^0.8.0;
/**
* @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822Proxiable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.0;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC1967 implementation slot:
* ```solidity
* contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._
* _Available since v4.9 for `string`, `bytes`._
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
/**
* @dev Returns an `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}{
"remappings": [
"ds-test/=lib/forge-std/lib/ds-test/src/",
"forge-std/=lib/forge-std/src/",
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"eth-gas-reporter/=node_modules/eth-gas-reporter/",
"hardhat/=node_modules/hardhat/",
"hyperevm-project-template/=lib/hyperevm-project-template/src/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"openzeppelin/=lib/openzeppelin-contracts/contracts/",
"solidity-code-metrics/=node_modules/solidity-code-metrics/"
],
"optimizer": {
"enabled": true,
"runs": 10000
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "shanghai",
"viaIR": false,
"libraries": {
"contracts/memedex/HyperpiePair.sol": {
"RoleCheckerLib": "0x16b586adf641eb0a94670ac91ff4769ecd3dd43a"
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"BelowMinimumK","type":"error"},{"inputs":[],"name":"DepositsNotEqual","type":"error"},{"inputs":[],"name":"DexV2Locked","type":"error"},{"inputs":[],"name":"FactoryAlreadySet","type":"error"},{"inputs":[],"name":"InsufficientInputAmount","type":"error"},{"inputs":[],"name":"InsufficientLiquidity","type":"error"},{"inputs":[],"name":"InsufficientLiquidityBurned","type":"error"},{"inputs":[],"name":"InsufficientLiquidityMinted","type":"error"},{"inputs":[],"name":"InsufficientOutputAmount","type":"error"},{"inputs":[],"name":"InvalidShortString","type":"error"},{"inputs":[],"name":"InvalidTo","type":"error"},{"inputs":[],"name":"InvariantKViolated","type":"error"},{"inputs":[],"name":"IsNotFactory","type":"error"},{"inputs":[],"name":"K","type":"error"},{"inputs":[],"name":"Overflow","type":"error"},{"inputs":[{"internalType":"string","name":"str","type":"string"}],"name":"StringTooLong","type":"error"},{"inputs":[],"name":"Y","type":"error"},{"inputs":[],"name":"ZeroAddressNotAllowed","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"Claim","type":"event"},{"anonymous":false,"inputs":[],"name":"EIP712DomainChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"Fees","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"}],"name":"SetName","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"symbol","type":"string"}],"name":"SetSymbol","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"swappedFor","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount0In","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1In","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount0Out","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1Out","type":"uint256"}],"name":"Swap","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"reserve0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reserve1","type":"uint256"}],"name":"Sync","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"hyperpieConfig","type":"address"}],"name":"UpdatedHyperpieConfig","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"burn","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimFees","outputs":[{"internalType":"uint256","name":"claimed0","type":"uint256"},{"internalType":"uint256","name":"claimed1","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"claimable0","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"claimable1","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentCumulativePrices","outputs":[{"internalType":"uint256","name":"reserve0Cumulative","type":"uint256"},{"internalType":"uint256","name":"reserve1Cumulative","type":"uint256"},{"internalType":"uint256","name":"blockTimestamp","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"address","name":"tokenIn","type":"address"}],"name":"getAmountOut","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getK","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReserves","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hyperpieConfig","outputs":[{"internalType":"contract IHyperpieConfig","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"index0","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"index1","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token0","type":"address"},{"internalType":"address","name":"_token1","type":"address"},{"internalType":"address","name":"_hyperpieConfig","type":"address"},{"internalType":"bool","name":"_stable","type":"bool"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lpRevShareBPS","outputs":[{"internalType":"uint256","name":"lpRevBps","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"mint","outputs":[{"internalType":"uint256","name":"liquidity","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"poolFees","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"reserve0CumulativeLast","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"reserve1CumulativeLast","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"__name","type":"string"}],"name":"setName","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"__symbol","type":"string"}],"name":"setSymbol","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"supplyIndex0","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"supplyIndex1","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount0Out","type":"uint256"},{"internalType":"uint256","name":"amount1Out","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"swap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sync","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"token0","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token1","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokens","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_hyperpieConfig","type":"address"}],"name":"updateConfig","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
6101606040525f6017555f60185534801562000019575f80fd5b5060408051602080820183525f8083528351808501855260018152603160f81b81840152845180840186528281528551938401909552908252919283929160036200006583826200025c565b5060046200007482826200025c565b50620000869150839050600562000139565b610120526200009781600662000139565b61014052815160208084019190912060e052815190820120610100524660a0526200012460e05161010051604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201529081019290925260608201524660808201523060a08201525f9060c00160405160208183030381529060405280519060200120905090565b60805250503060c05250600160095562000395565b5f6020835110156200015857620001508362000171565b90506200016b565b816200016584826200025c565b5060ff90505b92915050565b5f80829050601f81511115620001a7578260405163305a27a960e01b81526004016200019e919062000324565b60405180910390fd5b8051620001b48262000371565b179392505050565b634e487b7160e01b5f52604160045260245ffd5b600181811c90821680620001e557607f821691505b6020821081036200020457634e487b7160e01b5f52602260045260245ffd5b50919050565b601f82111562000257575f81815260208120601f850160051c81016020861015620002325750805b601f850160051c820191505b8181101562000253578281556001016200023e565b5050505b505050565b81516001600160401b03811115620002785762000278620001bc565b6200029081620002898454620001d0565b846200020a565b602080601f831160018114620002c6575f8415620002ae5750858301515b5f19600386901b1c1916600185901b17855562000253565b5f85815260208120601f198616915b82811015620002f657888601518255948401946001909101908401620002d5565b50858210156200031457878501515f19600388901b60f8161c191681555b5050505050600190811b01905550565b5f6020808352835180828501525f5b81811015620003515785810183015185820160400152820162000333565b505f604082860101526040601f19601f8301168501019250505092915050565b8051602080830151919081101562000204575f1960209190910360031b1b16919050565b60805160a05160c05160e051610100516101205161014051615977620003e75f395f6114e901525f6114bc01525f612d4501525f612d1d01525f612c7501525f612ca001525f612ccb01526159775ff3fe608060405234801562000010575f80fd5b506004361062000320575f3560e01c806395d89b4111620001a7578063c47f002711620000ef578063dd62ed3e116200009f578063fd8840fb1162000077578063fd8840fb146200071d578063fecf97341462000727578063fff6cae9146200073e575f80fd5b8063dd62ed3e14620006c1578063ee39e7a014620006fc578063f140a35a1462000706575f80fd5b8063d294f09311620000d3578063d294f093146200068c578063d320273b1462000696578063d505accf14620006aa575f80fd5b8063c47f00271462000661578063d21220a71462000678575f80fd5b8063a9059cbb1162000157578063bf944dbc116200012f578063bf944dbc1462000639578063c245febc1462000643578063c45a0155146200064d575f80fd5b8063a9059cbb1462000601578063b84c82461462000618578063bda39cad146200062f575f80fd5b80639f767c88116200018b5780639f767c8814620005a6578063a1ac4d1314620005c8578063a457c2d714620005ea575f80fd5b806395d89b4114620005705780639d63848a146200057a575f80fd5b806333580959116200026b5780636cc919c8116200021b5780637ecebe0011620001f35780637ecebe00146200050d57806384b0196e146200052457806389afcb441462000543575f80fd5b80636cc919c814620004b25780636d9a640a14620004cb57806370a0823114620004e2575f80fd5b806339509351116200024f5780633950935114620004625780634d5a9f8a14620004795780636a627842146200049b575f80fd5b80633358095914620004445780633644e5151462000458575f80fd5b80631df8c71711620002d357806323b872dd11620002ab57806323b872dd1462000413578063313ce567146200042a57806332c0defd146200043a575f80fd5b80631df8c71714620003d9578063205aabf114620003e357806322be3de11462000405575f80fd5b8063095ea7b31162000307578063095ea7b3146200036c5780630dfe1681146200039457806318160ddd14620003c6575f80fd5b806306fdde0314620003245780630902f1ac1462000346575b5f80fd5b6200032e62000748565b6040516200033d91906200474f565b60405180910390f35b6012546013546014545b604080519384526020840192909252908201526060016200033d565b620003836200037d36600462004778565b620007e0565b60405190151581526020016200033d565b600c54620003ad9061010090046001600160a01b031681565b6040516001600160a01b0390911681526020016200033d565b6002545b6040519081526020016200033d565b62000350620007fb565b620003ca620003f4366004620047a5565b601c6020525f908152604090205481565b600c54620003839060ff1681565b6200038362000424366004620047c3565b62000874565b604051601281526020016200033d565b620003ca60175481565b600f54620003ad906001600160a01b031681565b620003ca6200089d565b620003836200047336600462004778565b620008ad565b620003ca6200048a366004620047a5565b60196020525f908152604090205481565b620003ca620004ac366004620047a5565b620008ef565b620004c9620004c3366004620047a5565b62000d05565b005b620004c9620004dc36600462004806565b62000df9565b620003ca620004f3366004620047a5565b6001600160a01b03165f9081526020819052604090205490565b620003ca6200051e366004620047a5565b62001490565b6200052e620014ae565b6040516200033d97969594939291906200483f565b6200055a62000554366004620047a5565b62001555565b604080519283526020830191909152016200033d565b6200032e62001989565b600c54600d54604080516101009093046001600160a01b0390811684529091166020830152016200033d565b620003ca620005b7366004620047a5565b601b6020525f908152604090205481565b620003ca620005d9366004620047a5565b601a6020525f908152604090205481565b62000383620005fb36600462004778565b6200199a565b620003836200061236600462004778565b62001a56565b620004c962000629366004620048f5565b62001a65565b620003ca60185481565b620003ca60155481565b620003ca60165481565b600e54620003ad906001600160a01b031681565b620004c962000672366004620048f5565b62001b3d565b600d54620003ad906001600160a01b031681565b6200055a62001c09565b601d54620003ad906001600160a01b031681565b620004c9620006bb36600462004975565b62001e08565b620003ca620006d2366004620049e8565b6001600160a01b039182165f90815260016020908152604080832093909416825291909152205490565b620003ca62001f75565b620003ca6200071736600462004a24565b62001f86565b620003ca6200206d565b620004c96200073836600462004a58565b620020f4565b620004c962002707565b6060600a8054620007599062004aba565b80601f0160208091040260200160405190810160405280929190818152602001828054620007879062004aba565b8015620007d65780601f10620007ac57610100808354040283529160200191620007d6565b820191905f5260205f20905b815481529060010190602001808311620007b857829003601f168201915b5050505050905090565b5f33620007ef8185856200287a565b60019150505b92915050565b601554601654425f8080620008196012546013546014549192909190565b9250925092508381146200086c575f62000834828662004b34565b905062000842818562004b4a565b6200084e908862004b64565b96506200085c818462004b4a565b62000868908762004b64565b9550505b505050909192565b5f3362000883858285620029d5565b6200089085858562002a6a565b60019150505b9392505050565b5f620008a862002c69565b905090565b335f8181526001602090815260408083206001600160a01b0387168452909152812054909190620007ef9082908690620008e990879062004b64565b6200287a565b601d54604080517f257840ec00000000000000000000000000000000000000000000000000000000815290515f926001600160a01b03169163257840ec9160048083019260209291908290030181865afa15801562000950573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062000976919062004b7a565b15620009ae576040517f56783e0e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620009b862002d95565b601254601354600c54604080517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290515f9261010090046001600160a01b0316916370a082319160248083019260209291908290030181865afa15801562000a2a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062000a50919062004b98565b600d546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529192505f916001600160a01b03909116906370a0823190602401602060405180830381865afa15801562000ab5573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062000adb919062004b98565b90505f62000aea858462004b34565b90505f62000af9858462004b34565b90505f62000b0660025490565b9050805f0362000c20576103e862000b2962000b23848662004b4a565b62002df0565b62000b35919062004b34565b975062000b4660016103e862002ef1565b600c5460ff161562000c1a5760115462000b6983670de0b6b3a764000062004b4a565b62000b75919062004bdd565b60105462000b8c85670de0b6b3a764000062004b4a565b62000b98919062004bdd565b1462000bd0576040517f0a04d7fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6402540be40062000be2848462002fbf565b1162000c1a576040517f438d3ade00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000c5f565b62000c5c8762000c31838662004b4a565b62000c3d919062004bdd565b8762000c4a848662004b4a565b62000c56919062004bdd565b620030d2565b97505b875f0362000c99576040517fd226f9d400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000ca5898962002ef1565b62000cb385858989620030e9565b604080518481526020810184905233917f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f910160405180910390a25050505050505062000d006001600955565b919050565b62000d1081620031b7565b601d546040517f8321d8c20000000000000000000000000000000000000000000000000000000081526001600160a01b0390911660048201527316b586adf641eb0a94670ac91ff4769ecd3dd43a90638321d8c2906024015f6040518083038186803b15801562000d7f575f80fd5b505af415801562000d92573d5f803e3d5ffd5b5050601d80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0385169081179091556040519092507f70edc3ecaaed82c5ab4a171ac33229a3aa307576b6418dd6551b97da670cf2ad91505f90a250565b601d5f9054906101000a90046001600160a01b03166001600160a01b031663257840ec6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000e4a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062000e70919062004b7a565b1562000ea8576040517f56783e0e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000eb262002d95565b62000ebd81620031b7565b8215801562000eca575081155b1562000f02576040517f42301c2300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b601254601354818510158062000f185750808410155b1562000f50576040517fbb55fd2700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600c54600d545f9182916001600160a01b0361010090920482169190811690871682148062000f905750806001600160a01b0316876001600160a01b0316145b1562000fc8576040517f290fa18800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b881562000fe55762000fe56001600160a01b038316888b620031fb565b87156200100257620010026001600160a01b038216888a620031fb565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa1580156200105e573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062001084919062004b98565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529094506001600160a01b038216906370a0823190602401602060405180830381865afa158015620010e3573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062001109919062004b98565b925050505f87856200111c919062004b34565b83116200112a575f62001142565b62001136888662004b34565b62001142908462004b34565b90505f62001151888662004b34565b83116200115f575f62001177565b6200116b888662004b34565b62001177908462004b34565b90508115801562001186575080155b15620011be576040517f098fb56100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600c54600d54600e546040517fcc56b2c500000000000000000000000000000000000000000000000000000000815230600482015260ff8416151560248201526001600160a01b03610100909404841693928316925f92169063cc56b2c590604401602060405180830381865afa1580156200123c573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062001262919062004b98565b905084156200129057620012906127106200127e838862004b4a565b6200128a919062004bdd565b620032a6565b8315620012bc57620012bc612710620012aa838762004b4a565b620012b6919062004bdd565b6200335a565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b038416906370a0823190602401602060405180830381865afa15801562001318573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906200133e919062004b98565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529097506001600160a01b038316906370a0823190602401602060405180830381865afa1580156200139d573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620013c3919062004b98565b9550620013d1898962002fbf565b620013dd888862002fbf565b101562001416576040517fa932492f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050506200142784848888620030e9565b60408051838152602081018390529081018a9052606081018990526001600160a01b038816907f49926bbebe8474393f434dfa4f78694c0923efa07d19f2284518bfabd06eb7379060800160405180910390a25050505050506200148b6001600955565b505050565b6001600160a01b0381165f90815260076020526040812054620007f5565b5f60608082808083620014e37f0000000000000000000000000000000000000000000000000000000000000000600562003403565b620015107f0000000000000000000000000000000000000000000000000000000000000000600662003403565b604080515f808252602082019092527f0f000000000000000000000000000000000000000000000000000000000000009b939a50919850469750309650945092509050565b5f80601d5f9054906101000a90046001600160a01b03166001600160a01b031663257840ec6040518163ffffffff1660e01b8152600401602060405180830381865afa158015620015a8573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620015ce919062004b7a565b1562001606576040517f56783e0e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200161062002d95565b6200161b83620031b7565b601254601354600c54604080517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290515f9261010090046001600160a01b0316916370a082319160248083019260209291908290030181865afa1580156200168d573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620016b3919062004b98565b600d546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529192505f916001600160a01b03909116906370a0823190602401602060405180830381865afa15801562001718573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906200173e919062004b98565b305f90815260208190526040902054600254919250908062001761858462004b4a565b6200176d919062004bdd565b9750806200177c848462004b4a565b62001788919062004bdd565b965087158062001796575086155b15620017ce576040517f749383ad00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620017da3083620034b1565b600c54620017f89061010090046001600160a01b03168a8a620031fb565b600d5462001811906001600160a01b03168a89620031fb565b600c546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526200192d9161010090046001600160a01b0316906370a0823190602401602060405180830381865afa15801562001879573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906200189f919062004b98565b600d546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015620018ff573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062001925919062004b98565b8888620030e9565b60408051898152602081018990526001600160a01b038b169133917fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496910160405180910390a3505050505050620019846001600955565b915091565b6060600b8054620007599062004aba565b335f8181526001602090815260408083206001600160a01b03871684529091528120549091908381101562001a3c5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f00000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b62001a4b82868684036200287a565b506001949350505050565b5f33620007ef81858562002a6a565b601d546040517ff038621a0000000000000000000000000000000000000000000000000000000081526001600160a01b0390911660048201527316b586adf641eb0a94670ac91ff4769ecd3dd43a9063f038621a906024015f6040518083038186803b15801562001ad4575f80fd5b505af415801562001ae7573d5f803e3d5ffd5b50600b925062001afd9150839050848362004c8c565b507fadf3ae8bd543b3007d464f15cb8ea1db3f44e84d41d203164f40b95e27558ac6828260405162001b3192919062004d55565b60405180910390a15050565b601d546040517ff038621a0000000000000000000000000000000000000000000000000000000081526001600160a01b0390911660048201527316b586adf641eb0a94670ac91ff4769ecd3dd43a9063f038621a906024015f6040518083038186803b15801562001bac575f80fd5b505af415801562001bbf573d5f803e3d5ffd5b50600a925062001bd59150839050848362004c8c565b507f4df9dcd34ae35f40f2c756fd8ac83210ed0b76d065543ee73d868aec7c7fcf02828260405162001b3192919062004d55565b5f8062001c1562002d95565b601d5f9054906101000a90046001600160a01b03166001600160a01b031663257840ec6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562001c66573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062001c8c919062004b7a565b1562001cc4576040517f56783e0e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3362001cd08162003629565b6001600160a01b0381165f90815260196020908152604080832054601a9092529091205490935091508215158062001d0757505f82115b1562001df8576001600160a01b038181165f818152601960209081526040808320839055601a90915280822091909155600f5490517f533cf5ce000000000000000000000000000000000000000000000000000000008152600481019290925260248201869052604482018590529091169063533cf5ce906064015f604051808303815f87803b15801562001d9a575f80fd5b505af115801562001dad573d5f803e3d5ffd5b505060408051868152602081018690526001600160a01b03851693508392507f865ca08d59f5cb456e85cd2f7ef63664ea4f73327414e9d8152c4158b0e94645910160405180910390a35b5062001e046001600955565b9091565b8342111562001e5a5760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e65000000604482015260640162001a33565b5f7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c988888862001e8a8c620038b1565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090505f62001ee682620038d8565b90505f62001ef78287878762003922565b9050896001600160a01b0316816001600160a01b03161462001f5c5760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e61747572650000604482015260640162001a33565b62001f698a8a8a6200287a565b50505050505050505050565b5f620008a860125460135462002fbf565b601254601354600e54600c54604080517fcc56b2c500000000000000000000000000000000000000000000000000000000815230600482015260ff90921615156024830152515f949392612710926001600160a01b039091169163cc56b2c5916044808201926020929091908290030181865afa1580156200200a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062002030919062004b98565b6200203c908762004b4a565b62002048919062004bdd565b62002054908662004b34565b945062002064858584846200394e565b95945050505050565b600f54604080517ffd8840fb00000000000000000000000000000000000000000000000000000000815290515f926001600160a01b03169163fd8840fb9160048083019260209291908290030181865afa158015620020ce573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620008a8919062004b98565b600e546001600160a01b03161562002138576040517f154c51b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600e80547fffffffffffffffffffffffff000000000000000000000000000000000000000016331790556200216d84620031b7565b6200217883620031b7565b600c8054600d80547fffffffffffffffffffffffff00000000000000000000000000000000000000009081166001600160a01b03888116919091179092557fffffffffffffffffffffff000000000000000000000000000000000000000000909216610100888316027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00161784151517909255601d805490911691841691821790556040517f21f8a7210000000000000000000000000000000000000000000000000000000081527f1ea5cc7b31f5ba018100cef63223dd0cc95d5ebd8029e1da1d44c7e0a4fd463660048201525f91906321f8a72190602401602060405180830381865afa1580156200228e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620022b4919062004d83565b90505f620023405f306001600160a01b03165f1b60405180602001620022da90620046f0565b601f1982820381018352601f9091011660408181526001600160a01b0388166020830152808201525f606082015260800160408051601f19818403018152908290526200232b929160200162004da1565b60405160208183030381529060405262003b2b565b6040517fc0c53b8b0000000000000000000000000000000000000000000000000000000081526001600160a01b038881166004830152878116602483015286811660448301529192509082169063c0c53b8b906064015f604051808303815f87803b158015620023ae575f80fd5b505af1158015620023c1573d5f803e3d5ffd5b5050505080600f5f6101000a8154816001600160a01b0302191690836001600160a01b03160217905550856001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801562002428573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906200244e919062004dd3565b6200245b90600a62004eea565b601081905550846001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200249e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620024c4919062004dd3565b620024d190600a62004eea565b6011819055505f866001600160a01b03166395d89b416040518163ffffffff1660e01b81526004015f60405180830381865afa15801562002514573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526200253d919081019062004efa565b90505f866001600160a01b03166395d89b416040518163ffffffff1660e01b81526004015f60405180830381865afa1580156200257c573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052620025a5919081019062004efa565b600c5490915060ff16156200265b578181604051602001620025c992919062004fa3565b604051602081830303815290604052600a9081620025e8919062005028565b506040518060400160405280600781526020017f535441424c452d0000000000000000000000000000000000000000000000000081525082826040516020016200263593929190620050f1565b604051602081830303815290604052600b908162002654919062005028565b50620026fd565b8181604051602001620026709291906200518c565b604051602081830303815290604052600a90816200268f919062005028565b506040518060400160405280600381526020017f56322d00000000000000000000000000000000000000000000000000000000008152508282604051602001620026dc93929190620050f1565b604051602081830303815290604052600b9081620026fb919062005028565b505b5050505050505050565b6200271162002d95565b6002545f036200274d576040517fbb55fd2700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600c546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526200286d9161010090046001600160a01b0316906370a0823190602401602060405180830381865afa158015620027b5573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620027db919062004b98565b600d546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa1580156200283b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062002861919062004b98565b601254601354620030e9565b620028786001600955565b565b6001600160a01b038316620028f75760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f7265737300000000000000000000000000000000000000000000000000000000606482015260840162001a33565b6001600160a01b038216620029755760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f7373000000000000000000000000000000000000000000000000000000000000606482015260840162001a33565b6001600160a01b038381165f8181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038381165f908152600160209081526040808320938616835292905220545f19811462002a64578181101562002a555760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640162001a33565b62002a6484848484036200287a565b50505050565b6001600160a01b03831662002ae85760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f6472657373000000000000000000000000000000000000000000000000000000606482015260840162001a33565b6001600160a01b03821662002b665760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f6573730000000000000000000000000000000000000000000000000000000000606482015260840162001a33565b62002b7383838362003c33565b6001600160a01b0383165f908152602081905260409020548181101562002c035760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e63650000000000000000000000000000000000000000000000000000606482015260840162001a33565b6001600160a01b038481165f81815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a362002a64565b5f306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614801562002cc257507f000000000000000000000000000000000000000000000000000000000000000046145b1562002ced57507f000000000000000000000000000000000000000000000000000000000000000090565b620008a8604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f0000000000000000000000000000000000000000000000000000000000000000918101919091527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a08201525f9060c00160405160208183030381529060405280519060200120905090565b60026009540362002de95760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640162001a33565b6002600955565b5f815f0362002e0057505f919050565b5f600162002e0e8462003c49565b901c6001901b9050600181848162002e2a5762002e2a62004bb0565b048201901c9050600181848162002e455762002e4562004bb0565b048201901c9050600181848162002e605762002e6062004bb0565b048201901c9050600181848162002e7b5762002e7b62004bb0565b048201901c9050600181848162002e965762002e9662004bb0565b048201901c9050600181848162002eb15762002eb162004bb0565b048201901c9050600181848162002ecc5762002ecc62004bb0565b048201901c9050620008968182858162002eea5762002eea62004bb0565b04620030d2565b6001600160a01b03821662002f495760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640162001a33565b62002f565f838362003c33565b8060025f82825462002f69919062004b64565b90915550506001600160a01b0382165f81815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b600c545f9060ff1615620030be576010545f9062002fe685670de0b6b3a764000062004b4a565b62002ff2919062004bdd565b90505f60115484670de0b6b3a76400006200300e919062004b4a565b6200301a919062004bdd565b90505f670de0b6b3a764000062003032838562004b4a565b6200303e919062004bdd565b90505f670de0b6b3a764000062003056848062004b4a565b62003062919062004bdd565b670de0b6b3a764000062003077868062004b4a565b62003083919062004bdd565b6200308f919062004b64565b9050670de0b6b3a7640000620030a6828462004b4a565b620030b2919062004bdd565b945050505050620007f5565b620030ca828462004b4a565b9050620007f5565b5f818310620030e2578162000896565b5090919050565b60145442905f90620030fc908362004b34565b90505f811180156200310d57508315155b80156200311957508215155b1562003167576200312b818562004b4a565b60155f8282546200313d919062004b64565b909155506200314f9050818462004b4a565b60165f82825462003161919062004b64565b90915550505b60128690556013859055601482905560408051878152602081018790527fcf2aa50876cdfbb541206f89af0ee78d44a2abf8d328e37fa4917f982149848a910160405180910390a1505050505050565b6001600160a01b038116620031f8576040517f8579befe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50565b6040516001600160a01b0383166024820152604481018290526200148b9084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915262003ce4565b805f03620032b15750565b600c54620032ce9061010090046001600160a01b03168262003dd1565b5f620032d960025490565b620032ed83670de0b6b3a764000062004b4a565b620032f9919062004bdd565b905080156200331b578060175f82825462003315919062004b64565b90915550505b604080518381525f602082015233917f112c256902bf554b6ed882d2936687aaeb4225e8cd5b51303c90ca6cf43a860291015b60405180910390a25050565b805f03620033655750565b600d546200337d906001600160a01b03168262003dd1565b5f6200338860025490565b6200339c83670de0b6b3a764000062004b4a565b620033a8919062004bdd565b90508015620033ca578060185f828254620033c4919062004b64565b90915550505b604080515f81526020810184905233917f112c256902bf554b6ed882d2936687aaeb4225e8cd5b51303c90ca6cf43a860291016200334e565b606060ff83146200341957620030ca8362003e6d565b818054620034279062004aba565b80601f0160208091040260200160405190810160405280929190818152602001828054620034559062004aba565b8015620034a45780601f106200347a57610100808354040283529160200191620034a4565b820191905f5260205f20905b8154815290600101906020018083116200348657829003601f168201915b50505050509050620007f5565b6001600160a01b0382166200352f5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f7300000000000000000000000000000000000000000000000000000000000000606482015260840162001a33565b6200353c825f8362003c33565b6001600160a01b0382165f9081526020819052604090205481811015620035cc5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f6365000000000000000000000000000000000000000000000000000000000000606482015260840162001a33565b6001600160a01b0383165f818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3505050565b6001600160a01b0381165f90815260208190526040902054801562003880576001600160a01b0382165f908152601b602090815260408083208054601c80855292852080546017546018549481905594909552829055936200368c858462004b34565b90505f6200369b858462004b34565b905081156200378a575f670de0b6b3a7640000620036ba848a62004b4a565b620036c6919062004bdd565b9050612710600f5f9054906101000a90046001600160a01b03166001600160a01b031663fd8840fb6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200371c573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062003742919062004b98565b6200374e908362004b4a565b6200375a919062004bdd565b6001600160a01b038a165f90815260196020526040812080549091906200378390849062004b64565b9091555050505b8015620026fd575f670de0b6b3a7640000620037a7838a62004b4a565b620037b3919062004bdd565b9050612710600f5f9054906101000a90046001600160a01b03166001600160a01b031663fd8840fb6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562003809573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906200382f919062004b98565b6200383b908362004b4a565b62003847919062004bdd565b6001600160a01b038a165f908152601a6020526040812080549091906200387090849062004b64565b9091555050505050505050505050565b6017546001600160a01b0383165f908152601b6020908152604080832093909355601854601c909152919020555050565b6001600160a01b0381165f9081526007602052604090208054600181018255905b50919050565b5f620007f5620038e762002c69565b836040517f19010000000000000000000000000000000000000000000000000000000000008152600281019290925260228201526042902090565b5f805f620039338787878762003eac565b91509150620039428162003f6e565b5090505b949350505050565b600c545f9060ff161562003ace575f62003969848462002fbf565b6010549091506200398385670de0b6b3a764000062004b4a565b6200398f919062004bdd565b601154909450620039a984670de0b6b3a764000062004b4a565b620039b5919062004bdd565b600c549093505f9081906001600160a01b038881166101009092041614620039df578486620039e2565b85855b600c5491935091506001600160a01b03888116610100909204161462003a2b5760115462003a1989670de0b6b3a764000062004b4a565b62003a25919062004bdd565b62003a4e565b60105462003a4289670de0b6b3a764000062004b4a565b62003a4e919062004bdd565b97505f62003a6962003a61848b62004b64565b8584620040e5565b62003a75908362004b34565b600c54909150670de0b6b3a7640000906001600160a01b038a8116610100909204161462003aa65760105462003aaa565b6011545b62003ab6908362004b4a565b62003ac2919062004bdd565b94505050505062003946565b600c545f9081906001600160a01b03878116610100909204161462003af557838562003af8565b84845b909250905062003b09878362004b64565b62003b15828962004b4a565b62003b21919062004bdd565b9250505062003946565b5f8347101562003b7e5760405162461bcd60e51b815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e6365000000604482015260640162001a33565b81515f0362003bd05760405162461bcd60e51b815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f604482015260640162001a33565b8282516020840186f590506001600160a01b038116620008965760405162461bcd60e51b815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f7900000000000000604482015260640162001a33565b62003c3e8362003629565b6200148b8262003629565b5f80608083901c1562003c5e57608092831c92015b604083901c1562003c7157604092831c92015b602083901c1562003c8457602092831c92015b601083901c1562003c9757601092831c92015b600883901c1562003caa57600892831c92015b600483901c1562003cbd57600492831c92015b600283901c1562003cd057600292831c92015b600183901c15620007f55760010192915050565b5f62003d3a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316620042899092919063ffffffff16565b905080515f148062003d5d57508080602001905181019062003d5d919062004b7a565b6200148b5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840162001a33565b600f5462003ded906001600160a01b0384811691168362004299565b600f546040517f2ec0ff6c0000000000000000000000000000000000000000000000000000000081526001600160a01b0384811660048301526024820184905290911690632ec0ff6c906044015f604051808303815f87803b15801562003e52575f80fd5b505af115801562003e65573d5f803e3d5ffd5b505050505050565b60605f62003e7b83620043ed565b6040805160208082528183019092529192505f91906020820181803683375050509182525060208101929092525090565b5f807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111562003ee357505f9050600362003f65565b604080515f8082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa15801562003f35573d5f803e3d5ffd5b5050604051601f1901519150506001600160a01b03811662003f5f575f6001925092505062003f65565b91505f90505b94509492505050565b5f81600481111562003f845762003f8462005211565b0362003f8d5750565b600181600481111562003fa45762003fa462005211565b0362003ff35760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015260640162001a33565b60028160048111156200400a576200400a62005211565b03620040595760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015260640162001a33565b600381600481111562004070576200407062005211565b03620031f85760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f7565000000000000000000000000000000000000000000000000000000000000606482015260840162001a33565b5f805b60ff81101562004256575f620040ff86856200442e565b905084811015620041b2575f620041178786620044c5565b62004123838862004b34565b6200413790670de0b6b3a764000062004b4a565b62004143919062004bdd565b9050805f036200419d57858203620041615784935050505062000896565b856200417a886200417488600162004b64565b62002fbf565b111562004199576200418e85600162004b64565b935050505062000896565b5060015b620041a9818662004b64565b94505062004240565b5f620041bf8786620044c5565b620041cb878462004b34565b620041df90670de0b6b3a764000062004b4a565b620041eb919062004bdd565b9050805f036200423057858214806200421a57508562004218886200421260018962004b34565b6200442e565b105b156200422c5784935050505062000896565b5060015b6200423c818662004b34565b9450505b50806200424d816200523e565b915050620040e8565b506040517f45b3fe4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60606200394684845f8562004554565b8015806200432e57506040517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa15801562004306573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906200432c919062004b98565b155b620043a25760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e636500000000000000000000606482015260840162001a33565b6040516001600160a01b0383166024820152604481018290526200148b9084907f095ea7b3000000000000000000000000000000000000000000000000000000009060640162003241565b5f60ff8216601f811115620007f5576040517fb3512b0c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f80670de0b6b3a764000062004445848662004b4a565b62004451919062004bdd565b90505f670de0b6b3a764000062004469858062004b4a565b62004475919062004bdd565b670de0b6b3a76400006200448a878062004b4a565b62004496919062004bdd565b620044a2919062004b64565b9050670de0b6b3a7640000620044b9828462004b4a565b62002064919062004bdd565b5f670de0b6b3a76400008381620044dd828062004b4a565b620044e9919062004bdd565b620044f5919062004b4a565b62004501919062004bdd565b670de0b6b3a76400008062004517858062004b4a565b62004523919062004bdd565b6200453086600362004b4a565b6200453c919062004b4a565b62004548919062004bdd565b62000896919062004b64565b606082471015620045ce5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c0000000000000000000000000000000000000000000000000000606482015260840162001a33565b5f80866001600160a01b03168587604051620045eb919062005259565b5f6040518083038185875af1925050503d805f811462004627576040519150601f19603f3d011682016040523d82523d5f602084013e6200462c565b606091505b50915091506200463f878383876200464a565b979650505050505050565b60608315620046bd5782515f03620046b5576001600160a01b0385163b620046b55760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640162001a33565b508162003946565b620039468383815115620046d45781518083602001fd5b8060405162461bcd60e51b815260040162001a3391906200474f565b6106cb806200527783390190565b5f5b838110156200471a57818101518382015260200162004700565b50505f910152565b5f81518084526200473b816020860160208601620046fe565b601f01601f19169290920160200192915050565b602081525f62000896602083018462004722565b6001600160a01b0381168114620031f8575f80fd5b5f80604083850312156200478a575f80fd5b8235620047978162004763565b946020939093013593505050565b5f60208284031215620047b6575f80fd5b8135620008968162004763565b5f805f60608486031215620047d6575f80fd5b8335620047e38162004763565b92506020840135620047f58162004763565b929592945050506040919091013590565b5f805f6060848603121562004819575f80fd5b83359250602084013591506040840135620048348162004763565b809150509250925092565b7fff00000000000000000000000000000000000000000000000000000000000000881681525f602060e0818401526200487c60e084018a62004722565b838103604085015262004890818a62004722565b606085018990526001600160a01b038816608086015260a0850187905284810360c086015285518082528387019250908301905f5b81811015620048e357835183529284019291840191600101620048c5565b50909c9b505050505050505050505050565b5f806020838503121562004907575f80fd5b823567ffffffffffffffff808211156200491f575f80fd5b818501915085601f83011262004933575f80fd5b81358181111562004942575f80fd5b86602082850101111562004954575f80fd5b60209290920196919550909350505050565b60ff81168114620031f8575f80fd5b5f805f805f805f60e0888a0312156200498c575f80fd5b8735620049998162004763565b96506020880135620049ab8162004763565b955060408801359450606088013593506080880135620049cb8162004966565b9699959850939692959460a0840135945060c09093013592915050565b5f8060408385031215620049fa575f80fd5b823562004a078162004763565b9150602083013562004a198162004763565b809150509250929050565b5f806040838503121562004a36575f80fd5b82359150602083013562004a198162004763565b8015158114620031f8575f80fd5b5f805f806080858703121562004a6c575f80fd5b843562004a798162004763565b9350602085013562004a8b8162004763565b9250604085013562004a9d8162004763565b9150606085013562004aaf8162004a4a565b939692955090935050565b600181811c9082168062004acf57607f821691505b602082108103620038d2577f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b81810381811115620007f557620007f562004b07565b8082028115828204841417620007f557620007f562004b07565b80820180821115620007f557620007f562004b07565b5f6020828403121562004b8b575f80fd5b8151620008968162004a4a565b5f6020828403121562004ba9575f80fd5b5051919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f8262004c11577f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b500490565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b601f8211156200148b575f81815260208120601f850160051c8101602086101562004c6b5750805b601f850160051c820191505b8181101562003e655782815560010162004c77565b67ffffffffffffffff83111562004ca75762004ca762004c16565b62004cbf8362004cb8835462004aba565b8362004c43565b5f601f84116001811462004cf3575f851562004cdb5750838201355b5f19600387901b1c1916600186901b17835562004d4e565b5f83815260209020601f19861690835b8281101562004d25578685013582556020948501946001909201910162004d03565b508682101562004d42575f1960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b60208152816020820152818360408301375f818301604090810191909152601f909201601f19160101919050565b5f6020828403121562004d94575f80fd5b8151620008968162004763565b5f835162004db4818460208801620046fe565b83519083019062004dca818360208801620046fe565b01949350505050565b5f6020828403121562004de4575f80fd5b8151620008968162004966565b600181815b8085111562004e3157815f190482111562004e155762004e1562004b07565b8085161562004e2357918102915b93841c939080029062004df6565b509250929050565b5f8262004e4957506001620007f5565b8162004e5757505f620007f5565b816001811462004e70576002811462004e7b5762004e9b565b6001915050620007f5565b60ff84111562004e8f5762004e8f62004b07565b50506001821b620007f5565b5060208310610133831016604e8410600b841016171562004ec0575081810a620007f5565b62004ecc838362004df1565b805f190482111562004ee25762004ee262004b07565b029392505050565b5f6200089660ff84168362004e39565b5f6020828403121562004f0b575f80fd5b815167ffffffffffffffff8082111562004f23575f80fd5b818401915084601f83011262004f37575f80fd5b81518181111562004f4c5762004f4c62004c16565b604051601f8201601f19908116603f0116810190838211818310171562004f775762004f7762004c16565b8160405282815287602084870101111562004f90575f80fd5b6200463f836020830160208801620046fe565b5f835162004fb6818460208801620046fe565b7f2f00000000000000000000000000000000000000000000000000000000000000908301908152835162004ff2816001840160208801620046fe565b7f20537461626c65204c500000000000000000000000000000000000000000000060019290910191820152600b01949350505050565b815167ffffffffffffffff81111562005045576200504562004c16565b6200505d8162005056845462004aba565b8462004c43565b602080601f83116001811462005093575f84156200507b5750858301515b5f19600386901b1c1916600185901b17855562003e65565b5f85815260208120601f198616915b82811015620050c357888601518255948401946001909101908401620050a2565b5085821015620050e157878501515f19600388901b60f8161c191681555b5050505050600190811b01905550565b5f845162005104818460208901620046fe565b8451908301906200511a818360208901620046fe565b7f2d000000000000000000000000000000000000000000000000000000000000009101908152835162005155816001840160208801620046fe565b7f2d4c5000000000000000000000000000000000000000000000000000000000006001929091019182015260040195945050505050565b5f83516200519f818460208801620046fe565b7f2f000000000000000000000000000000000000000000000000000000000000009083019081528351620051db816001840160208801620046fe565b7f205632204c50000000000000000000000000000000000000000000000000000060019290910191820152600701949350505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b5f5f19820362005252576200525262004b07565b5060010190565b5f82516200526c818460208701620046fe565b919091019291505056fe60806040526040516106cb3803806106cb8339810160408190526100229161040f565b61002d82825f610034565b5050610530565b61003d836100f1565b6040516001600160a01b038416907f1cf3b03a6cf19fa2baba4df148e9dcabedea7f8a5c07840e207e5c089be95d3e905f90a25f8251118061007c5750805b156100ec576100ea836001600160a01b0316635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156100c0573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906100e491906104ca565b83610273565b505b505050565b6001600160a01b0381163b61015b5760405162461bcd60e51b815260206004820152602560248201527f455243313936373a206e657720626561636f6e206973206e6f74206120636f6e6044820152641d1c9858dd60da1b60648201526084015b60405180910390fd5b6101cd816001600160a01b0316635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561019a573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906101be91906104ca565b6001600160a01b03163b151590565b6102325760405162461bcd60e51b815260206004820152603060248201527f455243313936373a20626561636f6e20696d706c656d656e746174696f6e206960448201526f1cc81b9bdd08184818dbdb9d1c9858dd60821b6064820152608401610152565b7fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d5080546001600160a01b0319166001600160a01b0392909216919091179055565b606061029883836040518060600160405280602781526020016106a46027913961029f565b9392505050565b60605f80856001600160a01b0316856040516102bb91906104e3565b5f60405180830381855af49150503d805f81146102f3576040519150601f19603f3d011682016040523d82523d5f602084013e6102f8565b606091505b50909250905061030a86838387610314565b9695505050505050565b606083156103825782515f0361037b576001600160a01b0385163b61037b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610152565b508161038c565b61038c8383610394565b949350505050565b8151156103a45781518083602001fd5b8060405162461bcd60e51b815260040161015291906104fe565b80516001600160a01b03811681146103d4575f80fd5b919050565b634e487b7160e01b5f52604160045260245ffd5b5f5b838110156104075781810151838201526020016103ef565b50505f910152565b5f8060408385031215610420575f80fd5b610429836103be565b60208401519092506001600160401b0380821115610445575f80fd5b818501915085601f830112610458575f80fd5b81518181111561046a5761046a6103d9565b604051601f8201601f19908116603f01168101908382118183101715610492576104926103d9565b816040528281528860208487010111156104aa575f80fd5b6104bb8360208301602088016103ed565b80955050505050509250929050565b5f602082840312156104da575f80fd5b610298826103be565b5f82516104f48184602087016103ed565b9190910192915050565b602081525f825180602084015261051c8160408501602087016103ed565b601f01601f19169190910160400192915050565b6101678061053d5f395ff3fe60806040523661001357610011610017565b005b6100115b610027610022610029565b6100d9565b565b5f6100687fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d505473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff16635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156100b0573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906100d491906100f7565b905090565b365f80375f80365f845af43d5f803e8080156100f3573d5ff35b3d5ffd5b5f60208284031215610107575f80fd5b815173ffffffffffffffffffffffffffffffffffffffff8116811461012a575f80fd5b939250505056fea2646970667358221220ae401bc4313b5925ef59dc2e72de3b5e5662b84b8f37a8ab9c002d9f2656072364736f6c63430008150033416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220d876d39cf8d989278c724ff956b3617f78b2edf835c7e0acb34413fad44aa05164736f6c63430008150033
Deployed Bytecode
0x608060405234801562000010575f80fd5b506004361062000320575f3560e01c806395d89b4111620001a7578063c47f002711620000ef578063dd62ed3e116200009f578063fd8840fb1162000077578063fd8840fb146200071d578063fecf97341462000727578063fff6cae9146200073e575f80fd5b8063dd62ed3e14620006c1578063ee39e7a014620006fc578063f140a35a1462000706575f80fd5b8063d294f09311620000d3578063d294f093146200068c578063d320273b1462000696578063d505accf14620006aa575f80fd5b8063c47f00271462000661578063d21220a71462000678575f80fd5b8063a9059cbb1162000157578063bf944dbc116200012f578063bf944dbc1462000639578063c245febc1462000643578063c45a0155146200064d575f80fd5b8063a9059cbb1462000601578063b84c82461462000618578063bda39cad146200062f575f80fd5b80639f767c88116200018b5780639f767c8814620005a6578063a1ac4d1314620005c8578063a457c2d714620005ea575f80fd5b806395d89b4114620005705780639d63848a146200057a575f80fd5b806333580959116200026b5780636cc919c8116200021b5780637ecebe0011620001f35780637ecebe00146200050d57806384b0196e146200052457806389afcb441462000543575f80fd5b80636cc919c814620004b25780636d9a640a14620004cb57806370a0823114620004e2575f80fd5b806339509351116200024f5780633950935114620004625780634d5a9f8a14620004795780636a627842146200049b575f80fd5b80633358095914620004445780633644e5151462000458575f80fd5b80631df8c71711620002d357806323b872dd11620002ab57806323b872dd1462000413578063313ce567146200042a57806332c0defd146200043a575f80fd5b80631df8c71714620003d9578063205aabf114620003e357806322be3de11462000405575f80fd5b8063095ea7b31162000307578063095ea7b3146200036c5780630dfe1681146200039457806318160ddd14620003c6575f80fd5b806306fdde0314620003245780630902f1ac1462000346575b5f80fd5b6200032e62000748565b6040516200033d91906200474f565b60405180910390f35b6012546013546014545b604080519384526020840192909252908201526060016200033d565b620003836200037d36600462004778565b620007e0565b60405190151581526020016200033d565b600c54620003ad9061010090046001600160a01b031681565b6040516001600160a01b0390911681526020016200033d565b6002545b6040519081526020016200033d565b62000350620007fb565b620003ca620003f4366004620047a5565b601c6020525f908152604090205481565b600c54620003839060ff1681565b6200038362000424366004620047c3565b62000874565b604051601281526020016200033d565b620003ca60175481565b600f54620003ad906001600160a01b031681565b620003ca6200089d565b620003836200047336600462004778565b620008ad565b620003ca6200048a366004620047a5565b60196020525f908152604090205481565b620003ca620004ac366004620047a5565b620008ef565b620004c9620004c3366004620047a5565b62000d05565b005b620004c9620004dc36600462004806565b62000df9565b620003ca620004f3366004620047a5565b6001600160a01b03165f9081526020819052604090205490565b620003ca6200051e366004620047a5565b62001490565b6200052e620014ae565b6040516200033d97969594939291906200483f565b6200055a62000554366004620047a5565b62001555565b604080519283526020830191909152016200033d565b6200032e62001989565b600c54600d54604080516101009093046001600160a01b0390811684529091166020830152016200033d565b620003ca620005b7366004620047a5565b601b6020525f908152604090205481565b620003ca620005d9366004620047a5565b601a6020525f908152604090205481565b62000383620005fb36600462004778565b6200199a565b620003836200061236600462004778565b62001a56565b620004c962000629366004620048f5565b62001a65565b620003ca60185481565b620003ca60155481565b620003ca60165481565b600e54620003ad906001600160a01b031681565b620004c962000672366004620048f5565b62001b3d565b600d54620003ad906001600160a01b031681565b6200055a62001c09565b601d54620003ad906001600160a01b031681565b620004c9620006bb36600462004975565b62001e08565b620003ca620006d2366004620049e8565b6001600160a01b039182165f90815260016020908152604080832093909416825291909152205490565b620003ca62001f75565b620003ca6200071736600462004a24565b62001f86565b620003ca6200206d565b620004c96200073836600462004a58565b620020f4565b620004c962002707565b6060600a8054620007599062004aba565b80601f0160208091040260200160405190810160405280929190818152602001828054620007879062004aba565b8015620007d65780601f10620007ac57610100808354040283529160200191620007d6565b820191905f5260205f20905b815481529060010190602001808311620007b857829003601f168201915b5050505050905090565b5f33620007ef8185856200287a565b60019150505b92915050565b601554601654425f8080620008196012546013546014549192909190565b9250925092508381146200086c575f62000834828662004b34565b905062000842818562004b4a565b6200084e908862004b64565b96506200085c818462004b4a565b62000868908762004b64565b9550505b505050909192565b5f3362000883858285620029d5565b6200089085858562002a6a565b60019150505b9392505050565b5f620008a862002c69565b905090565b335f8181526001602090815260408083206001600160a01b0387168452909152812054909190620007ef9082908690620008e990879062004b64565b6200287a565b601d54604080517f257840ec00000000000000000000000000000000000000000000000000000000815290515f926001600160a01b03169163257840ec9160048083019260209291908290030181865afa15801562000950573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062000976919062004b7a565b15620009ae576040517f56783e0e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620009b862002d95565b601254601354600c54604080517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290515f9261010090046001600160a01b0316916370a082319160248083019260209291908290030181865afa15801562000a2a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062000a50919062004b98565b600d546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529192505f916001600160a01b03909116906370a0823190602401602060405180830381865afa15801562000ab5573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062000adb919062004b98565b90505f62000aea858462004b34565b90505f62000af9858462004b34565b90505f62000b0660025490565b9050805f0362000c20576103e862000b2962000b23848662004b4a565b62002df0565b62000b35919062004b34565b975062000b4660016103e862002ef1565b600c5460ff161562000c1a5760115462000b6983670de0b6b3a764000062004b4a565b62000b75919062004bdd565b60105462000b8c85670de0b6b3a764000062004b4a565b62000b98919062004bdd565b1462000bd0576040517f0a04d7fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6402540be40062000be2848462002fbf565b1162000c1a576040517f438d3ade00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000c5f565b62000c5c8762000c31838662004b4a565b62000c3d919062004bdd565b8762000c4a848662004b4a565b62000c56919062004bdd565b620030d2565b97505b875f0362000c99576040517fd226f9d400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000ca5898962002ef1565b62000cb385858989620030e9565b604080518481526020810184905233917f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f910160405180910390a25050505050505062000d006001600955565b919050565b62000d1081620031b7565b601d546040517f8321d8c20000000000000000000000000000000000000000000000000000000081526001600160a01b0390911660048201527316b586adf641eb0a94670ac91ff4769ecd3dd43a90638321d8c2906024015f6040518083038186803b15801562000d7f575f80fd5b505af415801562000d92573d5f803e3d5ffd5b5050601d80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0385169081179091556040519092507f70edc3ecaaed82c5ab4a171ac33229a3aa307576b6418dd6551b97da670cf2ad91505f90a250565b601d5f9054906101000a90046001600160a01b03166001600160a01b031663257840ec6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000e4a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062000e70919062004b7a565b1562000ea8576040517f56783e0e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000eb262002d95565b62000ebd81620031b7565b8215801562000eca575081155b1562000f02576040517f42301c2300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b601254601354818510158062000f185750808410155b1562000f50576040517fbb55fd2700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600c54600d545f9182916001600160a01b0361010090920482169190811690871682148062000f905750806001600160a01b0316876001600160a01b0316145b1562000fc8576040517f290fa18800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b881562000fe55762000fe56001600160a01b038316888b620031fb565b87156200100257620010026001600160a01b038216888a620031fb565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa1580156200105e573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062001084919062004b98565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529094506001600160a01b038216906370a0823190602401602060405180830381865afa158015620010e3573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062001109919062004b98565b925050505f87856200111c919062004b34565b83116200112a575f62001142565b62001136888662004b34565b62001142908462004b34565b90505f62001151888662004b34565b83116200115f575f62001177565b6200116b888662004b34565b62001177908462004b34565b90508115801562001186575080155b15620011be576040517f098fb56100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600c54600d54600e546040517fcc56b2c500000000000000000000000000000000000000000000000000000000815230600482015260ff8416151560248201526001600160a01b03610100909404841693928316925f92169063cc56b2c590604401602060405180830381865afa1580156200123c573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062001262919062004b98565b905084156200129057620012906127106200127e838862004b4a565b6200128a919062004bdd565b620032a6565b8315620012bc57620012bc612710620012aa838762004b4a565b620012b6919062004bdd565b6200335a565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b038416906370a0823190602401602060405180830381865afa15801562001318573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906200133e919062004b98565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529097506001600160a01b038316906370a0823190602401602060405180830381865afa1580156200139d573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620013c3919062004b98565b9550620013d1898962002fbf565b620013dd888862002fbf565b101562001416576040517fa932492f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050506200142784848888620030e9565b60408051838152602081018390529081018a9052606081018990526001600160a01b038816907f49926bbebe8474393f434dfa4f78694c0923efa07d19f2284518bfabd06eb7379060800160405180910390a25050505050506200148b6001600955565b505050565b6001600160a01b0381165f90815260076020526040812054620007f5565b5f60608082808083620014e37f0000000000000000000000000000000000000000000000000000000000000000600562003403565b620015107f3100000000000000000000000000000000000000000000000000000000000001600662003403565b604080515f808252602082019092527f0f000000000000000000000000000000000000000000000000000000000000009b939a50919850469750309650945092509050565b5f80601d5f9054906101000a90046001600160a01b03166001600160a01b031663257840ec6040518163ffffffff1660e01b8152600401602060405180830381865afa158015620015a8573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620015ce919062004b7a565b1562001606576040517f56783e0e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200161062002d95565b6200161b83620031b7565b601254601354600c54604080517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290515f9261010090046001600160a01b0316916370a082319160248083019260209291908290030181865afa1580156200168d573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620016b3919062004b98565b600d546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529192505f916001600160a01b03909116906370a0823190602401602060405180830381865afa15801562001718573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906200173e919062004b98565b305f90815260208190526040902054600254919250908062001761858462004b4a565b6200176d919062004bdd565b9750806200177c848462004b4a565b62001788919062004bdd565b965087158062001796575086155b15620017ce576040517f749383ad00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620017da3083620034b1565b600c54620017f89061010090046001600160a01b03168a8a620031fb565b600d5462001811906001600160a01b03168a89620031fb565b600c546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526200192d9161010090046001600160a01b0316906370a0823190602401602060405180830381865afa15801562001879573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906200189f919062004b98565b600d546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015620018ff573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062001925919062004b98565b8888620030e9565b60408051898152602081018990526001600160a01b038b169133917fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496910160405180910390a3505050505050620019846001600955565b915091565b6060600b8054620007599062004aba565b335f8181526001602090815260408083206001600160a01b03871684529091528120549091908381101562001a3c5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f00000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b62001a4b82868684036200287a565b506001949350505050565b5f33620007ef81858562002a6a565b601d546040517ff038621a0000000000000000000000000000000000000000000000000000000081526001600160a01b0390911660048201527316b586adf641eb0a94670ac91ff4769ecd3dd43a9063f038621a906024015f6040518083038186803b15801562001ad4575f80fd5b505af415801562001ae7573d5f803e3d5ffd5b50600b925062001afd9150839050848362004c8c565b507fadf3ae8bd543b3007d464f15cb8ea1db3f44e84d41d203164f40b95e27558ac6828260405162001b3192919062004d55565b60405180910390a15050565b601d546040517ff038621a0000000000000000000000000000000000000000000000000000000081526001600160a01b0390911660048201527316b586adf641eb0a94670ac91ff4769ecd3dd43a9063f038621a906024015f6040518083038186803b15801562001bac575f80fd5b505af415801562001bbf573d5f803e3d5ffd5b50600a925062001bd59150839050848362004c8c565b507f4df9dcd34ae35f40f2c756fd8ac83210ed0b76d065543ee73d868aec7c7fcf02828260405162001b3192919062004d55565b5f8062001c1562002d95565b601d5f9054906101000a90046001600160a01b03166001600160a01b031663257840ec6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562001c66573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062001c8c919062004b7a565b1562001cc4576040517f56783e0e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3362001cd08162003629565b6001600160a01b0381165f90815260196020908152604080832054601a9092529091205490935091508215158062001d0757505f82115b1562001df8576001600160a01b038181165f818152601960209081526040808320839055601a90915280822091909155600f5490517f533cf5ce000000000000000000000000000000000000000000000000000000008152600481019290925260248201869052604482018590529091169063533cf5ce906064015f604051808303815f87803b15801562001d9a575f80fd5b505af115801562001dad573d5f803e3d5ffd5b505060408051868152602081018690526001600160a01b03851693508392507f865ca08d59f5cb456e85cd2f7ef63664ea4f73327414e9d8152c4158b0e94645910160405180910390a35b5062001e046001600955565b9091565b8342111562001e5a5760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e65000000604482015260640162001a33565b5f7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c988888862001e8a8c620038b1565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090505f62001ee682620038d8565b90505f62001ef78287878762003922565b9050896001600160a01b0316816001600160a01b03161462001f5c5760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e61747572650000604482015260640162001a33565b62001f698a8a8a6200287a565b50505050505050505050565b5f620008a860125460135462002fbf565b601254601354600e54600c54604080517fcc56b2c500000000000000000000000000000000000000000000000000000000815230600482015260ff90921615156024830152515f949392612710926001600160a01b039091169163cc56b2c5916044808201926020929091908290030181865afa1580156200200a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062002030919062004b98565b6200203c908762004b4a565b62002048919062004bdd565b62002054908662004b34565b945062002064858584846200394e565b95945050505050565b600f54604080517ffd8840fb00000000000000000000000000000000000000000000000000000000815290515f926001600160a01b03169163fd8840fb9160048083019260209291908290030181865afa158015620020ce573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620008a8919062004b98565b600e546001600160a01b03161562002138576040517f154c51b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600e80547fffffffffffffffffffffffff000000000000000000000000000000000000000016331790556200216d84620031b7565b6200217883620031b7565b600c8054600d80547fffffffffffffffffffffffff00000000000000000000000000000000000000009081166001600160a01b03888116919091179092557fffffffffffffffffffffff000000000000000000000000000000000000000000909216610100888316027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00161784151517909255601d805490911691841691821790556040517f21f8a7210000000000000000000000000000000000000000000000000000000081527f1ea5cc7b31f5ba018100cef63223dd0cc95d5ebd8029e1da1d44c7e0a4fd463660048201525f91906321f8a72190602401602060405180830381865afa1580156200228e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620022b4919062004d83565b90505f620023405f306001600160a01b03165f1b60405180602001620022da90620046f0565b601f1982820381018352601f9091011660408181526001600160a01b0388166020830152808201525f606082015260800160408051601f19818403018152908290526200232b929160200162004da1565b60405160208183030381529060405262003b2b565b6040517fc0c53b8b0000000000000000000000000000000000000000000000000000000081526001600160a01b038881166004830152878116602483015286811660448301529192509082169063c0c53b8b906064015f604051808303815f87803b158015620023ae575f80fd5b505af1158015620023c1573d5f803e3d5ffd5b5050505080600f5f6101000a8154816001600160a01b0302191690836001600160a01b03160217905550856001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801562002428573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906200244e919062004dd3565b6200245b90600a62004eea565b601081905550846001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200249e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620024c4919062004dd3565b620024d190600a62004eea565b6011819055505f866001600160a01b03166395d89b416040518163ffffffff1660e01b81526004015f60405180830381865afa15801562002514573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526200253d919081019062004efa565b90505f866001600160a01b03166395d89b416040518163ffffffff1660e01b81526004015f60405180830381865afa1580156200257c573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052620025a5919081019062004efa565b600c5490915060ff16156200265b578181604051602001620025c992919062004fa3565b604051602081830303815290604052600a9081620025e8919062005028565b506040518060400160405280600781526020017f535441424c452d0000000000000000000000000000000000000000000000000081525082826040516020016200263593929190620050f1565b604051602081830303815290604052600b908162002654919062005028565b50620026fd565b8181604051602001620026709291906200518c565b604051602081830303815290604052600a90816200268f919062005028565b506040518060400160405280600381526020017f56322d00000000000000000000000000000000000000000000000000000000008152508282604051602001620026dc93929190620050f1565b604051602081830303815290604052600b9081620026fb919062005028565b505b5050505050505050565b6200271162002d95565b6002545f036200274d576040517fbb55fd2700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600c546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526200286d9161010090046001600160a01b0316906370a0823190602401602060405180830381865afa158015620027b5573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620027db919062004b98565b600d546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa1580156200283b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062002861919062004b98565b601254601354620030e9565b620028786001600955565b565b6001600160a01b038316620028f75760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f7265737300000000000000000000000000000000000000000000000000000000606482015260840162001a33565b6001600160a01b038216620029755760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f7373000000000000000000000000000000000000000000000000000000000000606482015260840162001a33565b6001600160a01b038381165f8181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038381165f908152600160209081526040808320938616835292905220545f19811462002a64578181101562002a555760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640162001a33565b62002a6484848484036200287a565b50505050565b6001600160a01b03831662002ae85760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f6472657373000000000000000000000000000000000000000000000000000000606482015260840162001a33565b6001600160a01b03821662002b665760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f6573730000000000000000000000000000000000000000000000000000000000606482015260840162001a33565b62002b7383838362003c33565b6001600160a01b0383165f908152602081905260409020548181101562002c035760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e63650000000000000000000000000000000000000000000000000000606482015260840162001a33565b6001600160a01b038481165f81815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a362002a64565b5f306001600160a01b037f000000000000000000000000cf10887fff956a6f5f13a561ee90550c50b67a331614801562002cc257507f00000000000000000000000000000000000000000000000000000000000003e746145b1562002ced57507f4123f687363aff2b32d91129a0ab71e2122f4243b763a70e6470af108d58cd9690565b620008a8604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a08201525f9060c00160405160208183030381529060405280519060200120905090565b60026009540362002de95760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640162001a33565b6002600955565b5f815f0362002e0057505f919050565b5f600162002e0e8462003c49565b901c6001901b9050600181848162002e2a5762002e2a62004bb0565b048201901c9050600181848162002e455762002e4562004bb0565b048201901c9050600181848162002e605762002e6062004bb0565b048201901c9050600181848162002e7b5762002e7b62004bb0565b048201901c9050600181848162002e965762002e9662004bb0565b048201901c9050600181848162002eb15762002eb162004bb0565b048201901c9050600181848162002ecc5762002ecc62004bb0565b048201901c9050620008968182858162002eea5762002eea62004bb0565b04620030d2565b6001600160a01b03821662002f495760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640162001a33565b62002f565f838362003c33565b8060025f82825462002f69919062004b64565b90915550506001600160a01b0382165f81815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b600c545f9060ff1615620030be576010545f9062002fe685670de0b6b3a764000062004b4a565b62002ff2919062004bdd565b90505f60115484670de0b6b3a76400006200300e919062004b4a565b6200301a919062004bdd565b90505f670de0b6b3a764000062003032838562004b4a565b6200303e919062004bdd565b90505f670de0b6b3a764000062003056848062004b4a565b62003062919062004bdd565b670de0b6b3a764000062003077868062004b4a565b62003083919062004bdd565b6200308f919062004b64565b9050670de0b6b3a7640000620030a6828462004b4a565b620030b2919062004bdd565b945050505050620007f5565b620030ca828462004b4a565b9050620007f5565b5f818310620030e2578162000896565b5090919050565b60145442905f90620030fc908362004b34565b90505f811180156200310d57508315155b80156200311957508215155b1562003167576200312b818562004b4a565b60155f8282546200313d919062004b64565b909155506200314f9050818462004b4a565b60165f82825462003161919062004b64565b90915550505b60128690556013859055601482905560408051878152602081018790527fcf2aa50876cdfbb541206f89af0ee78d44a2abf8d328e37fa4917f982149848a910160405180910390a1505050505050565b6001600160a01b038116620031f8576040517f8579befe00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50565b6040516001600160a01b0383166024820152604481018290526200148b9084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915262003ce4565b805f03620032b15750565b600c54620032ce9061010090046001600160a01b03168262003dd1565b5f620032d960025490565b620032ed83670de0b6b3a764000062004b4a565b620032f9919062004bdd565b905080156200331b578060175f82825462003315919062004b64565b90915550505b604080518381525f602082015233917f112c256902bf554b6ed882d2936687aaeb4225e8cd5b51303c90ca6cf43a860291015b60405180910390a25050565b805f03620033655750565b600d546200337d906001600160a01b03168262003dd1565b5f6200338860025490565b6200339c83670de0b6b3a764000062004b4a565b620033a8919062004bdd565b90508015620033ca578060185f828254620033c4919062004b64565b90915550505b604080515f81526020810184905233917f112c256902bf554b6ed882d2936687aaeb4225e8cd5b51303c90ca6cf43a860291016200334e565b606060ff83146200341957620030ca8362003e6d565b818054620034279062004aba565b80601f0160208091040260200160405190810160405280929190818152602001828054620034559062004aba565b8015620034a45780601f106200347a57610100808354040283529160200191620034a4565b820191905f5260205f20905b8154815290600101906020018083116200348657829003601f168201915b50505050509050620007f5565b6001600160a01b0382166200352f5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f7300000000000000000000000000000000000000000000000000000000000000606482015260840162001a33565b6200353c825f8362003c33565b6001600160a01b0382165f9081526020819052604090205481811015620035cc5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f6365000000000000000000000000000000000000000000000000000000000000606482015260840162001a33565b6001600160a01b0383165f818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3505050565b6001600160a01b0381165f90815260208190526040902054801562003880576001600160a01b0382165f908152601b602090815260408083208054601c80855292852080546017546018549481905594909552829055936200368c858462004b34565b90505f6200369b858462004b34565b905081156200378a575f670de0b6b3a7640000620036ba848a62004b4a565b620036c6919062004bdd565b9050612710600f5f9054906101000a90046001600160a01b03166001600160a01b031663fd8840fb6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200371c573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062003742919062004b98565b6200374e908362004b4a565b6200375a919062004bdd565b6001600160a01b038a165f90815260196020526040812080549091906200378390849062004b64565b9091555050505b8015620026fd575f670de0b6b3a7640000620037a7838a62004b4a565b620037b3919062004bdd565b9050612710600f5f9054906101000a90046001600160a01b03166001600160a01b031663fd8840fb6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562003809573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906200382f919062004b98565b6200383b908362004b4a565b62003847919062004bdd565b6001600160a01b038a165f908152601a6020526040812080549091906200387090849062004b64565b9091555050505050505050505050565b6017546001600160a01b0383165f908152601b6020908152604080832093909355601854601c909152919020555050565b6001600160a01b0381165f9081526007602052604090208054600181018255905b50919050565b5f620007f5620038e762002c69565b836040517f19010000000000000000000000000000000000000000000000000000000000008152600281019290925260228201526042902090565b5f805f620039338787878762003eac565b91509150620039428162003f6e565b5090505b949350505050565b600c545f9060ff161562003ace575f62003969848462002fbf565b6010549091506200398385670de0b6b3a764000062004b4a565b6200398f919062004bdd565b601154909450620039a984670de0b6b3a764000062004b4a565b620039b5919062004bdd565b600c549093505f9081906001600160a01b038881166101009092041614620039df578486620039e2565b85855b600c5491935091506001600160a01b03888116610100909204161462003a2b5760115462003a1989670de0b6b3a764000062004b4a565b62003a25919062004bdd565b62003a4e565b60105462003a4289670de0b6b3a764000062004b4a565b62003a4e919062004bdd565b97505f62003a6962003a61848b62004b64565b8584620040e5565b62003a75908362004b34565b600c54909150670de0b6b3a7640000906001600160a01b038a8116610100909204161462003aa65760105462003aaa565b6011545b62003ab6908362004b4a565b62003ac2919062004bdd565b94505050505062003946565b600c545f9081906001600160a01b03878116610100909204161462003af557838562003af8565b84845b909250905062003b09878362004b64565b62003b15828962004b4a565b62003b21919062004bdd565b9250505062003946565b5f8347101562003b7e5760405162461bcd60e51b815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e6365000000604482015260640162001a33565b81515f0362003bd05760405162461bcd60e51b815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f604482015260640162001a33565b8282516020840186f590506001600160a01b038116620008965760405162461bcd60e51b815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f7900000000000000604482015260640162001a33565b62003c3e8362003629565b6200148b8262003629565b5f80608083901c1562003c5e57608092831c92015b604083901c1562003c7157604092831c92015b602083901c1562003c8457602092831c92015b601083901c1562003c9757601092831c92015b600883901c1562003caa57600892831c92015b600483901c1562003cbd57600492831c92015b600283901c1562003cd057600292831c92015b600183901c15620007f55760010192915050565b5f62003d3a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316620042899092919063ffffffff16565b905080515f148062003d5d57508080602001905181019062003d5d919062004b7a565b6200148b5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840162001a33565b600f5462003ded906001600160a01b0384811691168362004299565b600f546040517f2ec0ff6c0000000000000000000000000000000000000000000000000000000081526001600160a01b0384811660048301526024820184905290911690632ec0ff6c906044015f604051808303815f87803b15801562003e52575f80fd5b505af115801562003e65573d5f803e3d5ffd5b505050505050565b60605f62003e7b83620043ed565b6040805160208082528183019092529192505f91906020820181803683375050509182525060208101929092525090565b5f807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111562003ee357505f9050600362003f65565b604080515f8082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa15801562003f35573d5f803e3d5ffd5b5050604051601f1901519150506001600160a01b03811662003f5f575f6001925092505062003f65565b91505f90505b94509492505050565b5f81600481111562003f845762003f8462005211565b0362003f8d5750565b600181600481111562003fa45762003fa462005211565b0362003ff35760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015260640162001a33565b60028160048111156200400a576200400a62005211565b03620040595760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015260640162001a33565b600381600481111562004070576200407062005211565b03620031f85760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f7565000000000000000000000000000000000000000000000000000000000000606482015260840162001a33565b5f805b60ff81101562004256575f620040ff86856200442e565b905084811015620041b2575f620041178786620044c5565b62004123838862004b34565b6200413790670de0b6b3a764000062004b4a565b62004143919062004bdd565b9050805f036200419d57858203620041615784935050505062000896565b856200417a886200417488600162004b64565b62002fbf565b111562004199576200418e85600162004b64565b935050505062000896565b5060015b620041a9818662004b64565b94505062004240565b5f620041bf8786620044c5565b620041cb878462004b34565b620041df90670de0b6b3a764000062004b4a565b620041eb919062004bdd565b9050805f036200423057858214806200421a57508562004218886200421260018962004b34565b6200442e565b105b156200422c5784935050505062000896565b5060015b6200423c818662004b34565b9450505b50806200424d816200523e565b915050620040e8565b506040517f45b3fe4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60606200394684845f8562004554565b8015806200432e57506040517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa15801562004306573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906200432c919062004b98565b155b620043a25760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e636500000000000000000000606482015260840162001a33565b6040516001600160a01b0383166024820152604481018290526200148b9084907f095ea7b3000000000000000000000000000000000000000000000000000000009060640162003241565b5f60ff8216601f811115620007f5576040517fb3512b0c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f80670de0b6b3a764000062004445848662004b4a565b62004451919062004bdd565b90505f670de0b6b3a764000062004469858062004b4a565b62004475919062004bdd565b670de0b6b3a76400006200448a878062004b4a565b62004496919062004bdd565b620044a2919062004b64565b9050670de0b6b3a7640000620044b9828462004b4a565b62002064919062004bdd565b5f670de0b6b3a76400008381620044dd828062004b4a565b620044e9919062004bdd565b620044f5919062004b4a565b62004501919062004bdd565b670de0b6b3a76400008062004517858062004b4a565b62004523919062004bdd565b6200453086600362004b4a565b6200453c919062004b4a565b62004548919062004bdd565b62000896919062004b64565b606082471015620045ce5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c0000000000000000000000000000000000000000000000000000606482015260840162001a33565b5f80866001600160a01b03168587604051620045eb919062005259565b5f6040518083038185875af1925050503d805f811462004627576040519150601f19603f3d011682016040523d82523d5f602084013e6200462c565b606091505b50915091506200463f878383876200464a565b979650505050505050565b60608315620046bd5782515f03620046b5576001600160a01b0385163b620046b55760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640162001a33565b508162003946565b620039468383815115620046d45781518083602001fd5b8060405162461bcd60e51b815260040162001a3391906200474f565b6106cb806200527783390190565b5f5b838110156200471a57818101518382015260200162004700565b50505f910152565b5f81518084526200473b816020860160208601620046fe565b601f01601f19169290920160200192915050565b602081525f62000896602083018462004722565b6001600160a01b0381168114620031f8575f80fd5b5f80604083850312156200478a575f80fd5b8235620047978162004763565b946020939093013593505050565b5f60208284031215620047b6575f80fd5b8135620008968162004763565b5f805f60608486031215620047d6575f80fd5b8335620047e38162004763565b92506020840135620047f58162004763565b929592945050506040919091013590565b5f805f6060848603121562004819575f80fd5b83359250602084013591506040840135620048348162004763565b809150509250925092565b7fff00000000000000000000000000000000000000000000000000000000000000881681525f602060e0818401526200487c60e084018a62004722565b838103604085015262004890818a62004722565b606085018990526001600160a01b038816608086015260a0850187905284810360c086015285518082528387019250908301905f5b81811015620048e357835183529284019291840191600101620048c5565b50909c9b505050505050505050505050565b5f806020838503121562004907575f80fd5b823567ffffffffffffffff808211156200491f575f80fd5b818501915085601f83011262004933575f80fd5b81358181111562004942575f80fd5b86602082850101111562004954575f80fd5b60209290920196919550909350505050565b60ff81168114620031f8575f80fd5b5f805f805f805f60e0888a0312156200498c575f80fd5b8735620049998162004763565b96506020880135620049ab8162004763565b955060408801359450606088013593506080880135620049cb8162004966565b9699959850939692959460a0840135945060c09093013592915050565b5f8060408385031215620049fa575f80fd5b823562004a078162004763565b9150602083013562004a198162004763565b809150509250929050565b5f806040838503121562004a36575f80fd5b82359150602083013562004a198162004763565b8015158114620031f8575f80fd5b5f805f806080858703121562004a6c575f80fd5b843562004a798162004763565b9350602085013562004a8b8162004763565b9250604085013562004a9d8162004763565b9150606085013562004aaf8162004a4a565b939692955090935050565b600181811c9082168062004acf57607f821691505b602082108103620038d2577f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b81810381811115620007f557620007f562004b07565b8082028115828204841417620007f557620007f562004b07565b80820180821115620007f557620007f562004b07565b5f6020828403121562004b8b575f80fd5b8151620008968162004a4a565b5f6020828403121562004ba9575f80fd5b5051919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f8262004c11577f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b500490565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b601f8211156200148b575f81815260208120601f850160051c8101602086101562004c6b5750805b601f850160051c820191505b8181101562003e655782815560010162004c77565b67ffffffffffffffff83111562004ca75762004ca762004c16565b62004cbf8362004cb8835462004aba565b8362004c43565b5f601f84116001811462004cf3575f851562004cdb5750838201355b5f19600387901b1c1916600186901b17835562004d4e565b5f83815260209020601f19861690835b8281101562004d25578685013582556020948501946001909201910162004d03565b508682101562004d42575f1960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b60208152816020820152818360408301375f818301604090810191909152601f909201601f19160101919050565b5f6020828403121562004d94575f80fd5b8151620008968162004763565b5f835162004db4818460208801620046fe565b83519083019062004dca818360208801620046fe565b01949350505050565b5f6020828403121562004de4575f80fd5b8151620008968162004966565b600181815b8085111562004e3157815f190482111562004e155762004e1562004b07565b8085161562004e2357918102915b93841c939080029062004df6565b509250929050565b5f8262004e4957506001620007f5565b8162004e5757505f620007f5565b816001811462004e70576002811462004e7b5762004e9b565b6001915050620007f5565b60ff84111562004e8f5762004e8f62004b07565b50506001821b620007f5565b5060208310610133831016604e8410600b841016171562004ec0575081810a620007f5565b62004ecc838362004df1565b805f190482111562004ee25762004ee262004b07565b029392505050565b5f6200089660ff84168362004e39565b5f6020828403121562004f0b575f80fd5b815167ffffffffffffffff8082111562004f23575f80fd5b818401915084601f83011262004f37575f80fd5b81518181111562004f4c5762004f4c62004c16565b604051601f8201601f19908116603f0116810190838211818310171562004f775762004f7762004c16565b8160405282815287602084870101111562004f90575f80fd5b6200463f836020830160208801620046fe565b5f835162004fb6818460208801620046fe565b7f2f00000000000000000000000000000000000000000000000000000000000000908301908152835162004ff2816001840160208801620046fe565b7f20537461626c65204c500000000000000000000000000000000000000000000060019290910191820152600b01949350505050565b815167ffffffffffffffff81111562005045576200504562004c16565b6200505d8162005056845462004aba565b8462004c43565b602080601f83116001811462005093575f84156200507b5750858301515b5f19600386901b1c1916600185901b17855562003e65565b5f85815260208120601f198616915b82811015620050c357888601518255948401946001909101908401620050a2565b5085821015620050e157878501515f19600388901b60f8161c191681555b5050505050600190811b01905550565b5f845162005104818460208901620046fe565b8451908301906200511a818360208901620046fe565b7f2d000000000000000000000000000000000000000000000000000000000000009101908152835162005155816001840160208801620046fe565b7f2d4c5000000000000000000000000000000000000000000000000000000000006001929091019182015260040195945050505050565b5f83516200519f818460208801620046fe565b7f2f000000000000000000000000000000000000000000000000000000000000009083019081528351620051db816001840160208801620046fe565b7f205632204c50000000000000000000000000000000000000000000000000000060019290910191820152600701949350505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b5f5f19820362005252576200525262004b07565b5060010190565b5f82516200526c818460208701620046fe565b919091019291505056fe60806040526040516106cb3803806106cb8339810160408190526100229161040f565b61002d82825f610034565b5050610530565b61003d836100f1565b6040516001600160a01b038416907f1cf3b03a6cf19fa2baba4df148e9dcabedea7f8a5c07840e207e5c089be95d3e905f90a25f8251118061007c5750805b156100ec576100ea836001600160a01b0316635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156100c0573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906100e491906104ca565b83610273565b505b505050565b6001600160a01b0381163b61015b5760405162461bcd60e51b815260206004820152602560248201527f455243313936373a206e657720626561636f6e206973206e6f74206120636f6e6044820152641d1c9858dd60da1b60648201526084015b60405180910390fd5b6101cd816001600160a01b0316635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561019a573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906101be91906104ca565b6001600160a01b03163b151590565b6102325760405162461bcd60e51b815260206004820152603060248201527f455243313936373a20626561636f6e20696d706c656d656e746174696f6e206960448201526f1cc81b9bdd08184818dbdb9d1c9858dd60821b6064820152608401610152565b7fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d5080546001600160a01b0319166001600160a01b0392909216919091179055565b606061029883836040518060600160405280602781526020016106a46027913961029f565b9392505050565b60605f80856001600160a01b0316856040516102bb91906104e3565b5f60405180830381855af49150503d805f81146102f3576040519150601f19603f3d011682016040523d82523d5f602084013e6102f8565b606091505b50909250905061030a86838387610314565b9695505050505050565b606083156103825782515f0361037b576001600160a01b0385163b61037b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610152565b508161038c565b61038c8383610394565b949350505050565b8151156103a45781518083602001fd5b8060405162461bcd60e51b815260040161015291906104fe565b80516001600160a01b03811681146103d4575f80fd5b919050565b634e487b7160e01b5f52604160045260245ffd5b5f5b838110156104075781810151838201526020016103ef565b50505f910152565b5f8060408385031215610420575f80fd5b610429836103be565b60208401519092506001600160401b0380821115610445575f80fd5b818501915085601f830112610458575f80fd5b81518181111561046a5761046a6103d9565b604051601f8201601f19908116603f01168101908382118183101715610492576104926103d9565b816040528281528860208487010111156104aa575f80fd5b6104bb8360208301602088016103ed565b80955050505050509250929050565b5f602082840312156104da575f80fd5b610298826103be565b5f82516104f48184602087016103ed565b9190910192915050565b602081525f825180602084015261051c8160408501602087016103ed565b601f01601f19169190910160400192915050565b6101678061053d5f395ff3fe60806040523661001357610011610017565b005b6100115b610027610022610029565b6100d9565b565b5f6100687fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d505473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff16635c60da1b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156100b0573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906100d491906100f7565b905090565b365f80375f80365f845af43d5f803e8080156100f3573d5ff35b3d5ffd5b5f60208284031215610107575f80fd5b815173ffffffffffffffffffffffffffffffffffffffff8116811461012a575f80fd5b939250505056fea2646970667358221220ae401bc4313b5925ef59dc2e72de3b5e5662b84b8f37a8ab9c002d9f2656072364736f6c63430008150033416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220d876d39cf8d989278c724ff956b3617f78b2edf835c7e0acb34413fad44aa05164736f6c63430008150033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in HYPE
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.