Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- PassTokenFactory
- Optimization enabled
- true
- Compiler version
- v0.8.19+commit.7dd6d404
- Optimization runs
- 200
- EVM Version
- default
- Verified at
- 2024-01-09T01:51:31.733477Z
contracts/PassTokenFactory.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.0;
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import {IERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import {ECDSAUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
import {SafeMathUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol";
import {AddressUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import {BlockContext} from "./base/BlockContext.sol";
import {Multicall} from "./base/Multicall.sol";
import {PassTokenProxy} from "./PassTokenProxy.sol";
import {IPassTokenFactory} from "./interfaces/IPassTokenFactory.sol";
import {PassTokenFactoryStorage} from "./storage/PassTokenFactoryStorage.sol";
import {IPassToken} from "./interfaces/IPassToken.sol";
import {IAlphaGovernorFactory} from "./interfaces/IAlphaGovernorFactory.sol";
import {INonfungiblePositionManager} from "./interfaces/INonfungiblePositionManager.sol";
contract PassTokenFactory is
IPassTokenFactory,
BlockContext,
Multicall,
OwnableUpgradeable,
ReentrancyGuardUpgradeable,
PassTokenFactoryStorage
{
//
using AddressUpgradeable for address;
//
modifier onlyAdmin() {
require(_msgSender() == _admin, "PTF_NA");
_;
}
modifier onlyToken(address token) {
require(token != address(0), "PTF_TZ");
require((_tokenTwitters[token] > 0), "PTF_BT");
_;
}
modifier onlyTwitterId(uint256 twitterId) {
require(twitterId > 0, "PTF_TZ");
require((_twitterTokens[twitterId] != address(0)), "PTF_BTI");
_;
}
modifier notContract() {
// caller is contract
require(!_msgSender().isContract(), "PTF_CIC");
_;
}
function initialize(
address alphaKeysFactory,
address nonfungiblePositionManager,
address swapRouter
) external initializer {
__Ownable_init();
__ReentrancyGuard_init();
//
_admin = _msgSender();
_alphaKeysFactory = alphaKeysFactory;
//
_nonfungiblePositionManager = nonfungiblePositionManager;
_uniswapV3Factory = INonfungiblePositionManager(
nonfungiblePositionManager
).factory();
_swapRouter = swapRouter;
//
}
function getPassTokenImplementation()
external
view
override
returns (address)
{
return _passTokenImplementation;
}
function setPassTokenImplementation(
address passTokenImplementation
) external onlyOwner {
_passTokenImplementation = passTokenImplementation;
}
function setAdmin(address admin) external onlyOwner {
_admin = admin;
}
function getAdmin() external view returns (address) {
return _admin;
}
function setAlphaGovernorFactory(
address alphaGovernorFactory
) external onlyOwner {
_alphaGovernorFactory = alphaGovernorFactory;
}
function getAlphaGovernorFactory() external view returns (address) {
return _alphaGovernorFactory;
}
function getTwitterToken(uint256 twitterId) public view returns (address) {
return _twitterTokens[twitterId];
}
function getTokenTwitter(address token) public view returns (uint256) {
return _tokenTwitters[token];
}
function getAlphaKeysFactory() external view returns (address) {
return _alphaKeysFactory;
}
function getPassTokenStaking() external view override returns (address) {
return _passTokenStaking;
}
function setPassTokenStaking(address passTokenStaking) external onlyOwner {
_passTokenStaking = passTokenStaking;
}
function getNonfungiblePositionManager()
external
view
override
returns (address)
{
return _nonfungiblePositionManager;
}
function setNonfungiblePositionManager(
address nonfungiblePositionManager
) external onlyOwner {
_nonfungiblePositionManager = nonfungiblePositionManager;
_uniswapV3Factory = INonfungiblePositionManager(
nonfungiblePositionManager
).factory();
}
function getSwapRouter() external view override returns (address) {
return _swapRouter;
}
function setSwapRouter(address swapRouter) external onlyOwner {
_swapRouter = swapRouter;
}
function getUniswapV3Factory() external view override returns (address) {
return _uniswapV3Factory;
}
function getTokenGovernor(
address token
) external view override returns (address) {
uint256 twitterId = _tokenTwitters[token];
return
IAlphaGovernorFactory(_alphaGovernorFactory).getTwitterGovernor(
twitterId
);
}
function getPassTokenAirdropPool()
external
view
override
returns (address)
{
return _passTokenAirdropPool;
}
function setPassTokenAirdropPool(
address passTokenAirdropPool
) external onlyOwner {
_passTokenAirdropPool = passTokenAirdropPool;
}
function getPassTokenReferralPool() external view returns (address) {
return _passTokenReferralPool;
}
function setPassTokenReferralPool(
address passTokenReferralPool
) external onlyOwner {
_passTokenReferralPool = passTokenReferralPool;
}
function createPassTokenForTwitter(
uint256 twitterId,
string calldata name,
string calldata symbol
) external nonReentrant onlyAdmin {
//
require(twitterId > 0, "PTF_TZV");
require(_twitterTokens[twitterId] == address(0), "PTF_TTNZA");
//
IPassToken token = IPassToken(address(new PassTokenProxy()));
//
token.initialize(address(this), name, symbol, twitterId);
//
_twitterTokens[twitterId] = address(token);
_tokenTwitters[address(token)] = twitterId;
//
emit PassTokenCreated(twitterId, address(token));
}
}
@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol
// 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 MathUpgradeable {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// 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);
}
}
}
contracts/interfaces/IAlphaGovernorFactoryImpl.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.0;
interface IAlphaGovernorFactoryImpl {
function getGovernorImplementation() external view returns (address);
}
@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
function __Ownable_init() internal onlyInitializing {
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal onlyInitializing {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}
@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol
// 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;
}
}
@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol
// 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;
}
@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol
// 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 IERC20Upgradeable {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol
// 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);
}
}
}
@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}
@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/MathUpgradeable.sol";
import "./math/SignedMathUpgradeable.sol";
/**
* @dev String operations.
*/
library StringsUpgradeable {
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 = MathUpgradeable.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(SignedMathUpgradeable.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, MathUpgradeable.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));
}
}
@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.0;
import "../StringsUpgradeable.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 ECDSAUpgradeable {
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", StringsUpgradeable.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));
}
}
@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/SafeMath.sol)
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/
library SafeMathUpgradeable {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
@openzeppelin/contracts-upgradeable/utils/math/SignedMathUpgradeable.sol
// 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 SignedMathUpgradeable {
/**
* @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);
}
}
}
@openzeppelin/contracts/proxy/Proxy.sol
// 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 {}
}
contracts/PassTokenProxy.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
import {Proxy} from "@openzeppelin/contracts/proxy/Proxy.sol";
import {IPassTokenFactoryImpl} from "./interfaces/IPassTokenFactoryImpl.sol";
/**
* @title AlphaKeysTokenProxy
* @author 0xkongamoto
*/
contract PassTokenProxy is Proxy {
//
IPassTokenFactoryImpl public immutable factory;
// ======== Constructor =========
constructor() {
factory = IPassTokenFactoryImpl(msg.sender);
}
/**
* @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
override
returns (address impl)
{
return factory.getPassTokenImplementation();
}
}
contracts/base/BlockContext.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.0;
abstract contract BlockContext {
function _blockTimestamp() internal view virtual returns (uint256) {
// Reply from Arbitrum
// block.timestamp returns timestamp at the time at which the sequencer receives the tx.
// It may not actually correspond to a particular L1 block
return block.timestamp;
}
function _blockNumber() internal view virtual returns (uint256) {
return block.number;
}
}
contracts/base/Multicall.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >0.8.0;
/// @title Multicall
/// @notice Enables calling multiple methods in a single call to the contract
abstract contract Multicall {
function multicall(
bytes[] calldata data
) public payable returns (bytes[] memory results) {
results = new bytes[](data.length);
for (uint256 i = 0; i < data.length; i++) {
(bool success, bytes memory result) = address(this).delegatecall(
data[i]
);
if (!success) {
// Next 5 lines from https://ethereum.stackexchange.com/a/83577
if (result.length < 68) revert();
assembly {
result := add(result, 0x04)
}
revert(abi.decode(result, (string)));
}
results[i] = result;
}
}
}
contracts/interfaces/IAlphaGovernorFactory.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.0;
import {IAlphaGovernorFactoryImpl} from "./IAlphaGovernorFactoryImpl.sol";
interface IAlphaGovernorFactory is IAlphaGovernorFactoryImpl {
//
event GovernorCreated(uint256 indexed twitterId, address indexed governor);
//
function getTwitterGovernor(
uint256 twitterId
) external view returns (address);
}
contracts/interfaces/INonfungiblePositionManager.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.8.0;
/// @title Non-fungible token for positions
/// @notice Wraps Uniswap V3 positions in a non-fungible token interface which allows for them to be transferred
/// and authorized.
interface INonfungiblePositionManager {
function WTC() external view returns (address);
function factory() external view returns (address);
struct MintParams {
address token0;
address token1;
uint24 fee;
int24 tickLower;
int24 tickUpper;
uint256 amount0Desired;
uint256 amount1Desired;
uint256 amount0Min;
uint256 amount1Min;
address recipient;
uint256 deadline;
}
function mint(
MintParams calldata params
)
external
payable
returns (
uint256 tokenId,
uint128 liquidity,
uint256 amount0,
uint256 amount1
);
function createAndInitializePoolIfNecessary(
address token0,
address token1,
uint24 fee,
uint160 sqrtPriceX96
) external payable returns (address pool);
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
struct DecreaseLiquidityParams {
uint256 tokenId;
uint128 liquidity;
uint256 amount0Min;
uint256 amount1Min;
uint256 deadline;
}
function positions(
uint256 tokenId
)
external
view
returns (
uint96 nonce,
address operator,
address token0,
address token1,
uint24 fee,
int24 tickLower,
int24 tickUpper,
uint128 liquidity,
uint256 feeGrowthInside0LastX128,
uint256 feeGrowthInside1LastX128,
uint128 tokensOwed0,
uint128 tokensOwed1
);
struct IncreaseLiquidityParams {
uint256 tokenId;
uint256 amount0Desired;
uint256 amount1Desired;
uint256 amount0Min;
uint256 amount1Min;
uint256 deadline;
}
function increaseLiquidity(
IncreaseLiquidityParams calldata params
)
external
payable
returns (uint128 liquidity, uint256 amount0, uint256 amount1);
function decreaseLiquidity(
DecreaseLiquidityParams calldata params
) external payable returns (uint256 amount0, uint256 amount1);
struct CollectParams {
uint256 tokenId;
address recipient;
uint128 amount0Max;
uint128 amount1Max;
}
function collect(
CollectParams calldata params
) external payable returns (uint256 amount0, uint256 amount1);
function unwrapWTC(
uint256 amountMinimum,
address recipient
) external payable;
function sweepToken(
address token,
uint256 amountMinimum,
address recipient
) external payable;
function refundTC() external payable;
function burn(uint256 tokenId) external payable;
}
contracts/interfaces/IPassToken.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.0;
interface IPassToken {
//
event FeeEarned(address creator, uint256 amountToken, uint256 amountBTC);
event LockedTs(
address user,
uint256 amount,
uint256 duationTs,
uint256 expiredTs
);
event FundDeposited(
address trader,
uint256 amountBTC,
uint256 balanceBTCUser,
uint256 balanceBTC
);
event FundClaimed(
address trader,
uint256 balanceBTCUser,
uint256 balanceToken,
uint256 balanceClaimedBTC,
uint256 balanceClaimedToken
);
event FundEnded(uint256 balanceBTC, uint256 balanceToken);
event TokenClaimed(address creator, address token, uint256 amount);
event Tokenomic(uint version);
//
function initialize(
address factory,
string calldata name,
string calldata symbol,
uint256 twitterId
) external;
function getCreator() external view returns (address);
function getPoolV3() external view returns (address);
function getCreatedTimestamp() external view returns (uint256);
function airdropToUser(address user, uint256 amount) external;
function referralToUser(address user, uint256 amount) external;
}
contracts/interfaces/IPassTokenFactory.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.0;
import {IPassTokenFactoryImpl} from "./IPassTokenFactoryImpl.sol";
interface IPassTokenFactory is IPassTokenFactoryImpl {
//
event PassTokenCreated(uint256 twitterId, address token);
//
function getTwitterToken(uint256 twitterId) external view returns (address);
function getTokenTwitter(address token) external view returns (uint256);
function getAlphaKeysFactory() external view returns (address);
function getNonfungiblePositionManager() external view returns (address);
function getSwapRouter() external view returns (address);
function getUniswapV3Factory() external view returns (address);
function getPassTokenStaking() external view returns (address);
function getTokenGovernor(address token) external view returns (address);
function getPassTokenAirdropPool() external view returns (address);
function getPassTokenReferralPool() external view returns (address);
}
contracts/interfaces/IPassTokenFactoryImpl.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.0;
interface IPassTokenFactoryImpl {
function getPassTokenImplementation()
external
view
returns (address);
}
contracts/storage/PassTokenFactoryStorage.sol
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.0;
abstract contract PassTokenFactoryStorage {
//
address internal _passTokenImplementation;
//
address internal _admin;
//
address internal _alphaKeysFactory;
address internal _nonfungiblePositionManager;
address internal _uniswapV3Factory;
address internal _swapRouter;
address internal _passTokenStaking;
//
mapping(uint256 => address) internal _twitterTokens;
mapping(address => uint256) internal _tokenTwitters;
//
address internal _alphaGovernorFactory;
//
address internal _passTokenAirdropPool;
address internal _passTokenReferralPool;
}
Compiler Settings
{"viaIR":true,"outputSelection":{"*":{"*":["*"],"":["*"]}},"optimizer":{"runs":200,"enabled":true},"libraries":{}}
Contract ABI
[{"type":"event","name":"Initialized","inputs":[{"type":"uint8","name":"version","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"PassTokenCreated","inputs":[{"type":"uint256","name":"twitterId","internalType":"uint256","indexed":false},{"type":"address","name":"token","internalType":"address","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"createPassTokenForTwitter","inputs":[{"type":"uint256","name":"twitterId","internalType":"uint256"},{"type":"string","name":"name","internalType":"string"},{"type":"string","name":"symbol","internalType":"string"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getAdmin","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getAlphaGovernorFactory","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getAlphaKeysFactory","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getNonfungiblePositionManager","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getPassTokenAirdropPool","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getPassTokenImplementation","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getPassTokenReferralPool","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getPassTokenStaking","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getSwapRouter","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getTokenGovernor","inputs":[{"type":"address","name":"token","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getTokenTwitter","inputs":[{"type":"address","name":"token","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getTwitterToken","inputs":[{"type":"uint256","name":"twitterId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getUniswapV3Factory","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"alphaKeysFactory","internalType":"address"},{"type":"address","name":"nonfungiblePositionManager","internalType":"address"},{"type":"address","name":"swapRouter","internalType":"address"}]},{"type":"function","stateMutability":"payable","outputs":[{"type":"bytes[]","name":"results","internalType":"bytes[]"}],"name":"multicall","inputs":[{"type":"bytes[]","name":"data","internalType":"bytes[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setAdmin","inputs":[{"type":"address","name":"admin","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setAlphaGovernorFactory","inputs":[{"type":"address","name":"alphaGovernorFactory","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setNonfungiblePositionManager","inputs":[{"type":"address","name":"nonfungiblePositionManager","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setPassTokenAirdropPool","inputs":[{"type":"address","name":"passTokenAirdropPool","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setPassTokenImplementation","inputs":[{"type":"address","name":"passTokenImplementation","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setPassTokenReferralPool","inputs":[{"type":"address","name":"passTokenReferralPool","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setPassTokenStaking","inputs":[{"type":"address","name":"passTokenStaking","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setSwapRouter","inputs":[{"type":"address","name":"swapRouter","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]}]
Contract Creation Code
0x608080604052346100165761151e908161001c8239f35b600080fdfe6080604052600436101561001257600080fd5b60003560e01c80630a576b62146101c75780631e6a721b146101c25780632715812d146101bd57806341273657146101b857806343503b13146101b3578063498d5f8c146101ae5780634c28c89a146101a95780636e9960c3146101a4578063704b6c021461019f578063715018a61461019a578063725c9c491461019557806375683a9f1461019057806382ff8ba71461018b5780638428f72f146101865780638da5cb5b146101815780639e5d38011461017c578063a5af02b714610177578063ac9650d814610172578063b081983b1461016d578063c0c53b8b14610168578063c8296dd514610163578063cb8451ef1461015e578063e066dbfc14610159578063e69be31714610154578063ed1c07f91461014f578063f2fde38b1461014a5763f8b0a90f1461014557600080fd5b610d67565b610cd4565b610a96565b610a21565b6109da565b61093c565b610913565b61080d565b6107e4565b6106dd565b61060a565b6105e1565b6105b8565b61058f565b610566565b61049d565b610474565b610413565b6103cc565b6103a3565b61036f565b610328565b6102eb565b6102a4565b61025d565b610234565b6101e2565b6001600160a01b038116036101dd57565b600080fd5b346101dd5760203660031901126101dd576004356101ff816101cc565b610207610d90565b60a080546001600160a01b0319166001600160a01b0392909216919091179055005b60009103126101dd57565b346101dd5760003660031901126101dd5760a1546040516001600160a01b039091168152602090f35b346101dd5760203660031901126101dd5760043561027a816101cc565b610282610d90565b60a280546001600160a01b0319166001600160a01b0392909216919091179055005b346101dd5760203660031901126101dd576004356102c1816101cc565b6102c9610d90565b609c80546001600160a01b0319166001600160a01b0392909216919091179055005b346101dd5760203660031901126101dd57600435610308816101cc565b60018060a01b0316600052609f6020526020604060002054604051908152f35b346101dd5760203660031901126101dd57600435610345816101cc565b61034d610d90565b60a180546001600160a01b0319166001600160a01b0392909216919091179055005b346101dd5760203660031901126101dd57600435600052609e602052602060018060a01b0360406000205416604051908152f35b346101dd5760003660031901126101dd576098546040516001600160a01b039091168152602090f35b346101dd5760203660031901126101dd576004356103e9816101cc565b6103f1610d90565b609880546001600160a01b0319166001600160a01b0392909216919091179055005b346101dd576000806003193601126104715761042d610d90565b603380546001600160a01b0319811690915581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b80fd5b346101dd5760003660031901126101dd57609c546040516001600160a01b039091168152602090f35b346101dd5760203660031901126101dd576104fe60206004356104bf816101cc565b6001600160a01b039081166000908152609f8352604090205460a0549091166040518080958194635b4fd79760e11b8352600483019190602083019252565b03915afa80156105615761052f91600091610533575b506040516001600160a01b0390911681529081906020820190565b0390f35b610554915060203d811161055a575b61054c8183610ebe565b810190610ee0565b38610514565b503d610542565b610ef8565b346101dd5760003660031901126101dd5760a0546040516001600160a01b039091168152602090f35b346101dd5760003660031901126101dd576099546040516001600160a01b039091168152602090f35b346101dd5760003660031901126101dd576033546040516001600160a01b039091168152602090f35b346101dd5760003660031901126101dd57609a546040516001600160a01b039091168152602090f35b346101dd5760003660031901126101dd57609d546040516001600160a01b039091168152602090f35b60005b8381106106465750506000910152565b8181015183820152602001610636565b9060209161066f81518092818552858086019101610633565b601f01601f1916010190565b602080820190808352835180925260408301928160408460051b8301019501936000915b8483106106af5750505050505090565b90919293949584806106cd600193603f198682030187528a51610656565b980193019301919493929061069f565b60203660031901126101dd576004803567ffffffffffffffff918282116101dd57366023830112156101dd57818101359283116101dd57602490818301928236918660051b0101116101dd5761073284611169565b9360005b81811061074b576040518061052f888261067b565b6000806107598385896111ee565b6040939161076b855180938193611235565b0390305af49061077961125f565b918290156107a8575050906107a39161079282896112ff565b5261079d81886112ff565b506111b3565b610736565b8683879260448251106101dd57826107e093856107cb940151830101910161128f565b925162461bcd60e51b815292839283016112ee565b0390fd5b346101dd5760003660031901126101dd57609b546040516001600160a01b039091168152602090f35b346101dd5760603660031901126101dd5760043561082a816101cc565b610887602435610839816101cc565b60443590610846826101cc565b6000549361086b60ff8660081c161580968197610905575b81156108e5575b50610e31565b8461087e600160ff196000541617600055565b6108cc57610f04565b61088d57005b61089d61ff001960005416600055565b604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602090a1005b6108e061010061ff00196000541617600055565b610f04565b303b159150816108f7575b5038610865565b6001915060ff1614386108f0565b600160ff821610915061085e565b346101dd5760003660031901126101dd5760a2546040516001600160a01b039091168152602090f35b346101dd5760203660031901126101dd57600435610959816101cc565b610961610d90565b609a80546001600160a01b039283166001600160a01b0319918216811790925560405163c45a015560e01b8152909291602090829060049082905afa908115610561576000916109bc575b501690609b541617609b55600080f35b6109d4915060203d811161055a5761054c8183610ebe565b386109ac565b346101dd5760203660031901126101dd576004356109f7816101cc565b6109ff610d90565b609780546001600160a01b0319166001600160a01b0392909216919091179055005b346101dd5760203660031901126101dd57600435610a3e816101cc565b610a46610d90565b609d80546001600160a01b0319166001600160a01b0392909216919091179055005b9181601f840112156101dd5782359167ffffffffffffffff83116101dd57602083818601950101116101dd57565b346101dd5760603660031901126101dd5767ffffffffffffffff60048035906024358381116101dd57610acc9036908301610a68565b92906044358581116101dd57610ae59036908501610a68565b919093600260655414610c905760026065556098546001600160a01b03939084163303610c6357610b17851515611084565b610b4684610b3f610b3288600052609e602052604060002090565b546001600160a01b031690565b16156110ba565b6040516101d5808201998a11828b1017610c5e57611314823980600099039089f09384156105615788941695863b15610c5a57610b9a918691604051998a9687966326896a5b60e11b885230908801611113565b038183865af1928315610561577ffa4b716e7c11d0b64c59a439915a6b9a24e2126106dbae0513cea2f2f5429e1993610c41575b50610c0682610be783600052609e602052604060002090565b80546001600160a01b0319166001600160a01b03909216919091179055565b6001600160a01b03919091166000818152609f6020908152604091829020849055815193845283019190915290a1610c3e6001606555565b80f35b80610c4e610c5492610eaa565b80610229565b38610bce565b8480fd5b610e94565b60405162461bcd60e51b815260208184015260066024820152655054465f4e4160d01b6044820152606490fd5b60649060206040519162461bcd60e51b8352820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152fd5b346101dd5760203660031901126101dd57600435610cf1816101cc565b610cf9610d90565b6001600160a01b03811615610d1357610d1190610de8565b005b60405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608490fd5b346101dd5760003660031901126101dd576097546040516001600160a01b039091168152602090f35b6033546001600160a01b03163303610da457565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b603380546001600160a01b039283166001600160a01b0319821681179092559091167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b15610e3857565b60405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b634e487b7160e01b600052604160045260246000fd5b67ffffffffffffffff8111610c5e57604052565b90601f8019910116810190811067ffffffffffffffff821117610c5e57604052565b908160209103126101dd5751610ef5816101cc565b90565b6040513d6000823e3d90fd5b60049291610f7a602092610f2860ff60005460081c16610f2381611024565b611024565b610f3133610de8565b610f4660ff60005460081c16610f2381611024565b6001606555609880546001600160a01b0319163317905560018060a01b03166001600160601b0360a01b6099541617609955565b609a80546001600160a01b0319166001600160a01b03831617905560405163c45a015560e01b815293849182906001600160a01b03165afa9182156105615761100492610fe791600091611006575b5060018060a01b03166001600160601b0360a01b609b541617609b55565b60018060a01b03166001600160601b0360a01b609c541617609c55565b565b61101e915060203d811161055a5761054c8183610ebe565b38610fc9565b1561102b57565b60405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608490fd5b1561108b57565b60405162461bcd60e51b8152602060048201526007602482015266282a232faa2d2b60c91b6044820152606490fd5b156110c157565b60405162461bcd60e51b81526020600482015260096024820152685054465f54544e5a4160b81b6044820152606490fd5b908060209392818452848401376000828201840152601f01601f1916010190565b969594906060949261114c9461113e9260018060a01b03168a52608060208b015260808a01916110f2565b9187830360408901526110f2565b930152565b67ffffffffffffffff8111610c5e5760051b60200190565b9061117382611151565b6111806040519182610ebe565b8281528092611191601f1991611151565b019060005b8281106111a257505050565b806060602080938501015201611196565b60001981146111c25760010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b91908110156112305760051b81013590601e19813603018212156101dd57019081359167ffffffffffffffff83116101dd5760200182360381136101dd579190565b6111d8565b908092918237016000815290565b67ffffffffffffffff8111610c5e57601f01601f191660200190565b3d1561128a573d9061127082611243565b9161127e6040519384610ebe565b82523d6000602084013e565b606090565b6020818303126101dd5780519067ffffffffffffffff82116101dd570181601f820112156101dd5780516112c281611243565b926112d06040519485610ebe565b818452602082840101116101dd57610ef59160208085019101610633565b906020610ef5928181520190610656565b80518210156112305760209160051b01019056fe60a0806040523461002857336080526101a7908161002e823960805181818160410152608b0152f35b600080fdfe60806040526004361015610018575b3661007657610076565b6000803560e01c63c45a01551461002f575061000e565b346100735780600319360112610073577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166080908152602090f35b80fd5b60405163f8b0a90f60e01b81526020816004817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa908115610122576000916100ca575b5061012e565b60203d811161011b575b601f8101601f1916820167ffffffffffffffff81118382101761010757610101935060405281019061014d565b386100c4565b634e487b7160e01b84526041600452602484fd5b503d6100d4565b6040513d6000823e3d90fd5b6000808092368280378136915af43d82803e15610149573d90f35b3d90fd5b9081602091031261016c57516001600160a01b038116810361016c5790565b600080fdfea26469706673582212206a338266865973d548c48ef92af2713c74a2987fcaccf63e3c078359f42ac14464736f6c63430008130033a2646970667358221220294d4ce497c8caf60278ea8860e39ae9af316c4768e3e609824c22dac732b57664736f6c63430008130033
Deployed ByteCode
0x6080604052600436101561001257600080fd5b60003560e01c80630a576b62146101c75780631e6a721b146101c25780632715812d146101bd57806341273657146101b857806343503b13146101b3578063498d5f8c146101ae5780634c28c89a146101a95780636e9960c3146101a4578063704b6c021461019f578063715018a61461019a578063725c9c491461019557806375683a9f1461019057806382ff8ba71461018b5780638428f72f146101865780638da5cb5b146101815780639e5d38011461017c578063a5af02b714610177578063ac9650d814610172578063b081983b1461016d578063c0c53b8b14610168578063c8296dd514610163578063cb8451ef1461015e578063e066dbfc14610159578063e69be31714610154578063ed1c07f91461014f578063f2fde38b1461014a5763f8b0a90f1461014557600080fd5b610d67565b610cd4565b610a96565b610a21565b6109da565b61093c565b610913565b61080d565b6107e4565b6106dd565b61060a565b6105e1565b6105b8565b61058f565b610566565b61049d565b610474565b610413565b6103cc565b6103a3565b61036f565b610328565b6102eb565b6102a4565b61025d565b610234565b6101e2565b6001600160a01b038116036101dd57565b600080fd5b346101dd5760203660031901126101dd576004356101ff816101cc565b610207610d90565b60a080546001600160a01b0319166001600160a01b0392909216919091179055005b60009103126101dd57565b346101dd5760003660031901126101dd5760a1546040516001600160a01b039091168152602090f35b346101dd5760203660031901126101dd5760043561027a816101cc565b610282610d90565b60a280546001600160a01b0319166001600160a01b0392909216919091179055005b346101dd5760203660031901126101dd576004356102c1816101cc565b6102c9610d90565b609c80546001600160a01b0319166001600160a01b0392909216919091179055005b346101dd5760203660031901126101dd57600435610308816101cc565b60018060a01b0316600052609f6020526020604060002054604051908152f35b346101dd5760203660031901126101dd57600435610345816101cc565b61034d610d90565b60a180546001600160a01b0319166001600160a01b0392909216919091179055005b346101dd5760203660031901126101dd57600435600052609e602052602060018060a01b0360406000205416604051908152f35b346101dd5760003660031901126101dd576098546040516001600160a01b039091168152602090f35b346101dd5760203660031901126101dd576004356103e9816101cc565b6103f1610d90565b609880546001600160a01b0319166001600160a01b0392909216919091179055005b346101dd576000806003193601126104715761042d610d90565b603380546001600160a01b0319811690915581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b80fd5b346101dd5760003660031901126101dd57609c546040516001600160a01b039091168152602090f35b346101dd5760203660031901126101dd576104fe60206004356104bf816101cc565b6001600160a01b039081166000908152609f8352604090205460a0549091166040518080958194635b4fd79760e11b8352600483019190602083019252565b03915afa80156105615761052f91600091610533575b506040516001600160a01b0390911681529081906020820190565b0390f35b610554915060203d811161055a575b61054c8183610ebe565b810190610ee0565b38610514565b503d610542565b610ef8565b346101dd5760003660031901126101dd5760a0546040516001600160a01b039091168152602090f35b346101dd5760003660031901126101dd576099546040516001600160a01b039091168152602090f35b346101dd5760003660031901126101dd576033546040516001600160a01b039091168152602090f35b346101dd5760003660031901126101dd57609a546040516001600160a01b039091168152602090f35b346101dd5760003660031901126101dd57609d546040516001600160a01b039091168152602090f35b60005b8381106106465750506000910152565b8181015183820152602001610636565b9060209161066f81518092818552858086019101610633565b601f01601f1916010190565b602080820190808352835180925260408301928160408460051b8301019501936000915b8483106106af5750505050505090565b90919293949584806106cd600193603f198682030187528a51610656565b980193019301919493929061069f565b60203660031901126101dd576004803567ffffffffffffffff918282116101dd57366023830112156101dd57818101359283116101dd57602490818301928236918660051b0101116101dd5761073284611169565b9360005b81811061074b576040518061052f888261067b565b6000806107598385896111ee565b6040939161076b855180938193611235565b0390305af49061077961125f565b918290156107a8575050906107a39161079282896112ff565b5261079d81886112ff565b506111b3565b610736565b8683879260448251106101dd57826107e093856107cb940151830101910161128f565b925162461bcd60e51b815292839283016112ee565b0390fd5b346101dd5760003660031901126101dd57609b546040516001600160a01b039091168152602090f35b346101dd5760603660031901126101dd5760043561082a816101cc565b610887602435610839816101cc565b60443590610846826101cc565b6000549361086b60ff8660081c161580968197610905575b81156108e5575b50610e31565b8461087e600160ff196000541617600055565b6108cc57610f04565b61088d57005b61089d61ff001960005416600055565b604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602090a1005b6108e061010061ff00196000541617600055565b610f04565b303b159150816108f7575b5038610865565b6001915060ff1614386108f0565b600160ff821610915061085e565b346101dd5760003660031901126101dd5760a2546040516001600160a01b039091168152602090f35b346101dd5760203660031901126101dd57600435610959816101cc565b610961610d90565b609a80546001600160a01b039283166001600160a01b0319918216811790925560405163c45a015560e01b8152909291602090829060049082905afa908115610561576000916109bc575b501690609b541617609b55600080f35b6109d4915060203d811161055a5761054c8183610ebe565b386109ac565b346101dd5760203660031901126101dd576004356109f7816101cc565b6109ff610d90565b609780546001600160a01b0319166001600160a01b0392909216919091179055005b346101dd5760203660031901126101dd57600435610a3e816101cc565b610a46610d90565b609d80546001600160a01b0319166001600160a01b0392909216919091179055005b9181601f840112156101dd5782359167ffffffffffffffff83116101dd57602083818601950101116101dd57565b346101dd5760603660031901126101dd5767ffffffffffffffff60048035906024358381116101dd57610acc9036908301610a68565b92906044358581116101dd57610ae59036908501610a68565b919093600260655414610c905760026065556098546001600160a01b03939084163303610c6357610b17851515611084565b610b4684610b3f610b3288600052609e602052604060002090565b546001600160a01b031690565b16156110ba565b6040516101d5808201998a11828b1017610c5e57611314823980600099039089f09384156105615788941695863b15610c5a57610b9a918691604051998a9687966326896a5b60e11b885230908801611113565b038183865af1928315610561577ffa4b716e7c11d0b64c59a439915a6b9a24e2126106dbae0513cea2f2f5429e1993610c41575b50610c0682610be783600052609e602052604060002090565b80546001600160a01b0319166001600160a01b03909216919091179055565b6001600160a01b03919091166000818152609f6020908152604091829020849055815193845283019190915290a1610c3e6001606555565b80f35b80610c4e610c5492610eaa565b80610229565b38610bce565b8480fd5b610e94565b60405162461bcd60e51b815260208184015260066024820152655054465f4e4160d01b6044820152606490fd5b60649060206040519162461bcd60e51b8352820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152fd5b346101dd5760203660031901126101dd57600435610cf1816101cc565b610cf9610d90565b6001600160a01b03811615610d1357610d1190610de8565b005b60405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608490fd5b346101dd5760003660031901126101dd576097546040516001600160a01b039091168152602090f35b6033546001600160a01b03163303610da457565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b603380546001600160a01b039283166001600160a01b0319821681179092559091167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b15610e3857565b60405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b634e487b7160e01b600052604160045260246000fd5b67ffffffffffffffff8111610c5e57604052565b90601f8019910116810190811067ffffffffffffffff821117610c5e57604052565b908160209103126101dd5751610ef5816101cc565b90565b6040513d6000823e3d90fd5b60049291610f7a602092610f2860ff60005460081c16610f2381611024565b611024565b610f3133610de8565b610f4660ff60005460081c16610f2381611024565b6001606555609880546001600160a01b0319163317905560018060a01b03166001600160601b0360a01b6099541617609955565b609a80546001600160a01b0319166001600160a01b03831617905560405163c45a015560e01b815293849182906001600160a01b03165afa9182156105615761100492610fe791600091611006575b5060018060a01b03166001600160601b0360a01b609b541617609b55565b60018060a01b03166001600160601b0360a01b609c541617609c55565b565b61101e915060203d811161055a5761054c8183610ebe565b38610fc9565b1561102b57565b60405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608490fd5b1561108b57565b60405162461bcd60e51b8152602060048201526007602482015266282a232faa2d2b60c91b6044820152606490fd5b156110c157565b60405162461bcd60e51b81526020600482015260096024820152685054465f54544e5a4160b81b6044820152606490fd5b908060209392818452848401376000828201840152601f01601f1916010190565b969594906060949261114c9461113e9260018060a01b03168a52608060208b015260808a01916110f2565b9187830360408901526110f2565b930152565b67ffffffffffffffff8111610c5e5760051b60200190565b9061117382611151565b6111806040519182610ebe565b8281528092611191601f1991611151565b019060005b8281106111a257505050565b806060602080938501015201611196565b60001981146111c25760010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b91908110156112305760051b81013590601e19813603018212156101dd57019081359167ffffffffffffffff83116101dd5760200182360381136101dd579190565b6111d8565b908092918237016000815290565b67ffffffffffffffff8111610c5e57601f01601f191660200190565b3d1561128a573d9061127082611243565b9161127e6040519384610ebe565b82523d6000602084013e565b606090565b6020818303126101dd5780519067ffffffffffffffff82116101dd570181601f820112156101dd5780516112c281611243565b926112d06040519485610ebe565b818452602082840101116101dd57610ef59160208085019101610633565b906020610ef5928181520190610656565b80518210156112305760209160051b01019056fe60a0806040523461002857336080526101a7908161002e823960805181818160410152608b0152f35b600080fdfe60806040526004361015610018575b3661007657610076565b6000803560e01c63c45a01551461002f575061000e565b346100735780600319360112610073577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166080908152602090f35b80fd5b60405163f8b0a90f60e01b81526020816004817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa908115610122576000916100ca575b5061012e565b60203d811161011b575b601f8101601f1916820167ffffffffffffffff81118382101761010757610101935060405281019061014d565b386100c4565b634e487b7160e01b84526041600452602484fd5b503d6100d4565b6040513d6000823e3d90fd5b6000808092368280378136915af43d82803e15610149573d90f35b3d90fd5b9081602091031261016c57516001600160a01b038116810361016c5790565b600080fdfea26469706673582212206a338266865973d548c48ef92af2713c74a2987fcaccf63e3c078359f42ac14464736f6c63430008130033a2646970667358221220294d4ce497c8caf60278ea8860e39ae9af316c4768e3e609824c22dac732b57664736f6c63430008130033