Source Code
More Info
Private Name Tags
ContractCreator
TokenTracker
Latest 25 from a total of 95,397 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Multicall | 25451521 | 5 mins ago | IN | 0 HYPE | 0.00005013 | ||||
| Multicall | 25451399 | 7 mins ago | IN | 0 HYPE | 0.00010115 | ||||
| Multicall | 25450929 | 14 mins ago | IN | 0 HYPE | 0.00005648 | ||||
| Multicall | 25450666 | 19 mins ago | IN | 0 HYPE | 0.0000672 | ||||
| Set Approval For... | 25450332 | 24 mins ago | IN | 0 HYPE | 0.00000567 | ||||
| Multicall | 25449754 | 34 mins ago | IN | 0 HYPE | 0.0000752 | ||||
| Multicall | 25449091 | 44 mins ago | IN | 0.92524266 HYPE | 0.00040026 | ||||
| Multicall | 25448023 | 1 hr ago | IN | 14.86566785 HYPE | 0.00024226 | ||||
| Multicall | 25447861 | 1 hr ago | IN | 9.89999999 HYPE | 0.00003942 | ||||
| Multicall | 25446918 | 1 hr ago | IN | 0 HYPE | 0.00006029 | ||||
| Multicall | 25444758 | 1 hr ago | IN | 0 HYPE | 0.00238204 | ||||
| Multicall | 25444097 | 2 hrs ago | IN | 0 HYPE | 0.0007753 | ||||
| Multicall | 25443957 | 2 hrs ago | IN | 0 HYPE | 0.00014101 | ||||
| Multicall | 25440663 | 3 hrs ago | IN | 9.65350976 HYPE | 0.00046044 | ||||
| Multicall | 25440236 | 3 hrs ago | IN | 0 HYPE | 0.00013298 | ||||
| Multicall | 25439626 | 3 hrs ago | IN | 11 HYPE | 0.00017395 | ||||
| Set Approval For... | 25439399 | 3 hrs ago | IN | 0 HYPE | 0.0001226 | ||||
| Multicall | 25435661 | 4 hrs ago | IN | 0 HYPE | 0.00146144 | ||||
| Multicall | 25434685 | 4 hrs ago | IN | 4.4376893 HYPE | 0.00009201 | ||||
| Multicall | 25434441 | 4 hrs ago | IN | 0 HYPE | 0.00004603 | ||||
| Multicall | 25429434 | 6 hrs ago | IN | 0.56964449 HYPE | 0.00025442 | ||||
| Multicall | 25429305 | 6 hrs ago | IN | 0 HYPE | 0.00008277 | ||||
| Set Approval For... | 25429173 | 6 hrs ago | IN | 0 HYPE | 0.00000467 | ||||
| Multicall | 25429104 | 6 hrs ago | IN | 0 HYPE | 0.00007502 | ||||
| Multicall | 25427112 | 6 hrs ago | IN | 140.26715314 HYPE | 0.00004928 |
Latest 25 internal transactions (View All)
Advanced mode:
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 25451521 | 5 mins ago | 0.85255198 HYPE | ||||
| 25451521 | 5 mins ago | 0.85255198 HYPE | ||||
| 25450666 | 19 mins ago | 0.93470006 HYPE | ||||
| 25450666 | 19 mins ago | 0.93470006 HYPE | ||||
| 25449091 | 44 mins ago | 0.02671612 HYPE | ||||
| 25449091 | 44 mins ago | 0.89852653 HYPE | ||||
| 25448023 | 1 hr ago | 0 HYPE | ||||
| 25448023 | 1 hr ago | 14.86566785 HYPE | ||||
| 25447861 | 1 hr ago | 9.89999999 HYPE | ||||
| 25444758 | 1 hr ago | 13.15723936 HYPE | ||||
| 25444758 | 1 hr ago | 13.15723936 HYPE | ||||
| 25440663 | 3 hrs ago | 0.49600974 HYPE | ||||
| 25440663 | 3 hrs ago | 9.15750002 HYPE | ||||
| 25439626 | 3 hrs ago | 11 HYPE | ||||
| 25435661 | 4 hrs ago | 4.43150509 HYPE | ||||
| 25435661 | 4 hrs ago | 4.43150509 HYPE | ||||
| 25434685 | 4 hrs ago | 4.4376893 HYPE | ||||
| 25429434 | 6 hrs ago | 0.56964449 HYPE | ||||
| 25428890 | 6 hrs ago | 0.405 HYPE | ||||
| 25428890 | 6 hrs ago | 0.405 HYPE | ||||
| 25427112 | 6 hrs ago | 0.00074439 HYPE | ||||
| 25427112 | 6 hrs ago | 140.26640875 HYPE | ||||
| 25427076 | 6 hrs ago | 240.78254988 HYPE | ||||
| 25427025 | 6 hrs ago | 20.18476334 HYPE | ||||
| 25427010 | 6 hrs ago | 124.21013259 HYPE |
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:
NonfungiblePositionManager
Compiler Version
v0.8.28+commit.7893614a
Optimization Enabled:
Yes with 1000 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.15;
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
import "@uniswap/v3-core/contracts/libraries/FixedPoint128.sol";
import "@uniswap/v3-core/contracts/libraries/FullMath.sol";
import "openzeppelin-v4/utils/math/Math.sol";
import "./base/ERC721Permit.sol";
import {LiquidityManagement} from "./base/LiquidityManagement.sol";
import "./base/Multicall.sol";
import "./base/PeripheryImmutableState.sol";
import "./base/PeripheryValidation.sol";
import "./base/PoolInitializer.sol";
import "./base/SelfPermit.sol";
import {INonfungiblePositionManager} from "./interfaces/INonfungiblePositionManager.sol";
import "./interfaces/INonfungibleTokenPositionDescriptor.sol";
import "./libraries/PoolAddress.sol";
import "./libraries/PositionKey.sol";
import {Context as ContextV4} from "openzeppelin-v4/utils/Context.sol";
import {Strings} from "openzeppelin-v4/utils/Strings.sol";
import {Context as ContextV5} from "openzeppelin-v5/utils/Context.sol";
function unsafeSub(uint256 a, uint256 b) pure returns (uint256) {
unchecked {
return a - b;
}
}
function clipToUint128(uint256 a) pure returns (uint128) {
return uint128(Math.min(type(uint128).max, a));
}
/// @title NFT positions
/// @notice Wraps Uniswap V3 positions in the ERC721 non-fungible token interface
contract NonfungiblePositionManager is INonfungiblePositionManager, Multicall, ERC721Permit, PeripheryImmutableState, PoolInitializer, LiquidityManagement, PeripheryValidation, SelfPermit {
// details about the uniswap position
struct Position {
// the nonce for permits
uint96 nonce;
// the address that is approved for spending this token
address operator;
// the ID of the pool with which this token is connected
IUniswapV3Pool pool;
// the tick range of the position
int24 tickLower;
int24 tickUpper;
// the liquidity of the position
uint128 liquidity;
uint128 liquidityStaked;
// the fee growth of the aggregate position as of the last action on the individual position
uint256 feeGrowthInside0LastX128;
uint256 feeGrowthInside1LastX128;
uint256 rewardGrowthInsideLastX128;
// how many uncollected tokens are owed to the position, as of the last computation
uint128 tokensOwed0;
uint128 tokensOwed1;
uint128 rewardsOwed;
}
/// @dev The token ID position data
mapping(uint256 => Position) private _positions;
/// @dev The ID of the next token that will be minted. Skips 0
uint176 private _nextId = 1;
string private baseURI;
constructor(address _factory, address _WETH9, bytes32 initCodeHash, string memory baseURI_, string memory name, string memory symbol) ERC721Permit(name, symbol, "1") PeripheryImmutableState(_factory, _WETH9) PoolAddress(initCodeHash) {
baseURI = baseURI_;
}
/// @inheritdoc INonfungiblePositionManager
function positions(uint256 tokenId) external view override 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) {
Position memory position = _positions[tokenId];
require(address(position.pool) != address(0), "Invalid token ID");
return (position.nonce, position.operator, position.pool.token0(), position.pool.token1(), position.pool.fee(), position.tickLower, position.tickUpper, position.liquidity, position.feeGrowthInside0LastX128, position.feeGrowthInside1LastX128, position.tokensOwed0, position.tokensOwed1);
}
function positions2(uint256 tokenId) external view returns (uint128 liquidityStaked, address pool) {
Position memory position = _positions[tokenId];
require(address(position.pool) != address(0), "Invalid token ID");
return (position.liquidityStaked, address(position.pool));
}
function positionRewardsOwed(uint256 tokenId) external returns (uint256) {
Position storage position = _positions[tokenId];
position.pool.burn(position.tickLower, position.tickUpper, 0);
_updatePosition(tokenId);
return position.rewardsOwed;
}
/// @inheritdoc INonfungiblePositionManager
function mint(MintParams calldata params) external payable override checkDeadline(params.deadline) returns (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1) {
IUniswapV3Pool pool;
(liquidity, amount0, amount1, pool) = addLiquidity(AddLiquidityParams({token0: params.token0, token1: params.token1, fee: params.fee, recipient: address(this), tickLower: params.tickLower, tickUpper: params.tickUpper, amount0Desired: params.amount0Desired, amount1Desired: params.amount1Desired, amount0Min: params.amount0Min, amount1Min: params.amount1Min}));
_mint(params.recipient, (tokenId = _nextId++));
_positions[tokenId] = Position({nonce: 0, operator: address(0), pool: pool, tickLower: params.tickLower, tickUpper: params.tickUpper, liquidity: 0, liquidityStaked: 0, feeGrowthInside0LastX128: 0, feeGrowthInside1LastX128: 0, rewardGrowthInsideLastX128: 0, tokensOwed0: 0, tokensOwed1: 0, rewardsOwed: 0});
_updatePosition(tokenId);
_positions[tokenId].liquidity += liquidity;
emit IncreaseLiquidity(tokenId, liquidity, amount0, amount1);
}
function isApprovedOrOwner(address spender, uint256 tokenId) external view returns (bool) {
return _isApprovedOrOwner(spender, tokenId);
}
modifier isAuthorizedForToken(uint256 tokenId) {
require(_isApprovedOrOwner(_msgSender(), tokenId), "Not approved");
_;
}
function tokenURI(uint256 tokenId) public view override(ERC721, IERC721Metadata) returns (string memory) {
require(_exists(tokenId));
return string(abi.encodePacked(baseURI, Strings.toString(block.chainid), "/", Strings.toHexString(address(this)), "/", Strings.toString(tokenId)));
}
/// @inheritdoc INonfungiblePositionManager
function increaseLiquidity(IncreaseLiquidityParams calldata params) external payable override checkDeadline(params.deadline) returns (uint128 liquidity, uint256 amount0, uint256 amount1) {
Position storage position = _positions[params.tokenId];
IUniswapV3Pool pool;
(liquidity, amount0, amount1, pool) = addLiquidity(AddLiquidityParams({token0: position.pool.token0(), token1: position.pool.token1(), fee: position.pool.fee(), tickLower: position.tickLower, tickUpper: position.tickUpper, amount0Desired: params.amount0Desired, amount1Desired: params.amount1Desired, amount0Min: params.amount0Min, amount1Min: params.amount1Min, recipient: address(this)}));
_updatePosition(params.tokenId);
position.liquidity += liquidity;
emit IncreaseLiquidity(params.tokenId, liquidity, amount0, amount1);
}
/// @inheritdoc INonfungiblePositionManager
function decreaseLiquidity(DecreaseLiquidityParams calldata params) external payable override isAuthorizedForToken(params.tokenId) checkDeadline(params.deadline) returns (uint256 amount0, uint256 amount1) {
require(params.liquidity > 0);
Position storage position = _positions[params.tokenId];
require(position.liquidity >= params.liquidity);
require(position.liquidity - params.liquidity >= position.liquidityStaked);
(amount0, amount1) = position.pool.burn(position.tickLower, position.tickUpper, params.liquidity);
require(amount0 >= params.amount0Min && amount1 >= params.amount1Min, "Price slippage check");
_updatePosition(params.tokenId);
position.liquidity -= params.liquidity;
position.tokensOwed0 += uint128(amount0);
position.tokensOwed1 += uint128(amount1);
emit DecreaseLiquidity(params.tokenId, params.liquidity, amount0, amount1);
}
function _updatePosition(uint256 tokenId) internal {
emit UpdatePosition(tokenId);
Position storage position = _positions[tokenId];
bytes32 positionKey = PositionKey.compute(address(this), position.tickLower, position.tickUpper);
(, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128,,) = position.pool.positions(positionKey);
(, uint256 rewardGrowthInsideLastX128,) = position.pool.positionRewardInformation(positionKey);
uint128 liquidityUnstaked = position.liquidity - position.liquidityStaked;
unchecked {
position.tokensOwed0 = clipToUint128(position.tokensOwed0 + FullMath.mulDiv(unsafeSub(feeGrowthInside0LastX128, position.feeGrowthInside0LastX128), liquidityUnstaked, FixedPoint128.Q128));
position.tokensOwed1 = clipToUint128(position.tokensOwed1 + FullMath.mulDiv(unsafeSub(feeGrowthInside1LastX128, position.feeGrowthInside1LastX128), liquidityUnstaked, FixedPoint128.Q128));
position.rewardsOwed = clipToUint128(position.rewardsOwed + FullMath.mulDiv(unsafeSub(rewardGrowthInsideLastX128, position.rewardGrowthInsideLastX128), position.liquidityStaked, FixedPoint128.Q128));
}
position.feeGrowthInside0LastX128 = feeGrowthInside0LastX128;
position.feeGrowthInside1LastX128 = feeGrowthInside1LastX128;
position.rewardGrowthInsideLastX128 = rewardGrowthInsideLastX128;
}
function unstake(uint256 tokenId, uint128 liquidityStakedDelta) external payable isAuthorizedForToken(tokenId) {
_unstake(tokenId, liquidityStakedDelta);
}
function unstake(uint256 tokenId) external payable isAuthorizedForToken(tokenId) {
Position storage position = _positions[tokenId];
_unstake(tokenId, position.liquidityStaked);
}
function _unstake(uint256 tokenId, uint128 liquidityStakedDelta) internal {
Position storage position = _positions[tokenId];
position.pool.unstake(position.tickLower, position.tickUpper, liquidityStakedDelta);
_updatePosition(tokenId);
position.liquidityStaked -= liquidityStakedDelta;
emit Unstake(tokenId, liquidityStakedDelta);
}
function stake(uint256 tokenId, uint128 liquidityStakedDelta) external payable isAuthorizedForToken(tokenId) {
_stake(tokenId, liquidityStakedDelta);
}
function stake(uint256 tokenId) public payable isAuthorizedForToken(tokenId) {
Position storage position = _positions[tokenId];
_stake(tokenId, position.liquidity - position.liquidityStaked);
}
function stake() external payable {
stake(_nextId - 1);
}
function _stake(uint256 tokenId, uint128 liquidityStakedDelta) internal {
Position storage position = _positions[tokenId];
position.pool.stake(position.tickLower, position.tickUpper, liquidityStakedDelta);
_updatePosition(tokenId);
position.liquidityStaked += liquidityStakedDelta;
require(position.liquidity >= position.liquidityStaked);
emit Stake(tokenId, liquidityStakedDelta);
}
/// @inheritdoc INonfungiblePositionManager
function collect(CollectParams calldata params) external payable override isAuthorizedForToken(params.tokenId) returns (uint256 amount0, uint256 amount1) {
require(params.amount0Max > 0 || params.amount1Max > 0);
// allow collecting to the nft position manager address with address 0
address recipient = params.recipient == address(0) ? address(this) : params.recipient;
Position storage position = _positions[params.tokenId];
// trigger an update of the position fees owed and fee growth snapshots if it has any liquidity
if (position.liquidity > 0) {
position.pool.burn(position.tickLower, position.tickUpper, 0);
_updatePosition(params.tokenId);
}
// compute the arguments to give to the pool#collect method
(uint128 amount0Collect, uint128 amount1Collect) = (uint128(Math.min(params.amount0Max, position.tokensOwed0)), uint128(Math.min(params.amount1Max, position.tokensOwed1)));
// the actual amounts collected are returned
(amount0, amount1) = position.pool.collect(recipient, position.tickLower, position.tickUpper, amount0Collect, amount1Collect);
// sometimes there will be a few less wei than expected due to rounding down in core, but we just subtract the full amount expected
// instead of the actual amount so we can burn the token
position.tokensOwed0 -= amount0Collect;
position.tokensOwed1 -= amount1Collect;
emit Collect(params.tokenId, recipient, amount0Collect, amount1Collect);
}
function collectReward(CollectRewardParams calldata params) external payable override isAuthorizedForToken(params.tokenId) returns (uint256 amountReward) {
require(params.amountRewardMax > 0);
// allow collecting to the nft position manager address with address 0
address recipient = params.recipient == address(0) ? address(this) : params.recipient;
Position storage position = _positions[params.tokenId];
// trigger an update of the position fees owed and fee growth snapshots if it has any liquidity
if (position.liquidity > 0) {
position.pool.burn(position.tickLower, position.tickUpper, 0);
_updatePosition(params.tokenId);
}
// compute the arguments to give to the pool#collect method
uint128 amountRewardCollect = uint128(Math.min(params.amountRewardMax, position.rewardsOwed));
// the actual amounts collected are returned
amountReward = position.pool.collectReward(recipient, position.tickLower, position.tickUpper, amountRewardCollect);
// sometimes there will be a few less wei than expected due to rounding down in core, but we just subtract the full amount expected
// instead of the actual amount so we can burn the token
position.rewardsOwed -= amountRewardCollect;
emit CollectReward(params.tokenId, recipient, amountRewardCollect);
}
/// @inheritdoc INonfungiblePositionManager
function burn(uint256 tokenId) external payable override isAuthorizedForToken(tokenId) {
Position storage position = _positions[tokenId];
require(position.liquidity == 0 && position.tokensOwed0 == 0 && position.tokensOwed1 == 0 && position.rewardsOwed == 0, "Not cleared");
delete _positions[tokenId];
_burn(tokenId);
}
function _getAndIncrementNonce(uint256 tokenId) internal override returns (uint256) {
return uint256(_positions[tokenId].nonce++);
}
/// @inheritdoc IERC721
function getApproved(uint256 tokenId) public view override(ERC721, IERC721) returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _positions[tokenId].operator;
}
/// @dev Overrides _approve to use the operator in the position, which is packed with the position permit nonce
function _approve(address to, uint256 tokenId) internal override(ERC721) {
_positions[tokenId].operator = to;
emit Approval(ownerOf(tokenId), to, tokenId);
}
// To prevent contracts unaware of the staking feature from misbehaving, all positions get unstaked on transfer.
// staking-aware contracts can explicitly stake the position again.
function _beforeTokenTransfer(address from, address to, uint256 tokenId, uint256 amount) internal override {
uint128 liquidityStaked = _positions[tokenId].liquidityStaked;
if (liquidityStaked > 0) _unstake(tokenId, liquidityStaked);
super._beforeTokenTransfer(from, to, tokenId, amount);
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
import {IUniswapV3PoolActions} from "./pool/IUniswapV3PoolActions.sol";
import {IUniswapV3PoolDerivedState} from "./pool/IUniswapV3PoolDerivedState.sol";
import {IUniswapV3PoolErrors} from "./pool/IUniswapV3PoolErrors.sol";
import {IUniswapV3PoolEvents} from "./pool/IUniswapV3PoolEvents.sol";
import {IUniswapV3PoolImmutables} from "./pool/IUniswapV3PoolImmutables.sol";
import {IUniswapV3PoolOwnerActions} from "./pool/IUniswapV3PoolOwnerActions.sol";
import {IUniswapV3PoolState} from "./pool/IUniswapV3PoolState.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, IUniswapV3PoolErrors, IUniswapV3PoolEvents {}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.4.0;
/// @title FixedPoint128
/// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format)
library FixedPoint128 {
uint256 internal constant Q128 = 0x100000000000000000000000000000000;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title Contains 512-bit math functions
/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision
/// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits
library FullMath {
/// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
/// @param denominator The divisor
/// @return result The 256-bit result
/// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv
function mulDiv(uint256 a, uint256 b, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = a * b
// Compute the product mod 2**256 and mod 2**256 - 1
// then use the Chinese Remainder Theorem to reconstruct
// the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2**256 + prod0
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(a, b, not(0))
prod0 := mul(a, b)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division
if (prod1 == 0) {
require(denominator > 0);
assembly {
result := div(prod0, denominator)
}
return result;
}
// Make sure the result is less than 2**256.
// Also prevents denominator == 0
require(denominator > prod1);
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0]
// Compute remainder using mulmod
uint256 remainder;
assembly {
remainder := mulmod(a, b, denominator)
}
// Subtract 256 bit number from 512 bit number
assembly {
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator
// Compute largest power of two divisor of denominator.
// Always >= 1.
uint256 twos = (0 - denominator) & denominator;
// Divide denominator by power of two
assembly {
denominator := div(denominator, twos)
}
// Divide [prod1 prod0] by the factors of two
assembly {
prod0 := div(prod0, twos)
}
// Shift in bits from prod1 into prod0. For this we need
// to flip `twos` such that it is 2**256 / twos.
// If twos is zero, then it becomes one
assembly {
twos := add(div(sub(0, twos), twos), 1)
}
prod0 |= prod1 * twos;
// Invert denominator mod 2**256
// Now that denominator is an odd number, it has an inverse
// modulo 2**256 such that denominator * inv = 1 mod 2**256.
// Compute the inverse by starting with a seed that is correct
// correct for four bits. That is, denominator * inv = 1 mod 2**4
uint256 inv = (3 * denominator) ^ 2;
// Now use Newton-Raphson iteration to improve the precision.
// Thanks to Hensel's lifting lemma, this also works in modular
// arithmetic, doubling the correct bits in each step.
inv *= 2 - denominator * inv; // inverse mod 2**8
inv *= 2 - denominator * inv; // inverse mod 2**16
inv *= 2 - denominator * inv; // inverse mod 2**32
inv *= 2 - denominator * inv; // inverse mod 2**64
inv *= 2 - denominator * inv; // inverse mod 2**128
inv *= 2 - denominator * inv; // inverse mod 2**256
// Because the division is now exact we can divide by multiplying
// with the modular inverse of denominator. This will give us the
// correct result modulo 2**256. Since the precoditions guarantee
// that the outcome is less than 2**256, this is the final result.
// We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inv;
return result;
}
}
/// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
/// @param denominator The divisor
/// @return result The 256-bit result
function mulDivRoundingUp(uint256 a, uint256 b, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
result = mulDiv(a, b, denominator);
if (mulmod(a, b, denominator) > 0) {
require(result < type(uint256).max);
result++;
}
}
}
function addLiquidity(uint128 a, int128 d) internal pure returns (uint128) {
return d < 0 ? a - uint128(-d) : a + uint128(d);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1, "Math: mulDiv overflow");
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
}
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.15;
import "openzeppelin-v4/token/ERC721/extensions/ERC721Enumerable.sol";
import "openzeppelin-v4/utils/Address.sol";
import {IERC721Permit} from "../interfaces/IERC721Permit.sol";
import "../interfaces/external/IERC1271.sol";
import "../libraries/ChainId.sol";
/// @title ERC721 with permit
/// @notice Nonfungible tokens that support an approve via signature, i.e. permit
abstract contract ERC721Permit is ERC721Enumerable, IERC721Permit {
/// @dev Gets the current nonce for a token ID and then increments it, returning the original value
function _getAndIncrementNonce(uint256 tokenId) internal virtual returns (uint256);
/// @dev The hash of the name used in the permit signature verification
bytes32 private immutable nameHash;
/// @dev The hash of the version string used in the permit signature verification
bytes32 private immutable versionHash;
/// @notice Computes the nameHash and versionHash
constructor(string memory name_, string memory symbol_, string memory version_) ERC721(name_, symbol_) {
nameHash = keccak256(bytes(name_));
versionHash = keccak256(bytes(version_));
}
/// @inheritdoc IERC721Permit
function DOMAIN_SEPARATOR() public view override returns (bytes32) {
return keccak256(
abi.encode(
// keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)')
0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f,
nameHash,
versionHash,
ChainId.get(),
address(this)
)
);
}
/// @inheritdoc IERC721Permit
/// @dev Value is equal to keccak256("Permit(address spender,uint256 tokenId,uint256 nonce,uint256 deadline)");
bytes32 public constant override PERMIT_TYPEHASH = 0x49ecf333e5b8c95c40fdafc95c1ad136e8914a8fb55e9dc8bb01eaa83a2df9ad;
/// @inheritdoc IERC721Permit
function permit(address spender, uint256 tokenId, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external payable override {
require(block.timestamp <= deadline, "Permit expired");
bytes32 digest = keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR(), keccak256(abi.encode(PERMIT_TYPEHASH, spender, tokenId, _getAndIncrementNonce(tokenId), deadline))));
address owner = ownerOf(tokenId);
require(spender != owner, "ERC721Permit: approval to current owner");
if (Address.isContract(owner)) {
require(IERC1271(owner).isValidSignature(digest, abi.encodePacked(r, s, v)) == 0x1626ba7e, "Unauthorized");
} else {
address recoveredAddress = ecrecover(digest, v, r, s);
require(recoveredAddress != address(0), "Invalid signature");
require(recoveredAddress == owner, "Unauthorized");
}
_approve(spender, tokenId);
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.15;
pragma abicoder v2;
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol";
import "@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3MintCallback.sol";
import "@uniswap/v3-core/contracts/libraries/TickMath.sol";
import "openzeppelin-v4/utils/Context.sol";
import "../libraries/CallbackValidation.sol";
import "../libraries/LiquidityAmounts.sol";
import "../libraries/PoolAddress.sol";
import "./PeripheryImmutableState.sol";
import "./PeripheryPayments.sol";
/// @title Liquidity management functions
/// @notice Internal functions for safely managing liquidity in Uniswap V3
abstract contract LiquidityManagement is Context, IUniswapV3MintCallback, PeripheryImmutableState, PeripheryPayments, CallbackValidation {
struct MintCallbackData {
PoolAddress.PoolKey poolKey;
address payer;
}
/// @inheritdoc IUniswapV3MintCallback
function uniswapV3MintCallback(uint256 amount0Owed, uint256 amount1Owed, bytes calldata data) external override {
MintCallbackData memory decoded = abi.decode(data, (MintCallbackData));
CallbackValidation.verifyCallback(factory, decoded.poolKey);
if (amount0Owed > 0) pay(decoded.poolKey.token0, decoded.payer, msg.sender, amount0Owed);
if (amount1Owed > 0) pay(decoded.poolKey.token1, decoded.payer, msg.sender, amount1Owed);
}
struct AddLiquidityParams {
address token0;
address token1;
uint24 fee;
address recipient;
int24 tickLower;
int24 tickUpper;
uint256 amount0Desired;
uint256 amount1Desired;
uint256 amount0Min;
uint256 amount1Min;
}
/// @notice Add liquidity to an initialized pool
function addLiquidity(AddLiquidityParams memory params) internal returns (uint128 liquidity, uint256 amount0, uint256 amount1, IUniswapV3Pool pool) {
PoolAddress.PoolKey memory poolKey = PoolAddress.PoolKey({token0: params.token0, token1: params.token1, fee: params.fee});
pool = IUniswapV3Pool(PoolAddress.computeAddress(factory, poolKey));
// compute the liquidity amount
{
(uint160 sqrtPriceX96,,,,,,) = pool.slot0();
uint160 sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(params.tickLower);
uint160 sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(params.tickUpper);
liquidity = LiquidityAmounts.getLiquidityForAmounts(sqrtPriceX96, sqrtRatioAX96, sqrtRatioBX96, params.amount0Desired, params.amount1Desired);
}
(amount0, amount1) = pool.mint(params.recipient, params.tickLower, params.tickUpper, liquidity, abi.encode(MintCallbackData({poolKey: poolKey, payer: _msgSender()})));
require(amount0 >= params.amount0Min && amount1 >= params.amount1Min, "Price slippage check");
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.15;
pragma abicoder v2;
import "../interfaces/IMulticall.sol";
/// @title Multicall
/// @notice Enables calling multiple methods in a single call to the contract
abstract contract Multicall is IMulticall {
/// @inheritdoc IMulticall
function multicall(bytes[] calldata data) public payable override returns (bytes[] memory results) {
results = new bytes[](data.length);
for (uint256 i = 0; i < data.length; i++) {
(bool success, bytes memory result) = address(this).delegatecall(data[i]);
if (!success) {
// Next 5 lines from https://ethereum.stackexchange.com/a/83577
if (result.length < 68) revert();
assembly {
result := add(result, 0x04)
}
revert(abi.decode(result, (string)));
}
results[i] = result;
}
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.15;
import "../interfaces/IPeripheryImmutableState.sol";
/// @title Immutable state
/// @notice Immutable state used by periphery contracts
abstract contract PeripheryImmutableState is IPeripheryImmutableState {
/// @inheritdoc IPeripheryImmutableState
address public immutable override factory;
/// @inheritdoc IPeripheryImmutableState
address public immutable override WETH9;
constructor(address _factory, address _WETH9) {
factory = _factory;
WETH9 = _WETH9;
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.15;
abstract contract PeripheryValidation {
modifier checkDeadline(uint256 deadline) {
require(block.timestamp <= deadline, "Transaction too old");
_;
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.15;
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol";
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
import "../interfaces/IPoolInitializer.sol";
import "./PeripheryImmutableState.sol";
/// @title Creates and initializes V3 Pools
abstract contract PoolInitializer is IPoolInitializer, PeripheryImmutableState {
/// @inheritdoc IPoolInitializer
function createAndInitializePoolIfNecessary(address token0, address token1, uint24 fee, uint160 sqrtPriceX96) external payable override returns (address pool) {
require(token0 < token1);
pool = IUniswapV3Factory(factory).getPool(token0, token1, fee);
if (pool == address(0)) {
pool = IUniswapV3Factory(factory).createPool(token0, token1, fee);
IUniswapV3Pool(pool).initialize(sqrtPriceX96);
} else {
(uint160 sqrtPriceX96Existing,,,,,,) = IUniswapV3Pool(pool).slot0();
if (sqrtPriceX96Existing == 0) IUniswapV3Pool(pool).initialize(sqrtPriceX96);
}
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
import "openzeppelin-v4/token/ERC20/IERC20.sol";
import "openzeppelin-v4/token/ERC20/extensions/IERC20Permit.sol";
import "openzeppelin-v4/utils/Context.sol";
import "../interfaces/ISelfPermit.sol";
import "../interfaces/external/IERC20PermitAllowed.sol";
/// @title Self Permit
/// @notice Functionality to call permit on any EIP-2612-compliant token for use in the route
/// @dev These functions are expected to be embedded in multicalls to allow EOAs to approve a contract and call a function
/// that requires an approval in a single transaction.
abstract contract SelfPermit is ISelfPermit, Context {
/// @inheritdoc ISelfPermit
function selfPermit(address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public payable override {
IERC20Permit(token).permit(_msgSender(), address(this), value, deadline, v, r, s);
}
/// @inheritdoc ISelfPermit
function selfPermitIfNecessary(address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external payable override {
if (IERC20(token).allowance(_msgSender(), address(this)) < value) selfPermit(token, value, deadline, v, r, s);
}
/// @inheritdoc ISelfPermit
function selfPermitAllowed(address token, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) public payable override {
IERC20PermitAllowed(token).permit(_msgSender(), address(this), nonce, expiry, true, v, r, s);
}
/// @inheritdoc ISelfPermit
function selfPermitAllowedIfNecessary(address token, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) external payable override {
if (IERC20(token).allowance(_msgSender(), address(this)) < type(uint256).max) selfPermitAllowed(token, nonce, expiry, v, r, s);
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;
import "openzeppelin-v4/token/ERC721/extensions/IERC721Enumerable.sol";
import "openzeppelin-v4/token/ERC721/extensions/IERC721Metadata.sol";
import "../libraries/PoolAddress.sol";
import "./IERC721Permit.sol";
import "./IPeripheryImmutableState.sol";
import "./IPeripheryPayments.sol";
import "./IPoolInitializer.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 {
event UpdatePosition(uint256 tokenId);
/// @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);
event CollectReward(uint256 indexed tokenId, address recipient, uint256 amountReward);
event Stake(uint256 indexed tokenId, uint256 amount);
event Unstake(uint256 indexed tokenId, uint256 amount);
/// @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;
}
struct CollectRewardParams {
uint256 tokenId;
address recipient;
uint128 amountRewardMax;
}
/// @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);
function collectReward(CollectRewardParams calldata params) external payable returns (uint256 amountReward);
/// @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;
import "./INonfungiblePositionManager.sol";
/// @title Describes position NFT tokens via URI
interface INonfungibleTokenPositionDescriptor {
/// @notice Produces the URI describing a particular token ID for a position manager
/// @dev Note this URI may be a data: URI with the JSON contents directly inlined
/// @param positionManager The position manager for which to describe the token
/// @param tokenId The ID of the token for which to produce a description, which may not be valid
/// @return The URI of the ERC721-compliant metadata
function tokenURI(INonfungiblePositionManager positionManager, uint256 tokenId) external view returns (string memory);
}// 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
contract PoolAddress {
bytes32 internal immutable POOL_INIT_CODE_HASH;
constructor(bytes32 initCodeHash) {
POOL_INIT_CODE_HASH = initCodeHash;
}
/// @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 view 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;
library PositionKey {
/// @dev Returns the key of the position in the core library
function compute(address owner, int24 tickLower, int24 tickUpper) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(owner, tickLower, tickUpper));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/Math.sol";
import "./math/SignedMath.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toString(int256 value) internal pure returns (string memory) {
return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return keccak256(bytes(a)) == keccak256(bytes(b));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated 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: 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);
function collectReward(address recipient, int24 tickLower, int24 tickUpper, uint128 amountRewardRequested) external returns (uint128 amountReward);
function stake(int24 tickLower, int24 tickUpper, uint128 amount) external;
function unstake(int24 tickLower, int24 tickUpper, uint128 amount) external;
/// @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 Errors emitted by a pool
/// @notice Contains all events emitted by the pool
interface IUniswapV3PoolErrors {
error SPL();
error LOK();
error TLU();
error TLM();
error TUM();
error AI();
error M0();
error M1();
error AS();
error IIA();
error L();
error F0();
error F1();
}// 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 {
event FeeExempted(address txOrigin);
event Reward(uint256 additionalReward);
/// @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);
event CollectReward(address indexed owner, address recipient, int24 indexed tickLower, int24 indexed tickUpper, uint128 amountReward);
/// @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);
event Stake(address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount);
event Unstake(address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount);
/// @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 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: 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 {
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 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
/// @return 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.
/// @return observationIndex The index of the last oracle observation that was written,
/// @return observationCardinality The current maximum number of observations stored in the pool,
/// @return observationCardinalityNext The next maximum number of observations, to be updated when the observation.
/// @return 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
/// @return The liquidity at the current price of the pool
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
/// @return liquidityNet how much liquidity changes when the pool price crosses the tick,
/// @return feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0,
/// @return feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1,
/// @return tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick
/// @return secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick,
/// @return secondsOutside the seconds spent on the other side of the tick from the current tick,
/// @return 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,
/// @return feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke,
/// @return feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke,
/// @return tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke,
/// @return 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);
function positionRewardInformation(bytes32 key) external view returns (uint128 liquidityStaked, uint256 rewardGrowthInsideLastX128, uint128 rewardsOwed);
/// @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,
/// @return tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp,
/// @return secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp,
/// @return 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: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Enumerable.sol)
pragma solidity ^0.8.0;
import "../ERC721.sol";
import "./IERC721Enumerable.sol";
/**
* @dev This implements an optional extension of {ERC721} defined in the EIP that adds
* enumerability of all the token ids in the contract as well as all token ids owned by each
* account.
*/
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
// Mapping from owner to list of owned token IDs
mapping(address => mapping(uint256 => uint256)) private _ownedTokens;
// Mapping from token ID to index of the owner tokens list
mapping(uint256 => uint256) private _ownedTokensIndex;
// Array with all token ids, used for enumeration
uint256[] private _allTokens;
// Mapping from token id to position in the allTokens array
mapping(uint256 => uint256) private _allTokensIndex;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
return _ownedTokens[owner][index];
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _allTokens.length;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
return _allTokens[index];
}
/**
* @dev See {ERC721-_beforeTokenTransfer}.
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 firstTokenId,
uint256 batchSize
) internal virtual override {
super._beforeTokenTransfer(from, to, firstTokenId, batchSize);
if (batchSize > 1) {
// Will only trigger during construction. Batch transferring (minting) is not available afterwards.
revert("ERC721Enumerable: consecutive transfers not supported");
}
uint256 tokenId = firstTokenId;
if (from == address(0)) {
_addTokenToAllTokensEnumeration(tokenId);
} else if (from != to) {
_removeTokenFromOwnerEnumeration(from, tokenId);
}
if (to == address(0)) {
_removeTokenFromAllTokensEnumeration(tokenId);
} else if (to != from) {
_addTokenToOwnerEnumeration(to, tokenId);
}
}
/**
* @dev Private function to add a token to this extension's ownership-tracking data structures.
* @param to address representing the new owner of the given token ID
* @param tokenId uint256 ID of the token to be added to the tokens list of the given address
*/
function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
uint256 length = ERC721.balanceOf(to);
_ownedTokens[to][length] = tokenId;
_ownedTokensIndex[tokenId] = length;
}
/**
* @dev Private function to add a token to this extension's token tracking data structures.
* @param tokenId uint256 ID of the token to be added to the tokens list
*/
function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
_allTokensIndex[tokenId] = _allTokens.length;
_allTokens.push(tokenId);
}
/**
* @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
* while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
* gas optimizations e.g. when performing a transfer operation (avoiding double writes).
* This has O(1) time complexity, but alters the order of the _ownedTokens array.
* @param from address representing the previous owner of the given token ID
* @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
*/
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
// To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
uint256 tokenIndex = _ownedTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary
if (tokenIndex != lastTokenIndex) {
uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];
_ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
}
// This also deletes the contents at the last position of the array
delete _ownedTokensIndex[tokenId];
delete _ownedTokens[from][lastTokenIndex];
}
/**
* @dev Private function to remove a token from this extension's token tracking data structures.
* This has O(1) time complexity, but alters the order of the _allTokens array.
* @param tokenId uint256 ID of the token to be removed from the tokens list
*/
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
// To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
// rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
// an 'if' statement (like in _removeTokenFromOwnerEnumeration)
uint256 lastTokenId = _allTokens[lastTokenIndex];
_allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
// This also deletes the contents at the last position of the array
delete _allTokensIndex[tokenId];
_allTokens.pop();
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
import {IERC721} from "openzeppelin-v4/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.5.0;
/// @title Interface for verifying contract-based account signatures
/// @notice Interface that verifies provided signature for the data
/// @dev Interface defined by EIP-1271
interface IERC1271 {
/// @notice Returns whether the provided signature is valid for the provided data
/// @dev MUST return the bytes4 magic value 0x1626ba7e when function passes.
/// MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5).
/// MUST allow external calls.
/// @param hash Hash of the data to be signed
/// @param signature Signature byte array associated with _data
/// @return magicValue The bytes4 magic value 0x1626ba7e
function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.0;
/// @title Function for getting the current chain ID
library ChainId {
/// @dev Gets the current chain ID
/// @return chainId The current chain ID
function get() internal view returns (uint256 chainId) {
assembly {
chainId := chainid()
}
}
}// 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);
event PoolCreated(address token0, address token1, uint24 fee, int24 tickSpacing, address pool, address rewardToken, address rewardSource, address protocolFeeCollector);
/// @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 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);
function getProtocolFeeRate(address pool) external view returns (uint24);
function feeExempted(address pool) external view returns (bool);
function collectBribe(address pool, address recipient, uint128 amountMax0, uint128 amountMax1) external returns (uint128, uint128);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Callback for IUniswapV3PoolActions#mint
/// @notice Any contract that calls IUniswapV3PoolActions#mint must implement this interface
interface IUniswapV3MintCallback {
/// @notice Called to `msg.sender` after minting liquidity to a position from IUniswapV3Pool#mint.
/// @dev In the implementation you must pay the pool tokens owed for the minted liquidity.
/// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.
/// @param amount0Owed The amount of token0 due to the pool for the minted liquidity
/// @param amount1Owed The amount of token1 due to the pool for the minted liquidity
/// @param data Any data passed through by the caller via the IUniswapV3PoolActions#mint call
function uniswapV3MintCallback(uint256 amount0Owed, uint256 amount1Owed, bytes calldata data) external;
}// 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 {
error T();
error R();
/// @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) {
unchecked {
uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));
if (absTick > uint256(int256(MAX_TICK))) revert 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) {
unchecked {
// second inequality must be < because the price can never reach the price at the max tick
if (!(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO)) revert 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: GPL-2.0-or-later
pragma solidity ^0.8.0;
import "./PoolAddress.sol";
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
/// @notice Provides validation for callbacks from Uniswap V3 Pools
abstract contract CallbackValidation is PoolAddress {
/// @notice Returns the address of a valid Uniswap V3 Pool
/// @param factory The contract address of the Uniswap V3 factory
/// @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 V3 pool contract address
function verifyCallback(address factory, address tokenA, address tokenB, uint24 fee) internal view returns (IUniswapV3Pool pool) {
return verifyCallback(factory, PoolAddress.getPoolKey(tokenA, tokenB, fee));
}
/// @notice Returns the address of a valid Uniswap V3 Pool
/// @param factory The contract address of the Uniswap V3 factory
/// @param poolKey The identifying key of the V3 pool
/// @return pool The V3 pool contract address
function verifyCallback(address factory, PoolAddress.PoolKey memory poolKey) internal view returns (IUniswapV3Pool pool) {
pool = IUniswapV3Pool(PoolAddress.computeAddress(factory, poolKey));
require(msg.sender == address(pool));
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
import "@uniswap/v3-core/contracts/libraries/FixedPoint96.sol";
import "@uniswap/v3-core/contracts/libraries/FullMath.sol";
/// @title Liquidity amount functions
/// @notice Provides functions for computing liquidity amounts from token amounts and prices
library LiquidityAmounts {
/// @notice Downcasts uint256 to uint128
/// @param x The uint258 to be downcasted
/// @return y The passed value, downcasted to uint128
function toUint128(uint256 x) private pure returns (uint128 y) {
require((y = uint128(x)) == x);
}
/// @notice Computes the amount of liquidity received for a given amount of token0 and price range
/// @dev Calculates amount0 * (sqrt(upper) * sqrt(lower)) / (sqrt(upper) - sqrt(lower))
/// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
/// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
/// @param amount0 The amount0 being sent in
/// @return liquidity The amount of returned liquidity
function getLiquidityForAmount0(uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount0) internal pure returns (uint128 liquidity) {
if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
uint256 intermediate = FullMath.mulDiv(sqrtRatioAX96, sqrtRatioBX96, FixedPoint96.Q96);
unchecked {
return toUint128(FullMath.mulDiv(amount0, intermediate, sqrtRatioBX96 - sqrtRatioAX96));
}
}
/// @notice Computes the amount of liquidity received for a given amount of token1 and price range
/// @dev Calculates amount1 / (sqrt(upper) - sqrt(lower)).
/// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
/// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
/// @param amount1 The amount1 being sent in
/// @return liquidity The amount of returned liquidity
function getLiquidityForAmount1(uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount1) internal pure returns (uint128 liquidity) {
if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
unchecked {
return toUint128(FullMath.mulDiv(amount1, FixedPoint96.Q96, sqrtRatioBX96 - sqrtRatioAX96));
}
}
/// @notice Computes the maximum amount of liquidity received for a given amount of token0, token1, the current
/// pool prices and the prices at the tick boundaries
/// @param sqrtRatioX96 A sqrt price representing the current pool prices
/// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
/// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
/// @param amount0 The amount of token0 being sent in
/// @param amount1 The amount of token1 being sent in
/// @return liquidity The maximum amount of liquidity received
function getLiquidityForAmounts(uint160 sqrtRatioX96, uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount0, uint256 amount1) internal pure returns (uint128 liquidity) {
if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
if (sqrtRatioX96 <= sqrtRatioAX96) {
liquidity = getLiquidityForAmount0(sqrtRatioAX96, sqrtRatioBX96, amount0);
} else if (sqrtRatioX96 < sqrtRatioBX96) {
uint128 liquidity0 = getLiquidityForAmount0(sqrtRatioX96, sqrtRatioBX96, amount0);
uint128 liquidity1 = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioX96, amount1);
liquidity = liquidity0 < liquidity1 ? liquidity0 : liquidity1;
} else {
liquidity = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioBX96, amount1);
}
}
/// @notice Computes the amount of token0 for a given amount of liquidity and a price range
/// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
/// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
/// @param liquidity The liquidity being valued
/// @return amount0 The amount of token0
function getAmount0ForLiquidity(uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity) internal pure returns (uint256 amount0) {
unchecked {
if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
return FullMath.mulDiv(uint256(liquidity) << FixedPoint96.RESOLUTION, sqrtRatioBX96 - sqrtRatioAX96, sqrtRatioBX96) / sqrtRatioAX96;
}
}
/// @notice Computes the amount of token1 for a given amount of liquidity and a price range
/// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
/// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
/// @param liquidity The liquidity being valued
/// @return amount1 The amount of token1
function getAmount1ForLiquidity(uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity) internal pure returns (uint256 amount1) {
if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
unchecked {
return FullMath.mulDiv(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96);
}
}
/// @notice Computes the token0 and token1 value for a given amount of liquidity, the current
/// pool prices and the prices at the tick boundaries
/// @param sqrtRatioX96 A sqrt price representing the current pool prices
/// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
/// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
/// @param liquidity The liquidity being valued
/// @return amount0 The amount of token0
/// @return amount1 The amount of token1
function getAmountsForLiquidity(uint160 sqrtRatioX96, uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity) internal pure returns (uint256 amount0, uint256 amount1) {
if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
if (sqrtRatioX96 <= sqrtRatioAX96) {
amount0 = getAmount0ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity);
} else if (sqrtRatioX96 < sqrtRatioBX96) {
amount0 = getAmount0ForLiquidity(sqrtRatioX96, sqrtRatioBX96, liquidity);
amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioX96, liquidity);
} else {
amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity);
}
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
import "openzeppelin-v4/utils/Context.sol";
import "openzeppelin-v5/token/ERC20/IERC20.sol";
import "../interfaces/IPeripheryPayments.sol";
import "../interfaces/external/IWETH9.sol";
import "../libraries/TransferHelper.sol";
import "./PeripheryImmutableState.sol";
abstract contract PeripheryPayments is Context, IPeripheryPayments, PeripheryImmutableState {
receive() external payable {
require(msg.sender == WETH9, "Not WETH9");
}
/// @inheritdoc IPeripheryPayments
function unwrapWETH9(uint256 amountMinimum, address recipient) public payable override {
uint256 balanceWETH9 = IWETH9(WETH9).balanceOf(address(this));
require(balanceWETH9 >= amountMinimum, "Insufficient WETH9");
if (balanceWETH9 > 0) {
IWETH9(WETH9).withdraw(balanceWETH9);
TransferHelper.safeTransferETH(recipient, balanceWETH9);
}
}
/// @inheritdoc IPeripheryPayments
function sweepToken(address token, uint256 amountMinimum, address recipient) public payable override {
uint256 balanceToken = IERC20(token).balanceOf(address(this));
require(balanceToken >= amountMinimum, "Insufficient token");
if (balanceToken > 0) TransferHelper.safeTransfer(token, recipient, balanceToken);
}
/// @inheritdoc IPeripheryPayments
function refundETH() external payable override {
if (address(this).balance > 0) TransferHelper.safeTransferETH(_msgSender(), address(this).balance);
}
/// @param token The token to pay
/// @param payer The entity that must pay
/// @param recipient The entity that will receive payment
/// @param value The amount to pay
function pay(address token, address payer, address recipient, uint256 value) internal {
if (token == WETH9 && address(this).balance >= value) {
// pay with WETH9
IWETH9(WETH9).deposit{value: value}(); // wrap only what is needed to pay
IWETH9(WETH9).transfer(recipient, value);
} else if (payer == address(this)) {
// pay with tokens already in the contract (for the exact input multihop case)
TransferHelper.safeTransfer(token, recipient, value);
} else {
// pull payment
TransferHelper.safeTransferFrom(token, payer, recipient, value);
}
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;
/// @title Multicall interface
/// @notice Enables calling multiple methods in a single call to the contract
interface IMulticall {
/// @notice Call multiple functions in the current contract and return the data from all of them if they all succeed
/// @dev The `msg.value` should not be trusted for any method callable from multicall.
/// @param data The encoded function data for each of the calls to make to this contract
/// @return results The results from each of the calls passed in via data
function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);
}// 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;
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
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
/// @title Self Permit
/// @notice Functionality to call permit on any EIP-2612-compliant token for use in the route
interface ISelfPermit {
/// @notice Permits this contract to spend a given token from `msg.sender`
/// @dev The `owner` is always msg.sender and the `spender` is always address(this).
/// @param token The address of the token spent
/// @param value The amount that can be spent of token
/// @param deadline A timestamp, the current blocktime must be less than or equal to this timestamp
/// @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 selfPermit(address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external payable;
/// @notice Permits this contract to spend a given token from `msg.sender`
/// @dev The `owner` is always msg.sender and the `spender` is always address(this).
/// Can be used instead of #selfPermit to prevent calls from failing due to a frontrun of a call to #selfPermit
/// @param token The address of the token spent
/// @param value The amount that can be spent of token
/// @param deadline A timestamp, the current blocktime must be less than or equal to this timestamp
/// @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 selfPermitIfNecessary(address token, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external payable;
/// @notice Permits this contract to spend the sender's tokens for permit signatures that have the `allowed` parameter
/// @dev The `owner` is always msg.sender and the `spender` is always address(this)
/// @param token The address of the token spent
/// @param nonce The current nonce of the owner
/// @param expiry The timestamp at which the permit is no longer valid
/// @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 selfPermitAllowed(address token, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) external payable;
/// @notice Permits this contract to spend the sender's tokens for permit signatures that have the `allowed` parameter
/// @dev The `owner` is always msg.sender and the `spender` is always address(this)
/// Can be used instead of #selfPermitAllowed to prevent calls from failing due to a frontrun of a call to #selfPermitAllowed.
/// @param token The address of the token spent
/// @param nonce The current nonce of the owner
/// @param expiry The timestamp at which the permit is no longer valid
/// @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 selfPermitAllowedIfNecessary(address token, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) external payable;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Interface for permit
/// @notice Interface used by DAI/CHAI for permit
interface IERC20PermitAllowed {
/// @notice Approve the spender to spend some tokens via the holder signature
/// @dev This is the permit interface used by DAI and CHAI
/// @param holder The address of the token holder, the token owner
/// @param spender The address of the token spender
/// @param nonce The holder's nonce, increases at each call to permit
/// @param expiry The timestamp at which the permit is no longer valid
/// @param allowed Boolean that sets approval amount, true for type(uint256).max and false for 0
/// @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 holder, address spender, uint256 nonce, uint256 expiry, bool allowed, uint8 v, bytes32 r, bytes32 s) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)
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);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
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.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: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/ERC721.sol)
pragma solidity ^0.8.0;
import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: address zero is not a valid owner");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _ownerOf(tokenId);
require(owner != address(0), "ERC721: invalid token ID");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
_requireMinted(tokenId);
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overridden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not token owner or approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
_requireMinted(tokenId);
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(address from, address to, uint256 tokenId) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved");
_safeTransfer(from, to, tokenId, data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist
*/
function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
return _owners[tokenId];
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _ownerOf(tokenId) != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId, 1);
// Check that tokenId was not minted by `_beforeTokenTransfer` hook
require(!_exists(tokenId), "ERC721: token already minted");
unchecked {
// Will not overflow unless all 2**256 token ids are minted to the same owner.
// Given that tokens are minted one by one, it is impossible in practice that
// this ever happens. Might change if we allow batch minting.
// The ERC fails to describe this case.
_balances[to] += 1;
}
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
_afterTokenTransfer(address(0), to, tokenId, 1);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
* This is an internal function that does not check if the sender is authorized to operate on the token.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId, 1);
// Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook
owner = ERC721.ownerOf(tokenId);
// Clear approvals
delete _tokenApprovals[tokenId];
unchecked {
// Cannot overflow, as that would require more tokens to be burned/transferred
// out than the owner initially received through minting and transferring in.
_balances[owner] -= 1;
}
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
_afterTokenTransfer(owner, address(0), tokenId, 1);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(address from, address to, uint256 tokenId) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId, 1);
// Check that tokenId was not transferred by `_beforeTokenTransfer` hook
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
// Clear approvals from the previous owner
delete _tokenApprovals[tokenId];
unchecked {
// `_balances[from]` cannot overflow for the same reason as described in `_burn`:
// `from`'s balance is the number of token held, which is at least one before the current
// transfer.
// `_balances[to]` could overflow in the conditions described in `_mint`. That would require
// all 2**256 token ids to be minted, which in practice is impossible.
_balances[from] -= 1;
_balances[to] += 1;
}
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
_afterTokenTransfer(from, to, tokenId, 1);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits an {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits an {ApprovalForAll} event.
*/
function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
require(owner != operator, "ERC721: approve to caller");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Reverts if the `tokenId` has not been minted yet.
*/
function _requireMinted(uint256 tokenId) internal view virtual {
require(_exists(tokenId), "ERC721: invalid token ID");
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
/// @solidity memory-safe-assembly
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is
* used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.
* - When `from` is zero, the tokens will be minted for `to`.
* - When `to` is zero, ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
* - `batchSize` is non-zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {}
/**
* @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is
* used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.
* - When `from` is zero, the tokens were minted for `to`.
* - When `to` is zero, ``from``'s tokens were burned.
* - `from` and `to` are never both zero.
* - `batchSize` is non-zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {}
/**
* @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override.
*
* WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant
* being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such
* that `ownerOf(tokenId)` is `a`.
*/
// solhint-disable-next-line func-name-mixedcase
function __unsafe_increaseBalance(address account, uint256 amount) internal {
_balances[account] += amount;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../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 caller.
*
* 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: GPL-2.0-or-later
pragma solidity >=0.4.0;
/// @title FixedPoint96
/// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format)
/// @dev Used in SqrtPriceMath.sol
library FixedPoint96 {
uint8 internal constant RESOLUTION = 96;
uint256 internal constant Q96 = 0x1000000000000000000000000;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
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: GPL-2.0-or-later
pragma solidity ^0.8.15;
import "openzeppelin-v5/token/ERC20/IERC20.sol";
/// @title Interface for WETH9
interface IWETH9 is IERC20 {
/// @notice Deposit ether to get wrapped ether
function deposit() external payable;
/// @notice Withdraw wrapped ether to get ether
function withdraw(uint256) external;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.6.0;
import "openzeppelin-v5/token/ERC20/IERC20.sol";
library TransferHelper {
/// @notice Transfers tokens from the targeted address to the given destination
/// @notice Errors with 'STF' if transfer fails
/// @param token The contract address of the token to be transferred
/// @param from The originating address from which the tokens will be transferred
/// @param to The destination address of the transfer
/// @param value The amount to be transferred
function safeTransferFrom(address token, address from, address to, uint256 value) internal {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), "STF");
}
/// @notice Transfers tokens from msg.sender to a recipient
/// @dev Errors with ST if transfer fails
/// @param token The contract address of the token which will be transferred
/// @param to The recipient of the transfer
/// @param value The value of the transfer
function safeTransfer(address token, address to, uint256 value) internal {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), "ST");
}
/// @notice Approves the stipulated contract to spend the given allowance in the given token
/// @dev Errors with 'SA' if transfer fails
/// @param token The contract address of the token to be approved
/// @param to The target of the approval
/// @param value The amount of the given token the target will be allowed to spend
function safeApprove(address token, address to, uint256 value) internal {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), "SA");
}
/// @notice Transfers ETH to the recipient address
/// @dev Fails with `STE`
/// @param to The destination of the transfer
/// @param value The value to be transferred
function safeTransferETH(address to, uint256 value) internal {
(bool success,) = to.call{value: value}(new bytes(0));
require(success, "STE");
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./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);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface 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);
}{
"remappings": [
"lib/universal-router:solmate/=lib/solmate/",
"lib/universal-router:permit2/=lib/permit2/",
"ds-test/=lib/solmate/lib/ds-test/src/",
"forge-std/=lib/forge-std/src/",
"contracts:openzeppelin/=lib/openzeppelin-contracts/contracts/",
"test:openzeppelin/=lib/openzeppelin-contracts/contracts/",
"script:openzeppelin/=lib/openzeppelin-contracts/contracts/",
"contracts:openzeppelin-v5/=lib/openzeppelin-contracts-v5/contracts/",
"script:openzeppelin-v5/=lib/openzeppelin-contracts-v5/contracts/",
"test:openzeppelin-v5/=lib/openzeppelin-contracts-v5/contracts/",
"contracts:openzeppelin-v4/=lib/openzeppelin-contracts/contracts/",
"contracts:openzeppelin-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"contracts:solmate/=lib/solmate/src/",
"lib:solmate/=lib/solmate/",
"script:solmate/=lib/solmate/src/",
"contracts:permit2/=lib/permit2/src/",
"script:permit2/=lib/permit2/src/",
"universal-router/=lib/universal-router/contracts/",
"multicall/=lib/multicall/src/",
"@uniswap/v3-core/contracts/=contracts/univ3/",
"@uniswap/v2-core/contracts/=contracts/univ2/",
"@openzeppelin/=lib/openzeppelin-contracts/",
"@ds/=lib/multicall/lib/ds-test/src/",
"@std/=lib/multicall/lib/forge-std/src/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"forge-gas-snapshot/=lib/permit2/lib/forge-gas-snapshot/src/",
"halmos-cheatcodes/=lib/openzeppelin-contracts-v5/lib/halmos-cheatcodes/src/",
"openzeppelin-contracts-v5/=lib/openzeppelin-contracts-v5/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"openzeppelin/=lib/openzeppelin-contracts/contracts/",
"permit2/=lib/permit2/",
"prb-math/=lib/prb-math/src/",
"solmate/=lib/solmate/src/",
"v3-periphery/=lib/v3-periphery/contracts/"
],
"optimizer": {
"enabled": true,
"runs": 1000
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "none",
"appendCBOR": false
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "cancun",
"viaIR": true
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_factory","type":"address"},{"internalType":"address","name":"_WETH9","type":"address"},{"internalType":"bytes32","name":"initCodeHash","type":"bytes32"},{"internalType":"string","name":"baseURI_","type":"string"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"T","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"Collect","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountReward","type":"uint256"}],"name":"CollectReward","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"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":"DecreaseLiquidity","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"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":"IncreaseLiquidity","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Stake","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Unstake","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"UpdatePosition","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PERMIT_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WETH9","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint128","name":"amount0Max","type":"uint128"},{"internalType":"uint128","name":"amount1Max","type":"uint128"}],"internalType":"struct INonfungiblePositionManager.CollectParams","name":"params","type":"tuple"}],"name":"collect","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint128","name":"amountRewardMax","type":"uint128"}],"internalType":"struct INonfungiblePositionManager.CollectRewardParams","name":"params","type":"tuple"}],"name":"collectReward","outputs":[{"internalType":"uint256","name":"amountReward","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token0","type":"address"},{"internalType":"address","name":"token1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"uint160","name":"sqrtPriceX96","type":"uint160"}],"name":"createAndInitializePoolIfNecessary","outputs":[{"internalType":"address","name":"pool","type":"address"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"amount0Min","type":"uint256"},{"internalType":"uint256","name":"amount1Min","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct INonfungiblePositionManager.DecreaseLiquidityParams","name":"params","type":"tuple"}],"name":"decreaseLiquidity","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount0Desired","type":"uint256"},{"internalType":"uint256","name":"amount1Desired","type":"uint256"},{"internalType":"uint256","name":"amount0Min","type":"uint256"},{"internalType":"uint256","name":"amount1Min","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct INonfungiblePositionManager.IncreaseLiquidityParams","name":"params","type":"tuple"}],"name":"increaseLiquidity","outputs":[{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"isApprovedOrOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"token0","type":"address"},{"internalType":"address","name":"token1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"},{"internalType":"uint256","name":"amount0Desired","type":"uint256"},{"internalType":"uint256","name":"amount1Desired","type":"uint256"},{"internalType":"uint256","name":"amount0Min","type":"uint256"},{"internalType":"uint256","name":"amount1Min","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct INonfungiblePositionManager.MintParams","name":"params","type":"tuple"}],"name":"mint","outputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"positionRewardsOwed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"positions","outputs":[{"internalType":"uint96","name":"nonce","type":"uint96"},{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"token0","type":"address"},{"internalType":"address","name":"token1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"},{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"feeGrowthInside0LastX128","type":"uint256"},{"internalType":"uint256","name":"feeGrowthInside1LastX128","type":"uint256"},{"internalType":"uint128","name":"tokensOwed0","type":"uint128"},{"internalType":"uint128","name":"tokensOwed1","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"positions2","outputs":[{"internalType":"uint128","name":"liquidityStaked","type":"uint128"},{"internalType":"address","name":"pool","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"refundETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"selfPermit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"selfPermitAllowed","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"selfPermitAllowedIfNecessary","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"selfPermitIfNecessary","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stake","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint128","name":"liquidityStakedDelta","type":"uint128"}],"name":"stake","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amountMinimum","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"sweepToken","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount0Owed","type":"uint256"},{"internalType":"uint256","name":"amount1Owed","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"uniswapV3MintCallback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint128","name":"liquidityStakedDelta","type":"uint128"}],"name":"unstake","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"unstake","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountMinimum","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"unwrapWETH9","outputs":[],"stateMutability":"payable","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
61012060405234610535576165458038038061001a81610539565b928339810160c082820312610535576100328261055e565b61003e6020840161055e565b90604084015192606085015160018060401b0381116105355781610063918701610572565b60808601519095906001600160401b0381116105355782610085918301610572565b60a08201519092906001600160401b038111610535576100a59201610572565b906100b06040610539565b90600182526020820192603160f81b8452815160018060401b038111610360575f54600181811c9116801561052b575b602082101461034257601f81116104c9575b50806020601f8211600114610468575f9161045d575b508160011b915f199060031b1c1916175f555b8051906001600160401b0382116103605760015490600182811c92168015610453575b60208310146103425781601f8493116103e5575b50602090601f831160011461037f575f92610374575b50508160011b915f199060031b1c1916176001555b80516020919091012060805251902060a05260c05260e05261010052600b80546001600160b01b031916600117905580516001600160401b03811161036057600c54600181811c91168015610356575b602082101461034257601f81116102df575b50602091601f821160011461027f579181925f92610274575b50508160011b915f199060031b1c191617600c555b604051615f8190816105c4823960805181613281015260a051816132a7015260c051818181610a680152818161283801528181613de2015261452a015260e05181818161138f015281816114a401528181613f680152615024015261010051816154c60152f35b015190505f806101f8565b601f19821692600c5f52805f20915f5b8581106102c7575083600195106102af575b505050811b01600c5561020d565b01515f1960f88460031b161c191690555f80806102a1565b9192602060018192868501518155019401920161028f565b600c5f527fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c7601f830160051c81019160208410610338575b601f0160051c01905b81811061032d57506101df565b5f8155600101610320565b9091508190610317565b634e487b7160e01b5f52602260045260245ffd5b90607f16906101cd565b634e487b7160e01b5f52604160045260245ffd5b015190505f80610168565b60015f9081528281209350601f198516905b8181106103cd57509084600195949392106103b5575b505050811b0160015561017d565b01515f1960f88460031b161c191690555f80806103a7565b92936020600181928786015181550195019301610391565b60015f529091507fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6601f840160051c81019160208510610449575b90601f859493920160051c01905b81811061043b5750610152565b5f815584935060010161042e565b9091508190610420565b91607f169161013e565b90508301515f610108565b5f8080528181209250601f198416905b8181106104b157509083600194939210610499575b5050811b015f5561011b565b8501515f1960f88460031b161c191690555f8061048d565b9192602060018192868a015181550194019201610478565b5f80527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563601f830160051c81019160208410610521575b601f0160051c01905b81811061051657506100f2565b5f8155600101610509565b9091508190610500565b90607f16906100e0565b5f80fd5b6040519190601f01601f191682016001600160401b0381118382101761036057604052565b51906001600160a01b038216820361053557565b81601f82011215610535578051906001600160401b038211610360576105a1601f8301601f1916602001610539565b928284526020838301011161053557815f9260208093018386015e830101529056fe60806040526004361015610022575b3615610018575f80fd5b610020613f5e565b005b5f3560e01c806301ffc9a71461030157806306fdde03146102fc578063081812fc146102f7578063095ea7b3146102f25780630c49ccbe146102ed57806312210e8a146102e857806313ead562146102e357806318160ddd146102de578063219f5d17146102d957806322aa6cd8146102d457806323b872dd146102cf5780632e17de78146102ca5780632f745c59146102c557806330adf81f146102c05780633644e515146102bb5780633a4b66f1146102b657806342842e0e146102b157806342966c68146102ac578063430c2081146102a75780634659a494146102a257806349404b7c1461029d5780634aa4a4fc146102985780634f6ccce71461029357806353d48b031461028e5780635bc95da31461028957806360b34d19146102845780636352211e1461027f57806370a082311461027a5780637ac2ff7b146102755780637acfc9e214610270578063883164561461026b57806395d89b411461026657806399fbab8814610261578063a22cb4651461025c578063a4a78f0c14610257578063a694fc3a14610252578063ac9650d81461024d578063b88d4fde14610248578063c2e3140a14610243578063c45a01551461023e578063c87b56dd14610239578063d348799714610234578063df2ab5bb1461022f578063e985e9c51461022a578063f3995c67146102255763fc6f78650361000e57612b1d565b612b05565b612a9f565b612a02565b6129a0565b61285c565b612819565b6127a0565b612710565b612542565b6124c4565b61244a565b61235e565b61215d565b61200e565b611dee565b611dbe565b611b6c565b611b45565b611b27565b61193b565b611854565b611582565b6114c8565b611485565b611357565b61133f565b6112c7565b6111da565b6111b1565b61113e565b61111c565b6110e2565b611014565b610fdc565b610fb3565b610f57565b610cd7565b610cba565b6109c1565b610998565b610676565b610563565b610523565b61044c565b61031c565b6001600160e01b031981160361031857565b5f80fd5b34610318576020366003190112610318576001600160e01b031960043561034281610306565b167f780e9d6300000000000000000000000000000000000000000000000000000000811490811561037c575b506040519015158152602090f35b7f80ac58cd000000000000000000000000000000000000000000000000000000008114915081156103e0575b81156103b6575b505f61036e565b7f01ffc9a7000000000000000000000000000000000000000000000000000000009150145f6103af565b7f5b5e139f00000000000000000000000000000000000000000000000000000000811491506103a8565b5f91031261031857565b805180835260209291819084018484015e5f828201840152601f01601f1916010190565b906020610449928181520190610414565b90565b34610318575f366003190112610318576040515f5f5461046b81612e6d565b80845290600181169081156104ff57506001146104a3575b61049f8361049381850382612694565b60405191829182610438565b0390f35b5f8080527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563939250905b8082106104e557509091508101602001610493610483565b9192600181602092548385880101520191019092916104cd565b60ff191660208086019190915291151560051b840190910191506104939050610483565b34610318576020366003190112610318576020610541600435612ea5565b6001600160a01b0360405191168152f35b6001600160a01b0381160361031857565b346103185760403660031901126103185760043561058081610552565b60243561058c8161360a565b916001600160a01b038316806001600160a01b0383161461060c57610020936105bf9133149081156105c4575b50612f44565b613fd4565b61060691506105ff906105e933916001600160a01b03165f52600560205260405f2090565b906001600160a01b03165f5260205260405f2090565b5460ff1690565b5f6105b9565b608460405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f72000000000000000000000000000000000000000000000000000000000000006064820152fd5b60a036600319011261031857600435610697610692823361403f565b612fb5565b6106a66084355b421115613000565b6106c16001600160801b036106b961304b565b16151561306f565b6107ca6106d6825f52600a60205260405f2090565b91600283019261074484546001600160801b0361073b610710610734610702856001600160801b031690565b61072661071c61071061304b565b6001600160801b031690565b868316101561306f565b61072e61304b565b9061308a565b9360801c90565b9116101561306f565b6040600182015461076a61075e826001600160a01b031690565b6001600160a01b031690565b61078461077a8360a01c60020b90565b9260b81c60020b90565b5f61078d61304b565b855163a34123a760e01b8152600295860b60048201529290940b60248301526001600160801b039093166044820152958692839182906064820190565b03925af1938415610993575f935f95610950575b506108dc916108506006926107f260443590565b87101580610944575b610804906130cb565b61080d86614120565b61082d61081861304b565b82546001600160801b031661308a565b61308a565b6001600160801b03166fffffffffffffffffffffffffffffffff19825416179055565b0161089c6108776001600160801b03861661087284546001600160801b031690565b613116565b82906001600160801b03166fffffffffffffffffffffffffffffffff19825416179055565b6108b46001600160801b038616610872835460801c90565b6001600160801b036fffffffffffffffffffffffffffffffff1983549260801b169116179055565b7f26f6a048ee9138f2c0ce266f322cb99228e8d619ae2bff30c67f8dcf9d2377b48261090661304b565b61093086604051938493846040919493926001600160801b03606083019616825260208201520152565b0390a2604080519182526020820192909252f35b506064358810156107fb565b600691955061085094509161097f6108dc9360403d60401161098c575b6109778183612694565b8101906130aa565b95909596925050916107de565b503d61096d565b6130c0565b5f36600319011261031857476109aa57005b61002047336143ee565b62ffffff81160361031857565b6080366003190112610318576004356109d981610552565b602435906109e682610552565b604435906109f3826109b4565b60643592610a0084610552565b610a1d6001600160a01b0382166001600160a01b0384161061306f565b6040517f1698ee820000000000000000000000000000000000000000000000000000000081526001600160a01b038381166004830152828116602483015262ffffff851660448301527f0000000000000000000000000000000000000000000000000000000000000000169290602081606481875afa908115610993575f91610c9b575b506001600160a01b03811680610bcb5750506040517fa16712950000000000000000000000000000000000000000000000000000000081526001600160a01b0391821660048201529116602482015262ffffff929092166044830152602090829060649082905f905af1908115610993575f91610b9c575b506001600160a01b038116803b156103185760405163f637731d60e01b81526001600160a01b039390931660048401525f908390602490829084905af19182156109935761049f92610b82575b505b6040516001600160a01b0390911681529081906020820190565b80610b905f610b9693612694565b8061040a565b5f610b66565b610bbe915060203d602011610bc4575b610bb68183612694565b810190613136565b5f610b19565b503d610bac565b935093505050604051633850c7bd60e01b815260e081600481855afa8015610993576001600160a01b03915f91610c66575b501615610c10575b5061049f9150610b68565b803b156103185760405163f637731d60e01b81526001600160a01b039390931660048401525f908390602490829084905af19182156109935761049f9215610c055780610b905f610c6093612694565b5f610c05565b610c88915060e03d60e011610c94575b610c808183612694565b810190613165565b5050505050505f610bfd565b503d610c76565b610cb4915060203d602011610bc457610bb68183612694565b5f610aa1565b34610318575f366003190112610318576020600854604051908152f35b60c036600319011261031857610cee60a43561069e565b600435610d03815f52600a60205260405f2090565b60018101549091610d1c6001600160a01b03831661075e565b9160405191630dfe168160e01b8352602083600481875afa928315610993575f93610f25575b506040519363d21220a760e01b8552602085600481845afa948515610993575f95610f00575b5060206004916040519283809263ddca3f4360e01b82525afa9384156109935760029561049f95610e6695610e41945f92610ecf575b50610db9610daf8260a01c60020b90565b9160b81c60020b90565b610e2660243591610e1c60443594610e0c60643597610e006084355b9a610df0610de16126b6565b6001600160a01b03909e168e52565b6001600160a01b031660208d0152565b62ffffff1660408b0152565b3060608a015260020b6080890152565b60020b60a0870152565b60c085015260e08401526101008301526101208201526144b4565b509391959096610e5084614120565b0161082d8661087283546001600160801b031690565b604080516001600160801b0386168152602081018790529081018390527f3067048beee31b25b2f1681f88dac838c8bba36af25bfb2b7cf7473a5847e35f90606090a2604051938493846040919493926001600160801b03606083019616825260208201520152565b610ef291925060203d602011610ef9575b610eea8183612694565b8101906131ce565b905f610d9e565b503d610ee0565b6004919550610f1d602091823d8411610bc457610bb68183612694565b959150610d68565b610f3f91935060203d602011610bc457610bb68183612694565b915f610d42565b6001600160801b0381160361031857565b604036600319011261031857610020602435600435610f7582610f46565b610f82610692823361403f565b614711565b606090600319011261031857600435610f9f81610552565b90602435610fac81610552565b9060443590565b3461031857610020610fc436610f87565b91610fd7610fd2843361403f565b6131e3565b614898565b602036600319011261031857610020600435610ffb610692823361403f565b805f52600a602052600260405f20015460801c90614711565b346103185760403660031901126103185760043561103181610552565b6024359061103e8161366c565b821015611078576001600160a01b03165f52600660205260405f20905f5260205261049f60405f2054604051918291829190602083019252565b608460405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201527f74206f6620626f756e64730000000000000000000000000000000000000000006064820152fd5b34610318575f3660031901126103185760206040517f49ecf333e5b8c95c40fdafc95c1ad136e8914a8fb55e9dc8bb01eaa83a2df9ad8152f35b34610318575f366003190112610318576020611136613254565b604051908152f35b5f366003190112610318575f196001600160b01b03600b5416016001600160b01b0381116111ac576001600160b01b036100209116611180610692823361403f565b805f52600a6020526111a6600260405f2001546001600160801b038160801c911661308a565b90614b73565b613076565b34610318576100206111c236610f87565b90604051926111d2602085612694565b5f8452613c31565b6020366003190112610318576100206004356111f9610692823361403f565b805f52600a60205261123060405f206001600160801b036002820154161590816112b1575b81611297575b81611279575b506132ec565b611274611245825f52600a60205260405f2090565b60075f918281558260018201558260028201558260038201558260048201558260058201558260068201550155565b614a2d565b6007015461129091506001600160801b0316610710565b155f61122a565b90506112aa610710600683015460801c90565b1590611224565b60068101546001600160801b031615915061121e565b346103185760403660031901126103185760206112f26004356112e981610552565b6024359061403f565b6040519015158152f35b60ff81160361031857565b60c09060031901126103185760043561131f81610552565b906024359060443590606435611334816112fc565b906084359060a43590565b61002061134b36611307565b94939093929192613337565b60403660031901126103185760243560043561137282610552565b6040516370a0823160e01b81523060048201526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016929091602083602481875afa928315610993575f93611450575b506113d6908310156133db565b816113dd57005b823b15610318575f60405180947f2e1a7d4d00000000000000000000000000000000000000000000000000000000825281838161142288600483019190602083019252565b03925af1928315610993576100209361143c575b506143ee565b80610b905f61144a93612694565b5f611436565b6113d69193506114779060203d60201161147e575b61146f8183612694565b8101906133cc565b92906113c9565b503d611465565b34610318575f3660031901126103185760206040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b34610318576020366003190112610318576004356008548110156115185760085f527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30154604051908152602090f35b608460405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201527f7574206f6620626f756e647300000000000000000000000000000000000000006064820152fd5b60603660031901126103185760043561159e610692823361403f565b6115b16001600160801b036106b9613057565b6001600160a01b036115c161343a565b1661184757305b6115da825f52600a60205260405f2090565b906115f261071060028401546001600160801b031690565b6117a1575b6116c29260016020611607613057565b9461163561071060078301976001600160801b038061162d8b546001600160801b031690565b169116614b18565b920154829061164c6001600160a01b03821661075e565b905f61165e61077a8360a01c60020b90565b6040517f219d910f0000000000000000000000000000000000000000000000000000000081526001600160a01b038a166004820152600293840b6024820152920b60448301526001600160801b039093166064820152978892839182906084820190565b03925af1928315610993576001600160801b03955f9461174a575b5061171a8561082d846108287f7d4ce6ab964cec8b10cbee95517159742fd6782e35b0dbc95291291fca13e263979899546001600160801b031690565b604080516001600160a01b039290921682526001600160801b03929092166020820152a260405191168152602090f35b7f7d4ce6ab964cec8b10cbee95517159742fd6782e35b0dbc95291291fca13e26393945061179261171a9160203d60201161179a575b61178a8183612694565b81019061345f565b9493506116dd565b503d611780565b61180492604060018401546117bf61075e826001600160a01b031690565b6117cf61077a8360a01c60020b90565b915f845180998195829463a34123a760e01b8452600484016040905f929493606082019560020b825260020b60208201520152565b03925af1938415610993576116c294611829575b5061182281614120565b92506115f7565b6118419060403d60401161098c576109778183612694565b50611818565b61184f61343a565b6115c8565b3461031857602036600319011261031857600435805f52600a6020526118d760405f20916040600184015461189261075e826001600160a01b031690565b6118a261077a8360a01c60020b90565b915f845180978195829463a34123a760e01b8452600484016040905f929493606082019560020b825260020b60208201520152565b03925af19182156109935761049f936118ff6107109360079361190d9661191d575b50614120565b01546001600160801b031690565b6040519081529081906020820190565b6119359060403d60401161098c576109778183612694565b506118f9565b34610318576020366003190112610318576004355f52600a60205260405f20611b0161075e611af361196b6126c6565b936119aa61199a8254611994611987826001600160601b031690565b6001600160601b03168952565b60601c90565b6001600160a01b03166020870152565b611abf600182015495611a076119fd6119c9896001600160a01b031690565b6001600160a01b031660408401908152986119f46119ea8260a01c60020b90565b60020b6060860152565b60b81c60020b90565b60020b6080830152565b610180611ab16007611a406002870154611a3a611a2a826001600160801b031690565b6001600160801b031660a0880152565b60801c90565b6001600160801b031660c0850190815295600381015460e0860152600481015461010086015260058101546101208601526118ff611aa06006830154611a3a611a8f826001600160801b031690565b6001600160801b03166101408a0152565b6001600160801b0316610160870152565b6001600160801b0316910152565b611ae66001600160a01b03611ade61075e88516001600160a01b031690565b1615156135bf565b516001600160801b031690565b92516001600160a01b031690565b604080516001600160801b039390931683526001600160a01b0391909116602083015290f35b3461031857602036600319011261031857602061054160043561360a565b34610318576020366003190112610318576020611136600435611b6781610552565b61366c565b611b7536611307565b919492611b84814211156136f4565b611bfc611c4f611b92613254565b92611bfc611c0a611ba28a614b2a565b9260405192839160208301958d8d88909493926080926001600160a01b0360a08401977f49ecf333e5b8c95c40fdafc95c1ad136e8914a8fb55e9dc8bb01eaa83a2df9ad8552166020840152604083015260608201520152565b03601f198101835282612694565b51902060405192839160208301958690916042927f19010000000000000000000000000000000000000000000000000000000000008352600283015260228201520190565b51902090611c5c8561360a565b95611c866001600160a01b03881697611c80896001600160a01b038916141561373f565b3b151590565b15611d5d57604080516020808201949094529081019490945260f81b7fff0000000000000000000000000000000000000000000000000000000000000016606084015260418352611cfb95909291611cdf606184612694565b604051809781948293630b135d3f60e11b84526004840161385b565b03915afa92831561099357630b135d3f60e11b6001600160e01b0319610020956105bf935f91611d2e575b5016146137fb565b611d50915060203d602011611d56575b611d488183612694565b810190613846565b5f611d26565b503d611d3e565b9091611d8d6020945f94604051948594859094939260ff6060936080840197845216602083015260408201520152565b838052039060015afa15610993576105bf610020936001600160a01b035f5116611db88115156137b0565b146137fb565b604036600319011261031857610020602435600435611ddc82610f46565b611de9610692823361403f565b614b73565b61016036600319011261031857611e076101443561069e565b61049f611e56611e15613446565b611e1d61343a565b611e25613872565b611e2d61387e565b611e3561388a565b610e2660a43591610e1c60c43594610e0c60e43597610e0061010435610dd5565b929391611f5d611e64613452565b94611eca6001600160b01b03611e82600b546001600160b01b031690565b611ec2611e8e82613896565b6001600160b01b03167fffffffffffffffffffff00000000000000000000000000000000000000000000600b541617600b55565b168097614d00565b611f11611ed561387e565b6119fd611ee061388a565b91611f07611eec6126c6565b5f80825260208201526001600160a01b039096166040870152565b60020b6060850152565b5f60a08201525f60c08201525f60e08201525f6101008201525f6101208201525f6101408201525f6101608201525f610180820152611f58865f52600a60205260405f2090565b6138b3565b611f6684614120565b611f936002611f7d865f52600a60205260405f2090565b0161082d8761087283546001600160801b031690565b837f3067048beee31b25b2f1681f88dac838c8bba36af25bfb2b7cf7473a5847e35f60405180611fdf86868b846040919493926001600160801b03606083019616825260208201520152565b0390a260405194859485909493926001600160801b036060936080840197845216602083015260408201520152565b34610318575f366003190112610318576040515f60015461202e81612e6d565b80845290600181169081156104ff57506001146120555761049f8361049381850382612694565b91905060015f527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6915f905b80821061209957509091508101602001610493610483565b919260018160209254838588010152019101909291612081565b99979593919c9b9a98969492909c6101808b019d6001600160601b03168b526001600160a01b031660208b01526001600160a01b031660408a01526001600160a01b0316606089015262ffffff16608088015260a087016121159160020b9052565b60020b60c08601526001600160801b031660e08501526101008401526101208301526001600160801b03166101408201526101600161215b916001600160801b03169052565b565b346103185760203660031901126103185761218a6121856004355f52600a60205260405f2090565b613474565b604081016121ad6001600160a01b03611ade61075e84516001600160a01b031690565b60046121c083516001600160601b031690565b916121d560208501516001600160a01b031690565b9360206121ec61075e84516001600160a01b031690565b60405194858092630dfe168160e01b82525afa918215610993576004935f93612333575b50602061222761075e83516001600160a01b031690565b6040519586809263d21220a760e01b82525afa908115610993576004945f92612309575b5061226261075e602092516001600160a01b031690565b6040519586809263ddca3f4360e01b82525afa80156109935761049f945f916122ea575b50606083015160020b608084015160020b60a08501516001600160801b03169160e086015193610100870151956122dd6101606122ce6101408b01516001600160801b031690565b9901516001600160801b031690565b986040519c8d9c8d6120b3565b612303915060203d602011610ef957610eea8183612694565b5f612286565b602091925061075e61232a61226292843d8611610bc457610bb68183612694565b9392505061224b565b61234d91935060203d602011610bc457610bb68183612694565b915f612210565b8015150361031857565b346103185760403660031901126103185760043561237b81610552565b60243561238781612354565b6001600160a01b0382169182331461240657816123c36123d492335f52600560205260405f20906001600160a01b03165f5260205260405f2090565b9060ff801983541691151516179055565b604051901515815233907f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3190602090a3005b606460405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152fd5b61245336611307565b604051636eb1769f60e11b81523360048201523060248201529094919391906020816044816001600160a01b038b165afa908115610993575f916124a5575b505f191161249c57005b61002095613337565b6124be915060203d60201161147e5761146f8183612694565b5f612492565b602036600319011261031857610020600435611180610692823361403f565b602081016020825282518091526040820191602060408360051b8301019401925f915b83831061251557505050505090565b9091929394602080612533600193603f198682030187528951610414565b97019301930191939290612506565b60203660031901126103185760043567ffffffffffffffff811161031857366023820112156103185780600401359067ffffffffffffffff8211610318576024810190602436918460051b0101116103185761259d82613af3565b915f5b8181106125b5576040518061049f86826124e3565b5f806125c2838587613b3c565b906125d260405180938193613b7e565b0390305af46125df613b8b565b901561260557906001916125f38287613c1d565b526125fe8186613c1d565b50016125a0565b60448151106103185761262781602480600461263f9501518301019101613bba565b60405191829162461bcd60e51b835260048301610438565b0390fd5b634e487b7160e01b5f52604160045260245ffd5b6040810190811067ffffffffffffffff82111761267357604052565b612643565b6060810190811067ffffffffffffffff82111761267357604052565b90601f8019910116810190811067ffffffffffffffff82111761267357604052565b6040519061215b61014083612694565b6040519061215b6101a083612694565b6040519061215b606083612694565b6040519061215b604083612694565b67ffffffffffffffff811161267357601f01601f191660200190565b346103185760803660031901126103185760043561272d81610552565b6024359061273a82610552565b6044356064359267ffffffffffffffff841161031857366023850112156103185783600401359261276a846126f4565b936127786040519586612694565b8085523660248288010111610318576020815f92602461002099018389013786010152613c31565b6127a936611307565b604051636eb1769f60e11b81523360048201523060248201529094919391906020816044816001600160a01b038b165afa80156109935782915f916127fa575b50106127f157005b61002095613eba565b612813915060203d60201161147e5761146f8183612694565b5f6127e9565b34610318575f3660031901126103185760206040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b346103185760203660031901126103185760043561288e815f5260026020526001600160a01b0360405f205416151590565b156103185761289c46614e78565b30916128b06128ab6028615b1a565b6143bc565b9260306128bc85615b36565b5360786128c885615b43565b536128d36028615b28565b600181116129475761049f61291e61049386611bfc8961291861291e6129028b6128fd8c15615b70565b614e78565b9261291860405198899761291860208a01613cc7565b90613d4e565b7f2f00000000000000000000000000000000000000000000000000000000000000815260010190565b90600f8116601081101561299b57612996917f3031323334353637383961626364656600000000000000000000000000000000612990921a6129898589615b53565b5360041c90565b91615b64565b6128d3565b613426565b346103185760603660031901126103185760443560243560043567ffffffffffffffff831161031857366023840112156103185782600401359167ffffffffffffffff8311610318573660248486010111610318576024610020940191613d60565b606036600319011261031857600435612a1a81610552565b602435604435612a2981610552565b604051916370a0823160e01b83523060048401526020836024816001600160a01b0388165afa928315610993575f93612a7a575b50612a6a90831015613e6f565b81612a7157005b6100209261515f565b612a6a919350612a989060203d60201161147e5761146f8183612694565b9290612a5d565b3461031857604036600319011261031857602060ff612af9600435612ac381610552565b6001600160a01b0360243591612ad883610552565b165f526005845260405f20906001600160a01b03165f5260205260405f2090565b54166040519015158152f35b610020612b1136611307565b94939093929192613eba565b608036600319011261031857600435612b39610692823361403f565b6001600160801b03612b49613057565b1615801590612e55575b612b5c9061306f565b6001600160a01b03612b6c61343a565b16612e475730905b612b86815f52600a60205260405f2090565b91612b9e61071060028501546001600160801b031690565b612da9575b610710612bae613057565b92600685019360406001612bf4612bdd6107108954956001600160801b038061162d896001600160801b031690565b9586946001600160801b038061162d610734613063565b970154612c096001600160a01b03821661075e565b612c1961077a8360a01c60020b90565b83517f4f1eb3d80000000000000000000000000000000000000000000000000000000081526001600160a01b0389166004820152600293840b6024820152920b60448301526001600160801b039586166064830152948816608482015293849060a49082905f905af1938415610993576001600160801b03965f945f96612d41575b5090612d258392612cf289612ce36108777f40d0efd1a53d60ecbf40971b9daf7dc90178c3aadc7aab1765632738fa8b8f019861082861049f9d9e546001600160801b031690565b6108b483610828835460801c90565b604051938493849160409194936001600160801b0380926001600160a01b03606087019816865216602085015216910152565b0390a26040805191851682529290931660208401528291820190565b61049f9650612cf295507f40d0efd1a53d60ecbf40971b9daf7dc90178c3aadc7aab1765632738fa8b8f01939291612d93612d259260403d604011612da2575b612d8b8183612694565b810190613f39565b97909798505091929350612c9b565b503d612d81565b612e0b60406001850154612dc661075e826001600160a01b031690565b612dd661077a8360a01c60020b90565b915f845180968195829463a34123a760e01b8452600484016040905f929493606082019560020b825260020b60208201520152565b03925af1801561099357612e29575b50612e2482614120565b612ba3565b612e419060403d60401161098c576109778183612694565b50612e1a565b612e4f61343a565b90612b74565b50612b5c612e64610710613063565b15159050612b53565b90600182811c92168015612e9b575b6020831014612e8757565b634e487b7160e01b5f52602260045260245ffd5b91607f1691612e7c565b612ec3815f5260026020526001600160a01b0360405f205416151590565b15612eda575f52600a60205260405f205460601c90565b608460405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201527f697374656e7420746f6b656e00000000000000000000000000000000000000006064820152fd5b15612f4b57565b608460405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152fd5b15612fbc57565b606460405162461bcd60e51b815260206004820152600c60248201527f4e6f7420617070726f76656400000000000000000000000000000000000000006044820152fd5b1561300757565b606460405162461bcd60e51b815260206004820152601360248201527f5472616e73616374696f6e20746f6f206f6c64000000000000000000000000006044820152fd5b60243561044981610f46565b60443561044981610f46565b60643561044981610f46565b1561031857565b634e487b7160e01b5f52601160045260245ffd5b906001600160801b03809116911603906001600160801b0382116111ac57565b9190826040910312610318576020825192015190565b6040513d5f823e3d90fd5b156130d257565b606460405162461bcd60e51b815260206004820152601460248201527f507269636520736c69707061676520636865636b0000000000000000000000006044820152fd5b906001600160801b03809116911601906001600160801b0382116111ac57565b90816020910312610318575161044981610552565b8060020b0361031857565b519061ffff8216820361031857565b908160e091031261031857805161317b81610552565b91602082015161318a8161314b565b9161319760408201613156565b916131a460608301613156565b916131b160808201613156565b9160c060a08301516131c2816112fc565b92015161044981612354565b908160209103126103185751610449816109b4565b156131ea57565b608460405162461bcd60e51b815260206004820152602d60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201527f72206f7220617070726f766564000000000000000000000000000000000000006064820152fd5b60405160208101907f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f82527f000000000000000000000000000000000000000000000000000000000000000060408201527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a082015260a081526132e660c082612694565b51902090565b156132f357565b606460405162461bcd60e51b815260206004820152600b60248201527f4e6f7420636c65617265640000000000000000000000000000000000000000006044820152fd5b6001600160a01b0390959293951693843b15610318575f9461010493869260ff604051998a9889977f8fcbaf0c0000000000000000000000000000000000000000000000000000000089523360048a01523060248a015260448901526064880152600160848801521660a486015260c485015260e48401525af18015610993576133be5750565b80610b905f61215b93612694565b90816020910312610318575190565b156133e257565b606460405162461bcd60e51b815260206004820152601260248201527f496e73756666696369656e7420574554483900000000000000000000000000006044820152fd5b634e487b7160e01b5f52603260045260245ffd5b60243561044981610552565b60043561044981610552565b6101243561044981610552565b90816020910312610318575161044981610f46565b9061215b6135ae60076134856126c6565b946134be6134ae82546119946134a1826001600160601b031690565b6001600160601b03168a52565b6001600160a01b03166020880152565b61351061350660018301546134ec6134dc826001600160a01b031690565b6001600160a01b031660408b0152565b6119f46134fc8260a01c60020b90565b60020b60608b0152565b60020b6080880152565b61354e61353e6002830154611a3a61352e826001600160801b031690565b6001600160801b031660a08b0152565b6001600160801b031660c0880152565b600381015460e0870152600481015461010087015260058101546101208701526118ff61359d6006830154611a3a61358c826001600160801b031690565b6001600160801b03166101408b0152565b6001600160801b0316610160880152565b6001600160801b0316610180840152565b156135c657565b606460405162461bcd60e51b815260206004820152601060248201527f496e76616c696420746f6b656e204944000000000000000000000000000000006044820152fd5b5f5260026020526001600160a01b0360405f20541680156136285790565b606460405162461bcd60e51b815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e20494400000000000000006044820152fd5b6001600160a01b0316801561368a575f52600360205260405f205490565b608460405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f74206120766160448201527f6c6964206f776e657200000000000000000000000000000000000000000000006064820152fd5b156136fb57565b606460405162461bcd60e51b815260206004820152600e60248201527f5065726d697420657870697265640000000000000000000000000000000000006044820152fd5b1561374657565b608460405162461bcd60e51b815260206004820152602760248201527f4552433732315065726d69743a20617070726f76616c20746f2063757272656e60448201527f74206f776e6572000000000000000000000000000000000000000000000000006064820152fd5b156137b757565b606460405162461bcd60e51b815260206004820152601160248201527f496e76616c6964207369676e61747572650000000000000000000000000000006044820152fd5b1561380257565b606460405162461bcd60e51b815260206004820152600c60248201527f556e617574686f72697a656400000000000000000000000000000000000000006044820152fd5b90816020910312610318575161044981610306565b604090610449939281528160208201520190610414565b604435610449816109b4565b6064356104498161314b565b6084356104498161314b565b6001600160b01b03166001600160b01b0381146111ac5760010190565b6007613ab561018061215b946138f46138d382516001600160601b031690565b86546bffffffffffffffffffffffff19166001600160601b03909116178655565b61393061390b60208301516001600160a01b031690565b86546001600160601b031660609190911b6bffffffffffffffffffffffff1916178655565b613a236001860161397761394e60408501516001600160a01b031690565b82906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b6139d1613988606085015160020b90565b82907fffffffffffffffffff000000ffffffffffffffffffffffffffffffffffffffff82549160a01b76ffffff0000000000000000000000000000000000000000169116179055565b608083015160020b7fffffffffffff000000ffffffffffffffffffffffffffffffffffffffffffffff82549160b81b79ffffff0000000000000000000000000000000000000000000000169116179055565b613a5460028601613a4161087760a08501516001600160801b031690565b60c08301516001600160801b03166108b4565b60e0810151600386015561010081015160048601556101208101516005860155613aa760068601613a936108776101408501516001600160801b031690565b6101608301516001600160801b03166108b4565b01516001600160801b031690565b9101906001600160801b03166fffffffffffffffffffffffffffffffff19825416179055565b67ffffffffffffffff81116126735760051b60200190565b90613afd82613adb565b613b0a6040519182612694565b8281528092613b1b601f1991613adb565b01905f5b828110613b2b57505050565b806060602080938501015201613b1f565b919081101561299b5760051b81013590601e198136030182121561031857019081359167ffffffffffffffff8311610318576020018236038113610318579190565b908092918237015f815290565b3d15613bb5573d90613b9c826126f4565b91613baa6040519384612694565b82523d5f602084013e565b606090565b6020818303126103185780519067ffffffffffffffff8211610318570181601f8201121561031857805190613bee826126f4565b92613bfc6040519485612694565b8284526020838301011161031857815f9260208093018386015e8301015290565b805182101561299b5760209160051b010190565b90613c55939291613c45610fd2843361403f565b613c50838383614898565b615a10565b15613c5c57565b60405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608490fd5b600c545f9291613cd682612e6d565b9160018116908115613d3c5750600114613cee575050565b600c5f90815292935090917fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c75b838210613d285750500190565b600181602092548486015201910190613d1b565b60ff1916825250811515909102019150565b805191908290602001825e015f815290565b9291809192810103926080841261031857606060405194613d8086612657565b1261031857613e06606060405193613d9785612678565b8035613da281610552565b85526020810135613db281610552565b60208601526040810135613dc5816109b4565b6040860152848752013592613dd984610552565b602086019384527f0000000000000000000000000000000000000000000000000000000000000000614fe5565b5080613e48575b5081613e1857505050565b613e41613e33602061215b955101516001600160a01b031690565b91516001600160a01b031690565b3391615017565b835151613e6991906001600160a01b031683516001600160a01b0316613e41565b5f613e0d565b15613e7657565b606460405162461bcd60e51b815260206004820152601260248201527f496e73756666696369656e7420746f6b656e00000000000000000000000000006044820152fd5b6001600160a01b0390959293951693843b15610318575f9460e493869260ff604051998a9889977fd505accf0000000000000000000000000000000000000000000000000000000089523360048a01523060248a01526044890152606488015216608486015260a485015260c48401525af18015610993576133be5750565b91908260409103126103185760208251613f5281610f46565b92015161044981610f46565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163303613f9057565b606460405162461bcd60e51b815260206004820152600960248201527f4e6f7420574554483900000000000000000000000000000000000000000000006044820152fd5b5f828152600a6020526040902080546001600160601b0316606083901b6bffffffffffffffffffffffff19161790556001600160a01b03806140158461360a565b169116907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9255f80a4565b6001600160a01b036140508361360a565b16916001600160a01b0382169183831493841561408e575b5050821561407557505090565b6001600160a01b0391925061408990612ea5565b161490565b60ff929450906140b9915f52600560205260405f20906001600160a01b03165f5260205260405f2090565b5416915f80614068565b908160a09103126103185780516140d981610f46565b9160208201519160408101519160806060830151613f5281610f46565b9081606091031261031857805161410c81610f46565b916040602083015192015161044981610f46565b60405181815261415f91907f7712b7ec2b36906e03c806ce80ec28a260d1b94896e6f70f04aed55cfd347ada90602090a15f52600a60205260405f2090565b60018101549061419c61075e61418f61417b8560a01c60020b90565b6141888660b81c60020b90565b903061522a565b936001600160a01b031690565b6040517f514ea4bf000000000000000000000000000000000000000000000000000000008152600481018490529160a083602481855afa918215610993575f935f9361437a575b50614225939460609160405180809781947f2f52f64c000000000000000000000000000000000000000000000000000000008352600483019190602083019252565b03915afa928315610993575f9361433c575b508383946143378361082d6002879601916142f961426a845461072e614263826001600160801b031690565b9160801c90565b6108b460068401916142d46142af61428985546001600160801b031690565b6001600160801b036142a78160038b019e8f54900396168096615263565b9116016153c1565b84906001600160801b03166fffffffffffffffffffffffffffffffff19825416179055565b6001600160801b036142a76142ea855460801c90565b92600488019d8e549003615263565b6001600160801b036142a76007830194614331610710600561432289546001600160801b031690565b96019d8e549003925460801c90565b90615263565b555555565b8291935093806143666143379660603d606011614373575b61435e8183612694565b8101906140f6565b5090509492509450614237565b503d614354565b614225945060609193506143a59060a03d60a0116143b5575b61439d8183612694565b8101906140c3565b50509691509593915094936141e3565b503d614393565b906143c6826126f4565b6143d36040519182612694565b82815280926143e4601f19916126f4565b0190602036910137565b6040515f9283929190614402602083612694565b83825261440e846126f4565b602083019290601f190136843751925af1614427613b8b565b501561442f57565b606460405162461bcd60e51b815260206004820152600360248201527f53544500000000000000000000000000000000000000000000000000000000006044820152fd5b919360a09361044996956001600160a01b036001600160801b039416855260020b602085015260020b60408401521660608201528160808201520190610414565b80516001600160a01b0316906145216144d760208301516001600160a01b031690565b6145156144ea604085015162ffffff1690565b916145056144f66126d6565b6001600160a01b039097168752565b6001600160a01b03166020860152565b62ffffff166040840152565b61454e61075e837f00000000000000000000000000000000000000000000000000000000000000006153dd565b604051633850c7bd60e01b8152936001600160a01b03821660e086600481845afa958615610993575f966146ea575b506080840194855161458f9060020b90565b61459890615503565b9660a086019788516145aa9060020b90565b6145b390615503565b60c08801519060e0890151926145c8946158aa565b96879660608701516145e0906001600160a01b031690565b905160020b915160020b926145f36126e5565b8181523360209182019081526040805184516001600160a01b03908116828601529385015184168183015293015162ffffff1660608401525116608080830191909152815261464360a082612694565b6040517f3c8a7d8d000000000000000000000000000000000000000000000000000000008152988994859461467b9460048701614473565b03815a6040945f91f1928315610993575f945f946146c1575b5061215b908486610100830151111591826146b1575b50506130cb565b6101200151111590505f806146aa565b61215b95506146e091945060403d60401161098c576109778183612694565b9490949390614694565b61470491965060e03d60e011610c9457610c808183612694565b505050505050945f61457d565b90614724825f52600a60205260405f2090565b6001810154916001600160a01b03831692614745610daf8260a01c60020b90565b90843b15610318576040517f24473387000000000000000000000000000000000000000000000000000000008152600291820b600482015291900b60248201526001600160801b0382166044820152925f908490606490829084905af192831561099357600261480e936147f4927f9045c2ac9b2026de8075f2701bbdde882cd5e830b3b1ead9a15b22f2b5b9374296614813575b506147e487614120565b016108b483610828835460801c90565b6040516001600160801b0390911681529081906020820190565b0390a2565b80610b905f61482193612694565b5f6147da565b1561482e57565b608460405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201527f6f776e65720000000000000000000000000000000000000000000000000000006064820152fd5b6001600160a01b03906148b96148ad8561360a565b82841693168314614827565b6001600160a01b0383169283156149c45761493b826148dc878461499e96615945565b6148f2856148ec61075e8a61360a565b14614827565b614924614907885f52600460205260405f2090565b73ffffffffffffffffffffffffffffffffffffffff198154169055565b6001600160a01b03165f52600360205260405f2090565b5f19815401905561495d816001600160a01b03165f52600360205260405f2090565b60018154019055614976855f52600260205260405f2090565b906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef5f80a4565b608460405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152fd5b614a368161360a565b815f52600a602052600260405f20015460801c80614b08575b50816001600160a01b038216614afa57614a699150615dfd565b614a7281615e92565b5f6001600160a01b03614a848361360a565b83835260046020526040832073ffffffffffffffffffffffffffffffffffffffff1981541690551680825260036020526040822082198154019055614ad4614907845f52600260205260405f2090565b7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8280a4565b614b0391615d31565b614a69565b614b129083614711565b5f614a4f565b9080821015614b25575090565b905090565b5f52600a60205260405f206001600160601b03815416906001600160601b0382146111ac5780546bffffffffffffffffffffffff19166001600160601b03600184011617905590565b90614b86825f52600a60205260405f2090565b600181015491614b9e6001600160a01b03841661075e565b92614baf610daf8260a01c60020b90565b90843b15610318576040517fae1cd183000000000000000000000000000000000000000000000000000000008152600291820b600482015291900b60248201526001600160801b0382166044820152925f908490606490829084905af192831561099357600261480e936147f4927fc9ec05ea5037818736839e1365dc3d9a74a735c447af0697da66633b7a9d0fab96614ca1575b50614c4e87614120565b01614c8a614c6184610872845460801c90565b82546001600160801b031660809190911b6fffffffffffffffffffffffffffffffff1916178255565b546001600160801b0361073b610710828416610734565b80610b905f614caf93612694565b5f614c44565b15614cbc57565b606460405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152fd5b6001600160a01b038116908115614e1457614dce90614d3c614d36855f5260026020526001600160a01b0360405f205416151590565b15614cb5565b835f52600a602052600260405f20015460801c80614e04575b50614d5f84615dfd565b82614df557614d6d84615e92565b614d9a614d95614d91865f5260026020526001600160a01b0360405f205416151590565b1590565b614cb5565b614db5816001600160a01b03165f52600360205260405f2090565b60018154019055614976845f52600260205260405f2090565b5f7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a4565b614dff8482615e59565b614d6d565b614e0e9085614711565b5f614d55565b606460405162461bcd60e51b815260206004820152602060248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152fd5b8015614e64575f190490565b634e487b7160e01b5f52601260045260245ffd5b805f917a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000821015614fbd575b806d04ee2d6d415b85acef8100000000600a921015614fa1575b662386f26fc10000811015614f8c575b6305f5e100811015614f7a575b612710811015614f6a575b6064811015614f5b575b1015614f50575b614f3b6021614f03600185016143bc565b938401015b5f1901917f3031323334353637383961626364656600000000000000000000000000000000600a82061a8353600a900490565b8015614f4b57614f3b9091614f08565b505090565b600190910190614ef2565b60029060649004930192614eeb565b6004906127109004930192614ee1565b6008906305f5e1009004930192614ed6565b601090662386f26fc100009004930192614ec9565b6020906d04ee2d6d415b85acef81000000009004930192614eb9565b50604091507a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008104614e9f565b6001600160a01b0391614ff7916153dd565b169081330361031857565b90816020910312610318575161044981612354565b9290926001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001693846001600160a01b0383161480615155575b1561512c575050823b1561031857604051927fd0e30db00000000000000000000000000000000000000000000000000000000084525f8460048185855af1928315610993576150dc94602094615118575b505f60405180968195829463a9059cbb60e01b845260048401602090939291936001600160a01b0360408201951681520152565b03925af18015610993576150ed5750565b61510e9060203d602011615111575b6151068183612694565b810190615002565b50565b503d6150fc565b80610b905f61512693612694565b5f6150a8565b9093509091906001600160a01b038116300361514c575061215b9261515f565b61215b93615bbb565b5082471015615057565b60405163a9059cbb60e01b602082019081526001600160a01b03909316602482015260448101939093525f92839290839061519d8160648101611bfc565b51925af16151a9613b8b565b816151fb575b50156151b757565b606460405162461bcd60e51b815260206004820152600260248201527f53540000000000000000000000000000000000000000000000000000000000006044820152fd5b8051801592508215615210575b50505f6151af565b6152239250602080918301019101615002565b5f80615208565b916040519160208301936001600160601b03199060601b16845260e81b603483015260e81b6037820152601a81526132e6603a82612694565b5f1982820990828102928380841093039280840393146152a25782600160801b111561031857600160801b910990828211900360801b910360801c1790565b50505060801c90565b5f19600160601b8209918160601b9182808510940393808503941461532e57600160601b82916152dc86841161306f565b0981805f03168092046002816003021880820260020302808202600203028082026002030280820260020302808202600203028091026002030293600183805f03040190848311900302920304170290565b50915061533c82151561306f565b0490565b5f19828209908281029283808410930392808403931461537f5782600160601b111561031857600160601b910990828211900360a01b910360601c1790565b50505060601c90565b90915f1983830992808302928380861095039480860395146153b2579082916152dc86841161306f565b5050915061533c82151561306f565b806001600160801b03105f1461071057506001600160801b0390565b908051916020820151916001600160a01b0383166001600160a01b0385161015610318576154f461075e93611bfc92615474615442604061543761542a6104499b6001600160a01b031690565b956001600160a01b031690565b93015162ffffff1690565b604080516001600160a01b0395861660208201908152959094169084015262ffffff1660608301528160808101611bfc565b5190206040517fff000000000000000000000000000000000000000000000000000000000000006020820190815260609590951b6bffffffffffffffffffffffff1916602182015260358101919091527f000000000000000000000000000000000000000000000000000000000000000060558201529182906075820190565b5190206001600160a01b031690565b60020b5f8112156158a457805f035b620d89e8811161587c576001600160a01b039160018216156158605770ffffffffffffffffffffffffffffffffff6ffffcb933bd6fad37aa2d162d1a5940015b169160028116615844575b60048116615828575b6008811661580c575b601081166157f0575b602081166157d4575b604081166157b8575b6080811661579c575b6101008116615780575b6102008116615764575b6104008116615748575b610800811661572c575b6110008116615710575b61200081166156f4575b61400081166156d8575b61800081166156bc575b6201000081166156a0575b620200008116615685575b62040000811661566a575b6208000016615651575b5f12615643575b61562c6156228260201c90565b9163ffffffff1690565b61563a5760ff5f5b16011690565b60ff6001615634565b61564c90614e58565b615615565b6b048a170391f7dc42444e8fa290910260801c9061560e565b6d2216e584f5fa1ea926041bedfe9890920260801c91615604565b916e5d6af8dedb81196699c329225ee6040260801c916155f9565b916f09aa508b5b7a84e1c677de54f3e99bc90260801c916155ee565b916f31be135f97d08fd981231505542fcfa60260801c916155e3565b916f70d869a156d2a1b890bb3df62baf32f70260801c916155d9565b916fa9f746462d870fdf8a65dc1f90e061e50260801c916155cf565b916fd097f3bdfd2022b8845ad8f792aa58250260801c916155c5565b916fe7159475a2c29b7443b29c7fa6e889d90260801c916155bb565b916ff3392b0822b70005940c7a398e4b70f30260801c916155b1565b916ff987a7253ac413176f2b074cf7815e540260801c916155a7565b916ffcbe86c7900a88aedcffc83b479aa3a40260801c9161559d565b916ffe5dee046a99a2a811c461f1969c30530260801c91615593565b916fff2ea16466c96a3843ec78b326b528610260801c9161558a565b916fff973b41fa98c081472e6896dfb254c00260801c91615581565b916fffcb9843d60f6159c9db58835c9266440260801c91615578565b916fffe5caca7e10e4e61c3624eaa0941cd00260801c9161556f565b916ffff2e50f5f656932ef12357cf3c7fdcc0260801c91615566565b916ffff97272373d413259a46990580e213a0260801c9161555d565b70ffffffffffffffffffffffffffffffffff600160801b615552565b7f2bc80f3a000000000000000000000000000000000000000000000000000000005f5260045ffd5b80615512565b936001600160a01b0383166001600160a01b0383161161593d575b6001600160a01b038581169590831686116158e65750506104499350615cd4565b92909391946001600160a01b038216115f1461593157829161590c916159129594615cd4565b93615ca4565b6001600160801b0381166001600160801b038316105f14614b25575090565b91505061044992615ca4565b9091906158c5565b919091815f52600a602052600260405f20015460801c806159d2575b506001600160a01b03811690816159a9575061597c82615dfd565b6001600160a01b0383168061599757505061215b9150615e92565b036159a0575050565b61215b91615e59565b826001600160a01b03851683036159c2575b505061597c565b6159cb91615d31565b5f826159bb565b6159dc9083614711565b5f615961565b90926001600160a01b0360809381610449979616845216602083015260408201528160608201520190610414565b919290803b15615b1157615a48935f6001600160a01b0360209560405197889687958693630a85bd0160e11b855233600486016159e2565b0393165af15f9181615af0575b50615ada57615a62613b8b565b80519081615ad55760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608490fd5b602001fd5b6001600160e01b031916630a85bd0160e11b1490565b615b0a91925060203d602011611d5657611d488183612694565b905f615a55565b50505050600190565b90600282018092116111ac57565b90600182018092116111ac57565b80511561299b5760200190565b80516001101561299b5760210190565b90815181101561299b570160200190565b80156111ac575f190190565b15615b7757565b606460405162461bcd60e51b815260206004820152602060248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152fd5b905f80949381946001600160a01b03604051928160208501967f23b872dd000000000000000000000000000000000000000000000000000000008852166024850152166044830152606482015260648152615c17608482612694565b51925af1615c23613b8b565b81615c75575b5015615c3157565b606460405162461bcd60e51b815260206004820152600360248201527f53544600000000000000000000000000000000000000000000000000000000006044820152fd5b8051801592508215615c8a575b50505f615c29565b615c9d9250602080918301019101615002565b5f80615c82565b916001600160a01b0361044993615cc99382811683831611615cce575b0316906152ab565b615d1d565b90615cc1565b91615cc991610449936001600160a01b0382166001600160a01b03821611615d17575b6001600160a01b0390615d0e828416838316615340565b92031691615388565b90615cf7565b906001600160801b03821691820361031857565b615d3a8161366c565b5f1981019081116111ac57615d8e615d9b925f615d76868297835260076020526040832054868103615d9e575b505f52600760205260405f2090565b556001600160a01b03165f52600660205260405f2090565b905f5260205260405f2090565b55565b6001600160a01b0385168452600660205260408420878552602052615df66040852054615ddc876001600160a01b03165f52600660205260405f2090565b8387526020528060408720555f52600760205260405f2090565b555f615d67565b600854815f5260096020528060405f205568010000000000000000811015612673576001810160085560085481101561299b5760085f527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b906001600160a01b03615e6b8361366c565b92165f52600660205260405f20825f526020528060405f20555f52600760205260405f2055565b6008545f198101918183116111ac57805f5260096020528160405f205493101561299b5760085f527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee28201549183101561299b577ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee383018290555f91825260096020526040808320939093558152908120556008548015615f6d575f1981019060085482101561299b5760085f8181527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee29092019190915555565b634e487b7160e01b5f52603160045260245ffd000000000000000000000000d883a0b7889475d362cea8fdf588266a3da554a10000000000000000000000005555555555555555555555555555555555555555f54c8516b0255aaf493382e8534bab492d4325d4c84374ac39f7fa643a5cfbcd00000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000002a68747470733a2f2f6170692e756c747261736f6c69642e78797a2f746f6b656e2d6d657461646174612f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b556c747261536f6c696420434c20506f736974696f6e73204e46540000000000000000000000000000000000000000000000000000000000000000000000000955532d434c2d504f530000000000000000000000000000000000000000000000
Deployed Bytecode
0x60806040526004361015610022575b3615610018575f80fd5b610020613f5e565b005b5f3560e01c806301ffc9a71461030157806306fdde03146102fc578063081812fc146102f7578063095ea7b3146102f25780630c49ccbe146102ed57806312210e8a146102e857806313ead562146102e357806318160ddd146102de578063219f5d17146102d957806322aa6cd8146102d457806323b872dd146102cf5780632e17de78146102ca5780632f745c59146102c557806330adf81f146102c05780633644e515146102bb5780633a4b66f1146102b657806342842e0e146102b157806342966c68146102ac578063430c2081146102a75780634659a494146102a257806349404b7c1461029d5780634aa4a4fc146102985780634f6ccce71461029357806353d48b031461028e5780635bc95da31461028957806360b34d19146102845780636352211e1461027f57806370a082311461027a5780637ac2ff7b146102755780637acfc9e214610270578063883164561461026b57806395d89b411461026657806399fbab8814610261578063a22cb4651461025c578063a4a78f0c14610257578063a694fc3a14610252578063ac9650d81461024d578063b88d4fde14610248578063c2e3140a14610243578063c45a01551461023e578063c87b56dd14610239578063d348799714610234578063df2ab5bb1461022f578063e985e9c51461022a578063f3995c67146102255763fc6f78650361000e57612b1d565b612b05565b612a9f565b612a02565b6129a0565b61285c565b612819565b6127a0565b612710565b612542565b6124c4565b61244a565b61235e565b61215d565b61200e565b611dee565b611dbe565b611b6c565b611b45565b611b27565b61193b565b611854565b611582565b6114c8565b611485565b611357565b61133f565b6112c7565b6111da565b6111b1565b61113e565b61111c565b6110e2565b611014565b610fdc565b610fb3565b610f57565b610cd7565b610cba565b6109c1565b610998565b610676565b610563565b610523565b61044c565b61031c565b6001600160e01b031981160361031857565b5f80fd5b34610318576020366003190112610318576001600160e01b031960043561034281610306565b167f780e9d6300000000000000000000000000000000000000000000000000000000811490811561037c575b506040519015158152602090f35b7f80ac58cd000000000000000000000000000000000000000000000000000000008114915081156103e0575b81156103b6575b505f61036e565b7f01ffc9a7000000000000000000000000000000000000000000000000000000009150145f6103af565b7f5b5e139f00000000000000000000000000000000000000000000000000000000811491506103a8565b5f91031261031857565b805180835260209291819084018484015e5f828201840152601f01601f1916010190565b906020610449928181520190610414565b90565b34610318575f366003190112610318576040515f5f5461046b81612e6d565b80845290600181169081156104ff57506001146104a3575b61049f8361049381850382612694565b60405191829182610438565b0390f35b5f8080527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563939250905b8082106104e557509091508101602001610493610483565b9192600181602092548385880101520191019092916104cd565b60ff191660208086019190915291151560051b840190910191506104939050610483565b34610318576020366003190112610318576020610541600435612ea5565b6001600160a01b0360405191168152f35b6001600160a01b0381160361031857565b346103185760403660031901126103185760043561058081610552565b60243561058c8161360a565b916001600160a01b038316806001600160a01b0383161461060c57610020936105bf9133149081156105c4575b50612f44565b613fd4565b61060691506105ff906105e933916001600160a01b03165f52600560205260405f2090565b906001600160a01b03165f5260205260405f2090565b5460ff1690565b5f6105b9565b608460405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f72000000000000000000000000000000000000000000000000000000000000006064820152fd5b60a036600319011261031857600435610697610692823361403f565b612fb5565b6106a66084355b421115613000565b6106c16001600160801b036106b961304b565b16151561306f565b6107ca6106d6825f52600a60205260405f2090565b91600283019261074484546001600160801b0361073b610710610734610702856001600160801b031690565b61072661071c61071061304b565b6001600160801b031690565b868316101561306f565b61072e61304b565b9061308a565b9360801c90565b9116101561306f565b6040600182015461076a61075e826001600160a01b031690565b6001600160a01b031690565b61078461077a8360a01c60020b90565b9260b81c60020b90565b5f61078d61304b565b855163a34123a760e01b8152600295860b60048201529290940b60248301526001600160801b039093166044820152958692839182906064820190565b03925af1938415610993575f935f95610950575b506108dc916108506006926107f260443590565b87101580610944575b610804906130cb565b61080d86614120565b61082d61081861304b565b82546001600160801b031661308a565b61308a565b6001600160801b03166fffffffffffffffffffffffffffffffff19825416179055565b0161089c6108776001600160801b03861661087284546001600160801b031690565b613116565b82906001600160801b03166fffffffffffffffffffffffffffffffff19825416179055565b6108b46001600160801b038616610872835460801c90565b6001600160801b036fffffffffffffffffffffffffffffffff1983549260801b169116179055565b7f26f6a048ee9138f2c0ce266f322cb99228e8d619ae2bff30c67f8dcf9d2377b48261090661304b565b61093086604051938493846040919493926001600160801b03606083019616825260208201520152565b0390a2604080519182526020820192909252f35b506064358810156107fb565b600691955061085094509161097f6108dc9360403d60401161098c575b6109778183612694565b8101906130aa565b95909596925050916107de565b503d61096d565b6130c0565b5f36600319011261031857476109aa57005b61002047336143ee565b62ffffff81160361031857565b6080366003190112610318576004356109d981610552565b602435906109e682610552565b604435906109f3826109b4565b60643592610a0084610552565b610a1d6001600160a01b0382166001600160a01b0384161061306f565b6040517f1698ee820000000000000000000000000000000000000000000000000000000081526001600160a01b038381166004830152828116602483015262ffffff851660448301527f000000000000000000000000d883a0b7889475d362cea8fdf588266a3da554a1169290602081606481875afa908115610993575f91610c9b575b506001600160a01b03811680610bcb5750506040517fa16712950000000000000000000000000000000000000000000000000000000081526001600160a01b0391821660048201529116602482015262ffffff929092166044830152602090829060649082905f905af1908115610993575f91610b9c575b506001600160a01b038116803b156103185760405163f637731d60e01b81526001600160a01b039390931660048401525f908390602490829084905af19182156109935761049f92610b82575b505b6040516001600160a01b0390911681529081906020820190565b80610b905f610b9693612694565b8061040a565b5f610b66565b610bbe915060203d602011610bc4575b610bb68183612694565b810190613136565b5f610b19565b503d610bac565b935093505050604051633850c7bd60e01b815260e081600481855afa8015610993576001600160a01b03915f91610c66575b501615610c10575b5061049f9150610b68565b803b156103185760405163f637731d60e01b81526001600160a01b039390931660048401525f908390602490829084905af19182156109935761049f9215610c055780610b905f610c6093612694565b5f610c05565b610c88915060e03d60e011610c94575b610c808183612694565b810190613165565b5050505050505f610bfd565b503d610c76565b610cb4915060203d602011610bc457610bb68183612694565b5f610aa1565b34610318575f366003190112610318576020600854604051908152f35b60c036600319011261031857610cee60a43561069e565b600435610d03815f52600a60205260405f2090565b60018101549091610d1c6001600160a01b03831661075e565b9160405191630dfe168160e01b8352602083600481875afa928315610993575f93610f25575b506040519363d21220a760e01b8552602085600481845afa948515610993575f95610f00575b5060206004916040519283809263ddca3f4360e01b82525afa9384156109935760029561049f95610e6695610e41945f92610ecf575b50610db9610daf8260a01c60020b90565b9160b81c60020b90565b610e2660243591610e1c60443594610e0c60643597610e006084355b9a610df0610de16126b6565b6001600160a01b03909e168e52565b6001600160a01b031660208d0152565b62ffffff1660408b0152565b3060608a015260020b6080890152565b60020b60a0870152565b60c085015260e08401526101008301526101208201526144b4565b509391959096610e5084614120565b0161082d8661087283546001600160801b031690565b604080516001600160801b0386168152602081018790529081018390527f3067048beee31b25b2f1681f88dac838c8bba36af25bfb2b7cf7473a5847e35f90606090a2604051938493846040919493926001600160801b03606083019616825260208201520152565b610ef291925060203d602011610ef9575b610eea8183612694565b8101906131ce565b905f610d9e565b503d610ee0565b6004919550610f1d602091823d8411610bc457610bb68183612694565b959150610d68565b610f3f91935060203d602011610bc457610bb68183612694565b915f610d42565b6001600160801b0381160361031857565b604036600319011261031857610020602435600435610f7582610f46565b610f82610692823361403f565b614711565b606090600319011261031857600435610f9f81610552565b90602435610fac81610552565b9060443590565b3461031857610020610fc436610f87565b91610fd7610fd2843361403f565b6131e3565b614898565b602036600319011261031857610020600435610ffb610692823361403f565b805f52600a602052600260405f20015460801c90614711565b346103185760403660031901126103185760043561103181610552565b6024359061103e8161366c565b821015611078576001600160a01b03165f52600660205260405f20905f5260205261049f60405f2054604051918291829190602083019252565b608460405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201527f74206f6620626f756e64730000000000000000000000000000000000000000006064820152fd5b34610318575f3660031901126103185760206040517f49ecf333e5b8c95c40fdafc95c1ad136e8914a8fb55e9dc8bb01eaa83a2df9ad8152f35b34610318575f366003190112610318576020611136613254565b604051908152f35b5f366003190112610318575f196001600160b01b03600b5416016001600160b01b0381116111ac576001600160b01b036100209116611180610692823361403f565b805f52600a6020526111a6600260405f2001546001600160801b038160801c911661308a565b90614b73565b613076565b34610318576100206111c236610f87565b90604051926111d2602085612694565b5f8452613c31565b6020366003190112610318576100206004356111f9610692823361403f565b805f52600a60205261123060405f206001600160801b036002820154161590816112b1575b81611297575b81611279575b506132ec565b611274611245825f52600a60205260405f2090565b60075f918281558260018201558260028201558260038201558260048201558260058201558260068201550155565b614a2d565b6007015461129091506001600160801b0316610710565b155f61122a565b90506112aa610710600683015460801c90565b1590611224565b60068101546001600160801b031615915061121e565b346103185760403660031901126103185760206112f26004356112e981610552565b6024359061403f565b6040519015158152f35b60ff81160361031857565b60c09060031901126103185760043561131f81610552565b906024359060443590606435611334816112fc565b906084359060a43590565b61002061134b36611307565b94939093929192613337565b60403660031901126103185760243560043561137282610552565b6040516370a0823160e01b81523060048201526001600160a01b037f000000000000000000000000555555555555555555555555555555555555555516929091602083602481875afa928315610993575f93611450575b506113d6908310156133db565b816113dd57005b823b15610318575f60405180947f2e1a7d4d00000000000000000000000000000000000000000000000000000000825281838161142288600483019190602083019252565b03925af1928315610993576100209361143c575b506143ee565b80610b905f61144a93612694565b5f611436565b6113d69193506114779060203d60201161147e575b61146f8183612694565b8101906133cc565b92906113c9565b503d611465565b34610318575f3660031901126103185760206040516001600160a01b037f0000000000000000000000005555555555555555555555555555555555555555168152f35b34610318576020366003190112610318576004356008548110156115185760085f527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30154604051908152602090f35b608460405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201527f7574206f6620626f756e647300000000000000000000000000000000000000006064820152fd5b60603660031901126103185760043561159e610692823361403f565b6115b16001600160801b036106b9613057565b6001600160a01b036115c161343a565b1661184757305b6115da825f52600a60205260405f2090565b906115f261071060028401546001600160801b031690565b6117a1575b6116c29260016020611607613057565b9461163561071060078301976001600160801b038061162d8b546001600160801b031690565b169116614b18565b920154829061164c6001600160a01b03821661075e565b905f61165e61077a8360a01c60020b90565b6040517f219d910f0000000000000000000000000000000000000000000000000000000081526001600160a01b038a166004820152600293840b6024820152920b60448301526001600160801b039093166064820152978892839182906084820190565b03925af1928315610993576001600160801b03955f9461174a575b5061171a8561082d846108287f7d4ce6ab964cec8b10cbee95517159742fd6782e35b0dbc95291291fca13e263979899546001600160801b031690565b604080516001600160a01b039290921682526001600160801b03929092166020820152a260405191168152602090f35b7f7d4ce6ab964cec8b10cbee95517159742fd6782e35b0dbc95291291fca13e26393945061179261171a9160203d60201161179a575b61178a8183612694565b81019061345f565b9493506116dd565b503d611780565b61180492604060018401546117bf61075e826001600160a01b031690565b6117cf61077a8360a01c60020b90565b915f845180998195829463a34123a760e01b8452600484016040905f929493606082019560020b825260020b60208201520152565b03925af1938415610993576116c294611829575b5061182281614120565b92506115f7565b6118419060403d60401161098c576109778183612694565b50611818565b61184f61343a565b6115c8565b3461031857602036600319011261031857600435805f52600a6020526118d760405f20916040600184015461189261075e826001600160a01b031690565b6118a261077a8360a01c60020b90565b915f845180978195829463a34123a760e01b8452600484016040905f929493606082019560020b825260020b60208201520152565b03925af19182156109935761049f936118ff6107109360079361190d9661191d575b50614120565b01546001600160801b031690565b6040519081529081906020820190565b6119359060403d60401161098c576109778183612694565b506118f9565b34610318576020366003190112610318576004355f52600a60205260405f20611b0161075e611af361196b6126c6565b936119aa61199a8254611994611987826001600160601b031690565b6001600160601b03168952565b60601c90565b6001600160a01b03166020870152565b611abf600182015495611a076119fd6119c9896001600160a01b031690565b6001600160a01b031660408401908152986119f46119ea8260a01c60020b90565b60020b6060860152565b60b81c60020b90565b60020b6080830152565b610180611ab16007611a406002870154611a3a611a2a826001600160801b031690565b6001600160801b031660a0880152565b60801c90565b6001600160801b031660c0850190815295600381015460e0860152600481015461010086015260058101546101208601526118ff611aa06006830154611a3a611a8f826001600160801b031690565b6001600160801b03166101408a0152565b6001600160801b0316610160870152565b6001600160801b0316910152565b611ae66001600160a01b03611ade61075e88516001600160a01b031690565b1615156135bf565b516001600160801b031690565b92516001600160a01b031690565b604080516001600160801b039390931683526001600160a01b0391909116602083015290f35b3461031857602036600319011261031857602061054160043561360a565b34610318576020366003190112610318576020611136600435611b6781610552565b61366c565b611b7536611307565b919492611b84814211156136f4565b611bfc611c4f611b92613254565b92611bfc611c0a611ba28a614b2a565b9260405192839160208301958d8d88909493926080926001600160a01b0360a08401977f49ecf333e5b8c95c40fdafc95c1ad136e8914a8fb55e9dc8bb01eaa83a2df9ad8552166020840152604083015260608201520152565b03601f198101835282612694565b51902060405192839160208301958690916042927f19010000000000000000000000000000000000000000000000000000000000008352600283015260228201520190565b51902090611c5c8561360a565b95611c866001600160a01b03881697611c80896001600160a01b038916141561373f565b3b151590565b15611d5d57604080516020808201949094529081019490945260f81b7fff0000000000000000000000000000000000000000000000000000000000000016606084015260418352611cfb95909291611cdf606184612694565b604051809781948293630b135d3f60e11b84526004840161385b565b03915afa92831561099357630b135d3f60e11b6001600160e01b0319610020956105bf935f91611d2e575b5016146137fb565b611d50915060203d602011611d56575b611d488183612694565b810190613846565b5f611d26565b503d611d3e565b9091611d8d6020945f94604051948594859094939260ff6060936080840197845216602083015260408201520152565b838052039060015afa15610993576105bf610020936001600160a01b035f5116611db88115156137b0565b146137fb565b604036600319011261031857610020602435600435611ddc82610f46565b611de9610692823361403f565b614b73565b61016036600319011261031857611e076101443561069e565b61049f611e56611e15613446565b611e1d61343a565b611e25613872565b611e2d61387e565b611e3561388a565b610e2660a43591610e1c60c43594610e0c60e43597610e0061010435610dd5565b929391611f5d611e64613452565b94611eca6001600160b01b03611e82600b546001600160b01b031690565b611ec2611e8e82613896565b6001600160b01b03167fffffffffffffffffffff00000000000000000000000000000000000000000000600b541617600b55565b168097614d00565b611f11611ed561387e565b6119fd611ee061388a565b91611f07611eec6126c6565b5f80825260208201526001600160a01b039096166040870152565b60020b6060850152565b5f60a08201525f60c08201525f60e08201525f6101008201525f6101208201525f6101408201525f6101608201525f610180820152611f58865f52600a60205260405f2090565b6138b3565b611f6684614120565b611f936002611f7d865f52600a60205260405f2090565b0161082d8761087283546001600160801b031690565b837f3067048beee31b25b2f1681f88dac838c8bba36af25bfb2b7cf7473a5847e35f60405180611fdf86868b846040919493926001600160801b03606083019616825260208201520152565b0390a260405194859485909493926001600160801b036060936080840197845216602083015260408201520152565b34610318575f366003190112610318576040515f60015461202e81612e6d565b80845290600181169081156104ff57506001146120555761049f8361049381850382612694565b91905060015f527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6915f905b80821061209957509091508101602001610493610483565b919260018160209254838588010152019101909291612081565b99979593919c9b9a98969492909c6101808b019d6001600160601b03168b526001600160a01b031660208b01526001600160a01b031660408a01526001600160a01b0316606089015262ffffff16608088015260a087016121159160020b9052565b60020b60c08601526001600160801b031660e08501526101008401526101208301526001600160801b03166101408201526101600161215b916001600160801b03169052565b565b346103185760203660031901126103185761218a6121856004355f52600a60205260405f2090565b613474565b604081016121ad6001600160a01b03611ade61075e84516001600160a01b031690565b60046121c083516001600160601b031690565b916121d560208501516001600160a01b031690565b9360206121ec61075e84516001600160a01b031690565b60405194858092630dfe168160e01b82525afa918215610993576004935f93612333575b50602061222761075e83516001600160a01b031690565b6040519586809263d21220a760e01b82525afa908115610993576004945f92612309575b5061226261075e602092516001600160a01b031690565b6040519586809263ddca3f4360e01b82525afa80156109935761049f945f916122ea575b50606083015160020b608084015160020b60a08501516001600160801b03169160e086015193610100870151956122dd6101606122ce6101408b01516001600160801b031690565b9901516001600160801b031690565b986040519c8d9c8d6120b3565b612303915060203d602011610ef957610eea8183612694565b5f612286565b602091925061075e61232a61226292843d8611610bc457610bb68183612694565b9392505061224b565b61234d91935060203d602011610bc457610bb68183612694565b915f612210565b8015150361031857565b346103185760403660031901126103185760043561237b81610552565b60243561238781612354565b6001600160a01b0382169182331461240657816123c36123d492335f52600560205260405f20906001600160a01b03165f5260205260405f2090565b9060ff801983541691151516179055565b604051901515815233907f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3190602090a3005b606460405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152fd5b61245336611307565b604051636eb1769f60e11b81523360048201523060248201529094919391906020816044816001600160a01b038b165afa908115610993575f916124a5575b505f191161249c57005b61002095613337565b6124be915060203d60201161147e5761146f8183612694565b5f612492565b602036600319011261031857610020600435611180610692823361403f565b602081016020825282518091526040820191602060408360051b8301019401925f915b83831061251557505050505090565b9091929394602080612533600193603f198682030187528951610414565b97019301930191939290612506565b60203660031901126103185760043567ffffffffffffffff811161031857366023820112156103185780600401359067ffffffffffffffff8211610318576024810190602436918460051b0101116103185761259d82613af3565b915f5b8181106125b5576040518061049f86826124e3565b5f806125c2838587613b3c565b906125d260405180938193613b7e565b0390305af46125df613b8b565b901561260557906001916125f38287613c1d565b526125fe8186613c1d565b50016125a0565b60448151106103185761262781602480600461263f9501518301019101613bba565b60405191829162461bcd60e51b835260048301610438565b0390fd5b634e487b7160e01b5f52604160045260245ffd5b6040810190811067ffffffffffffffff82111761267357604052565b612643565b6060810190811067ffffffffffffffff82111761267357604052565b90601f8019910116810190811067ffffffffffffffff82111761267357604052565b6040519061215b61014083612694565b6040519061215b6101a083612694565b6040519061215b606083612694565b6040519061215b604083612694565b67ffffffffffffffff811161267357601f01601f191660200190565b346103185760803660031901126103185760043561272d81610552565b6024359061273a82610552565b6044356064359267ffffffffffffffff841161031857366023850112156103185783600401359261276a846126f4565b936127786040519586612694565b8085523660248288010111610318576020815f92602461002099018389013786010152613c31565b6127a936611307565b604051636eb1769f60e11b81523360048201523060248201529094919391906020816044816001600160a01b038b165afa80156109935782915f916127fa575b50106127f157005b61002095613eba565b612813915060203d60201161147e5761146f8183612694565b5f6127e9565b34610318575f3660031901126103185760206040516001600160a01b037f000000000000000000000000d883a0b7889475d362cea8fdf588266a3da554a1168152f35b346103185760203660031901126103185760043561288e815f5260026020526001600160a01b0360405f205416151590565b156103185761289c46614e78565b30916128b06128ab6028615b1a565b6143bc565b9260306128bc85615b36565b5360786128c885615b43565b536128d36028615b28565b600181116129475761049f61291e61049386611bfc8961291861291e6129028b6128fd8c15615b70565b614e78565b9261291860405198899761291860208a01613cc7565b90613d4e565b7f2f00000000000000000000000000000000000000000000000000000000000000815260010190565b90600f8116601081101561299b57612996917f3031323334353637383961626364656600000000000000000000000000000000612990921a6129898589615b53565b5360041c90565b91615b64565b6128d3565b613426565b346103185760603660031901126103185760443560243560043567ffffffffffffffff831161031857366023840112156103185782600401359167ffffffffffffffff8311610318573660248486010111610318576024610020940191613d60565b606036600319011261031857600435612a1a81610552565b602435604435612a2981610552565b604051916370a0823160e01b83523060048401526020836024816001600160a01b0388165afa928315610993575f93612a7a575b50612a6a90831015613e6f565b81612a7157005b6100209261515f565b612a6a919350612a989060203d60201161147e5761146f8183612694565b9290612a5d565b3461031857604036600319011261031857602060ff612af9600435612ac381610552565b6001600160a01b0360243591612ad883610552565b165f526005845260405f20906001600160a01b03165f5260205260405f2090565b54166040519015158152f35b610020612b1136611307565b94939093929192613eba565b608036600319011261031857600435612b39610692823361403f565b6001600160801b03612b49613057565b1615801590612e55575b612b5c9061306f565b6001600160a01b03612b6c61343a565b16612e475730905b612b86815f52600a60205260405f2090565b91612b9e61071060028501546001600160801b031690565b612da9575b610710612bae613057565b92600685019360406001612bf4612bdd6107108954956001600160801b038061162d896001600160801b031690565b9586946001600160801b038061162d610734613063565b970154612c096001600160a01b03821661075e565b612c1961077a8360a01c60020b90565b83517f4f1eb3d80000000000000000000000000000000000000000000000000000000081526001600160a01b0389166004820152600293840b6024820152920b60448301526001600160801b039586166064830152948816608482015293849060a49082905f905af1938415610993576001600160801b03965f945f96612d41575b5090612d258392612cf289612ce36108777f40d0efd1a53d60ecbf40971b9daf7dc90178c3aadc7aab1765632738fa8b8f019861082861049f9d9e546001600160801b031690565b6108b483610828835460801c90565b604051938493849160409194936001600160801b0380926001600160a01b03606087019816865216602085015216910152565b0390a26040805191851682529290931660208401528291820190565b61049f9650612cf295507f40d0efd1a53d60ecbf40971b9daf7dc90178c3aadc7aab1765632738fa8b8f01939291612d93612d259260403d604011612da2575b612d8b8183612694565b810190613f39565b97909798505091929350612c9b565b503d612d81565b612e0b60406001850154612dc661075e826001600160a01b031690565b612dd661077a8360a01c60020b90565b915f845180968195829463a34123a760e01b8452600484016040905f929493606082019560020b825260020b60208201520152565b03925af1801561099357612e29575b50612e2482614120565b612ba3565b612e419060403d60401161098c576109778183612694565b50612e1a565b612e4f61343a565b90612b74565b50612b5c612e64610710613063565b15159050612b53565b90600182811c92168015612e9b575b6020831014612e8757565b634e487b7160e01b5f52602260045260245ffd5b91607f1691612e7c565b612ec3815f5260026020526001600160a01b0360405f205416151590565b15612eda575f52600a60205260405f205460601c90565b608460405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201527f697374656e7420746f6b656e00000000000000000000000000000000000000006064820152fd5b15612f4b57565b608460405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152fd5b15612fbc57565b606460405162461bcd60e51b815260206004820152600c60248201527f4e6f7420617070726f76656400000000000000000000000000000000000000006044820152fd5b1561300757565b606460405162461bcd60e51b815260206004820152601360248201527f5472616e73616374696f6e20746f6f206f6c64000000000000000000000000006044820152fd5b60243561044981610f46565b60443561044981610f46565b60643561044981610f46565b1561031857565b634e487b7160e01b5f52601160045260245ffd5b906001600160801b03809116911603906001600160801b0382116111ac57565b9190826040910312610318576020825192015190565b6040513d5f823e3d90fd5b156130d257565b606460405162461bcd60e51b815260206004820152601460248201527f507269636520736c69707061676520636865636b0000000000000000000000006044820152fd5b906001600160801b03809116911601906001600160801b0382116111ac57565b90816020910312610318575161044981610552565b8060020b0361031857565b519061ffff8216820361031857565b908160e091031261031857805161317b81610552565b91602082015161318a8161314b565b9161319760408201613156565b916131a460608301613156565b916131b160808201613156565b9160c060a08301516131c2816112fc565b92015161044981612354565b908160209103126103185751610449816109b4565b156131ea57565b608460405162461bcd60e51b815260206004820152602d60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201527f72206f7220617070726f766564000000000000000000000000000000000000006064820152fd5b60405160208101907f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f82527f2cd413b4fc8e0eb8a060dab3801c803a5065ad5c451be1a41edcc5424484ab1460408201527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260a081526132e660c082612694565b51902090565b156132f357565b606460405162461bcd60e51b815260206004820152600b60248201527f4e6f7420636c65617265640000000000000000000000000000000000000000006044820152fd5b6001600160a01b0390959293951693843b15610318575f9461010493869260ff604051998a9889977f8fcbaf0c0000000000000000000000000000000000000000000000000000000089523360048a01523060248a015260448901526064880152600160848801521660a486015260c485015260e48401525af18015610993576133be5750565b80610b905f61215b93612694565b90816020910312610318575190565b156133e257565b606460405162461bcd60e51b815260206004820152601260248201527f496e73756666696369656e7420574554483900000000000000000000000000006044820152fd5b634e487b7160e01b5f52603260045260245ffd5b60243561044981610552565b60043561044981610552565b6101243561044981610552565b90816020910312610318575161044981610f46565b9061215b6135ae60076134856126c6565b946134be6134ae82546119946134a1826001600160601b031690565b6001600160601b03168a52565b6001600160a01b03166020880152565b61351061350660018301546134ec6134dc826001600160a01b031690565b6001600160a01b031660408b0152565b6119f46134fc8260a01c60020b90565b60020b60608b0152565b60020b6080880152565b61354e61353e6002830154611a3a61352e826001600160801b031690565b6001600160801b031660a08b0152565b6001600160801b031660c0880152565b600381015460e0870152600481015461010087015260058101546101208701526118ff61359d6006830154611a3a61358c826001600160801b031690565b6001600160801b03166101408b0152565b6001600160801b0316610160880152565b6001600160801b0316610180840152565b156135c657565b606460405162461bcd60e51b815260206004820152601060248201527f496e76616c696420746f6b656e204944000000000000000000000000000000006044820152fd5b5f5260026020526001600160a01b0360405f20541680156136285790565b606460405162461bcd60e51b815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e20494400000000000000006044820152fd5b6001600160a01b0316801561368a575f52600360205260405f205490565b608460405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f74206120766160448201527f6c6964206f776e657200000000000000000000000000000000000000000000006064820152fd5b156136fb57565b606460405162461bcd60e51b815260206004820152600e60248201527f5065726d697420657870697265640000000000000000000000000000000000006044820152fd5b1561374657565b608460405162461bcd60e51b815260206004820152602760248201527f4552433732315065726d69743a20617070726f76616c20746f2063757272656e60448201527f74206f776e6572000000000000000000000000000000000000000000000000006064820152fd5b156137b757565b606460405162461bcd60e51b815260206004820152601160248201527f496e76616c6964207369676e61747572650000000000000000000000000000006044820152fd5b1561380257565b606460405162461bcd60e51b815260206004820152600c60248201527f556e617574686f72697a656400000000000000000000000000000000000000006044820152fd5b90816020910312610318575161044981610306565b604090610449939281528160208201520190610414565b604435610449816109b4565b6064356104498161314b565b6084356104498161314b565b6001600160b01b03166001600160b01b0381146111ac5760010190565b6007613ab561018061215b946138f46138d382516001600160601b031690565b86546bffffffffffffffffffffffff19166001600160601b03909116178655565b61393061390b60208301516001600160a01b031690565b86546001600160601b031660609190911b6bffffffffffffffffffffffff1916178655565b613a236001860161397761394e60408501516001600160a01b031690565b82906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b6139d1613988606085015160020b90565b82907fffffffffffffffffff000000ffffffffffffffffffffffffffffffffffffffff82549160a01b76ffffff0000000000000000000000000000000000000000169116179055565b608083015160020b7fffffffffffff000000ffffffffffffffffffffffffffffffffffffffffffffff82549160b81b79ffffff0000000000000000000000000000000000000000000000169116179055565b613a5460028601613a4161087760a08501516001600160801b031690565b60c08301516001600160801b03166108b4565b60e0810151600386015561010081015160048601556101208101516005860155613aa760068601613a936108776101408501516001600160801b031690565b6101608301516001600160801b03166108b4565b01516001600160801b031690565b9101906001600160801b03166fffffffffffffffffffffffffffffffff19825416179055565b67ffffffffffffffff81116126735760051b60200190565b90613afd82613adb565b613b0a6040519182612694565b8281528092613b1b601f1991613adb565b01905f5b828110613b2b57505050565b806060602080938501015201613b1f565b919081101561299b5760051b81013590601e198136030182121561031857019081359167ffffffffffffffff8311610318576020018236038113610318579190565b908092918237015f815290565b3d15613bb5573d90613b9c826126f4565b91613baa6040519384612694565b82523d5f602084013e565b606090565b6020818303126103185780519067ffffffffffffffff8211610318570181601f8201121561031857805190613bee826126f4565b92613bfc6040519485612694565b8284526020838301011161031857815f9260208093018386015e8301015290565b805182101561299b5760209160051b010190565b90613c55939291613c45610fd2843361403f565b613c50838383614898565b615a10565b15613c5c57565b60405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608490fd5b600c545f9291613cd682612e6d565b9160018116908115613d3c5750600114613cee575050565b600c5f90815292935090917fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c75b838210613d285750500190565b600181602092548486015201910190613d1b565b60ff1916825250811515909102019150565b805191908290602001825e015f815290565b9291809192810103926080841261031857606060405194613d8086612657565b1261031857613e06606060405193613d9785612678565b8035613da281610552565b85526020810135613db281610552565b60208601526040810135613dc5816109b4565b6040860152848752013592613dd984610552565b602086019384527f000000000000000000000000d883a0b7889475d362cea8fdf588266a3da554a1614fe5565b5080613e48575b5081613e1857505050565b613e41613e33602061215b955101516001600160a01b031690565b91516001600160a01b031690565b3391615017565b835151613e6991906001600160a01b031683516001600160a01b0316613e41565b5f613e0d565b15613e7657565b606460405162461bcd60e51b815260206004820152601260248201527f496e73756666696369656e7420746f6b656e00000000000000000000000000006044820152fd5b6001600160a01b0390959293951693843b15610318575f9460e493869260ff604051998a9889977fd505accf0000000000000000000000000000000000000000000000000000000089523360048a01523060248a01526044890152606488015216608486015260a485015260c48401525af18015610993576133be5750565b91908260409103126103185760208251613f5281610f46565b92015161044981610f46565b6001600160a01b037f0000000000000000000000005555555555555555555555555555555555555555163303613f9057565b606460405162461bcd60e51b815260206004820152600960248201527f4e6f7420574554483900000000000000000000000000000000000000000000006044820152fd5b5f828152600a6020526040902080546001600160601b0316606083901b6bffffffffffffffffffffffff19161790556001600160a01b03806140158461360a565b169116907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9255f80a4565b6001600160a01b036140508361360a565b16916001600160a01b0382169183831493841561408e575b5050821561407557505090565b6001600160a01b0391925061408990612ea5565b161490565b60ff929450906140b9915f52600560205260405f20906001600160a01b03165f5260205260405f2090565b5416915f80614068565b908160a09103126103185780516140d981610f46565b9160208201519160408101519160806060830151613f5281610f46565b9081606091031261031857805161410c81610f46565b916040602083015192015161044981610f46565b60405181815261415f91907f7712b7ec2b36906e03c806ce80ec28a260d1b94896e6f70f04aed55cfd347ada90602090a15f52600a60205260405f2090565b60018101549061419c61075e61418f61417b8560a01c60020b90565b6141888660b81c60020b90565b903061522a565b936001600160a01b031690565b6040517f514ea4bf000000000000000000000000000000000000000000000000000000008152600481018490529160a083602481855afa918215610993575f935f9361437a575b50614225939460609160405180809781947f2f52f64c000000000000000000000000000000000000000000000000000000008352600483019190602083019252565b03915afa928315610993575f9361433c575b508383946143378361082d6002879601916142f961426a845461072e614263826001600160801b031690565b9160801c90565b6108b460068401916142d46142af61428985546001600160801b031690565b6001600160801b036142a78160038b019e8f54900396168096615263565b9116016153c1565b84906001600160801b03166fffffffffffffffffffffffffffffffff19825416179055565b6001600160801b036142a76142ea855460801c90565b92600488019d8e549003615263565b6001600160801b036142a76007830194614331610710600561432289546001600160801b031690565b96019d8e549003925460801c90565b90615263565b555555565b8291935093806143666143379660603d606011614373575b61435e8183612694565b8101906140f6565b5090509492509450614237565b503d614354565b614225945060609193506143a59060a03d60a0116143b5575b61439d8183612694565b8101906140c3565b50509691509593915094936141e3565b503d614393565b906143c6826126f4565b6143d36040519182612694565b82815280926143e4601f19916126f4565b0190602036910137565b6040515f9283929190614402602083612694565b83825261440e846126f4565b602083019290601f190136843751925af1614427613b8b565b501561442f57565b606460405162461bcd60e51b815260206004820152600360248201527f53544500000000000000000000000000000000000000000000000000000000006044820152fd5b919360a09361044996956001600160a01b036001600160801b039416855260020b602085015260020b60408401521660608201528160808201520190610414565b80516001600160a01b0316906145216144d760208301516001600160a01b031690565b6145156144ea604085015162ffffff1690565b916145056144f66126d6565b6001600160a01b039097168752565b6001600160a01b03166020860152565b62ffffff166040840152565b61454e61075e837f000000000000000000000000d883a0b7889475d362cea8fdf588266a3da554a16153dd565b604051633850c7bd60e01b8152936001600160a01b03821660e086600481845afa958615610993575f966146ea575b506080840194855161458f9060020b90565b61459890615503565b9660a086019788516145aa9060020b90565b6145b390615503565b60c08801519060e0890151926145c8946158aa565b96879660608701516145e0906001600160a01b031690565b905160020b915160020b926145f36126e5565b8181523360209182019081526040805184516001600160a01b03908116828601529385015184168183015293015162ffffff1660608401525116608080830191909152815261464360a082612694565b6040517f3c8a7d8d000000000000000000000000000000000000000000000000000000008152988994859461467b9460048701614473565b03815a6040945f91f1928315610993575f945f946146c1575b5061215b908486610100830151111591826146b1575b50506130cb565b6101200151111590505f806146aa565b61215b95506146e091945060403d60401161098c576109778183612694565b9490949390614694565b61470491965060e03d60e011610c9457610c808183612694565b505050505050945f61457d565b90614724825f52600a60205260405f2090565b6001810154916001600160a01b03831692614745610daf8260a01c60020b90565b90843b15610318576040517f24473387000000000000000000000000000000000000000000000000000000008152600291820b600482015291900b60248201526001600160801b0382166044820152925f908490606490829084905af192831561099357600261480e936147f4927f9045c2ac9b2026de8075f2701bbdde882cd5e830b3b1ead9a15b22f2b5b9374296614813575b506147e487614120565b016108b483610828835460801c90565b6040516001600160801b0390911681529081906020820190565b0390a2565b80610b905f61482193612694565b5f6147da565b1561482e57565b608460405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201527f6f776e65720000000000000000000000000000000000000000000000000000006064820152fd5b6001600160a01b03906148b96148ad8561360a565b82841693168314614827565b6001600160a01b0383169283156149c45761493b826148dc878461499e96615945565b6148f2856148ec61075e8a61360a565b14614827565b614924614907885f52600460205260405f2090565b73ffffffffffffffffffffffffffffffffffffffff198154169055565b6001600160a01b03165f52600360205260405f2090565b5f19815401905561495d816001600160a01b03165f52600360205260405f2090565b60018154019055614976855f52600260205260405f2090565b906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef5f80a4565b608460405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152fd5b614a368161360a565b815f52600a602052600260405f20015460801c80614b08575b50816001600160a01b038216614afa57614a699150615dfd565b614a7281615e92565b5f6001600160a01b03614a848361360a565b83835260046020526040832073ffffffffffffffffffffffffffffffffffffffff1981541690551680825260036020526040822082198154019055614ad4614907845f52600260205260405f2090565b7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8280a4565b614b0391615d31565b614a69565b614b129083614711565b5f614a4f565b9080821015614b25575090565b905090565b5f52600a60205260405f206001600160601b03815416906001600160601b0382146111ac5780546bffffffffffffffffffffffff19166001600160601b03600184011617905590565b90614b86825f52600a60205260405f2090565b600181015491614b9e6001600160a01b03841661075e565b92614baf610daf8260a01c60020b90565b90843b15610318576040517fae1cd183000000000000000000000000000000000000000000000000000000008152600291820b600482015291900b60248201526001600160801b0382166044820152925f908490606490829084905af192831561099357600261480e936147f4927fc9ec05ea5037818736839e1365dc3d9a74a735c447af0697da66633b7a9d0fab96614ca1575b50614c4e87614120565b01614c8a614c6184610872845460801c90565b82546001600160801b031660809190911b6fffffffffffffffffffffffffffffffff1916178255565b546001600160801b0361073b610710828416610734565b80610b905f614caf93612694565b5f614c44565b15614cbc57565b606460405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152fd5b6001600160a01b038116908115614e1457614dce90614d3c614d36855f5260026020526001600160a01b0360405f205416151590565b15614cb5565b835f52600a602052600260405f20015460801c80614e04575b50614d5f84615dfd565b82614df557614d6d84615e92565b614d9a614d95614d91865f5260026020526001600160a01b0360405f205416151590565b1590565b614cb5565b614db5816001600160a01b03165f52600360205260405f2090565b60018154019055614976845f52600260205260405f2090565b5f7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a4565b614dff8482615e59565b614d6d565b614e0e9085614711565b5f614d55565b606460405162461bcd60e51b815260206004820152602060248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152fd5b8015614e64575f190490565b634e487b7160e01b5f52601260045260245ffd5b805f917a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000821015614fbd575b806d04ee2d6d415b85acef8100000000600a921015614fa1575b662386f26fc10000811015614f8c575b6305f5e100811015614f7a575b612710811015614f6a575b6064811015614f5b575b1015614f50575b614f3b6021614f03600185016143bc565b938401015b5f1901917f3031323334353637383961626364656600000000000000000000000000000000600a82061a8353600a900490565b8015614f4b57614f3b9091614f08565b505090565b600190910190614ef2565b60029060649004930192614eeb565b6004906127109004930192614ee1565b6008906305f5e1009004930192614ed6565b601090662386f26fc100009004930192614ec9565b6020906d04ee2d6d415b85acef81000000009004930192614eb9565b50604091507a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008104614e9f565b6001600160a01b0391614ff7916153dd565b169081330361031857565b90816020910312610318575161044981612354565b9290926001600160a01b037f00000000000000000000000055555555555555555555555555555555555555551693846001600160a01b0383161480615155575b1561512c575050823b1561031857604051927fd0e30db00000000000000000000000000000000000000000000000000000000084525f8460048185855af1928315610993576150dc94602094615118575b505f60405180968195829463a9059cbb60e01b845260048401602090939291936001600160a01b0360408201951681520152565b03925af18015610993576150ed5750565b61510e9060203d602011615111575b6151068183612694565b810190615002565b50565b503d6150fc565b80610b905f61512693612694565b5f6150a8565b9093509091906001600160a01b038116300361514c575061215b9261515f565b61215b93615bbb565b5082471015615057565b60405163a9059cbb60e01b602082019081526001600160a01b03909316602482015260448101939093525f92839290839061519d8160648101611bfc565b51925af16151a9613b8b565b816151fb575b50156151b757565b606460405162461bcd60e51b815260206004820152600260248201527f53540000000000000000000000000000000000000000000000000000000000006044820152fd5b8051801592508215615210575b50505f6151af565b6152239250602080918301019101615002565b5f80615208565b916040519160208301936001600160601b03199060601b16845260e81b603483015260e81b6037820152601a81526132e6603a82612694565b5f1982820990828102928380841093039280840393146152a25782600160801b111561031857600160801b910990828211900360801b910360801c1790565b50505060801c90565b5f19600160601b8209918160601b9182808510940393808503941461532e57600160601b82916152dc86841161306f565b0981805f03168092046002816003021880820260020302808202600203028082026002030280820260020302808202600203028091026002030293600183805f03040190848311900302920304170290565b50915061533c82151561306f565b0490565b5f19828209908281029283808410930392808403931461537f5782600160601b111561031857600160601b910990828211900360a01b910360601c1790565b50505060601c90565b90915f1983830992808302928380861095039480860395146153b2579082916152dc86841161306f565b5050915061533c82151561306f565b806001600160801b03105f1461071057506001600160801b0390565b908051916020820151916001600160a01b0383166001600160a01b0385161015610318576154f461075e93611bfc92615474615442604061543761542a6104499b6001600160a01b031690565b956001600160a01b031690565b93015162ffffff1690565b604080516001600160a01b0395861660208201908152959094169084015262ffffff1660608301528160808101611bfc565b5190206040517fff000000000000000000000000000000000000000000000000000000000000006020820190815260609590951b6bffffffffffffffffffffffff1916602182015260358101919091527ff54c8516b0255aaf493382e8534bab492d4325d4c84374ac39f7fa643a5cfbcd60558201529182906075820190565b5190206001600160a01b031690565b60020b5f8112156158a457805f035b620d89e8811161587c576001600160a01b039160018216156158605770ffffffffffffffffffffffffffffffffff6ffffcb933bd6fad37aa2d162d1a5940015b169160028116615844575b60048116615828575b6008811661580c575b601081166157f0575b602081166157d4575b604081166157b8575b6080811661579c575b6101008116615780575b6102008116615764575b6104008116615748575b610800811661572c575b6110008116615710575b61200081166156f4575b61400081166156d8575b61800081166156bc575b6201000081166156a0575b620200008116615685575b62040000811661566a575b6208000016615651575b5f12615643575b61562c6156228260201c90565b9163ffffffff1690565b61563a5760ff5f5b16011690565b60ff6001615634565b61564c90614e58565b615615565b6b048a170391f7dc42444e8fa290910260801c9061560e565b6d2216e584f5fa1ea926041bedfe9890920260801c91615604565b916e5d6af8dedb81196699c329225ee6040260801c916155f9565b916f09aa508b5b7a84e1c677de54f3e99bc90260801c916155ee565b916f31be135f97d08fd981231505542fcfa60260801c916155e3565b916f70d869a156d2a1b890bb3df62baf32f70260801c916155d9565b916fa9f746462d870fdf8a65dc1f90e061e50260801c916155cf565b916fd097f3bdfd2022b8845ad8f792aa58250260801c916155c5565b916fe7159475a2c29b7443b29c7fa6e889d90260801c916155bb565b916ff3392b0822b70005940c7a398e4b70f30260801c916155b1565b916ff987a7253ac413176f2b074cf7815e540260801c916155a7565b916ffcbe86c7900a88aedcffc83b479aa3a40260801c9161559d565b916ffe5dee046a99a2a811c461f1969c30530260801c91615593565b916fff2ea16466c96a3843ec78b326b528610260801c9161558a565b916fff973b41fa98c081472e6896dfb254c00260801c91615581565b916fffcb9843d60f6159c9db58835c9266440260801c91615578565b916fffe5caca7e10e4e61c3624eaa0941cd00260801c9161556f565b916ffff2e50f5f656932ef12357cf3c7fdcc0260801c91615566565b916ffff97272373d413259a46990580e213a0260801c9161555d565b70ffffffffffffffffffffffffffffffffff600160801b615552565b7f2bc80f3a000000000000000000000000000000000000000000000000000000005f5260045ffd5b80615512565b936001600160a01b0383166001600160a01b0383161161593d575b6001600160a01b038581169590831686116158e65750506104499350615cd4565b92909391946001600160a01b038216115f1461593157829161590c916159129594615cd4565b93615ca4565b6001600160801b0381166001600160801b038316105f14614b25575090565b91505061044992615ca4565b9091906158c5565b919091815f52600a602052600260405f20015460801c806159d2575b506001600160a01b03811690816159a9575061597c82615dfd565b6001600160a01b0383168061599757505061215b9150615e92565b036159a0575050565b61215b91615e59565b826001600160a01b03851683036159c2575b505061597c565b6159cb91615d31565b5f826159bb565b6159dc9083614711565b5f615961565b90926001600160a01b0360809381610449979616845216602083015260408201528160608201520190610414565b919290803b15615b1157615a48935f6001600160a01b0360209560405197889687958693630a85bd0160e11b855233600486016159e2565b0393165af15f9181615af0575b50615ada57615a62613b8b565b80519081615ad55760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608490fd5b602001fd5b6001600160e01b031916630a85bd0160e11b1490565b615b0a91925060203d602011611d5657611d488183612694565b905f615a55565b50505050600190565b90600282018092116111ac57565b90600182018092116111ac57565b80511561299b5760200190565b80516001101561299b5760210190565b90815181101561299b570160200190565b80156111ac575f190190565b15615b7757565b606460405162461bcd60e51b815260206004820152602060248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152fd5b905f80949381946001600160a01b03604051928160208501967f23b872dd000000000000000000000000000000000000000000000000000000008852166024850152166044830152606482015260648152615c17608482612694565b51925af1615c23613b8b565b81615c75575b5015615c3157565b606460405162461bcd60e51b815260206004820152600360248201527f53544600000000000000000000000000000000000000000000000000000000006044820152fd5b8051801592508215615c8a575b50505f615c29565b615c9d9250602080918301019101615002565b5f80615c82565b916001600160a01b0361044993615cc99382811683831611615cce575b0316906152ab565b615d1d565b90615cc1565b91615cc991610449936001600160a01b0382166001600160a01b03821611615d17575b6001600160a01b0390615d0e828416838316615340565b92031691615388565b90615cf7565b906001600160801b03821691820361031857565b615d3a8161366c565b5f1981019081116111ac57615d8e615d9b925f615d76868297835260076020526040832054868103615d9e575b505f52600760205260405f2090565b556001600160a01b03165f52600660205260405f2090565b905f5260205260405f2090565b55565b6001600160a01b0385168452600660205260408420878552602052615df66040852054615ddc876001600160a01b03165f52600660205260405f2090565b8387526020528060408720555f52600760205260405f2090565b555f615d67565b600854815f5260096020528060405f205568010000000000000000811015612673576001810160085560085481101561299b5760085f527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b906001600160a01b03615e6b8361366c565b92165f52600660205260405f20825f526020528060405f20555f52600760205260405f2055565b6008545f198101918183116111ac57805f5260096020528160405f205493101561299b5760085f527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee28201549183101561299b577ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee383018290555f91825260096020526040808320939093558152908120556008548015615f6d575f1981019060085482101561299b5760085f8181527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee29092019190915555565b634e487b7160e01b5f52603160045260245ffd
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000d883a0b7889475d362cea8fdf588266a3da554a10000000000000000000000005555555555555555555555555555555555555555f54c8516b0255aaf493382e8534bab492d4325d4c84374ac39f7fa643a5cfbcd00000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000002a68747470733a2f2f6170692e756c747261736f6c69642e78797a2f746f6b656e2d6d657461646174612f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b556c747261536f6c696420434c20506f736974696f6e73204e46540000000000000000000000000000000000000000000000000000000000000000000000000955532d434c2d504f530000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : _factory (address): 0xD883a0B7889475d362CEA8fDf588266a3da554A1
Arg [1] : _WETH9 (address): 0x5555555555555555555555555555555555555555
Arg [2] : initCodeHash (bytes32): 0xf54c8516b0255aaf493382e8534bab492d4325d4c84374ac39f7fa643a5cfbcd
Arg [3] : baseURI_ (string): https://api.ultrasolid.xyz/token-metadata/
Arg [4] : name (string): UltraSolid CL Positions NFT
Arg [5] : symbol (string): US-CL-POS
-----Encoded View---------------
13 Constructor Arguments found :
Arg [0] : 000000000000000000000000d883a0b7889475d362cea8fdf588266a3da554a1
Arg [1] : 0000000000000000000000005555555555555555555555555555555555555555
Arg [2] : f54c8516b0255aaf493382e8534bab492d4325d4c84374ac39f7fa643a5cfbcd
Arg [3] : 00000000000000000000000000000000000000000000000000000000000000c0
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000120
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000160
Arg [6] : 000000000000000000000000000000000000000000000000000000000000002a
Arg [7] : 68747470733a2f2f6170692e756c747261736f6c69642e78797a2f746f6b656e
Arg [8] : 2d6d657461646174612f00000000000000000000000000000000000000000000
Arg [9] : 000000000000000000000000000000000000000000000000000000000000001b
Arg [10] : 556c747261536f6c696420434c20506f736974696f6e73204e46540000000000
Arg [11] : 0000000000000000000000000000000000000000000000000000000000000009
Arg [12] : 55532d434c2d504f530000000000000000000000000000000000000000000000
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in HYPE
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ 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.