Source Code
Latest 25 from a total of 46 transactions
| Transaction Hash |
Method
|
Block
|
From
|
|
To
|
||||
|---|---|---|---|---|---|---|---|---|---|
| Collect Fees Fro... | 22491259 | 304 days ago | IN | 0 ETH | 0.00014998 | ||||
| Collect Fees Fro... | 22487642 | 304 days ago | IN | 0 ETH | 0.00015727 | ||||
| Withdraw ETH | 22487626 | 304 days ago | IN | 0 ETH | 0.00005232 | ||||
| Set ERC721ex | 21828264 | 397 days ago | IN | 0 ETH | 0.00004346 | ||||
| Create Contract | 21804439 | 400 days ago | IN | 0.025 ETH | 0.00088382 | ||||
| Create Contract | 21594367 | 429 days ago | IN | 0.025 ETH | 0.0060003 | ||||
| Create Contract | 21591093 | 430 days ago | IN | 0.025 ETH | 0.00355961 | ||||
| Set Contract Act... | 21549854 | 435 days ago | IN | 0 ETH | 0.00025007 | ||||
| Withdraw ETH | 21549852 | 435 days ago | IN | 0 ETH | 0.00018818 | ||||
| Transfer ERC20To... | 21549850 | 435 days ago | IN | 0 ETH | 0.00022609 | ||||
| Set Contract Act... | 21549848 | 435 days ago | IN | 0 ETH | 0.00013879 | ||||
| Collect Fees Fro... | 21534848 | 438 days ago | IN | 0 ETH | 0.00741197 | ||||
| Create Contract | 21458727 | 448 days ago | IN | 0.025 ETH | 0.00646183 | ||||
| Create Contract | 21376854 | 460 days ago | IN | 0.025 ETH | 0.00972667 | ||||
| Create Contract | 21350964 | 463 days ago | IN | 0.025 ETH | 0.00873606 | ||||
| Create Contract | 21346351 | 464 days ago | IN | 0.025 ETH | 0.01491472 | ||||
| Create Contract | 21346230 | 464 days ago | IN | 0.025 ETH | 0.0175825 | ||||
| Create Contract | 21346155 | 464 days ago | IN | 0.025 ETH | 0.01833977 | ||||
| Collect Fees Fro... | 21343812 | 464 days ago | IN | 0 ETH | 0.00433556 | ||||
| Set ERC721ex | 21343541 | 464 days ago | IN | 0 ETH | 0.0006119 | ||||
| Create Contract | 21334414 | 466 days ago | IN | 0.025 ETH | 0.0116147 | ||||
| Create Contract | 21334350 | 466 days ago | IN | 0.025 ETH | 0.01242611 | ||||
| Create Contract | 21334321 | 466 days ago | IN | 0.025 ETH | 0.01311851 | ||||
| Create Contract | 21333136 | 466 days ago | IN | 0.025 ETH | 0.01043079 | ||||
| Create Contract | 21332582 | 466 days ago | IN | 0.025 ETH | 0.01456601 |
Latest 25 internal transactions (View All)
Advanced mode:
| Parent Transaction Hash | Method | Block |
From
|
|
To
|
||
|---|---|---|---|---|---|---|---|
| Transfer | 22487626 | 304 days ago | 0.07675079 ETH | ||||
| 0x3d602d80 | 22053430 | 365 days ago | Contract Creation | 0 ETH | |||
| 0x3d602d80 | 22042346 | 367 days ago | Contract Creation | 0 ETH | |||
| Transfer | 22005977 | 372 days ago | 0.00000002 ETH | ||||
| Transfer | 21996731 | 373 days ago | 0.0000002 ETH | ||||
| 0x3d602d80 | 21996330 | 373 days ago | Contract Creation | 0 ETH | |||
| 0x3d602d80 | 21996326 | 373 days ago | Contract Creation | 0 ETH | |||
| Transfer | 21996208 | 373 days ago | 0.000002 ETH | ||||
| Transfer | 21989152 | 374 days ago | 0.000002 ETH | ||||
| Transfer | 21986114 | 375 days ago | 0.0000006 ETH | ||||
| 0x3d602d80 | 21976880 | 376 days ago | Contract Creation | 0 ETH | |||
| 0x3d602d80 | 21976444 | 376 days ago | Contract Creation | 0 ETH | |||
| 0x3d602d80 | 21969995 | 377 days ago | Contract Creation | 0 ETH | |||
| Transfer | 21916698 | 384 days ago | 0.0000002 ETH | ||||
| 0x3d602d80 | 21895080 | 387 days ago | Contract Creation | 0 ETH | |||
| Transfer | 21818053 | 398 days ago | 0.0000002 ETH | ||||
| Transfer | 21817960 | 398 days ago | 0.000002 ETH | ||||
| Transfer | 21817827 | 398 days ago | 0.000002 ETH | ||||
| 0x3d602d80 | 21804439 | 400 days ago | Contract Creation | 0 ETH | |||
| Transfer | 21727878 | 411 days ago | 0.0001931 ETH | ||||
| Transfer | 21727721 | 411 days ago | 0.00008 ETH | ||||
| Transfer | 21702799 | 414 days ago | 0.00002065 ETH | ||||
| Transfer | 21699643 | 415 days ago | 0.00001 ETH | ||||
| 0x3d602d80 | 21699481 | 415 days ago | Contract Creation | 0 ETH | |||
| Transfer | 21691419 | 416 days ago | 0.00025797 ETH |
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
ERC721exFactory
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
/*
*
* All rights reserved. Property of Mintable PTE LTD.
*
*/
pragma solidity ^0.8.0;
/*
* ================================================
* ERC721exFactory Contract
* ================================================
*
* Summary:
* --------
* The ERC721exFactory contract facilitates the creation and management
* of ERC20 tokens and Uniswap V3 liquidity pools associated with specific
* NFT contracts. It leverages the Uniswap V3 protocol for liquidity provisioning
* and integrates with a bonding curve mechanism to manage token supply.
*
* Core Functionalities:
* ---------------------
* - **Contract Initialization**: Sets up the factory with necessary addresses and roles.
* - **Contract Creation**: Allows the creation of ERC20 contracts tied to NFT contracts.
* - **Pool Management**: Creates and manages Uniswap V3 pools for ERC20-WETH pairs.
* - **Liquidity Management**: Adds and removes liquidity to/from Uniswap pools.
* - **Fee Collection**: Collects fees generated from liquidity positions.
* - **Administrative Controls**: Enables admin roles to manage contract states and withdrawals.
*
* ================================================
*/
/*
* ======================
* External Contract Interfaces and Libraries
* ======================
*/
import "./Clones.sol"; // Importing Clones library for creating minimal proxy contracts
import "./WETHWrapper.sol"; // Importing WETHWrapper for handling Wrapped ETH interactions
import "./@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol"; // Interface for Uniswap V3 Factory
import "./@uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol"; // Interface for Uniswap V3 Position Manager
import "./@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol"; // Importing the missing ISwapRouter interface for Uniswap swaps
import "./@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol"; // Interface for Uniswap V3 Pool
import "./@openzeppelin/contracts/security/ReentrancyGuard.sol"; // OpenZeppelin's ReentrancyGuard for preventing reentrancy attacks
import "./@openzeppelin/contracts/access/AccessControl.sol"; // OpenZeppelin's AccessControl for role-based access
import "./@openzeppelin/contracts/token/ERC20/IERC20.sol"; // Interface for ERC20 tokens
import "./iLogicLib.sol"; // Interface for LogicLib
import "./@uniswap/v3-core/contracts/libraries/TickMath.sol"; // Uniswap's TickMath library
import "./SignatureParser.sol";
/**
* @title IERC721ex
* @dev Interface for interacting with ERC721ex contracts.
*/
interface IERC721ex {
/**
* @notice Initializes the NFT contract with necessary parameters.
* @param name_ Name of the NFT token.
* @param symbol_ Symbol of the NFT token.
* @param _NFTContract Address of the underlying NFT contract.
* @param maxSupplyTokens Maximum supply of ERC20 tokens.
* @param _bondingCurveContract Address of the bonding curve contract.
* @param _logicLibAddress Address of the logic library.
* @param deployer Address of the deployer.
* @return bool indicating successful initialization.
*/
function initialize(
string calldata name_,
string calldata symbol_,
address _NFTContract,
uint256 maxSupplyTokens,
address _bondingCurveContract,
address _logicLibAddress,
address deployer
) external returns (bool);
/**
* @notice Updates the bonding curve contract address.
* @param bondingCurveContract New bonding curve contract address.
*/
function updateBondingCurve(address bondingCurveContract) external;
/**
* @notice Withdraws a specified amount from the contract.
* @param amount Amount to withdraw.
* @return bool indicating successful withdrawal.
*/
function withdraw(uint256 amount) external returns (bool);
}
/**
* @title ERC721exFactory
* @dev Factory contract for creating ERC20 tokens and Uniswap V3 liquidity pools associated with NFT contracts.
*/
contract ERC721exFactory is ReentrancyGuard, WETHWrapper, AccessControl, SignatureParser {
// ============================================
// State Variables
// ============================================
IUniswapV3Factory public immutable uniswapFactory; // Instance of Uniswap V3 Factory
INonfungiblePositionManager public immutable positionManager; // Position Manager for Uniswap V3
ISwapRouter public immutable swapRouter;
address public ERC721exTemplate; // Template address for cloning NFT contracts
address public ERC721exTemplateNoBurn; // Template address for cloning NFT contracts without burn
address public bondingCurveContract; // Address of the bonding curve contract
address public LogicLibAddress; // Address of the Logic Library
address public MintableFactoryAddress; // Address of the Mintology Factory
uint256 public poolId = 0; // Counter for pool IDs
bool public isActive = true; // Flag to check if the contract is active
bytes32 public constant ERC20CONTRACT = keccak256("ERC20CONTRACT"); // Role identifier for ERC20 contracts
bytes32 public constant LOGICLIB = keccak256("LOGICLIB"); // Role identifier for Logic Library
mapping(address => BondingPools) public poolsMade; // Mapping from ERC20 contract address to pool information
mapping(address => address) public ercContractToNFTContract; // Mapping from ERC20 contract to NFT contract
mapping(address => address) public nftContractToDeployer; // Mapping from NFT contract to deployer address
// ============================================
// Structs
// ============================================
/**
* @dev Struct to hold information about bonding pools.
*/
struct BondingPools {
address uniswapPool; // Address of the Uniswap pool
uint256 liquidityTokenID; // Token ID representing the liquidity position
uint256 poolId; // ID of the pool
uint256 maxSupplyOfTokens; // Maximum supply of tokens in the pool
address token0; // stores token order
address token1; // stores token order
}
// ============================================
// Custom Errors
// ============================================
error ContractNotActive();
error NotNFTHolder();
error InsufficientValue();
error AlreadyCreatedTokenForNFT();
error NotAuthorized();
error NoLiquidityToRemove();
error FactoryDoesNotOwnPosition();
error UniswapPoolNotSet();
// ============================================
// Events
// ============================================
/**
* @dev Emitted when liquidity is added to a pool.
*/
event LiquidityAdded(
address indexed user,
uint256 tokenId,
uint128 liquidity,
uint256 amountAActual,
uint256 amountBActual
);
/**
* @dev Emitted when liquidity is removed from a pool.
*/
event LiquidityRemoved(uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);
/**
* @dev Emitted when a new pool is created.
*/
event PoolCreated(address indexed pool, address indexed tokenA, address indexed tokenB);
/**
* @dev Emitted when fees are collected from a liquidity position.
*/
event FeesCollected(uint256 tokenId, uint256 amount0Collected, uint256 amount1Collected);
/**
* @dev Emitted when a withdrawal is made.
*/
event Withdrawal(address account, uint256 amount);
/**
* @dev Emitted when a new ERC20 contract is created.
*/
event ERC20Created(
address indexed erc20Address,
address indexed deployer,
address nftContract,
string symbol,
uint256 maxSupplyTokens
);
// ============================================
// Modifiers
// ============================================
/**
* @dev Modifier to allow function execution only when the contract is active.
*/
modifier activeOnly() {
if (!isActive) revert ContractNotActive();
_;
}
/**
* @dev Modifier to restrict function access to NFT holders of a specific contract.
* @param _contract Address of the NFT contract.
*/
modifier nftHolderOnly(address _contract) {
if (IERC721(_contract).balanceOf(msg.sender) == 0) revert NotNFTHolder();
_;
}
// ============================================
// Constructor
// ============================================
/**
* @notice Initializes the ERC721exFactory contract with required parameters.
* @param _uniswapFactory Address of the Uniswap V3 Factory.
* @param _positionManager Address of the Uniswap V3 Position Manager.
* @param _ERC721exTemplate Address of the ERC721ex template contract.
* @param _bondingCurveContract Address of the bonding curve contract.
* @param _logicLibAddress Address of the logic library.
*/
constructor(
address _uniswapFactory,
address _positionManager,
address _ERC721exTemplate,
address _ERC721exTemplateNoBurn,
address _bondingCurveContract,
address _logicLibAddress,
address _mintableFactoryAddress
) {
// Grant the deployer the default admin role
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
// Initialize Uniswap Factory
uniswapFactory = IUniswapV3Factory(_uniswapFactory);
// Initialize Position Manager
positionManager = INonfungiblePositionManager(_positionManager);
// Initialize the SwapRouter
swapRouter = ISwapRouter(0xE592427A0AEce92De3Edee1F18E0157C05861564);
// Set the NFT template address
ERC721exTemplate = _ERC721exTemplate;
// Set the ERC721exNoBurn template address
ERC721exTemplateNoBurn = _ERC721exTemplateNoBurn;
// Set the bonding curve contract address
bondingCurveContract = _bondingCurveContract;
// Set the Logic Library address
LogicLibAddress = _logicLibAddress;
// Initialize Mintable Factory address
MintableFactoryAddress = _mintableFactoryAddress;
// Grant the Logic Library role
_grantRole(LOGICLIB, LogicLibAddress);
}
// ============================================
// Administrative Functions
// ============================================
/**
* @notice Sets a new ERC721ex template address.
* @param newDrip Address of the new ERC721ex template.
* @dev Only callable by accounts with DEFAULT_ADMIN_ROLE.
*/
function setERC721ex(address newDrip, address newDripNoBurn) external onlyRole(DEFAULT_ADMIN_ROLE) {
ERC721exTemplate = newDrip;
ERC721exTemplateNoBurn = newDripNoBurn;
}
/**
* @notice Sets a new bonding curve contract address.
* @param _bondingCurveContract Address of the new bonding curve contract.
* @dev Only callable by accounts with DEFAULT_ADMIN_ROLE.
*/
function setBondingCurveContract(address _bondingCurveContract) external onlyRole(DEFAULT_ADMIN_ROLE) {
bondingCurveContract = _bondingCurveContract;
}
/**
* @notice Toggles the active state of the contract in event of emergency.
* @dev Only callable by accounts with DEFAULT_ADMIN_ROLE.
*/
function setContractActive() external onlyRole(DEFAULT_ADMIN_ROLE) {
isActive = !isActive;
}
// ============================================
// Contract Creation Functions
// ============================================
/**
* @notice Creates a new ERC20 contract tied to an NFT contract.
* @param name_ Name of the ERC20 token.
* @param symbol_ Symbol of the ERC20 token.
* @param nftContract Address of the NFT contract.
* @param maxSupplyTokens Maximum supply of ERC20 tokens.
* @param signature signature of total supply
* @dev
* - Requires a minimum ETH payment of 0.05 ether.
* - Clones the ERC721ex template and initializes it.
* - Registers the new contract with LogicLib.
* - Emits an ERC20Created event.
* - Only callable when the factory is active and the caller owns NFTs from the specified contract.
*/
function createContract(
string calldata name_,
string calldata symbol_,
address nftContract,
uint256 maxSupplyTokens,
bytes calldata signature
) external payable nonReentrant activeOnly nftHolderOnly(nftContract) {
if (msg.value < 0.025 ether) revert InsufficientValue();
// Ensure that a token hasn't already been created for this NFT contract
if (ercContractToNFTContract[nftContract] != address(0)) revert AlreadyCreatedTokenForNFT();
require(isValidSignature(nftContract, maxSupplyTokens, signature), "wrong sig");
// Clone the ERC721ex template
address newERC20Addy = Clones.clone(ERC721exTemplate);
// Initialize the cloned NFT contract with provided parameters
IERC721ex(newERC20Addy).initialize(
name_,
symbol_,
nftContract,
maxSupplyTokens,
bondingCurveContract,
LogicLibAddress,
msg.sender // 2% to the deployer for their fee
);
// Map the new ERC20 contract to its deployer
nftContractToDeployer[newERC20Addy] = msg.sender;
// Register the new contract with the Logic Library
ILogicLib(LogicLibAddress).registerContract(newERC20Addy, (maxSupplyTokens * 20) / 100);
// Map the NFT contract to the newly created ERC20 contract
ercContractToNFTContract[nftContract] = newERC20Addy;
// Grant the ERC20Contract role to the new ERC20 contract
_grantRole(ERC20CONTRACT, newERC20Addy);
// Emit the ERC20Created event with relevant details
emit ERC20Created(newERC20Addy, msg.sender, nftContract, symbol_, maxSupplyTokens);
}
/**
* @notice Creates a new ERC20 contract by a factory with additional deployer parameter.
* @param name_ Name of the ERC20 token.
* @param symbol_ Symbol of the ERC20 token.
* @param nftContract Address of the NFT contract.
* @param maxSupplyTokens Maximum supply of ERC20 tokens.
* @param deployer Address of the deployer.
* @return bool if successfully created
* @dev
* - Requires a minimum ETH payment of 0.05 ether.
* - Clones the ERC721ex template and initializes it.
* - Registers the new contract with LogicLib.
* - Grants the ERC20Contract role to the new ERC20 contract.
* - Emits an ERC20Created event.
*/
function createContractByFactory(
string calldata name_,
string calldata symbol_,
address nftContract,
uint256 maxSupplyTokens,
address deployer
) external payable nonReentrant activeOnly returns (bool) {
// Ensure that the caller is authorized (e.g., mintable's factory 721 deployer calling this)
if (msg.sender != MintableFactoryAddress) revert NotAuthorized();
// Clone the ERC721ex template
address newERC20Addy = Clones.clone(ERC721exTemplateNoBurn);
// Initialize the cloned NFT contract with provided parameters
IERC721ex(newERC20Addy).initialize(
name_,
symbol_,
nftContract,
maxSupplyTokens,
bondingCurveContract,
LogicLibAddress,
deployer
);
// Map the NFT contract to its deployer
nftContractToDeployer[newERC20Addy] = deployer;
// Register the new contract with the Logic Library
ILogicLib(LogicLibAddress).registerContract(newERC20Addy, (maxSupplyTokens * 20) / 100);
// Map the NFT contract to the newly created ERC20 contract
ercContractToNFTContract[nftContract] = newERC20Addy;
// Grant the ERC20Contract role to the new ERC20 contract
_grantRole(ERC20CONTRACT, newERC20Addy);
// Emit the ERC20Created event with relevant details
emit ERC20Created(newERC20Addy, deployer, nftContract, symbol_, maxSupplyTokens);
// Return the address and max supply of the newly created ERC20 contract
return true;
}
// ============================================
// Pool Management Functions
// ============================================
/**
* @notice Creates a new Uniswap V3 pool for a given ERC20 contract if it doesn't already exist.
* @param maxSupply Maximum supply of tokens for the pool.
* @param _erc20Contract Address of the ERC20 contract.
* @return pool Address of the newly created pool or existing pool.
* @dev
* - Checks if the pool already exists; if not, creates a new pool.
* - Initializes the pool with a calculated sqrtPriceX96 based on token and WETH amounts.
* - Updates internal mappings and emits a PoolCreated event.
*/
function _createPool(
uint256 maxSupply,
address _erc20Contract,
uint160 sqrtPrice,
address existingPool
) internal activeOnly returns (address) {
address poolAddress;
if (existingPool != address(0)) {
// Use the existing pool
poolAddress = existingPool;
} else {
poolAddress = uniswapFactory.createPool(address(_erc20Contract), address(WETHWrapper.weth), uint24(3000));
}
// Initialize the newly created pool with the sqrt price
IUniswapV3Pool(poolAddress).initialize(sqrtPrice);
unchecked {
poolId += 1;
}
// Emit the PoolCreated event
emit PoolCreated(poolAddress, _erc20Contract, address(WETHWrapper.weth));
// Update the poolsMade mapping with the correct poolAddress
poolsMade[_erc20Contract] = BondingPools({
uniswapPool: poolAddress,
liquidityTokenID: 0,
poolId: poolId,
maxSupplyOfTokens: maxSupply,
token0: _erc20Contract,
token1: address(WETHWrapper.weth)
});
// Return the address of the newly created pool
return poolAddress;
}
/**
* @notice Adds liquidity to a Uniswap V3 pool.
* @param maxSupply Maximum supply of tokens for liquidity provisioning.
* @param wethAmount Amount of WETH to add as liquidity.
* @param _erc20Contract Address of the ERC20 contract.
* @return bool for success
* @dev
* - Approves the Position Manager to spend tokens and WETH.
* - Checks if the pool exists; if not, creates and initializes it.
* - Mints a new liquidity position using the Position Manager.
* - Emits a LiquidityAdded event.
* - Refunds any unused tokens to the caller.
*/
function _UniswapAddLiquidity(
uint256 maxSupply,
uint256 wethAmount,
address _erc20Contract,
bool poolSplit
) internal returns (bool) {
// Calculate 20% of the maximum supply to determine the token amount to add
uint256 tokenAmount = IERC20(_erc20Contract).balanceOf(address(this));
if (poolSplit) {
tokenAmount = tokenAmount / 2;
}
// Approve the Position Manager to spend the ERC20 tokens
_approveForPositionManager(_erc20Contract, tokenAmount, wethAmount);
// Calculate the initial sqrt price for the pool based on token and WETH amounts
(
uint160 sqrtPriceX96,
address token0,
address token1,
uint256 token0Amount,
uint256 token1Amount
) = calculateSqrtPriceX96(tokenAmount, wethAmount, _erc20Contract);
// Check if the Uniswap pool exists; if not, create it
address poolAddress = checkPoolExists(_erc20Contract);
_createPool(maxSupply, _erc20Contract, sqrtPriceX96, poolAddress);
// Prepare the parameters for minting a new liquidity position
INonfungiblePositionManager.MintParams memory params = INonfungiblePositionManager.MintParams({
token0: token0,
token1: token1,
fee: 3000,
tickLower: -887220,
tickUpper: 887220,
amount0Desired: token0Amount,
amount1Desired: token1Amount,
amount0Min: (token0Amount * 98) / 100,
amount1Min: (token1Amount * 98) / 100,
recipient: address(this),
deadline: block.timestamp + 4 hours
});
// Mint the liquidity position and capture the returned values
_mintPosition(params, _erc20Contract);
return true;
}
function _mintPosition(INonfungiblePositionManager.MintParams memory params, address _erc20Contract) internal {
(uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1) = positionManager.mint(params);
// Update the liquidity token ID in the poolsMade mapping
BondingPools memory pool = poolsMade[_erc20Contract];
pool.liquidityTokenID = tokenId;
pool.token0 = params.token0;
pool.token1 = params.token1;
poolsMade[_erc20Contract] = pool; // Write back to storage once
// Emit the LiquidityAdded event with relevant details
emit LiquidityAdded(msg.sender, tokenId, liquidity, amount0, amount1);
}
function _approveForPositionManager(address _erc20Contract, uint256 tokenAmount, uint256 wethAmount) internal {
IERC20(_erc20Contract).approve(address(positionManager), tokenAmount);
// Approve the Position Manager to spend WETH
IERC20(address(WETHWrapper.weth)).approve(address(positionManager), wethAmount);
}
/**
* @notice Public function to add liquidity to a specified ERC20 contract's pool.
* @param maxSupply Maximum supply of tokens for liquidity provisioning.
* @param _NFTContract Address of the NFT contract.
* @param _erc20Contract Address of the ERC20 contract.
* @return bool indicating successful addition of liquidity.
* @dev
* - Checks that the caller has appropriate roles.
* - Ensures that the ERC20 and NFT contracts are correctly linked.
* - Withdraws ETH from the ERC20 contract and wraps it into WETH.
* - Adds liquidity to the Uniswap pool.
* - Transfers a portion of ETH to the deployer as a fee.
*/
function UniswapAddLiquidity(
uint256 maxSupply,
address _NFTContract,
address _erc20Contract,
bool poolSplit
) external activeOnly returns (bool) {
// Ensure the caller has ERC20Contract role
if (!hasRole(ERC20CONTRACT, msg.sender)) revert NotAuthorized();
// Ensure that the ERC20 contract corresponds to the NFT contract
require(ercContractToNFTContract[_NFTContract] == _erc20Contract, "IC");
// Retrieve the ETH balance from the ERC20 contract's bonding curve
uint256 balanceETH = address(_erc20Contract).balance;
// Withdraw ETH from the ERC20 contract's bonding curve
require(IERC721ex(_erc20Contract).withdraw(balanceETH), "WF");
// Calculate the amount of ETH to add as liquidity (70% of the withdrawn ETH)
uint256 ethLiquidity = balanceETH - ((balanceETH * 20) / 100);
// Retrieve the deployer's address for the ERC20 contract
address deployer = nftContractToDeployer[_erc20Contract];
// Transfer 0.5 ETH to the deployer as a reward
payable(deployer).transfer(0.5 ether);
// Wrap the remaining ETH into WETH
wrapETH(ethLiquidity);
// Add liquidity to the Uniswap pool using internal function
return _UniswapAddLiquidity(maxSupply, ethLiquidity, _erc20Contract, poolSplit);
}
// ============================================
// Price Calculation Functions
// ============================================
/**
* @notice Calculates the square root price in Q96 format based on token and WETH amounts.
* @param tokenAmount Amount of the ERC20 token.
* @param wethAmount Amount of WETH.
* @return sqrtPriceX96 Calculated sqrt price in Q96 format.
* @return token0 address
* @return token1 address
* @dev
* - Computes the price as wethAmount / tokenAmount.
* - Calculates the square root of the price.
* - Scales the sqrt price to Q96 format.
* - Ensures the result fits within a uint160.
*/
function calculateSqrtPriceX96(
uint256 tokenAmount,
uint256 wethAmount,
address tokenAddress
) internal view returns (uint160, address token0, address token1, uint256 token0Amount, uint256 token1Amount) {
// Determine token ordering based on addresses
bool isWethToken0 = address(WETHWrapper.weth) < tokenAddress;
// Calculate price according to Uniswap V3's token1/token0 convention
uint256 price;
if (isWethToken0) {
// If WETH is token0, then tokenAddress is token1
// price = token1/token0 = tokenAmount/wethAmount
price = (tokenAmount * 1e18) / wethAmount;
token0 = address(WETHWrapper.weth);
token1 = tokenAddress;
token0Amount = wethAmount;
token1Amount = tokenAmount;
} else {
// If WETH is token1, then tokenAddress is token0
// price = token1/token0 = wethAmount/tokenAmount
price = (wethAmount * 1e18) / tokenAmount;
token0 = tokenAddress;
token1 = address(WETHWrapper.weth);
token0Amount = tokenAmount;
token1Amount = wethAmount;
}
// Calculate the square root of the price
uint256 sqrtPrice = sqrt(price);
// Scale the sqrt price to Q96 format
uint256 sqrtPriceX96 = (sqrtPrice * 2 ** 96) / 1e9;
return (uint160(sqrtPriceX96), token0, token1, token0Amount, token1Amount);
}
/**
* @notice Calculates the square root of a given number using the Babylonian method.
* @param x Input number.
* @return y Square root of the input number.
* @dev
* - Iteratively computes the square root until convergence.
*/
function sqrt(uint256 x) internal pure returns (uint256 y) {
uint256 z = (x + 1) / 2;
y = x;
while (z < y) {
y = z;
z = (x / z + z) / 2;
}
}
// ============================================
// Price Retrieval Function
// ============================================
/**
* @notice Retrieves the current price of the ERC20 token in the associated Uniswap pool.
* @param _erc20Contract Address of the ERC20 contract.
* @return price Current price of the ERC20 token.
* @dev
* - Fetches the pool associated with the ERC20 contract.
* - Retrieves the current sqrt price from the pool's slot0.
* - Calculates the actual price from the sqrt price.
*/
function getCurrentPrice(address _erc20Contract) public view returns (uint256 price) {
// Get the Uniswap pool associated with the ERC20 contract
address poolAddress = poolsMade[_erc20Contract].uniswapPool;
if (poolAddress == address(0)) revert UniswapPoolNotSet();
IUniswapV3Pool pool = IUniswapV3Pool(poolAddress);
// Retrieve the current sqrt price from the pool
(uint160 sqrtPriceX96, , , , , , ) = pool.slot0();
// Calculate the price from sqrtPriceX96
uint256 priceX192 = uint256(sqrtPriceX96) * uint256(sqrtPriceX96);
price = priceX192 / (2 ** 192);
return price;
}
/**
* @notice Checks if a Uniswap V3 pool exists for a given ERC20 contract and WETH.
* @param _erc20 Address of the ERC20 token.
* @return pool Address of the existing pool or address(0) if it doesn't exist.
*/
function checkPoolExists(address _erc20) public view returns (address) {
// Query the Uniswap factory for the pool address
address pool = uniswapFactory.getPool(
_erc20,
address(WETHWrapper.weth),
3000 // Fee tier of 0.3%
);
return pool;
}
// ============================================
// Liquidity Management Functions
// ============================================
/**
* @notice Removes 25% liquidity from the position and swaps the withdrawn ETH for tokens.
* The goal is to maintain all ETH in the pool while reducing the number of tokens, resulting in a higher token price.
*
* @param _erc20Contract The contract being referenced
* @return bool for success
* @dev
* - This function performs a 25% removal of liquidity, followed by a swap of the withdrawn ETH for tokens.
* - The function ensures the tokens are sorted in the correct order for Uniswap operations.
* - Emits `LiquidityRemoved` and `SwapExecuted` events to track operations.
*/
function removeAndSwapLiquidity(
address _erc20Contract
) external onlyRole(ERC20CONTRACT) nonReentrant activeOnly returns (bool) {
uint256 tokenId = poolsMade[_erc20Contract].liquidityTokenID;
// Step 1: Decrease Liquidity by 25%
(uint256 amount0, uint256 amount1) = _decreasePartialLiquidity(tokenId, 25);
// Step 2: Identify Token Pairs and Allocate Balances
(
uint256 ethBalance,
uint256 tokenBalance,
bool isToken0WETH,
address token0,
address token1
) = _identifyTokenAndAllocate(_erc20Contract, amount0, amount1);
// Step 3: Approve Tokens for Swap
_approveTokens(_erc20Contract, ethBalance, tokenBalance);
// Step 4: Perform Swap of Withdrawn ETH for Tokens
uint256 swapAmount = ethBalance; // Withdrawn ETH to swap for tokens
_swapETHForTokens(swapAmount, token0, token1, isToken0WETH);
// Return true for success
return true;
}
// Step 1: Decrease Partial Liquidity
function _decreasePartialLiquidity(
uint256 tokenId,
uint8 percentToRemove
) private returns (uint256 removedAmount0, uint256 removedAmount1) {
uint128 liquidity;
(, , , , , , , liquidity, , , , ) = positionManager.positions(tokenId);
if (liquidity == 0) revert NoLiquidityToRemove();
// Calculate partial liquidity to remove
uint128 liquidityToRemove = (liquidity * percentToRemove) / 100;
INonfungiblePositionManager.DecreaseLiquidityParams memory decreaseParams = INonfungiblePositionManager
.DecreaseLiquidityParams({
tokenId: tokenId,
liquidity: liquidityToRemove,
amount0Min: 0,
amount1Min: 0,
deadline: block.timestamp + 4 hours
});
(removedAmount0, removedAmount1) = positionManager.decreaseLiquidity(decreaseParams);
INonfungiblePositionManager.CollectParams memory collectParams = INonfungiblePositionManager.CollectParams({
tokenId: tokenId,
recipient: address(this),
amount0Max: type(uint128).max,
amount1Max: type(uint128).max
});
(removedAmount0, removedAmount1) = positionManager.collect(collectParams);
emit LiquidityRemoved(tokenId, liquidityToRemove, removedAmount0, removedAmount1);
return (removedAmount0, removedAmount1);
}
// Step 2: Identify Tokens and Allocate Balances
function _identifyTokenAndAllocate(
address _erc20Contract,
uint256 amount0,
uint256 amount1
)
private
view
returns (uint256 ethBalance, uint256 tokenBalance, bool isToken0WETH, address token0, address token1)
{
token0 = poolsMade[_erc20Contract].token0;
token1 = poolsMade[_erc20Contract].token1;
// Determine which token is ETH/WETH
isToken0WETH = (token0 == address(WETHWrapper.weth));
ethBalance = isToken0WETH ? amount0 : amount1;
tokenBalance = isToken0WETH ? amount1 : amount0;
return (ethBalance, tokenBalance, isToken0WETH, token0, token1);
}
// Step 3: Approve Tokens
function _approveTokens(address _erc20Contract, uint256 ethBalance, uint256 tokenBalance) private {
// Approve WETH for swapping
IERC20(address(WETHWrapper.weth)).approve(address(swapRouter), ethBalance);
// Approve ERC20 token for swapping
IERC20(_erc20Contract).approve(address(swapRouter), tokenBalance);
}
// Step 4: Swap ETH for Tokens
function _swapETHForTokens(uint256 ethAmount, address token0, address token1, bool isToken0WETH) private {
// Determine the token to receive
address tokenIn = isToken0WETH ? token0 : token1;
address tokenOut = isToken0WETH ? token1 : token0;
// Create swap parameters
ISwapRouter.ExactInputSingleParams memory params = ISwapRouter.ExactInputSingleParams({
tokenIn: tokenIn,
tokenOut: tokenOut,
fee: 3000,
recipient: address(this),
deadline: block.timestamp + 4 hours,
amountIn: ethAmount,
amountOutMinimum: 0, // Set to 0 to accept any amount due to slippage
sqrtPriceLimitX96: 0
});
// Execute swap using Uniswap Router
swapRouter.exactInputSingle{ value: ethAmount }(params);
}
// ============================================
// Fee Collection Function
// ============================================
/**
* @notice Collects fees from a specific liquidity position.
* @dev _erc20Contract Address of the ERC20 contract associated with the pool.
* @param tokenId Token ID of the liquidity position.
* @return amount0Collected Amount of token0 collected as fees.
* @return amount1Collected Amount of token1 collected as fees.
* @dev
* - Ensures that the pool is set and owned by the factory.
* - Collects the maximum possible fees.
* - Emits a FeesCollected event.
* - Only callable by account with DEFAULT_ADMIN_ROLE.
*/
function collectFeesFromPosition(
uint256 tokenId
) external onlyRole(DEFAULT_ADMIN_ROLE) activeOnly returns (uint256 amount0Collected, uint256 amount1Collected) {
// Ensure that the factory owns the liquidity position
if (!_ownsPosition(tokenId)) revert FactoryDoesNotOwnPosition();
// Prepare the parameters for collecting fees
INonfungiblePositionManager.CollectParams memory params = INonfungiblePositionManager.CollectParams({
tokenId: tokenId,
recipient: address(this),
amount0Max: type(uint128).max,
amount1Max: type(uint128).max
});
// Collect the fees from the liquidity position
(amount0Collected, amount1Collected) = positionManager.collect(params);
// Emit the FeesCollected event with relevant details
emit FeesCollected(tokenId, amount0Collected, amount1Collected);
return (amount0Collected, amount1Collected);
}
// ============================================
// Helper Functions
// ============================================
/**
* @notice Allows the admin to withdraw all fees collected from the factory.
* @param account Address to receive the withdrawn ETH.
* @dev
* - Transfers the entire ETH balance to the account.
* - Emits a Withdrawal event.
* - Only callable by DEFAULT_ADMIN_ROLE.
*/
function withdrawETH(address payable account) external onlyRole(DEFAULT_ADMIN_ROLE) {
uint256 balance = address(this).balance;
account.transfer(balance);
// Emit the Withdrawal event with relevant details
emit Withdrawal(account, balance);
}
/**
* @notice Withdraws ETH from contracts associated with a specific NFT contract.
* @param _nftContract Address of the NFT contract.
* @dev
* - Ensures the caller has DEFAULT_ADMIN_ROLE.
* - Only if in emergency mode and protocol contract is disabled
* - Retrieves the associated ERC20 contract and withdraws its ETH balance.
*/
function emergencyWithdrawFromContracts(address _nftContract) external {
if (!hasRole(DEFAULT_ADMIN_ROLE, msg.sender)) revert NotAuthorized();
require(!isActive, "Only in emergency mode");
address _contract = ercContractToNFTContract[_nftContract];
uint256 contractBalance = _contract.balance;
IERC721ex(_contract).withdraw(contractBalance);
}
/**
* @notice Transfers ERC20 tokens from the contract to a specified address.
* @param tokenAddress Address of the ERC20 token.
* @param to Address to receive the tokens.
* @param amount Amount of tokens to transfer.
* @dev
* - Ensures the transfer amount is greater than zero.
* - Checks that the contract has sufficient token balance.
* - Performs the token transfer.
* - Only callable by accounts with DEFAULT_ADMIN_ROLE.
*/
function transferERC20Tokens(
address tokenAddress,
address to,
uint256 amount
) external onlyRole(DEFAULT_ADMIN_ROLE) {
require(!isActive, "Only in emergency mode");
// Initialize the ERC20 token interface
IERC20 token = IERC20(tokenAddress);
// Retrieve the token balance of the contract
uint256 balance = token.balanceOf(address(this));
if (balance < amount) revert InsufficientValue();
// Attempt to transfer the tokens to the specified address
require(token.transfer(to, amount), "TTF");
}
/**
* @notice Checks if the factory contract owns a specific liquidity position.
* @param tokenId Token ID of the liquidity position.
* @return bool indicating ownership.
* @dev
* - Compares the owner of the token ID with the factory contract's address.
*/
function _ownsPosition(uint256 tokenId) internal view returns (bool) {
return positionManager.ownerOf(tokenId) == address(this);
}
/**
* @notice Transfers an NFT from the factory to a specified address.
* @param _NFTContract Address of the NFT contract.
* @param to Address to receive the NFT.
* @param _tokenID Token ID of the NFT.
* @return bool indicating successful transfer.
* @dev
* - Ensures the caller has DEFAULT_ADMIN_ROLE.
* - Transfers the NFT from the factory to the specified address.
*/
function transferNFTFromFactory(
address _NFTContract,
address to,
uint256 _tokenID
) external onlyRole(DEFAULT_ADMIN_ROLE) returns (bool) {
IERC721(_NFTContract).transferFrom(address(this), to, _tokenID);
return true;
}
// ============================================
// Fallback Function
// ============================================
/**
* @dev Fallback function to handle incoming ETH transfers with data.
*/
fallback() external payable {
// Handle ETH transfers with data
}
receive() external payable {
// Handle incoming Ether without data here.
}
}// SPDX-License-Identifier: MIT
/*
*
* All rights reserved. Property of Mintable PTE LTD.
*
*/
pragma solidity ^0.8.0;
import "./lib/DecodeSignature.sol";
/**
* @title Signer Contract
* @dev This contract is used for decoding signatures from a trusted source wallet address for data validation.
* It inherits Ownable and SignatureParser for handling ownership and signature parsing respectively.
* Updated to the latest Solidity standards and optimized for security and gas efficiency.
*/
contract SignatureParser is DecodeSignature {
bytes32 constant salt = 0xf2d857f4a3edcb9b78b4d503bfe733db1e3f6cdc2b7971ee739626c97e86a558; // Salt value used in hashing
bytes32 private constant EIP712_DOMAIN_TYPEHASH =
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)");
bytes32 private constant ERC721Ex_TYPEHASH = keccak256("ERC721Ex(address _contract,uint256 _totalSupply)");
uint256 constant chainId = 1; // Mainnet chain ID
string public constant version = "Mintable v3.1"; // Version of the contract
struct ERC721Ex {
address _contract;
uint256 _totalSupply;
}
/**
* @dev Generates a hash for a given ERC721Ex struct.
* Uses EIP-712 encoding standard to improve efficiency and security.
* @param _721Ex The struct to be hashed.
* @return bytes32 The hash of the struct.
*/
function hashListing(ERC721Ex memory _721Ex) private pure returns (bytes32) {
return keccak256(abi.encode(ERC721Ex_TYPEHASH, _721Ex._contract, _721Ex._totalSupply));
}
/**
* @dev Generates the domain separator for EIP-712 compliant hashing.
* @return bytes32 The domain separator.
*/
function getDomainSeparator() private view returns (bytes32) {
return
keccak256(
abi.encode(
EIP712_DOMAIN_TYPEHASH,
keccak256(bytes("Signer")),
keccak256(bytes(version)),
chainId,
address(this),
salt
)
);
}
/**
* @dev Generates a full EIP-712 hash for a given ERC721Ex struct.
* @param _721Ex The struct to be hashed.
* @return bytes32 The EIP-712 compliant hash of the data.
*/
function hashEIP712(ERC721Ex memory _721Ex) private view returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", getDomainSeparator(), hashListing(_721Ex)));
}
/**
* @dev Validates the signature of a given signature.
* @param _contract The contract of the token.
* @param _totalSupply The token total supply.
* @return bool True if the signature is valid, otherwise false.
*/
function isValidSignature(
address _contract,
uint256 _totalSupply,
bytes memory signature
) public view returns (bool) {
ERC721Ex memory ex = ERC721Ex({ _contract: _contract, _totalSupply: _totalSupply });
bytes32 signedMessage = hashEIP712(ex); // Generate EIP-712 compliant hash of the listing
address addr = _signatureRecover(signedMessage, signature); // Recover the signer from the signature
return signer == addr; // Compare the recovered address with the seller address
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;
/// @title Math library for computing sqrt prices from ticks and vice versa
/// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports
/// prices between 2**-128 and 2**128
library TickMath {
/// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128
int24 internal constant MIN_TICK = -887272;
/// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128
int24 internal constant MAX_TICK = -MIN_TICK;
/// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)
uint160 internal constant MIN_SQRT_RATIO = 4295128739;
/// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)
uint160 internal constant MAX_SQRT_RATIO =
1461446703485210103287273052203988822378723970342;
/// @notice Calculates sqrt(1.0001^tick) * 2^96
/// @dev Throws if |tick| > max tick
/// @param tick The input tick for the above formula
/// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
/// at the given tick
function getSqrtRatioAtTick(
int24 tick
) internal pure returns (uint160 sqrtPriceX96) {
uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));
require(absTick <= uint256(int256(MAX_TICK)), 'T');
uint256 ratio = absTick & 0x1 != 0
? 0xfffcb933bd6fad37aa2d162d1a594001
: 0x100000000000000000000000000000000;
if (absTick & 0x2 != 0)
ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;
if (absTick & 0x4 != 0)
ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;
if (absTick & 0x8 != 0)
ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;
if (absTick & 0x10 != 0)
ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128;
if (absTick & 0x20 != 0)
ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128;
if (absTick & 0x40 != 0)
ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128;
if (absTick & 0x80 != 0)
ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;
if (absTick & 0x100 != 0)
ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;
if (absTick & 0x200 != 0)
ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128;
if (absTick & 0x400 != 0)
ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;
if (absTick & 0x800 != 0)
ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;
if (absTick & 0x1000 != 0)
ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;
if (absTick & 0x2000 != 0)
ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;
if (absTick & 0x4000 != 0)
ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;
if (absTick & 0x8000 != 0)
ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128;
if (absTick & 0x10000 != 0)
ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;
if (absTick & 0x20000 != 0)
ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128;
if (absTick & 0x40000 != 0)
ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128;
if (absTick & 0x80000 != 0)
ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128;
if (tick > 0) ratio = type(uint256).max / ratio;
// this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96.
// we then downcast because we know the result always fits within 160 bits due to our tick input constraint
// we round up in the division so getTickAtSqrtRatio of the output price is always consistent
sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1));
}
/// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio
/// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may
/// ever return.
/// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96
/// @return tick The greatest tick for which the ratio is less than or equal to the input ratio
function getTickAtSqrtRatio(
uint160 sqrtPriceX96
) internal pure returns (int24 tick) {
// second inequality must be < because the price can never reach the price at the max tick
require(
sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO,
'R'
);
uint256 ratio = uint256(sqrtPriceX96) << 32;
uint256 r = ratio;
uint256 msb = 0;
assembly {
let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(5, gt(r, 0xFFFFFFFF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(4, gt(r, 0xFFFF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(3, gt(r, 0xFF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(2, gt(r, 0xF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(1, gt(r, 0x3))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := gt(r, 0x1)
msb := or(msb, f)
}
if (msb >= 128) r = ratio >> (msb - 127);
else r = ratio << (127 - msb);
int256 log_2 = (int256(msb) - 128) << 64;
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(63, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(62, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(61, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(60, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(59, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(58, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(57, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(56, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(55, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(54, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(53, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(52, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(51, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(50, f))
}
int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number
int24 tickLow = int24(
(log_sqrt10001 - 3402992956809132418596140100660247210) >> 128
);
int24 tickHi = int24(
(log_sqrt10001 + 291339464771989622907027621153398088495) >> 128
);
tick = tickLow == tickHi
? tickLow
: getSqrtRatioAtTick(tickHi) <= sqrtPriceX96
? tickHi
: tickLow;
}
}// SPDX-License-Identifier: MIT
/*
*
* All rights reserved. Property of Mintable PTE LTD.
*
*/
pragma solidity ^0.8.0;
interface ILogicLib {
enum VoteOption {
PoolSplit,
UniswapTrading,
ToggleClaim,
ToggleBurn
}
struct VotingOutcome {
uint256 yesVotes; // Number of yes votes
uint256 noVotes; // Number of no votes
bool executed; // If the vote has been executed
}
struct Proposal {
address proposer; // Address of the proposer
uint256 voteStartTime; // Start time of the voting
uint256 voteEndTime; // End time of the voting
uint256 totalVotes; // Total number of votes cast
uint256 id; // Proposal ID
bool executed; // Whether the proposal has been executed
bool isActive; // Whether the proposal is currently active
VoteOption voteOption; // The type of vote proposed
}
event ProposalCreated(
address indexed proposer,
address indexed contractAddress,
VoteOption voteOption,
uint256 duration
);
event VoteSubmitted(address indexed contractAddress, VoteOption voteOption, address indexed voter, bool vote);
event ActionExecuted(address indexed contractAddress, VoteOption voteOption);
function registerFactory(address contractAddress) external;
function registerContract(address contractAddress, uint256 _reservedTokens) external;
function proposeVote(address contractAddress, VoteOption voteOption, uint256 duration) external;
function submitVote(address contractAddress, bool vote, uint256 proposal_id, uint256 voteAmount) external;
function executeAction(address contractAddress, uint256 proposal_id) external;
function getVotingOutcome(
address contractAddress,
uint256 proposal_id
) external view returns (VotingOutcome memory);
function setActionTargets(address contractAddress, address[] calldata targets) external;
function removeDepositFromVote(uint256 proposal_id, address _voter) external;
function isProposalActive(address contractAddress, uint256 proposalId) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` 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 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "./IAccessControl.sol";
import {Context} from "../utils/Context.sol";
import {ERC165} from "../utils/introspection/ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address account => bool) hasRole;
bytes32 adminRole;
}
mapping(bytes32 role => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with an {AccessControlUnauthorizedAccount} error including the required role.
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual returns (bool) {
return _roles[role].hasRole[account];
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
* is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
* is missing `role`.
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert AccessControlUnauthorizedAccount(account, role);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address callerConfirmation) public virtual {
if (callerConfirmation != _msgSender()) {
revert AccessControlBadConfirmation();
}
_revokeRole(role, callerConfirmation);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
if (!hasRole(role, account)) {
_roles[role].hasRole[account] = true;
emit RoleGranted(role, account, _msgSender());
return true;
} else {
return false;
}
}
/**
* @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
if (hasRole(role, account)) {
_roles[role].hasRole[account] = false;
emit RoleRevoked(role, account, _msgSender());
return true;
} else {
return false;
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
import './pool/IUniswapV3PoolImmutables.sol';
import './pool/IUniswapV3PoolState.sol';
import './pool/IUniswapV3PoolDerivedState.sol';
import './pool/IUniswapV3PoolActions.sol';
import './pool/IUniswapV3PoolOwnerActions.sol';
import './pool/IUniswapV3PoolEvents.sol';
/// @title The interface for a Uniswap V3 Pool
/// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform
/// to the ERC20 specification
/// @dev The pool interface is broken up into many smaller pieces
interface IUniswapV3Pool is
IUniswapV3PoolImmutables,
IUniswapV3PoolState,
IUniswapV3PoolDerivedState,
IUniswapV3PoolActions,
IUniswapV3PoolOwnerActions,
IUniswapV3PoolEvents
{
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;
import '../../../v3-core/contracts/interfaces/IUniswapV3SwapCallback.sol';
/// @title Router token swapping functionality
/// @notice Functions for swapping tokens via Uniswap V3
interface ISwapRouter is IUniswapV3SwapCallback {
struct ExactInputSingleParams {
address tokenIn;
address tokenOut;
uint24 fee;
address recipient;
uint256 deadline;
uint256 amountIn;
uint256 amountOutMinimum;
uint160 sqrtPriceLimitX96;
}
/// @notice Swaps `amountIn` of one token for as much as possible of another token
/// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata
/// @return amountOut The amount of the received token
function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);
struct ExactInputParams {
bytes path;
address recipient;
uint256 deadline;
uint256 amountIn;
uint256 amountOutMinimum;
}
/// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path
/// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata
/// @return amountOut The amount of the received token
function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);
struct ExactOutputSingleParams {
address tokenIn;
address tokenOut;
uint24 fee;
address recipient;
uint256 deadline;
uint256 amountOut;
uint256 amountInMaximum;
uint160 sqrtPriceLimitX96;
}
/// @notice Swaps as little as possible of one token for `amountOut` of another token
/// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata
/// @return amountIn The amount of the input token
function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);
struct ExactOutputParams {
bytes path;
address recipient;
uint256 deadline;
uint256 amountOut;
uint256 amountInMaximum;
}
/// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)
/// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata
/// @return amountIn The amount of the input token
function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;
import '../../../../@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol';
import '../../../../@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol';
import './IPoolInitializer.sol';
import './IERC721Permit.sol';
import './IPeripheryPayments.sol';
import './IPeripheryImmutableState.sol';
import '../libraries/PoolAddress.sol';
/// @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 is
IPoolInitializer,
IPeripheryPayments,
IPeripheryImmutableState,
IERC721Metadata,
IERC721Enumerable,
IERC721Permit
{
/// @notice Emitted when liquidity is increased for a position NFT
/// @dev Also emitted when a token is minted
/// @param tokenId The ID of the token for which liquidity was increased
/// @param liquidity The amount by which liquidity for the NFT position was increased
/// @param amount0 The amount of token0 that was paid for the increase in liquidity
/// @param amount1 The amount of token1 that was paid for the increase in liquidity
event IncreaseLiquidity(
uint256 indexed tokenId,
uint128 liquidity,
uint256 amount0,
uint256 amount1
);
/// @notice Emitted when liquidity is decreased for a position NFT
/// @param tokenId The ID of the token for which liquidity was decreased
/// @param liquidity The amount by which liquidity for the NFT position was decreased
/// @param amount0 The amount of token0 that was accounted for the decrease in liquidity
/// @param amount1 The amount of token1 that was accounted for the decrease in liquidity
event DecreaseLiquidity(
uint256 indexed tokenId,
uint128 liquidity,
uint256 amount0,
uint256 amount1
);
/// @notice Emitted when tokens are collected for a position NFT
/// @dev The amounts reported may not be exactly equivalent to the amounts transferred, due to rounding behavior
/// @param tokenId The ID of the token for which underlying tokens were collected
/// @param recipient The address of the account that received the collected tokens
/// @param amount0 The amount of token0 owed to the position that was collected
/// @param amount1 The amount of token1 owed to the position that was collected
event Collect(
uint256 indexed tokenId,
address recipient,
uint256 amount0,
uint256 amount1
);
/// @notice Returns the position information associated with a given token ID.
/// @dev Throws if the token ID is not valid.
/// @param tokenId The ID of the token that represents the position
/// @return nonce The nonce for permits
/// @return operator The address that is approved for spending
/// @return token0 The address of the token0 for a specific pool
/// @return token1 The address of the token1 for a specific pool
/// @return fee The fee associated with the pool
/// @return tickLower The lower end of the tick range for the position
/// @return tickUpper The higher end of the tick range for the position
/// @return liquidity The liquidity of the position
/// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position
/// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position
/// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation
/// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation
function positions(
uint256 tokenId
)
external
view
returns (
uint96 nonce,
address operator,
address token0,
address token1,
uint24 fee,
int24 tickLower,
int24 tickUpper,
uint128 liquidity,
uint256 feeGrowthInside0LastX128,
uint256 feeGrowthInside1LastX128,
uint128 tokensOwed0,
uint128 tokensOwed1
);
struct MintParams {
address token0;
address token1;
uint24 fee;
int24 tickLower;
int24 tickUpper;
uint256 amount0Desired;
uint256 amount1Desired;
uint256 amount0Min;
uint256 amount1Min;
address recipient;
uint256 deadline;
}
/// @notice Creates a new position wrapped in a NFT
/// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized
/// a method does not exist, i.e. the pool is assumed to be initialized.
/// @param params The params necessary to mint a position, encoded as `MintParams` in calldata
/// @return tokenId The ID of the token that represents the minted position
/// @return liquidity The amount of liquidity for this position
/// @return amount0 The amount of token0
/// @return amount1 The amount of token1
function mint(
MintParams calldata params
)
external
payable
returns (
uint256 tokenId,
uint128 liquidity,
uint256 amount0,
uint256 amount1
);
struct IncreaseLiquidityParams {
uint256 tokenId;
uint256 amount0Desired;
uint256 amount1Desired;
uint256 amount0Min;
uint256 amount1Min;
uint256 deadline;
}
/// @notice Increases the amount of liquidity in a position, with tokens paid by the `msg.sender`
/// @param params tokenId The ID of the token for which liquidity is being increased,
/// amount0Desired The desired amount of token0 to be spent,
/// amount1Desired The desired amount of token1 to be spent,
/// amount0Min The minimum amount of token0 to spend, which serves as a slippage check,
/// amount1Min The minimum amount of token1 to spend, which serves as a slippage check,
/// deadline The time by which the transaction must be included to effect the change
/// @return liquidity The new liquidity amount as a result of the increase
/// @return amount0 The amount of token0 to acheive resulting liquidity
/// @return amount1 The amount of token1 to acheive resulting liquidity
function increaseLiquidity(
IncreaseLiquidityParams calldata params
)
external
payable
returns (uint128 liquidity, uint256 amount0, uint256 amount1);
struct DecreaseLiquidityParams {
uint256 tokenId;
uint128 liquidity;
uint256 amount0Min;
uint256 amount1Min;
uint256 deadline;
}
/// @notice Decreases the amount of liquidity in a position and accounts it to the position
/// @param params tokenId The ID of the token for which liquidity is being decreased,
/// amount The amount by which liquidity will be decreased,
/// amount0Min The minimum amount of token0 that should be accounted for the burned liquidity,
/// amount1Min The minimum amount of token1 that should be accounted for the burned liquidity,
/// deadline The time by which the transaction must be included to effect the change
/// @return amount0 The amount of token0 accounted to the position's tokens owed
/// @return amount1 The amount of token1 accounted to the position's tokens owed
function decreaseLiquidity(
DecreaseLiquidityParams calldata params
) external payable returns (uint256 amount0, uint256 amount1);
struct CollectParams {
uint256 tokenId;
address recipient;
uint128 amount0Max;
uint128 amount1Max;
}
/// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient
/// @param params tokenId The ID of the NFT for which tokens are being collected,
/// recipient The account that should receive the tokens,
/// amount0Max The maximum amount of token0 to collect,
/// amount1Max The maximum amount of token1 to collect
/// @return amount0 The amount of fees collected in token0
/// @return amount1 The amount of fees collected in token1
function collect(
CollectParams calldata params
) external payable returns (uint256 amount0, uint256 amount1);
/// @notice Burns a token ID, which deletes it from the NFT contract. The token must have 0 liquidity and all tokens
/// must be collected first.
/// @param tokenId The ID of the token that is being burned
function burn(uint256 tokenId) external payable;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title The interface for the Uniswap V3 Factory
/// @notice The Uniswap V3 Factory facilitates creation of Uniswap V3 pools and control over the protocol fees
interface IUniswapV3Factory {
/// @notice Emitted when the owner of the factory is changed
/// @param oldOwner The owner before the owner was changed
/// @param newOwner The owner after the owner was changed
event OwnerChanged(address indexed oldOwner, address indexed newOwner);
/// @notice Emitted when a pool is created
/// @param token0 The first token of the pool by address sort order
/// @param token1 The second token of the pool by address sort order
/// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
/// @param tickSpacing The minimum number of ticks between initialized ticks
/// @param pool The address of the created pool
event PoolCreated(
address indexed token0,
address indexed token1,
uint24 indexed fee,
int24 tickSpacing,
address pool
);
/// @notice Emitted when a new fee amount is enabled for pool creation via the factory
/// @param fee The enabled fee, denominated in hundredths of a bip
/// @param tickSpacing The minimum number of ticks between initialized ticks for pools created with the given fee
event FeeAmountEnabled(uint24 indexed fee, int24 indexed tickSpacing);
/// @notice Returns the current owner of the factory
/// @dev Can be changed by the current owner via setOwner
/// @return The address of the factory owner
function owner() external view returns (address);
/// @notice Returns the tick spacing for a given fee amount, if enabled, or 0 if not enabled
/// @dev A fee amount can never be removed, so this value should be hard coded or cached in the calling context
/// @param fee The enabled fee, denominated in hundredths of a bip. Returns 0 in case of unenabled fee
/// @return The tick spacing
function feeAmountTickSpacing(uint24 fee) external view returns (int24);
/// @notice Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist
/// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order
/// @param tokenA The contract address of either token0 or token1
/// @param tokenB The contract address of the other token
/// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
/// @return pool The pool address
function getPool(
address tokenA,
address tokenB,
uint24 fee
) external view returns (address pool);
/// @notice Creates a pool for the given two tokens and fee
/// @param tokenA One of the two tokens in the desired pool
/// @param tokenB The other of the two tokens in the desired pool
/// @param fee The desired fee for the pool
/// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved
/// from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments
/// are invalid.
/// @return pool The address of the newly created pool
function createPool(
address tokenA,
address tokenB,
uint24 fee
) external returns (address pool);
/// @notice Updates the owner of the factory
/// @dev Must be called by the current owner
/// @param _owner The new owner of the factory
function setOwner(address _owner) external;
/// @notice Enables a fee amount with the given tickSpacing
/// @dev Fee amounts may never be removed once enabled
/// @param fee The fee amount to enable, denominated in hundredths of a bip (i.e. 1e-6)
/// @param tickSpacing The spacing between ticks to be enforced for all pools created with the given fee amount
function enableFeeAmount(uint24 fee, int24 tickSpacing) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "./@openzeppelin/contracts/access/Ownable.sol";
import "./@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "./@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface IWETH is IERC20 {
function deposit() external payable;
function withdraw(uint256) external;
}
contract WETHWrapper is ReentrancyGuard {
IWETH public immutable weth;
event ETHWrapped(uint256 amount);
event WETHUnwrapped(uint256 amount);
// WETH address on Ethereum mainnet
constructor() {
weth = IWETH(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
}
/**
* @dev Wraps the contract's entire ETH balance into WETH.
* Can only be called by the owner.
*/
function wrapETH(uint256 amount) internal nonReentrant {
uint256 ethBalance = address(this).balance;
require(ethBalance > amount, "No ETH balance to wrap");
// Wrap the ETH balance into WETH
weth.deposit{ value: amount }();
emit ETHWrapped(amount);
// Verify the WETH balance after wrapping
require(weth.balanceOf(address(this)) >= amount, "WETH balance mismatch");
}
/**
* @dev Unwraps a specified amount of WETH back to ETH.
* Can only be called by the owner.
* @param amount The amount of WETH to unwrap
*/
function unwrapWETH(uint256 amount) internal nonReentrant {
require(amount > 0, "Amount must be greater than 0");
require(weth.balanceOf(address(this)) >= amount, "Insufficient WETH balance");
weth.withdraw(amount);
emit WETHUnwrapped(amount);
// Transfer the unwrapped ETH to the owner
(bool success, ) = address(msg.sender).call{ value: amount }("");
require(success, "ETH transfer failed");
}
/**
* @dev Allows the owner to withdraw any ERC20 tokens accidentally sent to this contract.
* @param token The address of the ERC20 token to withdraw
* @param amount The amount of tokens to withdraw
*/
function withdrawERC20(address token, uint256 amount) internal {
require(token != address(weth), "Cannot withdraw WETH directly");
IERC20(token).transfer(msg.sender, amount);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/Clones.sol)
pragma solidity ^0.8.0;
/**
* @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for
* deploying minimal proxy contracts, also known as "clones".
*
* > To simply and cheaply clone contract functionality in an immutable way, this standard specifies
* > a minimal bytecode implementation that delegates all calls to a known, fixed address.
*
* The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`
* (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the
* deterministic method.
*
* _Available since v3.4._
*/
library Clones {
/**
* @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
*
* This function uses the create opcode, which should never revert.
*/
function clone(address implementation) internal returns (address instance) {
/// @solidity memory-safe-assembly
assembly {
// Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
// of the `implementation` address with the bytecode before the address.
mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))
// Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))
instance := create(0, 0x09, 0x37)
}
require(instance != address(0), "ERC1167: create failed");
}
/**
* @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
*
* This function uses the create2 opcode and a `salt` to deterministically deploy
* the clone. Using the same `implementation` and `salt` multiple time will revert, since
* the clones cannot be deployed twice at the same address.
*/
function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {
/// @solidity memory-safe-assembly
assembly {
// Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
// of the `implementation` address with the bytecode before the address.
mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))
// Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))
instance := create2(0, 0x09, 0x37, salt)
}
require(instance != address(0), "ERC1167: create2 failed");
}
/**
* @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
*/
function predictDeterministicAddress(
address implementation,
bytes32 salt,
address deployer
) internal pure returns (address predicted) {
/// @solidity memory-safe-assembly
assembly {
let ptr := mload(0x40)
mstore(add(ptr, 0x38), deployer)
mstore(add(ptr, 0x24), 0x5af43d82803e903d91602b57fd5bf3ff)
mstore(add(ptr, 0x14), implementation)
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73)
mstore(add(ptr, 0x58), salt)
mstore(add(ptr, 0x78), keccak256(add(ptr, 0x0c), 0x37))
predicted := keccak256(add(ptr, 0x43), 0x55)
}
}
/**
* @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
*/
function predictDeterministicAddress(
address implementation,
bytes32 salt
) internal view returns (address predicted) {
return predictDeterministicAddress(implementation, salt, address(this));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: MIT
/*
*
* All rights reserved. Property of Mintable PTE LTD.
*
*/
pragma solidity ^0.8.0;
/**
* @title DecodeSignature Contract
* @dev This contract provides functions for parsing and verifying signatures.
* Updated to the latest Solidity standards.
*/
abstract contract DecodeSignature {
address public constant signer = 0x257d91E6453126e7B8863a836c53FE7c49a00ec2; // Address of the trusted signer
/**
* @dev Breaks a signature into its constituent parts (v, r, s).
* @param signature The signature to be broken.
* @return v The recovery id of the signature.
* @return r The r value of the signature.
* @return s The s value of the signature.
*/
function _breakUpSignature(bytes memory signature) internal pure returns (uint8 v, bytes32 r, bytes32 s) {
require(signature.length == 65, "Invalid signature length"); // Ensure the signature length is correct
assembly {
r := mload(add(signature, 32)) // Load `r` from bytes 32-63
s := mload(add(signature, 64)) // Load `s` from bytes 64-95
v := byte(0, mload(add(signature, 96))) // Load `v` from byte 96
}
// Normalize `v` value
if (v < 27) {
v += 27;
}
}
/**
* @dev Recovers the signer address from a given hash and signature.
* @param hash The hash that was signed.
* @param signature The signature generated.
* @return address The address of the signer.
*/
function _signatureRecover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(uint8 v, bytes32 r, bytes32 s) = _breakUpSignature(signature);
require(v == 27 || v == 28, "Invalid signature 'v' value"); // Ensure v value is valid
return ecrecover(hash, v, r, s); // Use ecrecover to recover the address from the signature
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Callback for IUniswapV3PoolActions#swap
/// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface
interface IUniswapV3SwapCallback {
/// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap.
/// @dev In the implementation you must pay the pool tokens owed for the swap.
/// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.
/// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.
/// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by
/// the end of the swap. If positive, the callback must send that amount of token0 to the pool.
/// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by
/// the end of the swap. If positive, the callback must send that amount of token1 to the pool.
/// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call
function uniswapV3SwapCallback(
int256 amount0Delta,
int256 amount1Delta,
bytes calldata data
) external;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Provides functions for deriving a pool address from the factory, tokens, and the fee
library PoolAddress {
bytes32 internal constant POOL_INIT_CODE_HASH = 0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54;
/// @notice The identifying key of the pool
struct PoolKey {
address token0;
address token1;
uint24 fee;
}
/// @notice Returns PoolKey: the ordered tokens with the matched fee levels
/// @param tokenA The first token of a pool, unsorted
/// @param tokenB The second token of a pool, unsorted
/// @param fee The fee level of the pool
/// @return Poolkey The pool details with ordered token0 and token1 assignments
function getPoolKey(
address tokenA,
address tokenB,
uint24 fee
) internal pure returns (PoolKey memory) {
if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA);
return PoolKey({token0: tokenA, token1: tokenB, fee: fee});
}
/// @notice Deterministically computes the pool address given the factory and PoolKey
/// @param factory The Uniswap V3 factory contract address
/// @param key The PoolKey
/// @return pool The contract address of the V3 pool
function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) {
require(key.token0 < key.token1);
pool = address(uint160(
uint256(
keccak256(
abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encode(key.token0, key.token1, key.fee)),
POOL_INIT_CODE_HASH
)
)
)
));
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Immutable state
/// @notice Functions that return immutable state of the router
interface IPeripheryImmutableState {
/// @return Returns the address of the Uniswap V3 factory
function factory() external view returns (address);
/// @return Returns the address of WETH9
function WETH9() external view returns (address);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
/// @title Periphery Payments
/// @notice Functions to ease deposits and withdrawals of ETH
interface IPeripheryPayments {
/// @notice Unwraps the contract's WETH9 balance and sends it to recipient as ETH.
/// @dev The amountMinimum parameter prevents malicious contracts from stealing WETH9 from users.
/// @param amountMinimum The minimum amount of WETH9 to unwrap
/// @param recipient The address receiving ETH
function unwrapWETH9(uint256 amountMinimum, address recipient) external payable;
/// @notice Refunds any ETH balance held by this contract to the `msg.sender`
/// @dev Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps
/// that use ether for the input amount
function refundETH() external payable;
/// @notice Transfers the full amount of a token held by this contract to recipient
/// @dev The amountMinimum parameter prevents malicious contracts from stealing the token from users
/// @param token The contract address of the token which will be transferred to `recipient`
/// @param amountMinimum The minimum amount of token required for a transfer
/// @param recipient The destination address of the token
function sweepToken(
address token,
uint256 amountMinimum,
address recipient
) external payable;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
import '../../../../@openzeppelin/contracts/token/ERC721/IERC721.sol';
/// @title ERC721 with permit
/// @notice Extension to ERC721 that includes a permit function for signature based approvals
interface IERC721Permit is IERC721 {
/// @notice The permit typehash used in the permit signature
/// @return The typehash for the permit
function PERMIT_TYPEHASH() external pure returns (bytes32);
/// @notice The domain separator used in the permit signature
/// @return The domain seperator used in encoding of permit signature
function DOMAIN_SEPARATOR() external view returns (bytes32);
/// @notice Approve of a specific token ID for spending by spender via signature
/// @param spender The account that is being approved
/// @param tokenId The ID of the token that is being approved for spending
/// @param deadline The deadline timestamp by which the call must be mined for the approve to work
/// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s`
/// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s`
/// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v`
function permit(
address spender,
uint256 tokenId,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external payable;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;
/// @title Creates and initializes V3 Pools
/// @notice Provides a method for creating and initializing a pool, if necessary, for bundling with other methods that
/// require the pool to exist.
interface IPoolInitializer {
/// @notice Creates a new pool if it does not exist, then initializes if not initialized
/// @dev This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool
/// @param token0 The contract address of token0 of the pool
/// @param token1 The contract address of token1 of the pool
/// @param fee The fee amount of the v3 pool for the specified token pair
/// @param sqrtPriceX96 The initial square root price of the pool as a Q64.96 value
/// @return pool Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary
function createAndInitializePoolIfNecessary(
address token0,
address token1,
uint24 fee,
uint160 sqrtPriceX96
) external payable returns (address pool);
}// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
import "./IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
import "./IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Events emitted by a pool
/// @notice Contains all events emitted by the pool
interface IUniswapV3PoolEvents {
/// @notice Emitted exactly once by a pool when #initialize is first called on the pool
/// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize
/// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96
/// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool
event Initialize(uint160 sqrtPriceX96, int24 tick);
/// @notice Emitted when liquidity is minted for a given position
/// @param sender The address that minted the liquidity
/// @param owner The owner of the position and recipient of any minted liquidity
/// @param tickLower The lower tick of the position
/// @param tickUpper The upper tick of the position
/// @param amount The amount of liquidity minted to the position range
/// @param amount0 How much token0 was required for the minted liquidity
/// @param amount1 How much token1 was required for the minted liquidity
event Mint(
address sender,
address indexed owner,
int24 indexed tickLower,
int24 indexed tickUpper,
uint128 amount,
uint256 amount0,
uint256 amount1
);
/// @notice Emitted when fees are collected by the owner of a position
/// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees
/// @param owner The owner of the position for which fees are collected
/// @param tickLower The lower tick of the position
/// @param tickUpper The upper tick of the position
/// @param amount0 The amount of token0 fees collected
/// @param amount1 The amount of token1 fees collected
event Collect(
address indexed owner,
address recipient,
int24 indexed tickLower,
int24 indexed tickUpper,
uint128 amount0,
uint128 amount1
);
/// @notice Emitted when a position's liquidity is removed
/// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect
/// @param owner The owner of the position for which liquidity is removed
/// @param tickLower The lower tick of the position
/// @param tickUpper The upper tick of the position
/// @param amount The amount of liquidity to remove
/// @param amount0 The amount of token0 withdrawn
/// @param amount1 The amount of token1 withdrawn
event Burn(
address indexed owner,
int24 indexed tickLower,
int24 indexed tickUpper,
uint128 amount,
uint256 amount0,
uint256 amount1
);
/// @notice Emitted by the pool for any swaps between token0 and token1
/// @param sender The address that initiated the swap call, and that received the callback
/// @param recipient The address that received the output of the swap
/// @param amount0 The delta of the token0 balance of the pool
/// @param amount1 The delta of the token1 balance of the pool
/// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96
/// @param liquidity The liquidity of the pool after the swap
/// @param tick The log base 1.0001 of price of the pool after the swap
event Swap(
address indexed sender,
address indexed recipient,
int256 amount0,
int256 amount1,
uint160 sqrtPriceX96,
uint128 liquidity,
int24 tick
);
/// @notice Emitted by the pool for any flashes of token0/token1
/// @param sender The address that initiated the swap call, and that received the callback
/// @param recipient The address that received the tokens from flash
/// @param amount0 The amount of token0 that was flashed
/// @param amount1 The amount of token1 that was flashed
/// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee
/// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee
event Flash(
address indexed sender,
address indexed recipient,
uint256 amount0,
uint256 amount1,
uint256 paid0,
uint256 paid1
);
/// @notice Emitted by the pool for increases to the number of observations that can be stored
/// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index
/// just before a mint/swap/burn.
/// @param observationCardinalityNextOld The previous value of the next observation cardinality
/// @param observationCardinalityNextNew The updated value of the next observation cardinality
event IncreaseObservationCardinalityNext(
uint16 observationCardinalityNextOld,
uint16 observationCardinalityNextNew
);
/// @notice Emitted when the protocol fee is changed by the pool
/// @param feeProtocol0Old The previous value of the token0 protocol fee
/// @param feeProtocol1Old The previous value of the token1 protocol fee
/// @param feeProtocol0New The updated value of the token0 protocol fee
/// @param feeProtocol1New The updated value of the token1 protocol fee
event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New);
/// @notice Emitted when the collected protocol fees are withdrawn by the factory owner
/// @param sender The address that collects the protocol fees
/// @param recipient The address that receives the collected protocol fees
/// @param amount0 The amount of token0 protocol fees that is withdrawn
/// @param amount0 The amount of token1 protocol fees that is withdrawn
event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Permissioned pool actions
/// @notice Contains pool methods that may only be called by the factory owner
interface IUniswapV3PoolOwnerActions {
/// @notice Set the denominator of the protocol's % share of the fees
/// @param feeProtocol0 new protocol fee for token0 of the pool
/// @param feeProtocol1 new protocol fee for token1 of the pool
function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external;
/// @notice Collect the protocol fee accrued to the pool
/// @param recipient The address to which collected protocol fees should be sent
/// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1
/// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0
/// @return amount0 The protocol fee collected in token0
/// @return amount1 The protocol fee collected in token1
function collectProtocol(
address recipient,
uint128 amount0Requested,
uint128 amount1Requested
) external returns (uint128 amount0, uint128 amount1);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Permissionless pool actions
/// @notice Contains pool methods that can be called by anyone
interface IUniswapV3PoolActions {
/// @notice Sets the initial price for the pool
/// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value
/// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96
function initialize(uint160 sqrtPriceX96) external;
/// @notice Adds liquidity for the given recipient/tickLower/tickUpper position
/// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback
/// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends
/// on tickLower, tickUpper, the amount of liquidity, and the current price.
/// @param recipient The address for which the liquidity will be created
/// @param tickLower The lower tick of the position in which to add liquidity
/// @param tickUpper The upper tick of the position in which to add liquidity
/// @param amount The amount of liquidity to mint
/// @param data Any data that should be passed through to the callback
/// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback
/// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback
function mint(
address recipient,
int24 tickLower,
int24 tickUpper,
uint128 amount,
bytes calldata data
) external returns (uint256 amount0, uint256 amount1);
/// @notice Collects tokens owed to a position
/// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.
/// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or
/// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the
/// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.
/// @param recipient The address which should receive the fees collected
/// @param tickLower The lower tick of the position for which to collect fees
/// @param tickUpper The upper tick of the position for which to collect fees
/// @param amount0Requested How much token0 should be withdrawn from the fees owed
/// @param amount1Requested How much token1 should be withdrawn from the fees owed
/// @return amount0 The amount of fees collected in token0
/// @return amount1 The amount of fees collected in token1
function collect(
address recipient,
int24 tickLower,
int24 tickUpper,
uint128 amount0Requested,
uint128 amount1Requested
) external returns (uint128 amount0, uint128 amount1);
/// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position
/// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0
/// @dev Fees must be collected separately via a call to #collect
/// @param tickLower The lower tick of the position for which to burn liquidity
/// @param tickUpper The upper tick of the position for which to burn liquidity
/// @param amount How much liquidity to burn
/// @return amount0 The amount of token0 sent to the recipient
/// @return amount1 The amount of token1 sent to the recipient
function burn(
int24 tickLower,
int24 tickUpper,
uint128 amount
) external returns (uint256 amount0, uint256 amount1);
/// @notice Swap token0 for token1, or token1 for token0
/// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback
/// @param recipient The address to receive the output of the swap
/// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0
/// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
/// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this
/// value after the swap. If one for zero, the price cannot be greater than this value after the swap
/// @param data Any data to be passed through to the callback
/// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive
/// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive
function swap(
address recipient,
bool zeroForOne,
int256 amountSpecified,
uint160 sqrtPriceLimitX96,
bytes calldata data
) external returns (int256 amount0, int256 amount1);
/// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback
/// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback
/// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling
/// with 0 amount{0,1} and sending the donation amount(s) from the callback
/// @param recipient The address which will receive the token0 and token1 amounts
/// @param amount0 The amount of token0 to send
/// @param amount1 The amount of token1 to send
/// @param data Any data to be passed through to the callback
function flash(
address recipient,
uint256 amount0,
uint256 amount1,
bytes calldata data
) external;
/// @notice Increase the maximum number of price and liquidity observations that this pool will store
/// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to
/// the input observationCardinalityNext.
/// @param observationCardinalityNext The desired minimum number of observations for the pool to store
function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Pool state that is not stored
/// @notice Contains view functions to provide information about the pool that is computed rather than stored on the
/// blockchain. The functions here may have variable gas costs.
interface IUniswapV3PoolDerivedState {
/// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp
/// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing
/// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick,
/// you must call it with secondsAgos = [3600, 0].
/// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in
/// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio.
/// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned
/// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp
/// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block
/// timestamp
function observe(uint32[] calldata secondsAgos)
external
view
returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);
/// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range
/// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed.
/// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first
/// snapshot is taken and the second snapshot is taken.
/// @param tickLower The lower tick of the range
/// @param tickUpper The upper tick of the range
/// @return tickCumulativeInside The snapshot of the tick accumulator for the range
/// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range
/// @return secondsInside The snapshot of seconds per liquidity for the range
function snapshotCumulativesInside(int24 tickLower, int24 tickUpper)
external
view
returns (
int56 tickCumulativeInside,
uint160 secondsPerLiquidityInsideX128,
uint32 secondsInside
);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Pool state that can change
/// @notice These methods compose the pool's state, and can change with any frequency including multiple times
/// per transaction
interface IUniswapV3PoolState {
/// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas
/// when accessed externally.
/// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value
/// tick The current tick of the pool, i.e. according to the last tick transition that was run.
/// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick
/// boundary.
/// observationIndex The index of the last oracle observation that was written,
/// observationCardinality The current maximum number of observations stored in the pool,
/// observationCardinalityNext The next maximum number of observations, to be updated when the observation.
/// feeProtocol The protocol fee for both tokens of the pool.
/// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0
/// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee.
/// unlocked Whether the pool is currently locked to reentrancy
function slot0()
external
view
returns (
uint160 sqrtPriceX96,
int24 tick,
uint16 observationIndex,
uint16 observationCardinality,
uint16 observationCardinalityNext,
uint8 feeProtocol,
bool unlocked
);
/// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool
/// @dev This value can overflow the uint256
function feeGrowthGlobal0X128() external view returns (uint256);
/// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool
/// @dev This value can overflow the uint256
function feeGrowthGlobal1X128() external view returns (uint256);
/// @notice The amounts of token0 and token1 that are owed to the protocol
/// @dev Protocol fees will never exceed uint128 max in either token
function protocolFees() external view returns (uint128 token0, uint128 token1);
/// @notice The currently in range liquidity available to the pool
/// @dev This value has no relationship to the total liquidity across all ticks
function liquidity() external view returns (uint128);
/// @notice Look up information about a specific tick in the pool
/// @param tick The tick to look up
/// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or
/// tick upper,
/// liquidityNet how much liquidity changes when the pool price crosses the tick,
/// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0,
/// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1,
/// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick
/// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick,
/// secondsOutside the seconds spent on the other side of the tick from the current tick,
/// initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false.
/// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0.
/// In addition, these values are only relative and must be used only in comparison to previous snapshots for
/// a specific position.
function ticks(int24 tick)
external
view
returns (
uint128 liquidityGross,
int128 liquidityNet,
uint256 feeGrowthOutside0X128,
uint256 feeGrowthOutside1X128,
int56 tickCumulativeOutside,
uint160 secondsPerLiquidityOutsideX128,
uint32 secondsOutside,
bool initialized
);
/// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information
function tickBitmap(int16 wordPosition) external view returns (uint256);
/// @notice Returns the information about a position by the position's key
/// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper
/// @return _liquidity The amount of liquidity in the position,
/// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke,
/// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke,
/// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke,
/// Returns tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke
function positions(bytes32 key)
external
view
returns (
uint128 _liquidity,
uint256 feeGrowthInside0LastX128,
uint256 feeGrowthInside1LastX128,
uint128 tokensOwed0,
uint128 tokensOwed1
);
/// @notice Returns data about a specific observation index
/// @param index The element of the observations array to fetch
/// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time
/// ago, rather than at a specific index in the array.
/// @return blockTimestamp The timestamp of the observation,
/// Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp,
/// Returns secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp,
/// Returns initialized whether the observation has been initialized and the values are safe to use
function observations(uint256 index)
external
view
returns (
uint32 blockTimestamp,
int56 tickCumulative,
uint160 secondsPerLiquidityCumulativeX128,
bool initialized
);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Pool state that never changes
/// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values
interface IUniswapV3PoolImmutables {
/// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface
/// @return The contract address
function factory() external view returns (address);
/// @notice The first of the two tokens of the pool, sorted by address
/// @return The token contract address
function token0() external view returns (address);
/// @notice The second of the two tokens of the pool, sorted by address
/// @return The token contract address
function token1() external view returns (address);
/// @notice The pool's fee in hundredths of a bip, i.e. 1e-6
/// @return The fee
function fee() external view returns (uint24);
/// @notice The pool tick spacing
/// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive
/// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ...
/// This value is an int24 to avoid casting even though it is always positive.
/// @return The tick spacing
function tickSpacing() external view returns (int24);
/// @notice The maximum amount of position liquidity that can use any tick in the range
/// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and
/// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool
/// @return The max amount of liquidity per tick
function maxLiquidityPerTick() external view returns (uint128);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)
pragma solidity ^0.8.20;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @dev The `account` is missing a role.
*/
error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);
/**
* @dev The caller of a function is not the expected one.
*
* NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
*/
error AccessControlBadConfirmation();
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*/
function renounceRole(bytes32 role, address callerConfirmation) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
* a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or
* {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
* a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the address zero.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"remappings": []
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_uniswapFactory","type":"address"},{"internalType":"address","name":"_positionManager","type":"address"},{"internalType":"address","name":"_ERC721exTemplate","type":"address"},{"internalType":"address","name":"_ERC721exTemplateNoBurn","type":"address"},{"internalType":"address","name":"_bondingCurveContract","type":"address"},{"internalType":"address","name":"_logicLibAddress","type":"address"},{"internalType":"address","name":"_mintableFactoryAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[],"name":"AlreadyCreatedTokenForNFT","type":"error"},{"inputs":[],"name":"ContractNotActive","type":"error"},{"inputs":[],"name":"FactoryDoesNotOwnPosition","type":"error"},{"inputs":[],"name":"InsufficientValue","type":"error"},{"inputs":[],"name":"NoLiquidityToRemove","type":"error"},{"inputs":[],"name":"NotAuthorized","type":"error"},{"inputs":[],"name":"NotNFTHolder","type":"error"},{"inputs":[],"name":"UniswapPoolNotSet","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"erc20Address","type":"address"},{"indexed":true,"internalType":"address","name":"deployer","type":"address"},{"indexed":false,"internalType":"address","name":"nftContract","type":"address"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"uint256","name":"maxSupplyTokens","type":"uint256"}],"name":"ERC20Created","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ETHWrapped","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount0Collected","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1Collected","type":"uint256"}],"name":"FeesCollected","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint128","name":"liquidity","type":"uint128"},{"indexed":false,"internalType":"uint256","name":"amountAActual","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountBActual","type":"uint256"}],"name":"LiquidityAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint128","name":"liquidity","type":"uint128"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"LiquidityRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pool","type":"address"},{"indexed":true,"internalType":"address","name":"tokenA","type":"address"},{"indexed":true,"internalType":"address","name":"tokenB","type":"address"}],"name":"PoolCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WETHUnwrapped","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawal","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ERC20CONTRACT","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ERC721exTemplate","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ERC721exTemplateNoBurn","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LOGICLIB","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LogicLibAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MintableFactoryAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"maxSupply","type":"uint256"},{"internalType":"address","name":"_NFTContract","type":"address"},{"internalType":"address","name":"_erc20Contract","type":"address"},{"internalType":"bool","name":"poolSplit","type":"bool"}],"name":"UniswapAddLiquidity","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"bondingCurveContract","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_erc20","type":"address"}],"name":"checkPoolExists","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"collectFeesFromPosition","outputs":[{"internalType":"uint256","name":"amount0Collected","type":"uint256"},{"internalType":"uint256","name":"amount1Collected","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"address","name":"nftContract","type":"address"},{"internalType":"uint256","name":"maxSupplyTokens","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"createContract","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"address","name":"nftContract","type":"address"},{"internalType":"uint256","name":"maxSupplyTokens","type":"uint256"},{"internalType":"address","name":"deployer","type":"address"}],"name":"createContractByFactory","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_nftContract","type":"address"}],"name":"emergencyWithdrawFromContracts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"ercContractToNFTContract","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_erc20Contract","type":"address"}],"name":"getCurrentPrice","outputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_contract","type":"address"},{"internalType":"uint256","name":"_totalSupply","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"isValidSignature","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nftContractToDeployer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"poolsMade","outputs":[{"internalType":"address","name":"uniswapPool","type":"address"},{"internalType":"uint256","name":"liquidityTokenID","type":"uint256"},{"internalType":"uint256","name":"poolId","type":"uint256"},{"internalType":"uint256","name":"maxSupplyOfTokens","type":"uint256"},{"internalType":"address","name":"token0","type":"address"},{"internalType":"address","name":"token1","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"positionManager","outputs":[{"internalType":"contract INonfungiblePositionManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_erc20Contract","type":"address"}],"name":"removeAndSwapLiquidity","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_bondingCurveContract","type":"address"}],"name":"setBondingCurveContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"setContractActive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newDrip","type":"address"},{"internalType":"address","name":"newDripNoBurn","type":"address"}],"name":"setERC721ex","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"signer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"swapRouter","outputs":[{"internalType":"contract ISwapRouter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferERC20Tokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_NFTContract","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"_tokenID","type":"uint256"}],"name":"transferNFTFromFactory","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"uniswapFactory","outputs":[{"internalType":"contract IUniswapV3Factory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"weth","outputs":[{"internalType":"contract IWETH","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address payable","name":"account","type":"address"}],"name":"withdrawETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
6101006040525f6007556008805460ff1916600117905534801562000022575f80fd5b5060405162003ca338038062003ca38339810160408190526200004591620001d5565b60015f90815573c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26080526200006f903362000125565b506001600160a01b0387811660a05286811660c05273e592427a0aece92de3edee1f18e0157c0586156460e052600280546001600160a01b0319908116888416179091556003805482168784161790556004805482168684161790556005805482168584169081179091556006805490921692841692909217905562000117907f646342bfcf58774c60f47a323d13625008fc866cc176e5a30b61001c04d936169062000125565b505050505050505062000265565b5f8281526001602090815260408083206001600160a01b038516845290915281205460ff16620001b0575f8381526001602081815260408084206001600160a01b0387168086529252808420805460ff19169093179092559051339286917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a4506001620001b3565b505f5b92915050565b80516001600160a01b0381168114620001d0575f80fd5b919050565b5f805f805f805f60e0888a031215620001ec575f80fd5b620001f788620001b9565b96506200020760208901620001b9565b95506200021760408901620001b9565b94506200022760608901620001b9565b93506200023760808901620001b9565b92506200024760a08901620001b9565b91506200025760c08901620001b9565b905092959891949750929550565b60805160a05160c05160e05161395b620003485f395f818161073d015281816124a301528181612554015261269401525f81816105c501528181610920015281816119650152818161211f015281816122870152818161233301528181612835015281816128c60152612cba01525f818161067401528181610fb70152612ac201525f81816104bd01528181610f8301528181611d3401528181611df201528181612439015281816124d2015281816128f50152818161293601528181612981015281816129d401528181612a9201528181612b9b0152612c25015261395b5ff3fe608060405260043610610226575f3560e01c8063791b98bc11610121578063a217fddf116100a4578063d547741f1161006b578063d547741f146107b2578063e6a9a885146107d1578063eb3ff47114610804578063ecbf7c2f14610823578063eea22d571461084257005b8063a217fddf14610706578063ba694b3814610719578063c31c9c071461072c578063c41c9a611461075f578063d0f4be941461077e57005b80638bdb2afa116100e85780638bdb2afa146106635780638ffdae031461069657806391d14854146106b55780639b848e5d146106d45780639f4ee4ee146106e757005b8063791b98bc146105b4578063825ea992146105e75780638359bbf81461060657806384cc315b1461062557806386a1cc761461064457005b806336568abe116101a9578063569a995f11610170578063569a995f146105245780635fe1fb0a1461053857806360015d8114610557578063690d8320146105765780636ebd1daf1461059557005b806336568abe14610444578063398f103d146104635780633e0dc34e146104975780633fc8cef3146104ac57806354fd4d50146104df57005b80631f696c75116101ed5780631f696c751461031b57806322f3e2d4146103b6578063238ac933146103cf578063248a9ca3146103f65780632f2ff15d1461042557005b806301ffc9a71461022f578063047b91131461026357806306cdd27714610297578063085cb451146102c55780630e7cc3d5146102fc57005b3661022d57005b005b34801561023a575f80fd5b5061024e610249366004612ff9565b610861565b60405190151581526020015b60405180910390f35b34801561026e575f80fd5b5061028261027d366004613020565b610897565b6040805192835260208301919091520161025a565b3480156102a2575f80fd5b506102b75f8051602061390683398151915281565b60405190815260200161025a565b3480156102d0575f80fd5b506006546102e4906001600160a01b031681565b6040516001600160a01b03909116815260200161025a565b348015610307575f80fd5b5061022d61031636600461304b565b6109e9565b348015610326575f80fd5b5061037861033536600461304b565b60096020525f90815260409020805460018201546002830154600384015460048501546005909501546001600160a01b0394851695939492939192918216911686565b604080516001600160a01b039788168152602081019690965285019390935260608401919091528316608083015290911660a082015260c00161025a565b3480156103c1575f80fd5b5060085461024e9060ff1681565b3480156103da575f80fd5b506102e473257d91e6453126e7b8863a836c53fe7c49a00ec281565b348015610401575f80fd5b506102b7610410366004613020565b5f908152600160208190526040909120015490565b348015610430575f80fd5b5061022d61043f366004613066565b610a16565b34801561044f575f80fd5b5061022d61045e366004613066565b610a41565b34801561046e575f80fd5b506102e461047d36600461304b565b600b6020525f90815260409020546001600160a01b031681565b3480156104a2575f80fd5b506102b760075481565b3480156104b7575f80fd5b506102e47f000000000000000000000000000000000000000000000000000000000000000081565b3480156104ea575f80fd5b506105176040518060400160405280600d81526020016c4d696e7461626c652076332e3160981b81525081565b60405161025a9190613094565b34801561052f575f80fd5b5061022d610a79565b348015610543575f80fd5b506002546102e4906001600160a01b031681565b348015610562575f80fd5b5061024e6105713660046130f3565b610a98565b348015610581575f80fd5b5061022d61059036600461304b565b610af8565b3480156105a0575f80fd5b5061022d6105af36600461304b565b610b7f565b3480156105bf575f80fd5b506102e47f000000000000000000000000000000000000000000000000000000000000000081565b3480156105f2575f80fd5b5061024e6106013660046131c6565b610c77565b348015610611575f80fd5b5061022d610620366004613216565b610e4b565b348015610630575f80fd5b506102b761063f36600461304b565b610e84565b34801561064f575f80fd5b506102e461065e36600461304b565b610f64565b34801561066e575f80fd5b506102e47f000000000000000000000000000000000000000000000000000000000000000081565b3480156106a1575f80fd5b506004546102e4906001600160a01b031681565b3480156106c0575f80fd5b5061024e6106cf366004613066565b611027565b61022d6106e2366004613280565b611051565b3480156106f2575f80fd5b506003546102e4906001600160a01b031681565b348015610711575f80fd5b506102b75f81565b61024e610727366004613330565b6113e6565b348015610737575f80fd5b506102e47f000000000000000000000000000000000000000000000000000000000000000081565b34801561076a575f80fd5b5061022d6107793660046133c9565b61164e565b348015610789575f80fd5b506102e461079836600461304b565b600a6020525f90815260409020546001600160a01b031681565b3480156107bd575f80fd5b5061022d6107cc366004613066565b6117db565b3480156107dc575f80fd5b506102b77f646342bfcf58774c60f47a323d13625008fc866cc176e5a30b61001c04d9361681565b34801561080f575f80fd5b5061024e61081e3660046133c9565b611800565b34801561082e575f80fd5b506005546102e4906001600160a01b031681565b34801561084d575f80fd5b5061024e61085c36600461304b565b611879565b5f6001600160e01b03198216637965db0b60e01b148061089157506301ffc9a760e01b6001600160e01b03198316145b92915050565b5f80806108a381611936565b60085460ff166108c657604051634e00e51360e01b815260040160405180910390fd5b6108cf84611943565b6108ec576040516374c9ab1160e11b815260040160405180910390fd5b604080516080810182528581523060208201526001600160801b038183018190526060820152905163fc6f786560e01b81527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063fc6f78659061095d908490600401613407565b60408051808303815f875af1158015610978573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061099c919061344a565b604080518881526020810184905290810182905291955093507fa54e6c2fc0861aa9c991b26891d71059d517983b9e84b91020f42609c452eb9d9060600160405180910390a15050915091565b5f6109f381611936565b50600480546001600160a01b0319166001600160a01b0392909216919091179055565b5f8281526001602081905260409091200154610a3181611936565b610a3b83836119de565b50505050565b6001600160a01b0381163314610a6a5760405163334bd91960e11b815260040160405180910390fd5b610a748282611a54565b505050565b5f610a8381611936565b506008805460ff19811660ff90911615179055565b604080518082019091526001600160a01b0384168152602081018390525f9081610ac182611abf565b90505f610ace8286611c08565b6001600160a01b031673257d91e6453126e7b8863a836c53fe7c49a00ec214979650505050505050565b5f610b0281611936565b60405147906001600160a01b0384169082156108fc029083905f818181858888f19350505050158015610b37573d5f803e3d5ffd5b50604080516001600160a01b0385168152602081018390527f7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65910160405180910390a1505050565b610b895f33611027565b610ba65760405163ea8e4eb560e01b815260040160405180910390fd5b60085460ff1615610bf75760405162461bcd60e51b81526020600482015260166024820152754f6e6c7920696e20656d657267656e6379206d6f646560501b60448201526064015b60405180910390fd5b6001600160a01b038181165f908152600a602052604090819020549051632e1a7d4d60e01b8152911680316004830181905290918290632e1a7d4d906024015b6020604051808303815f875af1158015610c53573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a3b919061346c565b6008545f9060ff16610c9c57604051634e00e51360e01b815260040160405180910390fd5b610cb35f8051602061390683398151915233611027565b610cd05760405163ea8e4eb560e01b815260040160405180910390fd5b6001600160a01b038481165f908152600a6020526040902054811690841614610d205760405162461bcd60e51b8152602060048201526002602482015261494360f01b6044820152606401610bee565b604051632e1a7d4d60e01b81526001600160a01b03841680316004830181905291632e1a7d4d906024016020604051808303815f875af1158015610d66573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d8a919061346c565b610dbb5760405162461bcd60e51b81526020600482015260026024820152612ba360f11b6044820152606401610bee565b5f6064610dc983601461349b565b610dd391906134c6565b610ddd90836134d9565b6001600160a01b038087165f908152600b6020526040808220549051939450909116918291906706f05b59d3b200009082818181858883f19350505050158015610e29573d5f803e3d5ffd5b50610e3382611ce1565b610e3f88838888611eb3565b98975050505050505050565b5f610e5581611936565b50600280546001600160a01b039384166001600160a01b03199182161790915560038054929093169116179055565b6001600160a01b038082165f9081526009602052604081205490911680610ebe576040516341765b5d60e01b815260040160405180910390fd5b5f8190505f816001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e060405180830381865afa158015610eff573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610f23919061350e565b50505050505090505f816001600160a01b0316826001600160a01b0316610f4a919061349b565b9050610f5a600160c01b826134c6565b9695505050505050565b604051630b4c774160e11b81526001600160a01b0382811660048301527f000000000000000000000000000000000000000000000000000000000000000081166024830152610bb860448301525f9182917f00000000000000000000000000000000000000000000000000000000000000001690631698ee8290606401602060405180830381865afa158015610ffc573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906110209190613598565b9392505050565b5f9182526001602090815260408084206001600160a01b0393909316845291905290205460ff1690565b61105961202c565b60085460ff1661107c57604051634e00e51360e01b815260040160405180910390fd5b6040516370a0823160e01b815233600482015284906001600160a01b038216906370a0823190602401602060405180830381865afa1580156110c0573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906110e491906135b3565b5f0361110357604051633617438360e11b815260040160405180910390fd5b6658d15e1762800034101561112b5760405163044044a560e21b815260040160405180910390fd5b6001600160a01b038581165f908152600a60205260409020541615611163576040516319fe0c9560e31b815260040160405180910390fd5b6111a3858585858080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92019190915250610a9892505050565b6111db5760405162461bcd60e51b815260206004820152600960248201526877726f6e672073696760b81b6044820152606401610bee565b6002545f906111f2906001600160a01b0316612083565b9050806001600160a01b031663e995e7358b8b8b8b8b8b60045f9054906101000a90046001600160a01b031660055f9054906101000a90046001600160a01b0316336040518a63ffffffff1660e01b8152600401611258999897969594939291906135f2565b6020604051808303815f875af1158015611274573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611298919061346c565b506001600160a01b038082165f908152600b6020526040902080546001600160a01b031916331790556005541663152f0eb58260646112d889601461349b565b6112e291906134c6565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044015f604051808303815f87803b158015611325575f80fd5b505af1158015611337573d5f803e3d5ffd5b505050506001600160a01b038681165f908152600a6020526040902080546001600160a01b03191691831691909117905561137f5f80516020613906833981519152826119de565b50336001600160a01b0316816001600160a01b03167f92045925827cf7f66dec7b7a7755aaa22afbaa0e3d117681dcd3597a926eff45888b8b8a6040516113c99493929190613656565b60405180910390a350506113dc60015f55565b5050505050505050565b5f6113ef61202c565b60085460ff1661141257604051634e00e51360e01b815260040160405180910390fd5b6006546001600160a01b0316331461143d5760405163ea8e4eb560e01b815260040160405180910390fd5b6003545f90611454906001600160a01b0316612083565b9050806001600160a01b031663e995e7358a8a8a8a8a8a60045f9054906101000a90046001600160a01b031660055f9054906101000a90046001600160a01b03168c6040518a63ffffffff1660e01b81526004016114ba999897969594939291906135f2565b6020604051808303815f875af11580156114d6573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906114fa919061346c565b506001600160a01b038181165f908152600b6020526040902080546001600160a01b0319168583161790556005541663152f0eb582606461153c88601461349b565b61154691906134c6565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044015f604051808303815f87803b158015611589575f80fd5b505af115801561159b573d5f803e3d5ffd5b505050506001600160a01b038581165f908152600a6020526040902080546001600160a01b0319169183169190911790556115e35f80516020613906833981519152826119de565b50826001600160a01b0316816001600160a01b03167f92045925827cf7f66dec7b7a7755aaa22afbaa0e3d117681dcd3597a926eff45878a8a8960405161162d9493929190613656565b60405180910390a3600191505061164360015f55565b979650505050505050565b5f61165881611936565b60085460ff16156116a45760405162461bcd60e51b81526020600482015260166024820152754f6e6c7920696e20656d657267656e6379206d6f646560501b6044820152606401610bee565b6040516370a0823160e01b815230600482015284905f906001600160a01b038316906370a0823190602401602060405180830381865afa1580156116ea573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061170e91906135b3565b9050838110156117315760405163044044a560e21b815260040160405180910390fd5b60405163a9059cbb60e01b81526001600160a01b0386811660048301526024820186905283169063a9059cbb906044016020604051808303815f875af115801561177d573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906117a1919061346c565b6117d35760405162461bcd60e51b81526020600482015260036024820152622a2a2360e91b6044820152606401610bee565b505050505050565b5f82815260016020819052604090912001546117f681611936565b610a3b8383611a54565b5f8061180b81611936565b6040516323b872dd60e01b81523060048201526001600160a01b038581166024830152604482018590528616906323b872dd906064015f604051808303815f87803b158015611858575f80fd5b505af115801561186a573d5f803e3d5ffd5b50600198975050505050505050565b5f5f8051602061390683398151915261189181611936565b61189961202c565b60085460ff166118bc57604051634e00e51360e01b815260040160405180910390fd5b6001600160a01b0383165f9081526009602052604081206001015490806118e483601961211a565b915091505f805f805f6118f88b8888612410565b9450945094509450945061190d8b868661248c565b8461191a81848487612592565b60019a5050505050505050505061193060015f55565b50919050565b6119408133612704565b50565b6040516331a9108f60e11b8152600481018290525f9030906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690636352211e90602401602060405180830381865afa1580156119aa573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906119ce9190613598565b6001600160a01b03161492915050565b5f6119e98383611027565b611a4d575f8381526001602081815260408084206001600160a01b0387168086529252808420805460ff19169093179092559051339286917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a4506001610891565b505f610891565b5f611a5f8383611027565b15611a4d575f8381526001602090815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a4506001610891565b5f611bc3604080518082018252600681526529b4b3b732b960d11b60209182015281518083018352600d81526c4d696e7461626c652076332e3160981b9082015281517fd87cd6ef79d4e2b95e15ce8abf732db51ec771f1ca2edccf22a46c729ac56472818301527f4ca6459022e96ac591406da8141b5e9b21c648122d7f0f94007990d12720bb55818401527f3483d0bf4ee728f4d90702c9130e4bbf203bf0f915d83ac9aecd84449f43bfe56060820152600160808201523060a08201527ff2d857f4a3edcb9b78b4d503bfe733db1e3f6cdc2b7971ee739626c97e86a55860c0808301919091528351808303909101815260e0909101909252815191012090565b611bcc83612741565b60405161190160f01b6020820152602281019290925260428201526062015b604051602081830303815290604052805190602001209050919050565b5f805f80611c1585612796565b9250925092508260ff16601b1480611c3057508260ff16601c145b611c7c5760405162461bcd60e51b815260206004820152601b60248201527f496e76616c6964207369676e6174757265202776272076616c756500000000006044820152606401610bee565b604080515f81526020810180835288905260ff851691810191909152606081018390526080810182905260019060a0016020604051602081039080840390855afa158015611ccc573d5f803e3d5ffd5b5050604051601f190151979650505050505050565b611ce961202c565b47818111611d325760405162461bcd60e51b815260206004820152601660248201527504e6f204554482062616c616e636520746f20777261760541b6044820152606401610bee565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d0e30db0836040518263ffffffff1660e01b81526004015f604051808303818588803b158015611d8b575f80fd5b505af1158015611d9d573d5f803e3d5ffd5b50505050507fa7ab2f19110369479302d27af3a7b798be5185c2a0140afc91712c32dbbbd73682604051611dd391815260200190565b60405180910390a16040516370a0823160e01b815230600482015282907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015611e3f573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611e6391906135b3565b1015611ea95760405162461bcd60e51b81526020600482015260156024820152740ae8aa89040c4c2d8c2dcc6ca40dad2e6dac2e8c6d605b1b6044820152606401610bee565b5061194060015f55565b6040516370a0823160e01b81523060048201525f9081906001600160a01b038516906370a0823190602401602060405180830381865afa158015611ef9573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611f1d91906135b3565b90508215611f3357611f306002826134c6565b90505b611f3e84828761281e565b5f805f805f611f4e868b8b612924565b945094509450945094505f611f628a610f64565b9050611f708c8b8884612a37565b5060408051610160810182526001600160a01b03808816825286166020820152610bb891810191909152620d89b3196060820152620d89b4608082015260a0810184905260c081018390525f9060e081016064611fce87606261349b565b611fd891906134c6565b81526020016064611fea86606261349b565b611ff491906134c6565b815230602082015260400161200b4261384061368b565b90529050612019818c612cb4565b5060019c9b505050505050505050505050565b60025f540361207d5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610bee565b60025f55565b5f763d602d80600a3d3981f3363d3d373d3d3d363d730000008260601b60e81c175f526e5af43d82803e903d91602b57fd5bf38260781b17602052603760095ff090506001600160a01b0381166121155760405162461bcd60e51b8152602060048201526016602482015275115490cc4c4d8dce8818dc99585d194819985a5b195960521b6044820152606401610bee565b919050565b5f805f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166399fbab88866040518263ffffffff1660e01b815260040161216b91815260200190565b61018060405180830381865afa158015612187573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906121ab91906136c6565b50929a5050506001600160801b0389165f0397506121e4965050505050505057604051632070838d60e01b815260040160405180910390fd5b5f60646121f460ff87168461379f565b6121fe91906137ca565b90505f6040518060a00160405280888152602001836001600160801b031681526020015f81526020015f81526020014261384061223b919061368b565b905260408051630624e65f60e11b81528251600482015260208301516001600160801b0316602482015290820151604482015260608201516064820152608082015160848201529091507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690630c49ccbe9060a40160408051808303815f875af11580156122d4573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906122f8919061344a565b604080516080810182528a81523060208201526001600160801b038183018190526060820152905163fc6f786560e01b8152929750909550907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063fc6f786590612370908490600401613407565b60408051808303815f875af115801561238b573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906123af919061344a565b604080518b81526001600160801b03871660208201529081018390526060810182905291975095507f43295ae021d68a6909823fa08299053e9036d8b4e2b917231e00ef7224ebf91b9060800160405180910390a1505050505b9250929050565b6001600160a01b038084165f9081526009602052604081206004810154600590910154919283927f000000000000000000000000000000000000000000000000000000000000000082169282169283149291168261246e5785612470565b865b94508261247d578661247f565b855b9350939792965093509350565b60405163095ea7b360e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152602482018490527f0000000000000000000000000000000000000000000000000000000000000000169063095ea7b3906044016020604051808303815f875af1158015612518573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061253c919061346c565b5060405163095ea7b360e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660048301526024820183905284169063095ea7b390604401610c37565b5f8161259e57826125a0565b835b90505f826125ae57846125b0565b835b90505f604051806101000160405280846001600160a01b03168152602001836001600160a01b03168152602001610bb862ffffff168152602001306001600160a01b0316815260200142613840612607919061368b565b815260208082018a90525f6040808401829052606093840191909152805163414bf38960e01b815284516001600160a01b03908116600483015292850151831660248201529084015162ffffff16604482015291830151811660648301526080830151608483015260a083015160a483015260c083015160c483015260e0830151811660e48301529192507f00000000000000000000000000000000000000000000000000000000000000009091169063414bf3899089906101040160206040518083038185885af11580156126df573d5f803e3d5ffd5b50505050506040513d601f19601f820116820180604052508101906113dc91906135b3565b61270e8282611027565b61273d5760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401610bee565b5050565b80516020808301516040515f93611beb937f784776d7e1dc5a69b5e658a6e2ca260b2171cbd86fb571a40dffa16606218732939192019283526001600160a01b03919091166020830152604082015260600190565b5f805f83516041146127ea5760405162461bcd60e51b815260206004820152601860248201527f496e76616c6964207369676e6174757265206c656e67746800000000000000006044820152606401610bee565b5050506020810151604082015160608301515f1a9190601b83101561281757612814601b846137ef565b92505b9193909250565b60405163095ea7b360e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660048301526024820184905284169063095ea7b3906044016020604051808303815f875af115801561288a573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906128ae919061346c565b5060405163095ea7b360e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152602482018390527f0000000000000000000000000000000000000000000000000000000000000000169063095ea7b390604401610c37565b5f808080806001600160a01b038087167f0000000000000000000000000000000000000000000000000000000000000000909116108181156129b057886129738b670de0b6b3a764000061349b565b61297d91906134c6565b90507f000000000000000000000000000000000000000000000000000000000000000095508794508893508992506129fc565b896129c38a670de0b6b3a764000061349b565b6129cd91906134c6565b90508795507f000000000000000000000000000000000000000000000000000000000000000094508993508892505b5f612a0682612fa7565b90505f633b9aca00612a1c83600160601b61349b565b612a2691906134c6565b985050505050939792965093509350565b6008545f9060ff16612a5c57604051634e00e51360e01b815260040160405180910390fd5b5f6001600160a01b03831615612a73575081612b2f565b60405163a167129560e01b81526001600160a01b0386811660048301527f000000000000000000000000000000000000000000000000000000000000000081166024830152610bb860448301527f0000000000000000000000000000000000000000000000000000000000000000169063a1671295906064016020604051808303815f875af1158015612b08573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612b2c9190613598565b90505b60405163f637731d60e01b81526001600160a01b03858116600483015282169063f637731d906024015f604051808303815f87803b158015612b6f575f80fd5b505af1158015612b81573d5f803e3d5ffd5b505060078054600101905550506040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811691878216918416907f9c5d829b9b23efc461f9aeef91979ec04bb903feb3bee4f26d22114abfc7335b905f90a46040805160c0810182526001600160a01b0380841682525f6020808401828152600754858701908152606086018d81528c8616608088018181527f0000000000000000000000000000000000000000000000000000000000000000881660a08a01908152918752600990955297909420955186549086166001600160a01b031991821617875591516001870155516002860155915160038501555160048401805491841691831691909117905592516005909201805492909116919092161790559050949350505050565b5f805f807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166388316456876040518263ffffffff1660e01b8152600401612d049190613808565b6080604051808303815f875af1158015612d20573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612d4491906138cc565b93509350935093505f60095f876001600160a01b03166001600160a01b031681526020019081526020015f206040518060c00160405290815f82015f9054906101000a90046001600160a01b03166001600160a01b03166001600160a01b03168152602001600182015481526020016002820154815260200160038201548152602001600482015f9054906101000a90046001600160a01b03166001600160a01b03166001600160a01b03168152602001600582015f9054906101000a90046001600160a01b03166001600160a01b03166001600160a01b031681525050905084816020018181525050865f015181608001906001600160a01b031690816001600160a01b03168152505086602001518160a001906001600160a01b031690816001600160a01b0316815250508060095f886001600160a01b03166001600160a01b031681526020019081526020015f205f820151815f015f6101000a8154816001600160a01b0302191690836001600160a01b031602179055506020820151816001015560408201518160020155606082015181600301556080820151816004015f6101000a8154816001600160a01b0302191690836001600160a01b0316021790555060a0820151816005015f6101000a8154816001600160a01b0302191690836001600160a01b03160217905550905050336001600160a01b03167f936f1605239d50a44520651cb0698a8f77eea34a13f43a4eac22872b1baf48cc86868686604051612f9694939291909384526001600160801b039290921660208401526040830152606082015260800190565b60405180910390a250505050505050565b5f806002612fb684600161368b565b612fc091906134c6565b90508291505b8181101561193057905080600281612fde81866134c6565b612fe8919061368b565b612ff291906134c6565b9050612fc6565b5f60208284031215613009575f80fd5b81356001600160e01b031981168114611020575f80fd5b5f60208284031215613030575f80fd5b5035919050565b6001600160a01b0381168114611940575f80fd5b5f6020828403121561305b575f80fd5b813561102081613037565b5f8060408385031215613077575f80fd5b82359150602083013561308981613037565b809150509250929050565b5f6020808352835180828501525f5b818110156130bf578581018301518582016040015282016130a3565b505f604082860101526040601f19601f8301168501019250505092915050565b634e487b7160e01b5f52604160045260245ffd5b5f805f60608486031215613105575f80fd5b833561311081613037565b925060208401359150604084013567ffffffffffffffff80821115613133575f80fd5b818601915086601f830112613146575f80fd5b813581811115613158576131586130df565b604051601f8201601f19908116603f01168101908382118183101715613180576131806130df565b81604052828152896020848701011115613198575f80fd5b826020860160208301375f6020848301015280955050505050509250925092565b8015158114611940575f80fd5b5f805f80608085870312156131d9575f80fd5b8435935060208501356131eb81613037565b925060408501356131fb81613037565b9150606085013561320b816131b9565b939692955090935050565b5f8060408385031215613227575f80fd5b823561323281613037565b9150602083013561308981613037565b5f8083601f840112613252575f80fd5b50813567ffffffffffffffff811115613269575f80fd5b602083019150836020828501011115612409575f80fd5b5f805f805f805f8060a0898b031215613297575f80fd5b883567ffffffffffffffff808211156132ae575f80fd5b6132ba8c838d01613242565b909a50985060208b01359150808211156132d2575f80fd5b6132de8c838d01613242565b909850965060408b013591506132f382613037565b90945060608a0135935060808a0135908082111561330f575f80fd5b5061331c8b828c01613242565b999c989b5096995094979396929594505050565b5f805f805f805f60a0888a031215613346575f80fd5b873567ffffffffffffffff8082111561335d575f80fd5b6133698b838c01613242565b909950975060208a0135915080821115613381575f80fd5b5061338e8a828b01613242565b90965094505060408801356133a281613037565b92506060880135915060808801356133b981613037565b8091505092959891949750929550565b5f805f606084860312156133db575f80fd5b83356133e681613037565b925060208401356133f681613037565b929592945050506040919091013590565b815181526020808301516001600160a01b0316908201526040808301516001600160801b0390811691830191909152606092830151169181019190915260800190565b5f806040838503121561345b575f80fd5b505080516020909101519092909150565b5f6020828403121561347c575f80fd5b8151611020816131b9565b634e487b7160e01b5f52601160045260245ffd5b808202811582820484141761089157610891613487565b634e487b7160e01b5f52601260045260245ffd5b5f826134d4576134d46134b2565b500490565b8181038181111561089157610891613487565b8051600281900b8114612115575f80fd5b805161ffff81168114612115575f80fd5b5f805f805f805f60e0888a031215613524575f80fd5b875161352f81613037565b965061353d602089016134ec565b955061354b604089016134fd565b9450613559606089016134fd565b9350613567608089016134fd565b925060a088015160ff8116811461357c575f80fd5b60c08901519092506133b9816131b9565b805161211581613037565b5f602082840312156135a8575f80fd5b815161102081613037565b5f602082840312156135c3575f80fd5b5051919050565b81835281816020850137505f828201602090810191909152601f909101601f19169091010190565b60e081525f61360560e083018b8d6135ca565b8281036020840152613618818a8c6135ca565b6001600160a01b03988916604085015260608401979097525050928516608084015290841660a083015290921660c090920191909152949350505050565b6001600160a01b03851681526060602082018190525f9061367a90830185876135ca565b905082604083015295945050505050565b8082018082111561089157610891613487565b805162ffffff81168114612115575f80fd5b80516001600160801b0381168114612115575f80fd5b5f805f805f805f805f805f806101808d8f0312156136e2575f80fd5b8c516bffffffffffffffffffffffff811681146136fd575f80fd5b9b5061370b60208e0161358d565b9a5061371960408e0161358d565b995061372760608e0161358d565b985061373560808e0161369e565b975061374360a08e016134ec565b965061375160c08e016134ec565b955061375f60e08e016136b0565b94506101008d015193506101208d0151925061377e6101408e016136b0565b915061378d6101608e016136b0565b90509295989b509295989b509295989b565b6001600160801b038181168382160280821691908281146137c2576137c2613487565b505092915050565b5f6001600160801b03808416806137e3576137e36134b2565b92169190910492915050565b60ff818116838216019081111561089157610891613487565b81516001600160a01b031681526101608101602083015161383460208401826001600160a01b03169052565b50604083015161384b604084018262ffffff169052565b506060830151613860606084018260020b9052565b506080830151613875608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e0830152610100808401518184015250610120808401516138bb828501826001600160a01b03169052565b505061014092830151919092015290565b5f805f80608085870312156138df575f80fd5b845193506138ef602086016136b0565b604086015160609096015194979096509250505056feeda12c967d41537df595863b12c47d93205bb25d9b53142e1602b253ecf6b74ba26469706673582212207b89c30c80423a39b1847379611dcec11b0ae5e6de68573324406275398a589164736f6c634300081400330000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f984000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe8800000000000000000000000031f9ba90d9df42ac8cc2ec694d937939af7ab4aa000000000000000000000000989c857623e58cfb5154d80453430bcf5b665b1d000000000000000000000000c98e0d1b47a1964afb3c2f661514ce48e2dbe650000000000000000000000000ed0570bfc991a66e2e21563a31ebea3baecd9738000000000000000000000000ec1e663a2e86df68b7a30974422a524a465d0653
Deployed Bytecode
0x608060405260043610610226575f3560e01c8063791b98bc11610121578063a217fddf116100a4578063d547741f1161006b578063d547741f146107b2578063e6a9a885146107d1578063eb3ff47114610804578063ecbf7c2f14610823578063eea22d571461084257005b8063a217fddf14610706578063ba694b3814610719578063c31c9c071461072c578063c41c9a611461075f578063d0f4be941461077e57005b80638bdb2afa116100e85780638bdb2afa146106635780638ffdae031461069657806391d14854146106b55780639b848e5d146106d45780639f4ee4ee146106e757005b8063791b98bc146105b4578063825ea992146105e75780638359bbf81461060657806384cc315b1461062557806386a1cc761461064457005b806336568abe116101a9578063569a995f11610170578063569a995f146105245780635fe1fb0a1461053857806360015d8114610557578063690d8320146105765780636ebd1daf1461059557005b806336568abe14610444578063398f103d146104635780633e0dc34e146104975780633fc8cef3146104ac57806354fd4d50146104df57005b80631f696c75116101ed5780631f696c751461031b57806322f3e2d4146103b6578063238ac933146103cf578063248a9ca3146103f65780632f2ff15d1461042557005b806301ffc9a71461022f578063047b91131461026357806306cdd27714610297578063085cb451146102c55780630e7cc3d5146102fc57005b3661022d57005b005b34801561023a575f80fd5b5061024e610249366004612ff9565b610861565b60405190151581526020015b60405180910390f35b34801561026e575f80fd5b5061028261027d366004613020565b610897565b6040805192835260208301919091520161025a565b3480156102a2575f80fd5b506102b75f8051602061390683398151915281565b60405190815260200161025a565b3480156102d0575f80fd5b506006546102e4906001600160a01b031681565b6040516001600160a01b03909116815260200161025a565b348015610307575f80fd5b5061022d61031636600461304b565b6109e9565b348015610326575f80fd5b5061037861033536600461304b565b60096020525f90815260409020805460018201546002830154600384015460048501546005909501546001600160a01b0394851695939492939192918216911686565b604080516001600160a01b039788168152602081019690965285019390935260608401919091528316608083015290911660a082015260c00161025a565b3480156103c1575f80fd5b5060085461024e9060ff1681565b3480156103da575f80fd5b506102e473257d91e6453126e7b8863a836c53fe7c49a00ec281565b348015610401575f80fd5b506102b7610410366004613020565b5f908152600160208190526040909120015490565b348015610430575f80fd5b5061022d61043f366004613066565b610a16565b34801561044f575f80fd5b5061022d61045e366004613066565b610a41565b34801561046e575f80fd5b506102e461047d36600461304b565b600b6020525f90815260409020546001600160a01b031681565b3480156104a2575f80fd5b506102b760075481565b3480156104b7575f80fd5b506102e47f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b3480156104ea575f80fd5b506105176040518060400160405280600d81526020016c4d696e7461626c652076332e3160981b81525081565b60405161025a9190613094565b34801561052f575f80fd5b5061022d610a79565b348015610543575f80fd5b506002546102e4906001600160a01b031681565b348015610562575f80fd5b5061024e6105713660046130f3565b610a98565b348015610581575f80fd5b5061022d61059036600461304b565b610af8565b3480156105a0575f80fd5b5061022d6105af36600461304b565b610b7f565b3480156105bf575f80fd5b506102e47f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe8881565b3480156105f2575f80fd5b5061024e6106013660046131c6565b610c77565b348015610611575f80fd5b5061022d610620366004613216565b610e4b565b348015610630575f80fd5b506102b761063f36600461304b565b610e84565b34801561064f575f80fd5b506102e461065e36600461304b565b610f64565b34801561066e575f80fd5b506102e47f0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f98481565b3480156106a1575f80fd5b506004546102e4906001600160a01b031681565b3480156106c0575f80fd5b5061024e6106cf366004613066565b611027565b61022d6106e2366004613280565b611051565b3480156106f2575f80fd5b506003546102e4906001600160a01b031681565b348015610711575f80fd5b506102b75f81565b61024e610727366004613330565b6113e6565b348015610737575f80fd5b506102e47f000000000000000000000000e592427a0aece92de3edee1f18e0157c0586156481565b34801561076a575f80fd5b5061022d6107793660046133c9565b61164e565b348015610789575f80fd5b506102e461079836600461304b565b600a6020525f90815260409020546001600160a01b031681565b3480156107bd575f80fd5b5061022d6107cc366004613066565b6117db565b3480156107dc575f80fd5b506102b77f646342bfcf58774c60f47a323d13625008fc866cc176e5a30b61001c04d9361681565b34801561080f575f80fd5b5061024e61081e3660046133c9565b611800565b34801561082e575f80fd5b506005546102e4906001600160a01b031681565b34801561084d575f80fd5b5061024e61085c36600461304b565b611879565b5f6001600160e01b03198216637965db0b60e01b148061089157506301ffc9a760e01b6001600160e01b03198316145b92915050565b5f80806108a381611936565b60085460ff166108c657604051634e00e51360e01b815260040160405180910390fd5b6108cf84611943565b6108ec576040516374c9ab1160e11b815260040160405180910390fd5b604080516080810182528581523060208201526001600160801b038183018190526060820152905163fc6f786560e01b81527f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b03169063fc6f78659061095d908490600401613407565b60408051808303815f875af1158015610978573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061099c919061344a565b604080518881526020810184905290810182905291955093507fa54e6c2fc0861aa9c991b26891d71059d517983b9e84b91020f42609c452eb9d9060600160405180910390a15050915091565b5f6109f381611936565b50600480546001600160a01b0319166001600160a01b0392909216919091179055565b5f8281526001602081905260409091200154610a3181611936565b610a3b83836119de565b50505050565b6001600160a01b0381163314610a6a5760405163334bd91960e11b815260040160405180910390fd5b610a748282611a54565b505050565b5f610a8381611936565b506008805460ff19811660ff90911615179055565b604080518082019091526001600160a01b0384168152602081018390525f9081610ac182611abf565b90505f610ace8286611c08565b6001600160a01b031673257d91e6453126e7b8863a836c53fe7c49a00ec214979650505050505050565b5f610b0281611936565b60405147906001600160a01b0384169082156108fc029083905f818181858888f19350505050158015610b37573d5f803e3d5ffd5b50604080516001600160a01b0385168152602081018390527f7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65910160405180910390a1505050565b610b895f33611027565b610ba65760405163ea8e4eb560e01b815260040160405180910390fd5b60085460ff1615610bf75760405162461bcd60e51b81526020600482015260166024820152754f6e6c7920696e20656d657267656e6379206d6f646560501b60448201526064015b60405180910390fd5b6001600160a01b038181165f908152600a602052604090819020549051632e1a7d4d60e01b8152911680316004830181905290918290632e1a7d4d906024015b6020604051808303815f875af1158015610c53573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a3b919061346c565b6008545f9060ff16610c9c57604051634e00e51360e01b815260040160405180910390fd5b610cb35f8051602061390683398151915233611027565b610cd05760405163ea8e4eb560e01b815260040160405180910390fd5b6001600160a01b038481165f908152600a6020526040902054811690841614610d205760405162461bcd60e51b8152602060048201526002602482015261494360f01b6044820152606401610bee565b604051632e1a7d4d60e01b81526001600160a01b03841680316004830181905291632e1a7d4d906024016020604051808303815f875af1158015610d66573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d8a919061346c565b610dbb5760405162461bcd60e51b81526020600482015260026024820152612ba360f11b6044820152606401610bee565b5f6064610dc983601461349b565b610dd391906134c6565b610ddd90836134d9565b6001600160a01b038087165f908152600b6020526040808220549051939450909116918291906706f05b59d3b200009082818181858883f19350505050158015610e29573d5f803e3d5ffd5b50610e3382611ce1565b610e3f88838888611eb3565b98975050505050505050565b5f610e5581611936565b50600280546001600160a01b039384166001600160a01b03199182161790915560038054929093169116179055565b6001600160a01b038082165f9081526009602052604081205490911680610ebe576040516341765b5d60e01b815260040160405180910390fd5b5f8190505f816001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e060405180830381865afa158015610eff573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610f23919061350e565b50505050505090505f816001600160a01b0316826001600160a01b0316610f4a919061349b565b9050610f5a600160c01b826134c6565b9695505050505050565b604051630b4c774160e11b81526001600160a01b0382811660048301527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281166024830152610bb860448301525f9182917f0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f9841690631698ee8290606401602060405180830381865afa158015610ffc573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906110209190613598565b9392505050565b5f9182526001602090815260408084206001600160a01b0393909316845291905290205460ff1690565b61105961202c565b60085460ff1661107c57604051634e00e51360e01b815260040160405180910390fd5b6040516370a0823160e01b815233600482015284906001600160a01b038216906370a0823190602401602060405180830381865afa1580156110c0573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906110e491906135b3565b5f0361110357604051633617438360e11b815260040160405180910390fd5b6658d15e1762800034101561112b5760405163044044a560e21b815260040160405180910390fd5b6001600160a01b038581165f908152600a60205260409020541615611163576040516319fe0c9560e31b815260040160405180910390fd5b6111a3858585858080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92019190915250610a9892505050565b6111db5760405162461bcd60e51b815260206004820152600960248201526877726f6e672073696760b81b6044820152606401610bee565b6002545f906111f2906001600160a01b0316612083565b9050806001600160a01b031663e995e7358b8b8b8b8b8b60045f9054906101000a90046001600160a01b031660055f9054906101000a90046001600160a01b0316336040518a63ffffffff1660e01b8152600401611258999897969594939291906135f2565b6020604051808303815f875af1158015611274573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611298919061346c565b506001600160a01b038082165f908152600b6020526040902080546001600160a01b031916331790556005541663152f0eb58260646112d889601461349b565b6112e291906134c6565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044015f604051808303815f87803b158015611325575f80fd5b505af1158015611337573d5f803e3d5ffd5b505050506001600160a01b038681165f908152600a6020526040902080546001600160a01b03191691831691909117905561137f5f80516020613906833981519152826119de565b50336001600160a01b0316816001600160a01b03167f92045925827cf7f66dec7b7a7755aaa22afbaa0e3d117681dcd3597a926eff45888b8b8a6040516113c99493929190613656565b60405180910390a350506113dc60015f55565b5050505050505050565b5f6113ef61202c565b60085460ff1661141257604051634e00e51360e01b815260040160405180910390fd5b6006546001600160a01b0316331461143d5760405163ea8e4eb560e01b815260040160405180910390fd5b6003545f90611454906001600160a01b0316612083565b9050806001600160a01b031663e995e7358a8a8a8a8a8a60045f9054906101000a90046001600160a01b031660055f9054906101000a90046001600160a01b03168c6040518a63ffffffff1660e01b81526004016114ba999897969594939291906135f2565b6020604051808303815f875af11580156114d6573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906114fa919061346c565b506001600160a01b038181165f908152600b6020526040902080546001600160a01b0319168583161790556005541663152f0eb582606461153c88601461349b565b61154691906134c6565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044015f604051808303815f87803b158015611589575f80fd5b505af115801561159b573d5f803e3d5ffd5b505050506001600160a01b038581165f908152600a6020526040902080546001600160a01b0319169183169190911790556115e35f80516020613906833981519152826119de565b50826001600160a01b0316816001600160a01b03167f92045925827cf7f66dec7b7a7755aaa22afbaa0e3d117681dcd3597a926eff45878a8a8960405161162d9493929190613656565b60405180910390a3600191505061164360015f55565b979650505050505050565b5f61165881611936565b60085460ff16156116a45760405162461bcd60e51b81526020600482015260166024820152754f6e6c7920696e20656d657267656e6379206d6f646560501b6044820152606401610bee565b6040516370a0823160e01b815230600482015284905f906001600160a01b038316906370a0823190602401602060405180830381865afa1580156116ea573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061170e91906135b3565b9050838110156117315760405163044044a560e21b815260040160405180910390fd5b60405163a9059cbb60e01b81526001600160a01b0386811660048301526024820186905283169063a9059cbb906044016020604051808303815f875af115801561177d573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906117a1919061346c565b6117d35760405162461bcd60e51b81526020600482015260036024820152622a2a2360e91b6044820152606401610bee565b505050505050565b5f82815260016020819052604090912001546117f681611936565b610a3b8383611a54565b5f8061180b81611936565b6040516323b872dd60e01b81523060048201526001600160a01b038581166024830152604482018590528616906323b872dd906064015f604051808303815f87803b158015611858575f80fd5b505af115801561186a573d5f803e3d5ffd5b50600198975050505050505050565b5f5f8051602061390683398151915261189181611936565b61189961202c565b60085460ff166118bc57604051634e00e51360e01b815260040160405180910390fd5b6001600160a01b0383165f9081526009602052604081206001015490806118e483601961211a565b915091505f805f805f6118f88b8888612410565b9450945094509450945061190d8b868661248c565b8461191a81848487612592565b60019a5050505050505050505061193060015f55565b50919050565b6119408133612704565b50565b6040516331a9108f60e11b8152600481018290525f9030906001600160a01b037f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe881690636352211e90602401602060405180830381865afa1580156119aa573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906119ce9190613598565b6001600160a01b03161492915050565b5f6119e98383611027565b611a4d575f8381526001602081815260408084206001600160a01b0387168086529252808420805460ff19169093179092559051339286917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a4506001610891565b505f610891565b5f611a5f8383611027565b15611a4d575f8381526001602090815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a4506001610891565b5f611bc3604080518082018252600681526529b4b3b732b960d11b60209182015281518083018352600d81526c4d696e7461626c652076332e3160981b9082015281517fd87cd6ef79d4e2b95e15ce8abf732db51ec771f1ca2edccf22a46c729ac56472818301527f4ca6459022e96ac591406da8141b5e9b21c648122d7f0f94007990d12720bb55818401527f3483d0bf4ee728f4d90702c9130e4bbf203bf0f915d83ac9aecd84449f43bfe56060820152600160808201523060a08201527ff2d857f4a3edcb9b78b4d503bfe733db1e3f6cdc2b7971ee739626c97e86a55860c0808301919091528351808303909101815260e0909101909252815191012090565b611bcc83612741565b60405161190160f01b6020820152602281019290925260428201526062015b604051602081830303815290604052805190602001209050919050565b5f805f80611c1585612796565b9250925092508260ff16601b1480611c3057508260ff16601c145b611c7c5760405162461bcd60e51b815260206004820152601b60248201527f496e76616c6964207369676e6174757265202776272076616c756500000000006044820152606401610bee565b604080515f81526020810180835288905260ff851691810191909152606081018390526080810182905260019060a0016020604051602081039080840390855afa158015611ccc573d5f803e3d5ffd5b5050604051601f190151979650505050505050565b611ce961202c565b47818111611d325760405162461bcd60e51b815260206004820152601660248201527504e6f204554482062616c616e636520746f20777261760541b6044820152606401610bee565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0836040518263ffffffff1660e01b81526004015f604051808303818588803b158015611d8b575f80fd5b505af1158015611d9d573d5f803e3d5ffd5b50505050507fa7ab2f19110369479302d27af3a7b798be5185c2a0140afc91712c32dbbbd73682604051611dd391815260200190565b60405180910390a16040516370a0823160e01b815230600482015282907f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316906370a0823190602401602060405180830381865afa158015611e3f573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611e6391906135b3565b1015611ea95760405162461bcd60e51b81526020600482015260156024820152740ae8aa89040c4c2d8c2dcc6ca40dad2e6dac2e8c6d605b1b6044820152606401610bee565b5061194060015f55565b6040516370a0823160e01b81523060048201525f9081906001600160a01b038516906370a0823190602401602060405180830381865afa158015611ef9573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611f1d91906135b3565b90508215611f3357611f306002826134c6565b90505b611f3e84828761281e565b5f805f805f611f4e868b8b612924565b945094509450945094505f611f628a610f64565b9050611f708c8b8884612a37565b5060408051610160810182526001600160a01b03808816825286166020820152610bb891810191909152620d89b3196060820152620d89b4608082015260a0810184905260c081018390525f9060e081016064611fce87606261349b565b611fd891906134c6565b81526020016064611fea86606261349b565b611ff491906134c6565b815230602082015260400161200b4261384061368b565b90529050612019818c612cb4565b5060019c9b505050505050505050505050565b60025f540361207d5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610bee565b60025f55565b5f763d602d80600a3d3981f3363d3d373d3d3d363d730000008260601b60e81c175f526e5af43d82803e903d91602b57fd5bf38260781b17602052603760095ff090506001600160a01b0381166121155760405162461bcd60e51b8152602060048201526016602482015275115490cc4c4d8dce8818dc99585d194819985a5b195960521b6044820152606401610bee565b919050565b5f805f7f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b03166399fbab88866040518263ffffffff1660e01b815260040161216b91815260200190565b61018060405180830381865afa158015612187573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906121ab91906136c6565b50929a5050506001600160801b0389165f0397506121e4965050505050505057604051632070838d60e01b815260040160405180910390fd5b5f60646121f460ff87168461379f565b6121fe91906137ca565b90505f6040518060a00160405280888152602001836001600160801b031681526020015f81526020015f81526020014261384061223b919061368b565b905260408051630624e65f60e11b81528251600482015260208301516001600160801b0316602482015290820151604482015260608201516064820152608082015160848201529091507f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b031690630c49ccbe9060a40160408051808303815f875af11580156122d4573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906122f8919061344a565b604080516080810182528a81523060208201526001600160801b038183018190526060820152905163fc6f786560e01b8152929750909550907f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b03169063fc6f786590612370908490600401613407565b60408051808303815f875af115801561238b573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906123af919061344a565b604080518b81526001600160801b03871660208201529081018390526060810182905291975095507f43295ae021d68a6909823fa08299053e9036d8b4e2b917231e00ef7224ebf91b9060800160405180910390a1505050505b9250929050565b6001600160a01b038084165f9081526009602052604081206004810154600590910154919283927f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc282169282169283149291168261246e5785612470565b865b94508261247d578661247f565b855b9350939792965093509350565b60405163095ea7b360e01b81526001600160a01b037f000000000000000000000000e592427a0aece92de3edee1f18e0157c0586156481166004830152602482018490527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2169063095ea7b3906044016020604051808303815f875af1158015612518573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061253c919061346c565b5060405163095ea7b360e01b81526001600160a01b037f000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564811660048301526024820183905284169063095ea7b390604401610c37565b5f8161259e57826125a0565b835b90505f826125ae57846125b0565b835b90505f604051806101000160405280846001600160a01b03168152602001836001600160a01b03168152602001610bb862ffffff168152602001306001600160a01b0316815260200142613840612607919061368b565b815260208082018a90525f6040808401829052606093840191909152805163414bf38960e01b815284516001600160a01b03908116600483015292850151831660248201529084015162ffffff16604482015291830151811660648301526080830151608483015260a083015160a483015260c083015160c483015260e0830151811660e48301529192507f000000000000000000000000e592427a0aece92de3edee1f18e0157c058615649091169063414bf3899089906101040160206040518083038185885af11580156126df573d5f803e3d5ffd5b50505050506040513d601f19601f820116820180604052508101906113dc91906135b3565b61270e8282611027565b61273d5760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401610bee565b5050565b80516020808301516040515f93611beb937f784776d7e1dc5a69b5e658a6e2ca260b2171cbd86fb571a40dffa16606218732939192019283526001600160a01b03919091166020830152604082015260600190565b5f805f83516041146127ea5760405162461bcd60e51b815260206004820152601860248201527f496e76616c6964207369676e6174757265206c656e67746800000000000000006044820152606401610bee565b5050506020810151604082015160608301515f1a9190601b83101561281757612814601b846137ef565b92505b9193909250565b60405163095ea7b360e01b81526001600160a01b037f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe88811660048301526024820184905284169063095ea7b3906044016020604051808303815f875af115801561288a573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906128ae919061346c565b5060405163095ea7b360e01b81526001600160a01b037f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe8881166004830152602482018390527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2169063095ea7b390604401610c37565b5f808080806001600160a01b038087167f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2909116108181156129b057886129738b670de0b6b3a764000061349b565b61297d91906134c6565b90507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc295508794508893508992506129fc565b896129c38a670de0b6b3a764000061349b565b6129cd91906134c6565b90508795507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc294508993508892505b5f612a0682612fa7565b90505f633b9aca00612a1c83600160601b61349b565b612a2691906134c6565b985050505050939792965093509350565b6008545f9060ff16612a5c57604051634e00e51360e01b815260040160405180910390fd5b5f6001600160a01b03831615612a73575081612b2f565b60405163a167129560e01b81526001600160a01b0386811660048301527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281166024830152610bb860448301527f0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f984169063a1671295906064016020604051808303815f875af1158015612b08573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612b2c9190613598565b90505b60405163f637731d60e01b81526001600160a01b03858116600483015282169063f637731d906024015f604051808303815f87803b158015612b6f575f80fd5b505af1158015612b81573d5f803e3d5ffd5b505060078054600101905550506040516001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2811691878216918416907f9c5d829b9b23efc461f9aeef91979ec04bb903feb3bee4f26d22114abfc7335b905f90a46040805160c0810182526001600160a01b0380841682525f6020808401828152600754858701908152606086018d81528c8616608088018181527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2881660a08a01908152918752600990955297909420955186549086166001600160a01b031991821617875591516001870155516002860155915160038501555160048401805491841691831691909117905592516005909201805492909116919092161790559050949350505050565b5f805f807f000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b03166388316456876040518263ffffffff1660e01b8152600401612d049190613808565b6080604051808303815f875af1158015612d20573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612d4491906138cc565b93509350935093505f60095f876001600160a01b03166001600160a01b031681526020019081526020015f206040518060c00160405290815f82015f9054906101000a90046001600160a01b03166001600160a01b03166001600160a01b03168152602001600182015481526020016002820154815260200160038201548152602001600482015f9054906101000a90046001600160a01b03166001600160a01b03166001600160a01b03168152602001600582015f9054906101000a90046001600160a01b03166001600160a01b03166001600160a01b031681525050905084816020018181525050865f015181608001906001600160a01b031690816001600160a01b03168152505086602001518160a001906001600160a01b031690816001600160a01b0316815250508060095f886001600160a01b03166001600160a01b031681526020019081526020015f205f820151815f015f6101000a8154816001600160a01b0302191690836001600160a01b031602179055506020820151816001015560408201518160020155606082015181600301556080820151816004015f6101000a8154816001600160a01b0302191690836001600160a01b0316021790555060a0820151816005015f6101000a8154816001600160a01b0302191690836001600160a01b03160217905550905050336001600160a01b03167f936f1605239d50a44520651cb0698a8f77eea34a13f43a4eac22872b1baf48cc86868686604051612f9694939291909384526001600160801b039290921660208401526040830152606082015260800190565b60405180910390a250505050505050565b5f806002612fb684600161368b565b612fc091906134c6565b90508291505b8181101561193057905080600281612fde81866134c6565b612fe8919061368b565b612ff291906134c6565b9050612fc6565b5f60208284031215613009575f80fd5b81356001600160e01b031981168114611020575f80fd5b5f60208284031215613030575f80fd5b5035919050565b6001600160a01b0381168114611940575f80fd5b5f6020828403121561305b575f80fd5b813561102081613037565b5f8060408385031215613077575f80fd5b82359150602083013561308981613037565b809150509250929050565b5f6020808352835180828501525f5b818110156130bf578581018301518582016040015282016130a3565b505f604082860101526040601f19601f8301168501019250505092915050565b634e487b7160e01b5f52604160045260245ffd5b5f805f60608486031215613105575f80fd5b833561311081613037565b925060208401359150604084013567ffffffffffffffff80821115613133575f80fd5b818601915086601f830112613146575f80fd5b813581811115613158576131586130df565b604051601f8201601f19908116603f01168101908382118183101715613180576131806130df565b81604052828152896020848701011115613198575f80fd5b826020860160208301375f6020848301015280955050505050509250925092565b8015158114611940575f80fd5b5f805f80608085870312156131d9575f80fd5b8435935060208501356131eb81613037565b925060408501356131fb81613037565b9150606085013561320b816131b9565b939692955090935050565b5f8060408385031215613227575f80fd5b823561323281613037565b9150602083013561308981613037565b5f8083601f840112613252575f80fd5b50813567ffffffffffffffff811115613269575f80fd5b602083019150836020828501011115612409575f80fd5b5f805f805f805f8060a0898b031215613297575f80fd5b883567ffffffffffffffff808211156132ae575f80fd5b6132ba8c838d01613242565b909a50985060208b01359150808211156132d2575f80fd5b6132de8c838d01613242565b909850965060408b013591506132f382613037565b90945060608a0135935060808a0135908082111561330f575f80fd5b5061331c8b828c01613242565b999c989b5096995094979396929594505050565b5f805f805f805f60a0888a031215613346575f80fd5b873567ffffffffffffffff8082111561335d575f80fd5b6133698b838c01613242565b909950975060208a0135915080821115613381575f80fd5b5061338e8a828b01613242565b90965094505060408801356133a281613037565b92506060880135915060808801356133b981613037565b8091505092959891949750929550565b5f805f606084860312156133db575f80fd5b83356133e681613037565b925060208401356133f681613037565b929592945050506040919091013590565b815181526020808301516001600160a01b0316908201526040808301516001600160801b0390811691830191909152606092830151169181019190915260800190565b5f806040838503121561345b575f80fd5b505080516020909101519092909150565b5f6020828403121561347c575f80fd5b8151611020816131b9565b634e487b7160e01b5f52601160045260245ffd5b808202811582820484141761089157610891613487565b634e487b7160e01b5f52601260045260245ffd5b5f826134d4576134d46134b2565b500490565b8181038181111561089157610891613487565b8051600281900b8114612115575f80fd5b805161ffff81168114612115575f80fd5b5f805f805f805f60e0888a031215613524575f80fd5b875161352f81613037565b965061353d602089016134ec565b955061354b604089016134fd565b9450613559606089016134fd565b9350613567608089016134fd565b925060a088015160ff8116811461357c575f80fd5b60c08901519092506133b9816131b9565b805161211581613037565b5f602082840312156135a8575f80fd5b815161102081613037565b5f602082840312156135c3575f80fd5b5051919050565b81835281816020850137505f828201602090810191909152601f909101601f19169091010190565b60e081525f61360560e083018b8d6135ca565b8281036020840152613618818a8c6135ca565b6001600160a01b03988916604085015260608401979097525050928516608084015290841660a083015290921660c090920191909152949350505050565b6001600160a01b03851681526060602082018190525f9061367a90830185876135ca565b905082604083015295945050505050565b8082018082111561089157610891613487565b805162ffffff81168114612115575f80fd5b80516001600160801b0381168114612115575f80fd5b5f805f805f805f805f805f806101808d8f0312156136e2575f80fd5b8c516bffffffffffffffffffffffff811681146136fd575f80fd5b9b5061370b60208e0161358d565b9a5061371960408e0161358d565b995061372760608e0161358d565b985061373560808e0161369e565b975061374360a08e016134ec565b965061375160c08e016134ec565b955061375f60e08e016136b0565b94506101008d015193506101208d0151925061377e6101408e016136b0565b915061378d6101608e016136b0565b90509295989b509295989b509295989b565b6001600160801b038181168382160280821691908281146137c2576137c2613487565b505092915050565b5f6001600160801b03808416806137e3576137e36134b2565b92169190910492915050565b60ff818116838216019081111561089157610891613487565b81516001600160a01b031681526101608101602083015161383460208401826001600160a01b03169052565b50604083015161384b604084018262ffffff169052565b506060830151613860606084018260020b9052565b506080830151613875608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e0830152610100808401518184015250610120808401516138bb828501826001600160a01b03169052565b505061014092830151919092015290565b5f805f80608085870312156138df575f80fd5b845193506138ef602086016136b0565b604086015160609096015194979096509250505056feeda12c967d41537df595863b12c47d93205bb25d9b53142e1602b253ecf6b74ba26469706673582212207b89c30c80423a39b1847379611dcec11b0ae5e6de68573324406275398a589164736f6c63430008140033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f984000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe8800000000000000000000000031f9ba90d9df42ac8cc2ec694d937939af7ab4aa000000000000000000000000989c857623e58cfb5154d80453430bcf5b665b1d000000000000000000000000c98e0d1b47a1964afb3c2f661514ce48e2dbe650000000000000000000000000ed0570bfc991a66e2e21563a31ebea3baecd9738000000000000000000000000ec1e663a2e86df68b7a30974422a524a465d0653
-----Decoded View---------------
Arg [0] : _uniswapFactory (address): 0x1F98431c8aD98523631AE4a59f267346ea31F984
Arg [1] : _positionManager (address): 0xC36442b4a4522E871399CD717aBDD847Ab11FE88
Arg [2] : _ERC721exTemplate (address): 0x31f9ba90d9DF42AC8cC2eC694D937939AF7Ab4aa
Arg [3] : _ERC721exTemplateNoBurn (address): 0x989C857623E58cfb5154d80453430BcF5B665B1D
Arg [4] : _bondingCurveContract (address): 0xc98e0d1b47A1964Afb3C2f661514ce48e2dBe650
Arg [5] : _logicLibAddress (address): 0xED0570bFc991a66e2e21563A31ebEa3BAEcD9738
Arg [6] : _mintableFactoryAddress (address): 0xeC1E663a2e86df68B7a30974422A524a465d0653
-----Encoded View---------------
7 Constructor Arguments found :
Arg [0] : 0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f984
Arg [1] : 000000000000000000000000c36442b4a4522e871399cd717abdd847ab11fe88
Arg [2] : 00000000000000000000000031f9ba90d9df42ac8cc2ec694d937939af7ab4aa
Arg [3] : 000000000000000000000000989c857623e58cfb5154d80453430bcf5b665b1d
Arg [4] : 000000000000000000000000c98e0d1b47a1964afb3c2f661514ce48e2dbe650
Arg [5] : 000000000000000000000000ed0570bfc991a66e2e21563a31ebea3baecd9738
Arg [6] : 000000000000000000000000ec1e663a2e86df68b7a30974422a524a465d0653
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 33 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.