Source Code
Latest 25 from a total of 327 transactions
| Transaction Hash |
Method
|
Block
|
From
|
|
To
|
||||
|---|---|---|---|---|---|---|---|---|---|
| Readjust Liquidi... | 19793478 | 551 days ago | IN | 0 ETH | 0.00441658 | ||||
| Readjust Liquidi... | 18388600 | 748 days ago | IN | 0 ETH | 0.00740584 | ||||
| Readjust Liquidi... | 18388581 | 748 days ago | IN | 0 ETH | 0.00637678 | ||||
| Readjust Liquidi... | 18388574 | 748 days ago | IN | 0 ETH | 0.00587284 | ||||
| Readjust Liquidi... | 18351232 | 753 days ago | IN | 0 ETH | 0.00763326 | ||||
| Readjust Liquidi... | 18351231 | 753 days ago | IN | 0 ETH | 0.00708853 | ||||
| Readjust Liquidi... | 18351205 | 753 days ago | IN | 0 ETH | 0.0061399 | ||||
| Readjust Liquidi... | 18351202 | 753 days ago | IN | 0 ETH | 0.00783662 | ||||
| Readjust Liquidi... | 18351183 | 753 days ago | IN | 0 ETH | 0.00673216 | ||||
| Readjust Liquidi... | 18351164 | 753 days ago | IN | 0 ETH | 0.0072975 | ||||
| Readjust Liquidi... | 18351150 | 753 days ago | IN | 0 ETH | 0.00695319 | ||||
| Readjust Liquidi... | 18351114 | 753 days ago | IN | 0 ETH | 0.0063996 | ||||
| Readjust Liquidi... | 15355859 | 1177 days ago | IN | 0 ETH | 0.01106337 | ||||
| Readjust Liquidi... | 15239130 | 1195 days ago | IN | 0 ETH | 0.01396821 | ||||
| Readjust Liquidi... | 14925556 | 1246 days ago | IN | 0 ETH | 0.03812791 | ||||
| Readjust Liquidi... | 14925555 | 1246 days ago | IN | 0 ETH | 0.04024038 | ||||
| Readjust Liquidi... | 14925554 | 1246 days ago | IN | 0 ETH | 0.03890569 | ||||
| Readjust Liquidi... | 14622689 | 1295 days ago | IN | 0 ETH | 0.04592644 | ||||
| Readjust Liquidi... | 14621792 | 1295 days ago | IN | 0 ETH | 0.02456853 | ||||
| Readjust Liquidi... | 14621791 | 1295 days ago | IN | 0 ETH | 0.02828474 | ||||
| Readjust Liquidi... | 14621745 | 1295 days ago | IN | 0 ETH | 0.02245538 | ||||
| Readjust Liquidi... | 14621661 | 1295 days ago | IN | 0 ETH | 0.02221674 | ||||
| Readjust Liquidi... | 14555020 | 1306 days ago | IN | 0 ETH | 0.01819498 | ||||
| Readjust Liquidi... | 14506811 | 1313 days ago | IN | 0 ETH | 0.03870384 | ||||
| Readjust Liquidi... | 14501826 | 1314 days ago | IN | 0 ETH | 0.06307191 |
Latest 25 internal transactions (View All)
Advanced mode:
| Parent Transaction Hash | Method | Block |
From
|
|
To
|
||
|---|---|---|---|---|---|---|---|
| Transfer | 15430738 | 1165 days ago | 0.00079081 ETH | ||||
| Transfer | 15430738 | 1165 days ago | 0.00079081 ETH | ||||
| Transfer | 15146329 | 1209 days ago | 2.95915166 ETH | ||||
| Transfer | 15146329 | 1209 days ago | 2.95915166 ETH | ||||
| - | 14780036 | 1270 days ago | 0.36381402 ETH | ||||
| - | 14780036 | 1270 days ago | 0.36381402 ETH | ||||
| - | 14713459 | 1281 days ago | 0.22933153 ETH | ||||
| - | 14713459 | 1281 days ago | 0.22933153 ETH | ||||
| - | 14713451 | 1281 days ago | 0.17937309 ETH | ||||
| - | 14713451 | 1281 days ago | 0.17937309 ETH | ||||
| - | 14711558 | 1281 days ago | 0.12304135 ETH | ||||
| - | 14711558 | 1281 days ago | 0.12304135 ETH | ||||
| - | 14671439 | 1287 days ago | 0.35449978 ETH | ||||
| - | 14671439 | 1287 days ago | 0.35449978 ETH | ||||
| - | 14671439 | 1287 days ago | 0.22570416 ETH | ||||
| - | 14671439 | 1287 days ago | 0.22570416 ETH | ||||
| - | 14671404 | 1287 days ago | 0.00010376 ETH | ||||
| - | 14671404 | 1287 days ago | 0.00010376 ETH | ||||
| - | 14671404 | 1287 days ago | 0.02491054 ETH | ||||
| - | 14671404 | 1287 days ago | 0.02491054 ETH | ||||
| - | 14621856 | 1295 days ago | 0.00035636 ETH | ||||
| - | 14621856 | 1295 days ago | 0.00035636 ETH | ||||
| - | 14621584 | 1295 days ago | 0.00072821 ETH | ||||
| - | 14621584 | 1295 days ago | 0.00072821 ETH | ||||
| - | 14554432 | 1306 days ago | 0.05855755 ETH |
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Name:
UniswapLiquidityManager
Compiler Version
v0.7.6+commit.7338295f
Optimization Enabled:
Yes with 800 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.6;
pragma abicoder v2;
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol";
import "../interfaces/IUniStrategy.sol";
import "../interfaces/IUnipilot.sol";
import "../interfaces/uniswap/IUniswapLiquidityManager.sol";
import "../oracle/interfaces/IOracle.sol";
import "../libraries/LiquidityReserves.sol";
import "../libraries/FixedPoint128.sol";
import "../libraries/SafeCast.sol";
import "../libraries/LiquidityPositions.sol";
import "../libraries/UserPositions.sol";
import "./PeripheryPayments.sol";
/// @title UniswapLiquidityManager Universal Liquidity Manager of Uniswap V3
/// @notice Universal & Automated liquidity managment contract that handles liquidity of any Uniswap V3 pool
/// @dev Instead of deploying a contract each time when a new vault is created, UniswapLiquidityManager will
/// manage this in a single contract, all of the vaults are managed within one contract with users just paying
/// storage fees when creating a new vault.
/// @dev UniswapLiquidityManager always maintains 2 range orders on Uniswap V3,
/// base order: The main liquidity range -- where the majority of LP capital sits
/// limit order: A single token range -- depending on which token it holds more of after the base order was placed.
/// @dev The vault readjustment function can be called by captains or anyone to ensure
/// the liquidity of each vault remains in the most optimum range, incentive will be provided for readjustment of vault
/// @dev Vault can not be readjust more than two times in 24 hrs,
/// pool is too volatile if it requires readjustment more than 2
/// @dev User can collect fees in 2 ways:
/// 1. Claim fees in tokens with vault fare, 2. Claim all fees in PILOT
contract UniswapLiquidityManager is PeripheryPayments, IUniswapLiquidityManager {
using LowGasSafeMath for uint256;
using SafeCast for uint256;
address private immutable uniswapFactory;
uint128 private constant MAX_UINT128 = type(uint128).max;
uint8 private _unlocked = 1;
/// @dev The token ID position data of the user
mapping(uint256 => Position) private positions;
/// @dev The data of the Unipilot base & range orders
mapping(address => LiquidityPosition) private liquidityPositions;
UnipilotProtocolDetails private unipilotProtocolDetails;
modifier onlyUnipilot() {
_isUnipilot();
_;
}
modifier onlyGovernance() {
_isGovernance();
_;
}
modifier nonReentrant() {
require(_unlocked == 1);
_unlocked = 0;
_;
_unlocked = 1;
}
constructor(UnipilotProtocolDetails memory params, address _uniswapFactory) {
unipilotProtocolDetails = params;
uniswapFactory = _uniswapFactory;
}
function userPositions(uint256 tokenId)
external
view
override
returns (Position memory)
{
return positions[tokenId];
}
function poolPositions(address pool)
external
view
override
returns (LiquidityPosition memory)
{
return liquidityPositions[pool];
}
/// @dev Blacklist/Whitelist swapping for getting pool in range & premium for readjust liquidity
/// @param pool Address of the uniswap v3 pool
/// @param feesInPilot_ Additional premium of a user as an incentive for optimization of vaults.
/// @param managed_ P
function setPoolIncentives(
address pool,
bool feesInPilot_,
bool managed_,
address oracle0,
address oracle1
) external onlyGovernance {
LiquidityPosition storage lp = liquidityPositions[pool];
lp.feesInPilot = feesInPilot_;
lp.managed = managed_;
lp.oracle0 = oracle0;
lp.oracle1 = oracle1;
}
/// @dev Sets the new details for unipilot protocol
function setPilotProtocolDetails(UnipilotProtocolDetails calldata params)
external
onlyGovernance
{
unipilotProtocolDetails = params;
}
/// @notice Returns the status of runnng readjust function, the limit is set to 2 readjusts per day
/// @param pool Address of the pool
/// @return status Pool rebase status
function readjustFrequencyStatus(address pool) public returns (bool status) {
LiquidityPosition storage lp = liquidityPositions[pool];
if (
block.timestamp - lp.timestamp > unipilotProtocolDetails.readjustFrequencyTime
) {
lp.counter = 0;
lp.status = false;
}
status = lp.status;
}
/// @inheritdoc IUniswapLiquidityManager
function uniswapV3MintCallback(
uint256 amount0Owed,
uint256 amount1Owed,
bytes calldata data
) external override {
address sender = msg.sender;
MintCallbackData memory decoded = abi.decode(data, (MintCallbackData));
_verifyCallback(decoded.token0, decoded.token1, decoded.fee);
if (amount0Owed > 0) pay(decoded.token0, decoded.payer, sender, amount0Owed);
if (amount1Owed > 0) pay(decoded.token1, decoded.payer, sender, amount1Owed);
}
/// @inheritdoc IUniswapLiquidityManager
function uniswapV3SwapCallback(
int256 amount0Delta,
int256 amount1Delta,
bytes calldata data
) external override {
address recipient = msg.sender;
SwapCallbackData memory decoded = abi.decode(data, (SwapCallbackData));
_verifyCallback(decoded.token0, decoded.token1, decoded.fee);
if (amount0Delta > 0)
pay(decoded.token0, address(this), recipient, uint256(amount0Delta));
if (amount1Delta > 0)
pay(decoded.token1, address(this), recipient, uint256(amount1Delta));
}
/// @inheritdoc IUniswapLiquidityManager
function getReserves(
address token0,
address token1,
bytes calldata data
)
external
view
override
returns (
uint256 totalAmount0,
uint256 totalAmount1,
uint256 totalLiquidity
)
{
uint24 fee = abi.decode(data, (uint24));
address pool = getPoolAddress(token0, token1, fee);
(totalAmount0, totalAmount1, totalLiquidity) = updatePositionTotalAmounts(pool);
}
/// @notice Returns maximum amount of fees owed to a specific user position
/// @dev Updates the unipilot base & range positions in order to fetch updated amount of user fees
/// @param tokenId The ID of the Unpilot NFT for which tokens will be collected
/// @return fees0 Amount of fees in token0
/// @return fees1 Amount of fees in token1
function getUserFees(uint256 tokenId)
external
returns (uint256 fees0, uint256 fees1)
{
Position memory position = positions[tokenId];
_collectPositionFees(position.pool);
LiquidityPosition memory lp = liquidityPositions[position.pool];
(uint256 tokensOwed0, uint256 tokensOwed1) = UserPositions.getTokensOwedAmount(
position.feeGrowth0,
position.feeGrowth1,
position.liquidity,
lp.feeGrowthGlobal0,
lp.feeGrowthGlobal1
);
fees0 = position.tokensOwed0.add(tokensOwed0);
fees1 = position.tokensOwed1.add(tokensOwed1);
}
/// @inheritdoc IUniswapLiquidityManager
function createPair(
address _token0,
address _token1,
bytes memory data
) external override returns (address _pool) {
(uint24 _fee, uint160 _sqrtPriceX96) = abi.decode(data, (uint24, uint160));
_pool = IUniswapV3Factory(uniswapFactory).createPool(_token0, _token1, _fee);
IUniswapV3Pool(_pool).initialize(_sqrtPriceX96);
emit PoolCreated(_token0, _token1, _pool, _fee, _sqrtPriceX96);
}
/// @inheritdoc IUniswapLiquidityManager
function deposit(
address token0,
address token1,
uint256 amount0Desired,
uint256 amount1Desired,
uint256 shares,
uint256 tokenId,
bool isTokenMinted,
bytes memory data
) external payable override onlyUnipilot {
DepositVars memory b;
b.fee = abi.decode(data, (uint24));
b.pool = getPoolAddress(token0, token1, b.fee);
LiquidityPosition storage poolPosition = liquidityPositions[b.pool];
// updating the feeGrowthGlobal of pool for new user
if (poolPosition.totalLiquidity > 0) _collectPositionFees(b.pool);
(
b.amount0Base,
b.amount1Base,
b.amount0Range,
b.amount1Range
) = _addLiquidityInManager(
AddLiquidityManagerParams({
pool: b.pool,
amount0Desired: amount0Desired,
amount1Desired: amount1Desired,
shares: shares
})
);
if (!isTokenMinted) {
Position storage userPosition = positions[tokenId];
require(b.pool == userPosition.pool);
userPosition.tokensOwed0 += FullMath.mulDiv(
poolPosition.feeGrowthGlobal0 - userPosition.feeGrowth0,
userPosition.liquidity,
FixedPoint128.Q128
);
userPosition.tokensOwed1 += FullMath.mulDiv(
poolPosition.feeGrowthGlobal1 - userPosition.feeGrowth1,
userPosition.liquidity,
FixedPoint128.Q128
);
userPosition.liquidity += shares;
userPosition.feeGrowth0 = poolPosition.feeGrowthGlobal0;
userPosition.feeGrowth1 = poolPosition.feeGrowthGlobal1;
} else {
positions[tokenId] = Position({
nonce: 0,
pool: b.pool,
liquidity: shares,
feeGrowth0: poolPosition.feeGrowthGlobal0,
feeGrowth1: poolPosition.feeGrowthGlobal1,
tokensOwed0: 0,
tokensOwed1: 0
});
}
_checkDustAmount(
b.pool,
(b.amount0Base + b.amount0Range),
(b.amount1Base + b.amount1Range),
amount0Desired,
amount1Desired
);
emit Deposited(b.pool, tokenId, amount0Desired, amount1Desired, shares);
}
/// @inheritdoc IUniswapLiquidityManager
function withdraw(
bool pilotToken,
bool wethToken,
uint256 liquidity,
uint256 tokenId,
bytes memory data
) external payable override onlyUnipilot nonReentrant {
Position storage position = positions[tokenId];
require(liquidity > 0);
require(liquidity <= position.liquidity);
WithdrawVars memory c;
c.recipient = abi.decode(data, (address));
(c.amount0Removed, c.amount1Removed) = _removeLiquidityUniswap(
false,
position.pool,
liquidity
);
(c.userAmount0, c.userAmount1, c.pilotAmount) = _distributeFeesAndLiquidity(
DistributeFeesParams({
pilotToken: pilotToken,
wethToken: wethToken,
pool: position.pool,
recipient: c.recipient,
tokenId: tokenId,
liquidity: liquidity,
amount0Removed: c.amount0Removed,
amount1Removed: c.amount1Removed
})
);
emit Withdrawn(
position.pool,
c.recipient,
tokenId,
c.amount0Removed,
c.amount1Removed
);
}
/// @inheritdoc IUniswapLiquidityManager
function collect(
bool pilotToken,
bool wethToken,
uint256 tokenId,
bytes memory data
) external payable override onlyUnipilot nonReentrant {
Position memory position = positions[tokenId];
require(position.liquidity > 0);
address recipient = abi.decode(data, (address));
_collectPositionFees(position.pool);
_distributeFeesAndLiquidity(
DistributeFeesParams({
pilotToken: pilotToken,
wethToken: wethToken,
pool: position.pool,
recipient: recipient,
tokenId: tokenId,
liquidity: 0,
amount0Removed: 0,
amount1Removed: 0
})
);
}
/// @dev Returns the status of the vault that needs reabsing
function shouldReadjust(
address pool,
int24 baseTickLower,
int24 baseTickUpper
) public view returns (bool readjust) {
(, , , , , , int24 currentTick, ) = getPoolDetails(pool);
int24 threshold = IUniStrategy(unipilotProtocolDetails.uniStrategy)
.getReadjustThreshold(pool);
if (
(currentTick < (baseTickLower + threshold)) ||
(currentTick > (baseTickUpper - threshold))
) {
readjust = true;
} else {
readjust = false;
}
}
function getPoolDetails(address pool)
internal
view
returns (
address token0,
address token1,
uint24 fee,
uint16 poolCardinality,
uint128 liquidity,
uint160 sqrtPriceX96,
int24 currentTick,
int24 tickSpacing
)
{
IUniswapV3Pool uniswapPool = IUniswapV3Pool(pool);
token0 = uniswapPool.token0();
token1 = uniswapPool.token1();
fee = uniswapPool.fee();
liquidity = uniswapPool.liquidity();
(sqrtPriceX96, currentTick, , poolCardinality, , , ) = uniswapPool.slot0();
tickSpacing = uniswapPool.tickSpacing();
}
/// @notice burns all positions, collects any fees accrued and mints new base & range positions for vault.
/// @dev This function can be called by anyone, also user gets the tx fees + premium on chain for readjusting the vault
/// @dev Only those vaults are eligible for readjust incentive that have liquidity greater than 100,000 USD through Unipilot,
/// @dev Pools can be readjust 2 times in 24 hrs (more than 2 requirement means pool is too volatile)
/// @dev If all assets are converted in a single token then 2% amount will be swapped from vault total liquidity
/// in order to add in range liquidity rather than waiting for price to come in range
function readjustLiquidity(
address token0,
address token1,
uint24 fee
) external {
// @dev calculating the gas amount at the begining
uint256 initialGas = gasleft();
ReadjustVars memory b;
b.poolAddress = getPoolAddress(token0, token1, fee);
LiquidityPosition storage position = liquidityPositions[b.poolAddress];
require(!readjustFrequencyStatus(b.poolAddress));
require(
shouldReadjust(b.poolAddress, position.baseTickLower, position.baseTickUpper)
);
position.timestamp = block.timestamp;
(, , , , , b.sqrtPriceX96, , ) = getPoolDetails(b.poolAddress);
(b.amount0, b.amount1) = _removeLiquidityUniswap(
true,
b.poolAddress,
position.totalLiquidity
);
if ((b.amount0 == 0 || b.amount1 == 0)) {
(b.zeroForOne, b.amountIn) = b.amount0 > 0
? (true, b.amount0)
: (false, b.amount1);
b.exactSqrtPriceImpact =
(b.sqrtPriceX96 * (unipilotProtocolDetails.swapPriceThreshold / 2)) /
1e6;
b.sqrtPriceLimitX96 = b.zeroForOne
? b.sqrtPriceX96 - b.exactSqrtPriceImpact
: b.sqrtPriceX96 + b.exactSqrtPriceImpact;
b.amountIn = FullMath.mulDiv(
b.amountIn,
unipilotProtocolDetails.swapPercentage,
100
);
(int256 amount0Delta, int256 amount1Delta) = IUniswapV3Pool(b.poolAddress)
.swap(
address(this),
b.zeroForOne,
b.amountIn.toInt256(),
b.sqrtPriceLimitX96,
abi.encode(
(SwapCallbackData({ token0: token0, token1: token1, fee: fee }))
)
);
if (amount1Delta < 1) {
amount1Delta = -amount1Delta;
b.amount0 = b.amount0.sub(uint256(amount0Delta));
b.amount1 = b.amount1.add(uint256(amount1Delta));
} else {
amount0Delta = -amount0Delta;
b.amount0 = b.amount0.add(uint256(amount0Delta));
b.amount1 = b.amount1.sub(uint256(amount1Delta));
}
}
// @dev calculating new ticks for base & range positions
Tick memory ticks;
(
ticks.baseTickLower,
ticks.baseTickUpper,
ticks.bidTickLower,
ticks.bidTickUpper,
ticks.rangeTickLower,
ticks.rangeTickUpper
) = _getTicksFromUniStrategy(b.poolAddress);
(b.baseLiquidity, b.amount0Added, b.amount1Added, ) = _addLiquidityUniswap(
AddLiquidityParams({
token0: token0,
token1: token1,
fee: fee,
tickLower: ticks.baseTickLower,
tickUpper: ticks.baseTickUpper,
amount0Desired: b.amount0,
amount1Desired: b.amount1
})
);
(position.baseLiquidity, position.baseTickLower, position.baseTickUpper) = (
b.baseLiquidity,
ticks.baseTickLower,
ticks.baseTickUpper
);
uint256 amount0Remaining = b.amount0.sub(b.amount0Added);
uint256 amount1Remaining = b.amount1.sub(b.amount1Added);
(uint128 bidLiquidity, , ) = LiquidityReserves.getLiquidityAmounts(
ticks.bidTickLower,
ticks.bidTickUpper,
0,
amount0Remaining,
amount1Remaining,
IUniswapV3Pool(b.poolAddress)
);
(uint128 rangeLiquidity, , ) = LiquidityReserves.getLiquidityAmounts(
ticks.rangeTickLower,
ticks.rangeTickUpper,
0,
amount0Remaining,
amount1Remaining,
IUniswapV3Pool(b.poolAddress)
);
// @dev adding bid or range order on Uniswap depending on which token is left
if (bidLiquidity > rangeLiquidity) {
(, b.amount0Range, b.amount1Range, ) = _addLiquidityUniswap(
AddLiquidityParams({
token0: token0,
token1: token1,
fee: fee,
tickLower: ticks.bidTickLower,
tickUpper: ticks.bidTickUpper,
amount0Desired: amount0Remaining,
amount1Desired: amount1Remaining
})
);
(
position.rangeLiquidity,
position.rangeTickLower,
position.rangeTickUpper
) = (bidLiquidity, ticks.bidTickLower, ticks.bidTickUpper);
} else {
(, b.amount0Range, b.amount1Range, ) = _addLiquidityUniswap(
AddLiquidityParams({
token0: token0,
token1: token1,
fee: fee,
tickLower: ticks.rangeTickLower,
tickUpper: ticks.rangeTickUpper,
amount0Desired: amount0Remaining,
amount1Desired: amount1Remaining
})
);
(
position.rangeLiquidity,
position.rangeTickLower,
position.rangeTickUpper
) = (rangeLiquidity, ticks.rangeTickLower, ticks.rangeTickUpper);
}
position.counter += 1;
if (position.counter == 2) position.status = true;
if (position.managed) {
require(tx.gasprice <= unipilotProtocolDetails.gasPriceLimit);
b.gasUsed = (tx.gasprice.mul(initialGas.sub(gasleft()))).add(
unipilotProtocolDetails.premium
);
b.pilotAmount = IOracle(unipilotProtocolDetails.oracle).ethToAsset(
PILOT,
unipilotProtocolDetails.pilotWethPair,
b.gasUsed
);
_mintPilot(msg.sender, b.pilotAmount);
}
_checkDustAmount(
b.poolAddress,
(b.amount0Added + b.amount0Range),
(b.amount1Added + b.amount1Range),
b.amount0,
b.amount1
);
emit PoolReajusted(
b.poolAddress,
position.baseLiquidity,
position.rangeLiquidity,
position.baseTickLower,
position.baseTickUpper,
position.rangeTickLower,
position.rangeTickUpper
);
}
function emergencyExit(address recipient, bytes[10] memory data)
external
onlyGovernance
{
for (uint256 i = 0; i < data.length; ++i) {
(
address token,
address pool,
int24 tickLower,
int24 tickUpper,
uint128 liquidity
) = abi.decode(data[i], (address, address, int24, int24, uint128));
if (pool != address(0)) {
IUniswapV3Pool(pool).burn(tickLower, tickUpper, liquidity);
IUniswapV3Pool(pool).collect(
recipient,
tickLower,
tickUpper,
MAX_UINT128,
MAX_UINT128
);
}
uint256 balanceToken = IERC20(token).balanceOf(address(this));
if (balanceToken > 0) {
TransferHelper.safeTransfer(token, recipient, balanceToken);
}
}
}
/// @inheritdoc IUniswapLiquidityManager
function updatePositionTotalAmounts(address _pool)
public
view
override
returns (
uint256 amount0,
uint256 amount1,
uint256 totalLiquidity
)
{
LiquidityPosition memory position = liquidityPositions[_pool];
if (position.totalLiquidity > 0) {
return LiquidityPositions.getTotalAmounts(position, _pool);
}
}
function getPoolAddress(
address token0,
address token1,
uint24 fee
) private view returns (address) {
return IUniswapV3Factory(uniswapFactory).getPool(token0, token1, fee);
}
function _isUnipilot() private view {
require(msg.sender == unipilotProtocolDetails.unipilot);
}
function _isGovernance() private view {
require(msg.sender == IUnipilot(unipilotProtocolDetails.unipilot).governance());
}
function _mintPilot(address recipient, uint256 amount) private {
IUnipilot(unipilotProtocolDetails.unipilot).mintPilot(recipient, amount);
}
/// @dev fetches the new ticks for base and range positions
function _getTicksFromUniStrategy(address pool)
private
returns (
int24 baseTickLower,
int24 baseTickUpper,
int24 bidTickLower,
int24 bidTickUpper,
int24 rangeTickLower,
int24 rangeTickUpper
)
{
return IUniStrategy(unipilotProtocolDetails.uniStrategy).getTicks(pool);
}
/// @dev checks the dust amount durnig deposit
function _checkDustAmount(
address pool,
uint256 amount0Added,
uint256 amount1Added,
uint256 amount0Desired,
uint256 amount1Desired
) private {
LiquidityPosition storage poolPosition = liquidityPositions[pool];
uint256 dust0 = amount0Desired.sub(amount0Added);
uint256 dust1 = amount1Desired.sub(amount1Added);
if (dust0 > 0) {
poolPosition.fees0 += dust0;
poolPosition.feeGrowthGlobal0 += FullMath.mulDiv(
dust0,
FixedPoint128.Q128,
poolPosition.totalLiquidity
);
}
if (dust1 > 0) {
poolPosition.fees1 += dust1;
poolPosition.feeGrowthGlobal1 += FullMath.mulDiv(
dust1,
FixedPoint128.Q128,
poolPosition.totalLiquidity
);
}
}
/// @dev Do zero-burns to poke a position on Uniswap so earned fees are
/// updated. Should be called if total amounts needs to include up-to-date
/// fees.
function _updatePosition(
int24 tickLower,
int24 tickUpper,
uint128 liquidity,
IUniswapV3Pool pool
) private {
if (liquidity > 0) {
pool.burn(tickLower, tickUpper, 0);
}
}
/// @notice Deposits user liquidity in a range order of Unipilot vault.
/// @dev If the liquidity of vault is out of range then contract will add user liquidity in a range position
/// of the vault, user liquidity gets in range as soon as vault will be rebase again by anyone
/// @param pool Address of the uniswap pool
/// @param amount0 The desired amount of token0 to be spent
/// @param amount1 The desired amount of token1 to be spent,
/// @param shares Amount of shares minted
function _addRangeLiquidity(
address pool,
uint256 amount0,
uint256 amount1,
uint256 shares
) private returns (uint256 amount0Range, uint256 amount1Range) {
RangeLiquidityVars memory b;
(b.token0, b.token1, b.fee, , , , , ) = getPoolDetails(pool);
LiquidityPosition storage position = liquidityPositions[pool];
(b.rangeLiquidity, b.amount0Range, b.amount1Range, ) = _addLiquidityUniswap(
AddLiquidityParams({
token0: b.token0,
token1: b.token1,
fee: b.fee,
tickLower: position.rangeTickLower,
tickUpper: position.rangeTickUpper,
amount0Desired: amount0,
amount1Desired: amount1
})
);
position.rangeLiquidity += b.rangeLiquidity;
position.totalLiquidity += shares;
(amount0Range, amount1Range) = (b.amount0Range, b.amount1Range);
}
/// @dev Deposits liquidity in a range on the UniswapV3 pool.
/// @param params The params necessary to mint a position, encoded as `AddLiquidityParams`
/// @return liquidity Amount of liquidity added in a range on UniswapV3
/// @return amount0 Amount of token0 added in a range
/// @return amount1 Amount of token1 added in a range
/// @return pool Instance of the UniswapV3 pool
function _addLiquidityUniswap(AddLiquidityParams memory params)
private
returns (
uint128 liquidity,
uint256 amount0,
uint256 amount1,
IUniswapV3Pool pool
)
{
pool = IUniswapV3Pool(getPoolAddress(params.token0, params.token1, params.fee));
(liquidity, , ) = LiquidityReserves.getLiquidityAmounts(
params.tickLower,
params.tickUpper,
0,
params.amount0Desired,
params.amount1Desired,
pool
);
(amount0, amount1) = pool.mint(
address(this),
params.tickLower,
params.tickUpper,
liquidity,
abi.encode(
(
MintCallbackData({
payer: address(this),
token0: params.token0,
token1: params.token1,
fee: params.fee
})
)
)
);
}
function _removeLiquiditySingle(
int24 tickLower,
int24 tickUpper,
uint128 liquidity,
uint256 liquiditySharePercentage,
IUniswapV3Pool pool
) private returns (RemoveLiquidity memory removedLiquidity) {
uint256 amount0;
uint256 amount1;
uint128 liquidityRemoved = _uint256ToUint128(
FullMath.mulDiv(liquidity, liquiditySharePercentage, 1e18)
);
if (liquidity > 0) {
(amount0, amount1) = pool.burn(tickLower, tickUpper, liquidityRemoved);
}
(uint256 collect0, uint256 collect1) = pool.collect(
address(this),
tickLower,
tickUpper,
MAX_UINT128,
MAX_UINT128
);
removedLiquidity = RemoveLiquidity(
amount0,
amount1,
liquidityRemoved,
collect0.sub(amount0),
collect1.sub(amount1)
);
}
/// @dev Do zero-burns to poke a position on Uniswap so earned fees & feeGrowthGlobal of vault are updated
function _collectPositionFees(address _pool) private {
LiquidityPosition storage position = liquidityPositions[_pool];
IUniswapV3Pool pool = IUniswapV3Pool(_pool);
_updatePosition(
position.baseTickLower,
position.baseTickUpper,
position.baseLiquidity,
pool
);
_updatePosition(
position.rangeTickLower,
position.rangeTickUpper,
position.rangeLiquidity,
pool
);
(uint256 collect0Base, uint256 collect1Base) = pool.collect(
address(this),
position.baseTickLower,
position.baseTickUpper,
MAX_UINT128,
MAX_UINT128
);
(uint256 collect0Range, uint256 collect1Range) = pool.collect(
address(this),
position.rangeTickLower,
position.rangeTickUpper,
MAX_UINT128,
MAX_UINT128
);
position.fees0 = position.fees0.add((collect0Base.add(collect0Range)));
position.fees1 = position.fees1.add((collect1Base.add(collect1Range)));
position.feeGrowthGlobal0 += FullMath.mulDiv(
collect0Base + collect0Range,
FixedPoint128.Q128,
position.totalLiquidity
);
position.feeGrowthGlobal1 += FullMath.mulDiv(
collect1Base + collect1Range,
FixedPoint128.Q128,
position.totalLiquidity
);
}
/// @notice Increases the amount of liquidity in a base & range positions of the vault, with tokens paid by the sender
/// @param pool Address of the uniswap pool
/// @param amount0Desired The desired amount of token0 to be spent
/// @param amount1Desired The desired amount of token1 to be spent,
/// @param shares Amount of shares minted
function _increaseLiquidity(
address pool,
uint256 amount0Desired,
uint256 amount1Desired,
uint256 shares
)
private
returns (
uint256 amount0Base,
uint256 amount1Base,
uint256 amount0Range,
uint256 amount1Range
)
{
LiquidityPosition storage position = liquidityPositions[pool];
IncreaseParams memory a;
(a.token0, a.token1, a.fee, , , , a.currentTick, ) = getPoolDetails(pool);
if (
a.currentTick < position.baseTickLower ||
a.currentTick > position.baseTickUpper
) {
(amount0Range, amount1Range) = _addRangeLiquidity(
pool,
amount0Desired,
amount1Desired,
shares
);
} else {
uint256 liquidityOffset = a.currentTick >= position.rangeTickLower &&
a.currentTick <= position.rangeTickUpper
? 1
: 0;
(a.baseLiquidity, a.baseAmount0, a.baseAmount1, ) = _addLiquidityUniswap(
AddLiquidityParams({
token0: a.token0,
token1: a.token1,
fee: a.fee,
tickLower: position.baseTickLower,
tickUpper: position.baseTickUpper,
amount0Desired: amount0Desired.sub(liquidityOffset),
amount1Desired: amount1Desired.sub(liquidityOffset)
})
);
(a.rangeLiquidity, a.rangeAmount0, a.rangeAmount1, ) = _addLiquidityUniswap(
AddLiquidityParams({
token0: a.token0,
token1: a.token1,
fee: a.fee,
tickLower: position.rangeTickLower,
tickUpper: position.rangeTickUpper,
amount0Desired: amount0Desired.sub(a.baseAmount0),
amount1Desired: amount1Desired.sub(a.baseAmount1)
})
);
position.baseLiquidity += a.baseLiquidity;
position.rangeLiquidity += a.rangeLiquidity;
position.totalLiquidity += shares;
(amount0Base, amount1Base) = (a.baseAmount0, a.baseAmount1);
(amount0Range, amount1Range) = (a.rangeAmount0, a.rangeAmount1);
}
}
/// @dev Two orders are placed - a base order and a range order. The base
/// order is placed first with as much liquidity as possible. This order
/// should use up all of one token, leaving only the other one. This excess
/// amount is then placed as a single-sided bid or ask order.
function _addLiquidityInManager(AddLiquidityManagerParams memory params)
private
returns (
uint256 amount0Base,
uint256 amount1Base,
uint256 amount0Range,
uint256 amount1Range
)
{
TokenDetails memory tokenDetails;
(
tokenDetails.token0,
tokenDetails.token1,
tokenDetails.fee,
tokenDetails.poolCardinality,
,
,
tokenDetails.currentTick,
) = getPoolDetails(params.pool);
LiquidityPosition storage position = liquidityPositions[params.pool];
if (position.totalLiquidity > 0) {
(amount0Base, amount1Base, amount0Range, amount1Range) = _increaseLiquidity(
params.pool,
params.amount0Desired,
params.amount1Desired,
params.shares
);
} else {
if (
tokenDetails.poolCardinality <
unipilotProtocolDetails.poolCardinalityDesired
)
IUniswapV3Pool(params.pool).increaseObservationCardinalityNext(
unipilotProtocolDetails.poolCardinalityDesired
);
// @dev calculate new ticks for base & range order
Tick memory ticks;
(
ticks.baseTickLower,
ticks.baseTickUpper,
ticks.bidTickLower,
ticks.bidTickUpper,
ticks.rangeTickLower,
ticks.rangeTickUpper
) = _getTicksFromUniStrategy(params.pool);
if (position.baseTickLower != 0 && position.baseTickUpper != 0) {
if (
tokenDetails.currentTick < position.baseTickLower ||
tokenDetails.currentTick > position.baseTickUpper
) {
(amount0Range, amount1Range) = _addRangeLiquidity(
params.pool,
params.amount0Desired,
params.amount1Desired,
params.shares
);
}
} else {
(
tokenDetails.baseLiquidity,
tokenDetails.amount0Added,
tokenDetails.amount1Added,
) = _addLiquidityUniswap(
AddLiquidityParams({
token0: tokenDetails.token0,
token1: tokenDetails.token1,
fee: tokenDetails.fee,
tickLower: ticks.baseTickLower,
tickUpper: ticks.baseTickUpper,
amount0Desired: params.amount0Desired,
amount1Desired: params.amount1Desired
})
);
(
position.baseLiquidity,
position.baseTickLower,
position.baseTickUpper
) = (
tokenDetails.baseLiquidity,
ticks.baseTickLower,
ticks.baseTickUpper
);
{
uint256 amount0 = params.amount0Desired.sub(
tokenDetails.amount0Added
);
uint256 amount1 = params.amount1Desired.sub(
tokenDetails.amount1Added
);
(tokenDetails.bidLiquidity, , ) = LiquidityReserves
.getLiquidityAmounts(
ticks.bidTickLower,
ticks.bidTickUpper,
0,
amount0,
amount1,
IUniswapV3Pool(params.pool)
);
(tokenDetails.rangeLiquidity, , ) = LiquidityReserves
.getLiquidityAmounts(
ticks.rangeTickLower,
ticks.rangeTickUpper,
0,
amount0,
amount1,
IUniswapV3Pool(params.pool)
);
// adding bid or range order on Uniswap depending on which token is left
if (tokenDetails.bidLiquidity > tokenDetails.rangeLiquidity) {
(, amount0Range, amount1Range, ) = _addLiquidityUniswap(
AddLiquidityParams({
token0: tokenDetails.token0,
token1: tokenDetails.token1,
fee: tokenDetails.fee,
tickLower: ticks.bidTickLower,
tickUpper: ticks.bidTickUpper,
amount0Desired: amount0,
amount1Desired: amount1
})
);
(
position.rangeLiquidity,
position.rangeTickLower,
position.rangeTickUpper
) = (
tokenDetails.bidLiquidity,
ticks.bidTickLower,
ticks.bidTickUpper
);
(amount0Base, amount1Base) = (
tokenDetails.amount0Added,
tokenDetails.amount1Added
);
} else {
(, amount0Range, amount1Range, ) = _addLiquidityUniswap(
AddLiquidityParams({
token0: tokenDetails.token0,
token1: tokenDetails.token1,
fee: tokenDetails.fee,
tickLower: ticks.rangeTickLower,
tickUpper: ticks.rangeTickUpper,
amount0Desired: amount0,
amount1Desired: amount1
})
);
(
position.rangeLiquidity,
position.rangeTickLower,
position.rangeTickUpper
) = (
tokenDetails.rangeLiquidity,
ticks.rangeTickLower,
ticks.rangeTickUpper
);
(amount0Base, amount1Base) = (
tokenDetails.amount0Added,
tokenDetails.amount1Added
);
}
}
position.totalLiquidity = position.totalLiquidity.add(params.shares);
}
}
}
/// @notice Convert 100% fees of the user in PILOT and transfer it to user
/// @dev token0 & token1 amount of user fees will be transfered to index fund
/// @param _recipient The account that should receive the PILOT,
/// @param _token0 The address of the token0 for a specific pool
/// @param _token1 The address of the token0 for a specific pool
/// @param _tokensOwed0 The uncollected amount of token0 fees to the user position as of the last computation
/// @param _tokensOwed1 The uncollected amount of token1 fees to the user position as of the last computation
function _distributeFeesInPilot(
address _recipient,
address _token0,
address _token1,
uint256 _tokensOwed0,
uint256 _tokensOwed1,
address _oracle0,
address _oracle1
) private returns (uint256 _pilotAmount) {
// if the incoming pair is weth pair then compute the amount
// of PILOT w.r.t alt token amount and the weth amount
uint256 _pilotAmountInitial = _token0 == WETH
? IOracle(unipilotProtocolDetails.oracle).getPilotAmountWethPair(
_token1,
_tokensOwed1,
_tokensOwed0,
_oracle1
)
: IOracle(unipilotProtocolDetails.oracle).getPilotAmountForTokens(
_token0,
_token1,
_tokensOwed0,
_tokensOwed1,
_oracle0,
_oracle1
);
_pilotAmount = FullMath.mulDiv(
_pilotAmountInitial,
unipilotProtocolDetails.userPilotPercentage,
100
);
_mintPilot(_recipient, _pilotAmount);
if (_tokensOwed0 > 0)
TransferHelper.safeTransfer(
_token0,
unipilotProtocolDetails.indexFund,
_tokensOwed0
);
if (_tokensOwed1 > 0)
TransferHelper.safeTransfer(
_token1,
unipilotProtocolDetails.indexFund,
_tokensOwed1
);
}
/// @notice Distribute the maximum amount of fees after calculating the percentage of user & index fund
/// @dev Total fees of user will be distributed in two parts i.e 98% will be transferred to user & remaining 2% to index fund
/// @param wethToken Boolean if the user wants fees in WETH or ETH, always false if it is not weth/alt pair
/// @param _recipient The account that should receive the PILOT,
/// @param _token0 The address of the token0 for a specific pool
/// @param _token1 The address of the token0 for a specific pool
/// @param _tokensOwed0 The uncollected amount of token0 fees to the user position as of the last computation
/// @param _tokensOwed1 The uncollected amount of token1 fees to the user position as of the last computation
function _distributeFeesInTokens(
bool wethToken,
address _recipient,
address _token0,
address _token1,
uint256 _tokensOwed0,
uint256 _tokensOwed1
) private {
(
uint256 _indexAmount0,
uint256 _indexAmount1,
uint256 _userBalance0,
uint256 _userBalance1
) = UserPositions.getUserAndIndexShares(
_tokensOwed0,
_tokensOwed1,
unipilotProtocolDetails.feesPercentageIndexFund
);
if (_tokensOwed0 > 0) {
if (_token0 == WETH && !wethToken) {
IWETH9(WETH).withdraw(_userBalance0);
TransferHelper.safeTransferETH(_recipient, _userBalance0);
} else {
TransferHelper.safeTransfer(_token0, _recipient, _userBalance0);
}
TransferHelper.safeTransfer(
_token0,
unipilotProtocolDetails.indexFund,
_indexAmount0
);
}
if (_tokensOwed1 > 0) {
if (_token1 == WETH && !wethToken) {
IWETH9(WETH).withdraw(_userBalance1);
TransferHelper.safeTransferETH(_recipient, _userBalance1);
} else {
TransferHelper.safeTransfer(_token1, _recipient, _userBalance1);
}
TransferHelper.safeTransfer(
_token1,
unipilotProtocolDetails.indexFund,
_indexAmount1
);
}
}
/// @notice Transfer the amount of liquidity to user which has been removed from base & range position of the vault
/// @param _token0 The address of the token0 for a specific pool
/// @param _token1 The address of the token1 for a specific pool
/// @param wethToken Boolean whether to recieve liquidity in WETH or ETH (only valid for WETH/ALT pairs)
/// @param _recipient The account that should receive the liquidity amounts
/// @param amount0Removed The amount of token0 that has been removed from base & range positions
/// @param amount1Removed The amount of token1 that has been removed from base & range positions
function _transferLiquidity(
address _token0,
address _token1,
bool wethToken,
address _recipient,
uint256 amount0Removed,
uint256 amount1Removed
) private {
if (_token0 == WETH || _token1 == WETH) {
(
address tokenAlt,
uint256 altAmount,
address tokenWeth,
uint256 wethAmount
) = _token0 == WETH
? (_token1, amount1Removed, _token0, amount0Removed)
: (_token0, amount0Removed, _token1, amount1Removed);
if (wethToken) {
if (amount0Removed > 0)
TransferHelper.safeTransfer(tokenWeth, _recipient, wethAmount);
if (amount1Removed > 0)
TransferHelper.safeTransfer(tokenAlt, _recipient, altAmount);
} else {
if (wethAmount > 0) {
IWETH9(WETH).withdraw(wethAmount);
TransferHelper.safeTransferETH(_recipient, wethAmount);
}
if (altAmount > 0)
TransferHelper.safeTransfer(tokenAlt, _recipient, altAmount);
}
} else {
if (amount0Removed > 0)
TransferHelper.safeTransfer(_token0, _recipient, amount0Removed);
if (amount1Removed > 0)
TransferHelper.safeTransfer(_token1, _recipient, amount1Removed);
}
}
function _distributeFeesAndLiquidity(DistributeFeesParams memory params)
private
returns (
uint256 userAmount0,
uint256 userAmount1,
uint256 pilotAmount
)
{
WithdrawTokenOwedParams memory a;
LiquidityPosition storage position = liquidityPositions[params.pool];
Position storage userPosition = positions[params.tokenId];
(a.token0, a.token1, , , , , , ) = getPoolDetails(params.pool);
(a.tokensOwed0, a.tokensOwed1) = UserPositions.getTokensOwedAmount(
userPosition.feeGrowth0,
userPosition.feeGrowth1,
userPosition.liquidity,
position.feeGrowthGlobal0,
position.feeGrowthGlobal1
);
userPosition.tokensOwed0 += a.tokensOwed0;
userPosition.tokensOwed1 += a.tokensOwed1;
userPosition.feeGrowth0 = position.feeGrowthGlobal0;
userPosition.feeGrowth1 = position.feeGrowthGlobal1;
if (position.feesInPilot && params.pilotToken) {
if (a.token0 == WETH || a.token1 == WETH) {
(
address tokenAlt,
uint256 altAmount,
address altOracle,
address tokenWeth,
uint256 wethAmount,
address wethOracle
) = a.token0 == WETH
? (
a.token1,
userPosition.tokensOwed1,
position.oracle1,
a.token0,
userPosition.tokensOwed0,
position.oracle0
)
: (
a.token0,
userPosition.tokensOwed0,
position.oracle0,
a.token1,
userPosition.tokensOwed1,
position.oracle1
);
pilotAmount = _distributeFeesInPilot(
params.recipient,
tokenWeth,
tokenAlt,
wethAmount,
altAmount,
wethOracle,
altOracle
);
} else {
pilotAmount = _distributeFeesInPilot(
params.recipient,
a.token0,
a.token1,
userPosition.tokensOwed0,
userPosition.tokensOwed1,
position.oracle0,
position.oracle1
);
}
} else {
_distributeFeesInTokens(
params.wethToken,
params.recipient,
a.token0,
a.token1,
userPosition.tokensOwed0,
userPosition.tokensOwed1
);
}
_transferLiquidity(
a.token0,
a.token1,
params.wethToken,
params.recipient,
params.amount0Removed,
params.amount1Removed
);
(userAmount0, userAmount1) = (userPosition.tokensOwed0, userPosition.tokensOwed1);
position.fees0 = position.fees0.sub(userPosition.tokensOwed0);
position.fees1 = position.fees1.sub(userPosition.tokensOwed1);
userPosition.tokensOwed0 = 0;
userPosition.tokensOwed1 = 0;
userPosition.liquidity = userPosition.liquidity.sub(params.liquidity);
emit Collect(
params.tokenId,
userAmount0,
userAmount1,
pilotAmount,
params.pool,
params.recipient
);
}
/// @notice Decreases the amount of liquidity (base and range positions) from Uniswap pool and collects all fees in the process.
/// @dev Total liquidity of Unipilot vault won't decrease in readjust because same liquidity amount is added
/// again in Uniswap, total liquidity will only decrease if user is withdrawing his share from vault
/// @param isRebase Boolean for the readjust liquidity function for not decreasing the total liquidity of vault
/// @param pool Address of the Uniswap pool
/// @param liquidity Liquidity amount of vault to remove from Uniswap positions
/// @return amount0Removed The amount of token0 removed from base & range positions
/// @return amount1Removed The amount of token1 removed from base & range positions
function _removeLiquidityUniswap(
bool isRebase,
address pool,
uint256 liquidity
) private returns (uint256 amount0Removed, uint256 amount1Removed) {
LiquidityPosition storage position = liquidityPositions[pool];
IUniswapV3Pool uniswapPool = IUniswapV3Pool(pool);
uint256 liquiditySharePercentage = FullMath.mulDiv(
liquidity,
1e18,
position.totalLiquidity
);
RemoveLiquidity memory bl = _removeLiquiditySingle(
position.baseTickLower,
position.baseTickUpper,
position.baseLiquidity,
liquiditySharePercentage,
uniswapPool
);
RemoveLiquidity memory rl = _removeLiquiditySingle(
position.rangeTickLower,
position.rangeTickUpper,
position.rangeLiquidity,
liquiditySharePercentage,
uniswapPool
);
position.fees0 = position.fees0.add(bl.feesCollected0.add(rl.feesCollected0));
position.fees1 = position.fees1.add(bl.feesCollected1.add(rl.feesCollected1));
position.feeGrowthGlobal0 += FullMath.mulDiv(
bl.feesCollected0 + rl.feesCollected0,
FixedPoint128.Q128,
position.totalLiquidity
);
position.feeGrowthGlobal1 += FullMath.mulDiv(
bl.feesCollected1 + rl.feesCollected1,
FixedPoint128.Q128,
position.totalLiquidity
);
amount0Removed = bl.amount0.add(rl.amount0);
amount1Removed = bl.amount1.add(rl.amount1);
if (!isRebase) {
position.totalLiquidity = position.totalLiquidity.sub(liquidity);
}
position.baseLiquidity = position.baseLiquidity - bl.liquidityRemoved;
position.rangeLiquidity = position.rangeLiquidity - rl.liquidityRemoved;
// @dev reseting the positions to initial state if total liquidity of vault gets zero
/// in order to calculate the amounts correctly from getSharesAndAmounts
if (position.totalLiquidity == 0) {
(position.baseTickLower, position.baseTickUpper) = (0, 0);
(position.rangeTickLower, position.rangeTickUpper) = (0, 0);
}
}
/// @notice Verify that caller should be the address of a valid Uniswap V3 Pool
/// @param token0 The contract address of token0
/// @param token1 The contract address of token1
/// @param fee Fee tier of the pool
function _verifyCallback(
address token0,
address token1,
uint24 fee
) private view {
require(msg.sender == getPoolAddress(token0, token1, fee));
}
function _uint256ToUint128(uint256 value) private pure returns (uint128) {
assert(value <= type(uint128).max);
return uint128(value);
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title The interface for the Uniswap V3 Factory
/// @notice The Uniswap V3 Factory facilitates creation of Uniswap V3 pools and control over the protocol fees
interface IUniswapV3Factory {
/// @notice Emitted when the owner of the factory is changed
/// @param oldOwner The owner before the owner was changed
/// @param newOwner The owner after the owner was changed
event OwnerChanged(address indexed oldOwner, address indexed newOwner);
/// @notice Emitted when a pool is created
/// @param token0 The first token of the pool by address sort order
/// @param token1 The second token of the pool by address sort order
/// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
/// @param tickSpacing The minimum number of ticks between initialized ticks
/// @param pool The address of the created pool
event PoolCreated(
address indexed token0,
address indexed token1,
uint24 indexed fee,
int24 tickSpacing,
address pool
);
/// @notice Emitted when a new fee amount is enabled for pool creation via the factory
/// @param fee The enabled fee, denominated in hundredths of a bip
/// @param tickSpacing The minimum number of ticks between initialized ticks for pools created with the given fee
event FeeAmountEnabled(uint24 indexed fee, int24 indexed tickSpacing);
/// @notice Returns the current owner of the factory
/// @dev Can be changed by the current owner via setOwner
/// @return The address of the factory owner
function owner() external view returns (address);
/// @notice Returns the tick spacing for a given fee amount, if enabled, or 0 if not enabled
/// @dev A fee amount can never be removed, so this value should be hard coded or cached in the calling context
/// @param fee The enabled fee, denominated in hundredths of a bip. Returns 0 in case of unenabled fee
/// @return The tick spacing
function feeAmountTickSpacing(uint24 fee) external view returns (int24);
/// @notice Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist
/// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order
/// @param tokenA The contract address of either token0 or token1
/// @param tokenB The contract address of the other token
/// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
/// @return pool The pool address
function getPool(
address tokenA,
address tokenB,
uint24 fee
) external view returns (address pool);
/// @notice Creates a pool for the given two tokens and fee
/// @param tokenA One of the two tokens in the desired pool
/// @param tokenB The other of the two tokens in the desired pool
/// @param fee The desired fee for the pool
/// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved
/// from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments
/// are invalid.
/// @return pool The address of the newly created pool
function createPool(
address tokenA,
address tokenB,
uint24 fee
) external returns (address pool);
/// @notice Updates the owner of the factory
/// @dev Must be called by the current owner
/// @param _owner The new owner of the factory
function setOwner(address _owner) external;
/// @notice Enables a fee amount with the given tickSpacing
/// @dev Fee amounts may never be removed once enabled
/// @param fee The fee amount to enable, denominated in hundredths of a bip (i.e. 1e-6)
/// @param tickSpacing The spacing between ticks to be enforced for all pools created with the given fee amount
function enableFeeAmount(uint24 fee, int24 tickSpacing) external;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.6;
pragma abicoder v2;
interface IUniStrategy {
struct PoolStrategy {
int24 baseThreshold;
int24 rangeThreshold;
int24 maxTwapDeviation;
int24 readjustThreshold;
uint32 twapDuration;
}
event StrategyUpdated(PoolStrategy oldStrategy, PoolStrategy newStrategy);
event MaxTwapDeviationUpdated(int24 oldDeviation, int24 newDeviation);
event BaseMultiplierUpdated(int24 oldMultiplier, int24 newMultiplier);
event RangeMultiplierUpdated(int24 oldMultiplier, int24 newMultiplier);
event PriceThresholdUpdated(uint24 oldThreshold, uint24 newThreshold);
event SwapPercentageUpdated(uint8 oldPercentage, uint8 newPercentage);
event TwapDurationUpdated(uint32 oldDuration, uint32 newDuration);
function getTicks(address _pool)
external
returns (
int24 baseLower,
int24 baseUpper,
int24 bidLower,
int24 bidUpper,
int24 askLower,
int24 askUpper
);
function getReadjustThreshold(address _pool)
external
view
returns (int24 readjustThreshold);
function getTwap(address _pool) external view returns (int24);
}// SPDX-License-Identifier: MIT
pragma solidity >=0.7.6;
pragma abicoder v2;
import "./IExchangeManager.sol";
interface IUnipilot {
struct DepositVars {
uint256 totalAmount0;
uint256 totalAmount1;
uint256 totalLiquidity;
uint256 shares;
}
event ExchangeWhitelisted(address newExchange);
event ExchangeStatus(address exchange, bool status);
event GovernanceUpdated(address oldGovernance, address newGovernance);
function governance() external view returns (address);
function mintProxy() external view returns (address);
function mintPilot(address recipient, uint256 amount) external;
function deposit(IExchangeManager.DepositParams memory params, bytes memory data)
external
payable
returns (uint256 amount0Added, uint256 amount1Added);
function createPoolAndDeposit(
IExchangeManager.DepositParams memory params,
bytes[2] calldata data
)
external
payable
returns (
uint256 amount0Added,
uint256 amount1Added,
uint256 mintedTokenId
);
function exchangeManagerWhitelist(address exchange) external view returns (bool);
}// SPDX-License-Identifier: MIT
pragma solidity >=0.7.6;
pragma abicoder v2;
import "./IULMEvents.sol";
interface IUniswapLiquidityManager is IULMEvents {
struct LiquidityPosition {
// base order position
int24 baseTickLower;
int24 baseTickUpper;
uint128 baseLiquidity;
// range order position
int24 rangeTickLower;
int24 rangeTickUpper;
uint128 rangeLiquidity;
// accumulated fees
uint256 fees0;
uint256 fees1;
uint256 feeGrowthGlobal0;
uint256 feeGrowthGlobal1;
// total liquidity
uint256 totalLiquidity;
// pool premiums
bool feesInPilot;
// oracle address for tokens to fetch prices from
address oracle0;
address oracle1;
// rebase
uint256 timestamp;
uint8 counter;
bool status;
bool managed;
}
struct Position {
uint256 nonce;
address pool;
uint256 liquidity;
uint256 feeGrowth0;
uint256 feeGrowth1;
uint256 tokensOwed0;
uint256 tokensOwed1;
}
struct ReadjustVars {
bool zeroForOne;
address poolAddress;
int24 currentTick;
uint160 sqrtPriceX96;
uint160 exactSqrtPriceImpact;
uint160 sqrtPriceLimitX96;
uint128 baseLiquidity;
uint256 amount0;
uint256 amount1;
uint256 amountIn;
uint256 amount0Added;
uint256 amount1Added;
uint256 amount0Range;
uint256 amount1Range;
uint256 currentTimestamp;
uint256 gasUsed;
uint256 pilotAmount;
}
struct VarsEmerency {
address token;
address pool;
int24 tickLower;
int24 tickUpper;
uint128 liquidity;
}
struct WithdrawVars {
address recipient;
uint256 amount0Removed;
uint256 amount1Removed;
uint256 userAmount0;
uint256 userAmount1;
uint256 pilotAmount;
}
struct WithdrawTokenOwedParams {
address token0;
address token1;
uint256 tokensOwed0;
uint256 tokensOwed1;
}
struct MintCallbackData {
address payer;
address token0;
address token1;
uint24 fee;
}
struct UnipilotProtocolDetails {
uint8 swapPercentage;
uint24 swapPriceThreshold;
uint256 premium;
uint256 gasPriceLimit;
uint256 userPilotPercentage;
uint256 feesPercentageIndexFund;
uint24 readjustFrequencyTime;
uint16 poolCardinalityDesired;
address pilotWethPair;
address oracle;
address indexFund; // 10%
address uniStrategy;
address unipilot;
}
struct SwapCallbackData {
address token0;
address token1;
uint24 fee;
}
struct AddLiquidityParams {
address token0;
address token1;
uint24 fee;
int24 tickLower;
int24 tickUpper;
uint256 amount0Desired;
uint256 amount1Desired;
}
struct RemoveLiquidity {
uint256 amount0;
uint256 amount1;
uint128 liquidityRemoved;
uint256 feesCollected0;
uint256 feesCollected1;
}
struct Tick {
int24 baseTickLower;
int24 baseTickUpper;
int24 bidTickLower;
int24 bidTickUpper;
int24 rangeTickLower;
int24 rangeTickUpper;
}
struct TokenDetails {
address token0;
address token1;
uint24 fee;
int24 currentTick;
uint16 poolCardinality;
uint128 baseLiquidity;
uint128 bidLiquidity;
uint128 rangeLiquidity;
uint256 amount0Added;
uint256 amount1Added;
}
struct DistributeFeesParams {
bool pilotToken;
bool wethToken;
address pool;
address recipient;
uint256 tokenId;
uint256 liquidity;
uint256 amount0Removed;
uint256 amount1Removed;
}
struct AddLiquidityManagerParams {
address pool;
uint256 amount0Desired;
uint256 amount1Desired;
uint256 shares;
}
struct DepositVars {
uint24 fee;
address pool;
uint256 amount0Base;
uint256 amount1Base;
uint256 amount0Range;
uint256 amount1Range;
}
struct RangeLiquidityVars {
address token0;
address token1;
uint24 fee;
uint128 rangeLiquidity;
uint256 amount0Range;
uint256 amount1Range;
}
struct IncreaseParams {
address token0;
address token1;
uint24 fee;
int24 currentTick;
uint128 baseLiquidity;
uint256 baseAmount0;
uint256 baseAmount1;
uint128 rangeLiquidity;
uint256 rangeAmount0;
uint256 rangeAmount1;
}
/// @notice Pull in tokens from sender. Called to `msg.sender` after minting liquidity to a position from IUniswapV3Pool#mint.
/// @dev In the implementation you must pay to the pool for the minted liquidity.
/// @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;
/// @notice Called to `msg.sender` after minting swaping from IUniswapV3Pool#swap.
/// @dev In the implementation you must pay to the pool for swap.
/// @param amount0Delta The amount of token0 due to the pool for the swap
/// @param amount1Delta The amount of token1 due to the pool for the swap
/// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call
function uniswapV3SwapCallback(
int256 amount0Delta,
int256 amount1Delta,
bytes calldata data
) external;
/// @notice Returns the user position information associated with a given token ID.
/// @param tokenId The ID of the token that represents the position
/// @return Position
/// - nonce The nonce for permits
/// - pool Address of the uniswap V3 pool
/// - liquidity The liquidity of the position
/// - feeGrowth0 The fee growth of token0 as of the last action on the individual position
/// - feeGrowth1 The fee growth of token1 as of the last action on the individual position
/// - tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation
/// - tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation
function userPositions(uint256 tokenId) external view returns (Position memory);
/// @notice Returns the vault information of unipilot base & range orders
/// @param pool Address of the Uniswap pool
/// @return LiquidityPosition
/// - baseTickLower The lower tick of the base position
/// - baseTickUpper The upper tick of the base position
/// - baseLiquidity The total liquidity of the base position
/// - rangeTickLower The lower tick of the range position
/// - rangeTickUpper The upper tick of the range position
/// - rangeLiquidity The total liquidity of the range position
/// - fees0 Total amount of fees collected by unipilot positions in terms of token0
/// - fees1 Total amount of fees collected by unipilot positions in terms of token1
/// - feeGrowthGlobal0 The fee growth of token0 collected per unit of liquidity for
/// the entire life of the unipilot vault
/// - feeGrowthGlobal1 The fee growth of token1 collected per unit of liquidity for
/// the entire life of the unipilot vault
/// - totalLiquidity Total amount of liquidity of vault including base & range orders
function poolPositions(address pool) external view returns (LiquidityPosition memory);
/// @notice Calculates the vault's total holdings of token0 and token1 - in
/// other words, how much of each token the vault would hold if it withdrew
/// all its liquidity from Uniswap.
/// @param _pool Address of the uniswap pool
/// @return amount0 Total amount of token0 in vault
/// @return amount1 Total amount of token1 in vault
/// @return totalLiquidity Total liquidity of the vault
function updatePositionTotalAmounts(address _pool)
external
view
returns (
uint256 amount0,
uint256 amount1,
uint256 totalLiquidity
);
/// @notice Calculates the vault's total holdings of TOKEN0 and TOKEN1 - in
/// other words, how much of each token the vault would hold if it withdrew
/// all its liquidity from Uniswap.
/// @dev Updates the position and return the latest reserves & liquidity.
/// @param token0 token0 of the pool
/// @param token0 token1 of the pool
/// @param data any necessary data needed to get reserves
/// @return totalAmount0 Amount of token0 in the pool of unipilot
/// @return totalAmount1 Amount of token1 in the pool of unipilot
/// @return totalLiquidity Total liquidity available in unipilot pool
function getReserves(
address token0,
address token1,
bytes calldata data
)
external
returns (
uint256 totalAmount0,
uint256 totalAmount1,
uint256 totalLiquidity
);
/// @notice Creates a new pool & then initializes the pool
/// @param _token0 The contract address of token0 of the pool
/// @param _token1 The contract address of token1 of the pool
/// @param data Necessary data needed to create pool
/// In data we will provide the `fee` amount of the v3 pool for the specified token pair,
/// also `sqrtPriceX96` The initial square root price of the pool
/// @return _pool Returns the pool address based on the pair of tokens and fee, will return the newly created pool address
function createPair(
address _token0,
address _token1,
bytes memory data
) external returns (address _pool);
/// @notice Deposits tokens in proportion to the Unipilot's current ticks, mints them
/// `Unipilot`s NFT.
/// @param token0 The first of the two tokens of the pool, sorted by address
/// @param token1 The second of the two tokens of the pool, sorted by address
/// @param amount0Desired Max amount of token0 to deposit
/// @param amount1Desired Max amount of token1 to deposit
/// @param shares Number of shares minted
/// @param tokenId Token Id of Unipilot
/// @param isTokenMinted Boolean to check the minting of new tokenId of Unipilot
/// @param data Necessary data needed to deposit
function deposit(
address token0,
address token1,
uint256 amount0Desired,
uint256 amount1Desired,
uint256 shares,
uint256 tokenId,
bool isTokenMinted,
bytes memory data
) external payable;
/// @notice withdraws the desired shares from the vault with accumulated user fees and transfers to recipient.
/// @param pilotToken whether to recieve fees in PILOT or not (valid if user is not reciving fees in token0, token1)
/// @param wethToken whether to recieve fees in WETH or ETH (only valid for WETH/ALT pairs)
/// @param liquidity The amount by which liquidity will be withdrawn
/// @param tokenId The ID of the token for which liquidity is being withdrawn
/// @param data Necessary data needed to withdraw liquidity from Unipilot
function withdraw(
bool pilotToken,
bool wethToken,
uint256 liquidity,
uint256 tokenId,
bytes memory data
) external payable;
/// @notice Collects up to a maximum amount of fees owed to a specific user position to the recipient
/// @dev User have both options whether to recieve fees in PILOT or in pool token0 & token1
/// @param pilotToken whether to recieve fees in PILOT or not (valid if user is not reciving fees in token0, token1)
/// @param wethToken whether to recieve fees in WETH or ETH (only valid for WETH/ALT pairs)
/// @param tokenId The ID of the Unpilot NFT for which tokens will be collected
/// @param data Necessary data needed to collect fees from Unipilot
function collect(
bool pilotToken,
bool wethToken,
uint256 tokenId,
bytes memory data
) external payable;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.7.5;
interface IOracle {
event UniStrategyUpdated(address oldStrategy, address newStrategy);
event GovernanceUpdated(address governance, address _governance);
function getPilotAmountForTokens(
address token0,
address token1,
uint256 amount0,
uint256 amount1,
address oracle0,
address oracle1
) external view returns (uint256 total);
function getPilotAmountWethPair(
address tokenAlt,
uint256 altAmount,
uint256 wethAmount,
address altOracle
) external view returns (uint256 amount);
function getPilotAmount(
address token,
uint256 amount,
address pool
) external view returns (uint256 pilotAmount);
function assetToEth(
address token,
address pool,
uint256 amountIn
) external view returns (uint256 ethAmountOut);
function ethToAsset(
address tokenOut,
address pool,
uint256 amountIn
) external view returns (uint256 amountOut);
function getPrice(
address tokenA,
address tokenB,
address pool,
uint256 _amountIn
) external view returns (uint256 amountOut);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
import "./PositionKey.sol";
import "./LiquidityAmounts.sol";
import "@uniswap/v3-core/contracts/libraries/TickMath.sol";
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
/// @title Liquidity amount functions
/// @notice Provides functions for computing liquidity amounts from token amounts and prices
library LiquidityReserves {
function getLiquidityAmounts(
int24 tickLower,
int24 tickUpper,
uint128 liquidityDesired,
uint256 amount0Desired,
uint256 amount1Desired,
IUniswapV3Pool pool
)
internal
view
returns (
uint128 liquidity,
uint256 amount0,
uint256 amount1
)
{
(uint160 sqrtPriceX96, , , , , , ) = pool.slot0();
uint160 sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(tickLower);
uint160 sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(tickUpper);
if (liquidityDesired > 0) {
(amount0, amount1) = LiquidityAmounts.getAmountsForLiquidity(
sqrtPriceX96,
sqrtRatioAX96,
sqrtRatioBX96,
liquidityDesired
);
} else {
liquidity = LiquidityAmounts.getLiquidityForAmounts(
sqrtPriceX96,
sqrtRatioAX96,
sqrtRatioBX96,
amount0Desired,
amount1Desired
);
}
}
function getPositionTokenAmounts(
int24 tickLower,
int24 tickUpper,
IUniswapV3Pool pool,
uint128 liquidity
) internal view returns (uint256 amount0, uint256 amount1) {
(, amount0, amount1) = LiquidityReserves.getLiquidityAmounts(
tickLower,
tickUpper,
liquidity,
0,
0,
pool
);
}
}// 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: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Safe casting methods
/// @notice Contains methods for safely casting between types
library SafeCast {
/// @notice Cast a uint256 to a uint160, revert on overflow
/// @param y The uint256 to be downcasted
/// @return z The downcasted integer, now type uint160
function toUint160(uint256 y) internal pure returns (uint160 z) {
require((z = uint160(y)) == y);
}
/// @notice Cast a int256 to a int128, revert on overflow or underflow
/// @param y The int256 to be downcasted
/// @return z The downcasted integer, now type int128
function toInt128(int256 y) internal pure returns (int128 z) {
require((z = int128(y)) == y);
}
/// @notice Cast a uint256 to a int256, revert on overflow
/// @param y The uint256 to be casted
/// @return z The casted integer, now type int256
function toInt256(uint256 y) internal pure returns (int256 z) {
require(y < 2**255);
z = int256(y);
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
pragma abicoder v2;
import "./PositionKey.sol";
import "./LiquidityAmounts.sol";
import "@uniswap/v3-core/contracts/libraries/TickMath.sol";
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
import "../interfaces/uniswap/IUniswapLiquidityManager.sol";
import "./LiquidityReserves.sol";
import "@uniswap/v3-core/contracts/libraries/LowGasSafeMath.sol";
// import "./LowGasSafeMath.sol";
/// @title Liquidity amount functions
/// @notice Provides functions for computing liquidity amounts from token amounts and prices
library LiquidityPositions {
using LowGasSafeMath for uint256;
struct Vars {
int24 baseTickLower;
int24 baseTickUpper;
int24 rangeTickLower;
int24 rangeTickUpper;
uint256 fees0;
uint256 fees1;
uint256 totalLiquidity;
uint256 baseAmount0;
uint256 baseAmount1;
uint256 rangeAmount0;
uint256 rangeAmount1;
}
function getTotalAmounts(
IUniswapLiquidityManager.LiquidityPosition memory self,
address pool
)
internal
view
returns (
uint256 amount0,
uint256 amount1,
uint256 totalLiquidity
)
{
IUniswapV3Pool uniswapPool = IUniswapV3Pool(pool);
Vars memory localVars;
(localVars.baseAmount0, localVars.baseAmount1) = LiquidityReserves
.getPositionTokenAmounts(
self.baseTickLower,
self.baseTickUpper,
uniswapPool,
self.baseLiquidity
);
(localVars.rangeAmount0, localVars.rangeAmount1) = LiquidityReserves
.getPositionTokenAmounts(
self.rangeTickLower,
self.rangeTickUpper,
uniswapPool,
self.rangeLiquidity
);
amount0 = localVars.baseAmount0.add(localVars.rangeAmount0);
amount1 = localVars.baseAmount1.add(localVars.rangeAmount1);
totalLiquidity = self.totalLiquidity;
}
function getPoolDetails(address pool)
internal
view
returns (
address token0,
address token1,
uint24 fee,
uint16 poolCardinality,
uint128 liquidity,
uint160 sqrtPriceX96,
int24 currentTick
)
{
IUniswapV3Pool uniswapPool = IUniswapV3Pool(pool);
token0 = uniswapPool.token0();
token1 = uniswapPool.token1();
fee = uniswapPool.fee();
liquidity = uniswapPool.liquidity();
(sqrtPriceX96, currentTick, , poolCardinality, , , ) = uniswapPool.slot0();
}
function shouldReadjust(
address pool,
int24 baseTickLower,
int24 baseTickUpper
) internal view returns (bool readjust) {
int24 tickSpacing = 0;
(, , , , , , int24 currentTick) = getPoolDetails(pool);
int24 threshold = tickSpacing; // will increase thershold for mainnet to 1200
if (
(currentTick < (baseTickLower + threshold)) ||
(currentTick > (baseTickUpper - threshold))
) {
readjust = true;
} else {
readjust = false;
}
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
pragma abicoder v2;
import "@uniswap/v3-core/contracts/libraries/LowGasSafeMath.sol";
import "@uniswap/v3-core/contracts/libraries/FullMath.sol";
import "../interfaces/uniswap/IUniswapLiquidityManager.sol";
import "./FixedPoint128.sol";
// import "./LowGasSafeMath.sol";
/// @title Liquidity amount functions
/// @notice Provides functions for computing liquidity amounts from token amounts and prices
library UserPositions {
using LowGasSafeMath for uint256;
function getTokensOwedAmount(
uint256 feeGrowth0,
uint256 feeGrowth1,
uint256 liquidity,
uint256 feeGrowthGlobal0,
uint256 feeGrowthGlobal1
) internal pure returns (uint256 tokensOwed0, uint256 tokensOwed1) {
tokensOwed0 = FullMath.mulDiv(
feeGrowthGlobal0.sub(feeGrowth0),
liquidity,
FixedPoint128.Q128
);
tokensOwed1 = FullMath.mulDiv(
feeGrowthGlobal1.sub(feeGrowth1),
liquidity,
FixedPoint128.Q128
);
}
function getUserAndIndexShares(
uint256 tokensOwed0,
uint256 tokensOwed1,
uint256 feesPercentageIndexFund
)
internal
pure
returns (
uint256 indexAmount0,
uint256 indexAmount1,
uint256 userAmount0,
uint256 userAmount1
)
{
indexAmount0 = FullMath.mulDiv(tokensOwed0, feesPercentageIndexFund, 100);
indexAmount1 = FullMath.mulDiv(tokensOwed1, feesPercentageIndexFund, 100);
userAmount0 = tokensOwed0.sub(indexAmount0);
userAmount1 = tokensOwed1.sub(indexAmount1);
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
import "../interfaces/external/IWETH9.sol";
import "../libraries/TransferHelper.sol";
abstract contract PeripheryPayments {
address internal constant PILOT = 0x37C997B35C619C21323F3518B9357914E8B99525;
address internal constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
receive() external payable {}
fallback() external payable {}
/// @notice Transfers the full amount of a token held by this contract to recipient (In case of Emergency transfer tokens out of vault)
/// @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
) internal {
uint256 balanceToken = IERC20(token).balanceOf(address(this));
require(balanceToken >= amountMinimum, "IT");
if (balanceToken > 0) {
TransferHelper.safeTransfer(token, recipient, balanceToken);
}
}
/// @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) internal {
uint256 balanceWETH9 = IWETH9(WETH).balanceOf(address(this));
require(balanceWETH9 >= amountMinimum, "IW");
if (balanceWETH9 > 0) {
IWETH9(WETH).withdraw(balanceWETH9);
TransferHelper.safeTransferETH(recipient, balanceWETH9);
}
}
/// @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() internal {
if (address(this).balance > 0)
TransferHelper.safeTransferETH(msg.sender, 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 == WETH && address(this).balance >= value) {
// pay with WETH9
IWETH9(WETH).deposit{ value: value }(); // wrap only what is needed to pay
IWETH9(WETH).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: MIT
pragma solidity >=0.7.6;
pragma abicoder v2;
/// @notice IExchangeManager is a generalized interface for all the liquidity managers
/// @dev Contains all necessary methods that should be available in liquidity manager contracts
interface IExchangeManager {
struct DepositParams {
address recipient;
address exchangeManagerAddress;
address token0;
address token1;
uint256 amount0Desired;
uint256 amount1Desired;
uint256 tokenId;
}
struct WithdrawParams {
bool pilotToken;
bool wethToken;
address exchangeManagerAddress;
uint256 liquidity;
uint256 tokenId;
}
struct CollectParams {
bool pilotToken;
bool wethToken;
address exchangeManagerAddress;
uint256 tokenId;
}
function createPair(
address _token0,
address _token1,
bytes calldata data
) external;
function deposit(
address token0,
address token1,
uint256 amount0,
uint256 amount1,
uint256 shares,
uint256 tokenId,
bool isTokenMinted,
bytes calldata data
) external payable;
function withdraw(
bool pilotToken,
bool wethToken,
uint256 liquidity,
uint256 tokenId,
bytes calldata data
) external;
function getReserves(
address token0,
address token1,
bytes calldata data
)
external
returns (
uint256 shares,
uint256 amount0,
uint256 amount1
);
function collect(
bool pilotToken,
bool wethToken,
uint256 tokenId,
bytes calldata data
) external payable;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.6;
interface IULMEvents {
event PoolCreated(
address indexed token0,
address indexed token1,
address indexed pool,
uint24 fee,
uint160 sqrtPriceX96
);
event PoolReajusted(
address pool,
uint128 baseLiquidity,
uint128 rangeLiquidity,
int24 newBaseTickLower,
int24 newBaseTickUpper,
int24 newRangeTickLower,
int24 newRangeTickUpper
);
event Deposited(
address indexed pool,
uint256 tokenId,
uint256 amount0,
uint256 amount1,
uint256 liquidity
);
event Collect(
uint256 tokenId,
uint256 userAmount0,
uint256 userAmount1,
uint256 pilotAmount,
address pool,
address recipient
);
event Withdrawn(
address indexed pool,
address indexed recipient,
uint256 tokenId,
uint256 amount0,
uint256 amount1
);
}// 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: GPL-2.0-or-later
pragma solidity >=0.5.0;
import "@uniswap/v3-core/contracts/libraries/FullMath.sol";
import "@uniswap/v3-core/contracts/libraries/FixedPoint96.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);
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);
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) {
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);
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.5.0;
/// @title Math library for computing sqrt prices from ticks and vice versa
/// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports
/// prices between 2**-128 and 2**128
library TickMath {
/// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128
int24 internal constant MIN_TICK = -887272;
/// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128
int24 internal constant MAX_TICK = -MIN_TICK;
/// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)
uint160 internal constant MIN_SQRT_RATIO = 4295128739;
/// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)
uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;
/// @notice Calculates sqrt(1.0001^tick) * 2^96
/// @dev Throws if |tick| > max tick
/// @param tick The input tick for the above formula
/// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
/// at the given tick
function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {
uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));
require(absTick <= uint256(MAX_TICK), 'T');
uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000;
if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;
if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;
if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;
if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128;
if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128;
if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128;
if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;
if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;
if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128;
if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;
if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;
if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;
if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;
if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;
if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128;
if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;
if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128;
if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128;
if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128;
if (tick > 0) ratio = type(uint256).max / ratio;
// this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96.
// we then downcast because we know the result always fits within 160 bits due to our tick input constraint
// we round up in the division so getTickAtSqrtRatio of the output price is always consistent
sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1));
}
/// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio
/// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may
/// ever return.
/// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96
/// @return tick The greatest tick for which the ratio is less than or equal to the input ratio
function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) {
// second inequality must be < because the price can never reach the price at the max tick
require(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO, 'R');
uint256 ratio = uint256(sqrtPriceX96) << 32;
uint256 r = ratio;
uint256 msb = 0;
assembly {
let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(5, gt(r, 0xFFFFFFFF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(4, gt(r, 0xFFFF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(3, gt(r, 0xFF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(2, gt(r, 0xF))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := shl(1, gt(r, 0x3))
msb := or(msb, f)
r := shr(f, r)
}
assembly {
let f := gt(r, 0x1)
msb := or(msb, f)
}
if (msb >= 128) r = ratio >> (msb - 127);
else r = ratio << (127 - msb);
int256 log_2 = (int256(msb) - 128) << 64;
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(63, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(62, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(61, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(60, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(59, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(58, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(57, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(56, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(55, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(54, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(53, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(52, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(51, f))
r := shr(f, r)
}
assembly {
r := shr(127, mul(r, r))
let f := shr(128, r)
log_2 := or(log_2, shl(50, f))
}
int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number
int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128);
int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128);
tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow;
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
import './pool/IUniswapV3PoolImmutables.sol';
import './pool/IUniswapV3PoolState.sol';
import './pool/IUniswapV3PoolDerivedState.sol';
import './pool/IUniswapV3PoolActions.sol';
import './pool/IUniswapV3PoolOwnerActions.sol';
import './pool/IUniswapV3PoolEvents.sol';
/// @title The interface for a Uniswap V3 Pool
/// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform
/// to the ERC20 specification
/// @dev The pool interface is broken up into many smaller pieces
interface IUniswapV3Pool is
IUniswapV3PoolImmutables,
IUniswapV3PoolState,
IUniswapV3PoolDerivedState,
IUniswapV3PoolActions,
IUniswapV3PoolOwnerActions,
IUniswapV3PoolEvents
{
}// SPDX-License-Identifier: MIT
pragma solidity >=0.4.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) {
// 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 = -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) {
result = mulDiv(a, b, denominator);
if (mulmod(a, b, denominator) > 0) {
require(result < type(uint256).max);
result++;
}
}
}// 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: 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 Pool state that can change
/// @notice These methods compose the pool's state, and can change with any frequency including multiple times
/// per transaction
interface IUniswapV3PoolState {
/// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas
/// when accessed externally.
/// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value
/// tick The current tick of the pool, i.e. according to the last tick transition that was run.
/// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick
/// boundary.
/// observationIndex The index of the last oracle observation that was written,
/// observationCardinality The current maximum number of observations stored in the pool,
/// observationCardinalityNext The next maximum number of observations, to be updated when the observation.
/// feeProtocol The protocol fee for both tokens of the pool.
/// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0
/// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee.
/// unlocked Whether the pool is currently locked to reentrancy
function slot0()
external
view
returns (
uint160 sqrtPriceX96,
int24 tick,
uint16 observationIndex,
uint16 observationCardinality,
uint16 observationCardinalityNext,
uint8 feeProtocol,
bool unlocked
);
/// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool
/// @dev This value can overflow the uint256
function feeGrowthGlobal0X128() external view returns (uint256);
/// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool
/// @dev This value can overflow the uint256
function feeGrowthGlobal1X128() external view returns (uint256);
/// @notice The amounts of token0 and token1 that are owed to the protocol
/// @dev Protocol fees will never exceed uint128 max in either token
function protocolFees() external view returns (uint128 token0, uint128 token1);
/// @notice The currently in range liquidity available to the pool
/// @dev This value has no relationship to the total liquidity across all ticks
function liquidity() external view returns (uint128);
/// @notice Look up information about a specific tick in the pool
/// @param tick The tick to look up
/// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or
/// tick upper,
/// liquidityNet how much liquidity changes when the pool price crosses the tick,
/// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0,
/// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1,
/// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick
/// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick,
/// secondsOutside the seconds spent on the other side of the tick from the current tick,
/// initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false.
/// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0.
/// In addition, these values are only relative and must be used only in comparison to previous snapshots for
/// a specific position.
function ticks(int24 tick)
external
view
returns (
uint128 liquidityGross,
int128 liquidityNet,
uint256 feeGrowthOutside0X128,
uint256 feeGrowthOutside1X128,
int56 tickCumulativeOutside,
uint160 secondsPerLiquidityOutsideX128,
uint32 secondsOutside,
bool initialized
);
/// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information
function tickBitmap(int16 wordPosition) external view returns (uint256);
/// @notice Returns the information about a position by the position's key
/// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper
/// @return _liquidity The amount of liquidity in the position,
/// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke,
/// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke,
/// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke,
/// Returns tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke
function positions(bytes32 key)
external
view
returns (
uint128 _liquidity,
uint256 feeGrowthInside0LastX128,
uint256 feeGrowthInside1LastX128,
uint128 tokensOwed0,
uint128 tokensOwed1
);
/// @notice Returns data about a specific observation index
/// @param index The element of the observations array to fetch
/// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time
/// ago, rather than at a specific index in the array.
/// @return blockTimestamp The timestamp of the observation,
/// Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp,
/// Returns secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp,
/// Returns initialized whether the observation has been initialized and the values are safe to use
function observations(uint256 index)
external
view
returns (
uint32 blockTimestamp,
int56 tickCumulative,
uint160 secondsPerLiquidityCumulativeX128,
bool initialized
);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Pool state that 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 Permissionless pool actions
/// @notice Contains pool methods that can be called by anyone
interface IUniswapV3PoolActions {
/// @notice Sets the initial price for the pool
/// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value
/// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96
function initialize(uint160 sqrtPriceX96) external;
/// @notice Adds liquidity for the given recipient/tickLower/tickUpper position
/// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback
/// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends
/// on tickLower, tickUpper, the amount of liquidity, and the current price.
/// @param recipient The address for which the liquidity will be created
/// @param tickLower The lower tick of the position in which to add liquidity
/// @param tickUpper The upper tick of the position in which to add liquidity
/// @param amount The amount of liquidity to mint
/// @param data Any data that should be passed through to the callback
/// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback
/// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback
function mint(
address recipient,
int24 tickLower,
int24 tickUpper,
uint128 amount,
bytes calldata data
) external returns (uint256 amount0, uint256 amount1);
/// @notice Collects tokens owed to a position
/// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.
/// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or
/// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the
/// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.
/// @param recipient The address which should receive the fees collected
/// @param tickLower The lower tick of the position for which to collect fees
/// @param tickUpper The upper tick of the position for which to collect fees
/// @param amount0Requested How much token0 should be withdrawn from the fees owed
/// @param amount1Requested How much token1 should be withdrawn from the fees owed
/// @return amount0 The amount of fees collected in token0
/// @return amount1 The amount of fees collected in token1
function collect(
address recipient,
int24 tickLower,
int24 tickUpper,
uint128 amount0Requested,
uint128 amount1Requested
) external returns (uint128 amount0, uint128 amount1);
/// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position
/// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0
/// @dev Fees must be collected separately via a call to #collect
/// @param tickLower The lower tick of the position for which to burn liquidity
/// @param tickUpper The upper tick of the position for which to burn liquidity
/// @param amount How much liquidity to burn
/// @return amount0 The amount of token0 sent to the recipient
/// @return amount1 The amount of token1 sent to the recipient
function burn(
int24 tickLower,
int24 tickUpper,
uint128 amount
) external returns (uint256 amount0, uint256 amount1);
/// @notice Swap token0 for token1, or token1 for token0
/// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback
/// @param recipient The address to receive the output of the swap
/// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0
/// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
/// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this
/// value after the swap. If one for zero, the price cannot be greater than this value after the swap
/// @param data Any data to be passed through to the callback
/// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive
/// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive
function swap(
address recipient,
bool zeroForOne,
int256 amountSpecified,
uint160 sqrtPriceLimitX96,
bytes calldata data
) external returns (int256 amount0, int256 amount1);
/// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback
/// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback
/// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling
/// with 0 amount{0,1} and sending the donation amount(s) from the callback
/// @param recipient The address which will receive the token0 and token1 amounts
/// @param amount0 The amount of token0 to send
/// @param amount1 The amount of token1 to send
/// @param data Any data to be passed through to the callback
function flash(
address recipient,
uint256 amount0,
uint256 amount1,
bytes calldata data
) external;
/// @notice Increase the maximum number of price and liquidity observations that this pool will store
/// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to
/// the input observationCardinalityNext.
/// @param observationCardinalityNext The desired minimum number of observations for the pool to store
function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Permissioned pool actions
/// @notice Contains pool methods that may only be called by the factory owner
interface IUniswapV3PoolOwnerActions {
/// @notice Set the denominator of the protocol's % share of the fees
/// @param feeProtocol0 new protocol fee for token0 of the pool
/// @param feeProtocol1 new protocol fee for token1 of the pool
function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external;
/// @notice Collect the protocol fee accrued to the pool
/// @param recipient The address to which collected protocol fees should be sent
/// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1
/// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0
/// @return amount0 The protocol fee collected in token0
/// @return amount1 The protocol fee collected in token1
function collectProtocol(
address recipient,
uint128 amount0Requested,
uint128 amount1Requested
) external returns (uint128 amount0, uint128 amount1);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Events emitted by a pool
/// @notice Contains all events emitted by the pool
interface IUniswapV3PoolEvents {
/// @notice Emitted exactly once by a pool when #initialize is first called on the pool
/// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize
/// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96
/// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool
event Initialize(uint160 sqrtPriceX96, int24 tick);
/// @notice Emitted when liquidity is minted for a given position
/// @param sender The address that minted the liquidity
/// @param owner The owner of the position and recipient of any minted liquidity
/// @param tickLower The lower tick of the position
/// @param tickUpper The upper tick of the position
/// @param amount The amount of liquidity minted to the position range
/// @param amount0 How much token0 was required for the minted liquidity
/// @param amount1 How much token1 was required for the minted liquidity
event Mint(
address sender,
address indexed owner,
int24 indexed tickLower,
int24 indexed tickUpper,
uint128 amount,
uint256 amount0,
uint256 amount1
);
/// @notice Emitted when fees are collected by the owner of a position
/// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees
/// @param owner The owner of the position for which fees are collected
/// @param tickLower The lower tick of the position
/// @param tickUpper The upper tick of the position
/// @param amount0 The amount of token0 fees collected
/// @param amount1 The amount of token1 fees collected
event Collect(
address indexed owner,
address recipient,
int24 indexed tickLower,
int24 indexed tickUpper,
uint128 amount0,
uint128 amount1
);
/// @notice Emitted when a position's liquidity is removed
/// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect
/// @param owner The owner of the position for which liquidity is removed
/// @param tickLower The lower tick of the position
/// @param tickUpper The upper tick of the position
/// @param amount The amount of liquidity to remove
/// @param amount0 The amount of token0 withdrawn
/// @param amount1 The amount of token1 withdrawn
event Burn(
address indexed owner,
int24 indexed tickLower,
int24 indexed tickUpper,
uint128 amount,
uint256 amount0,
uint256 amount1
);
/// @notice Emitted by the pool for any swaps between token0 and token1
/// @param sender The address that initiated the swap call, and that received the callback
/// @param recipient The address that received the output of the swap
/// @param amount0 The delta of the token0 balance of the pool
/// @param amount1 The delta of the token1 balance of the pool
/// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96
/// @param liquidity The liquidity of the pool after the swap
/// @param tick The log base 1.0001 of price of the pool after the swap
event Swap(
address indexed sender,
address indexed recipient,
int256 amount0,
int256 amount1,
uint160 sqrtPriceX96,
uint128 liquidity,
int24 tick
);
/// @notice Emitted by the pool for any flashes of token0/token1
/// @param sender The address that initiated the swap call, and that received the callback
/// @param recipient The address that received the tokens from flash
/// @param amount0 The amount of token0 that was flashed
/// @param amount1 The amount of token1 that was flashed
/// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee
/// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee
event Flash(
address indexed sender,
address indexed recipient,
uint256 amount0,
uint256 amount1,
uint256 paid0,
uint256 paid1
);
/// @notice Emitted by the pool for increases to the number of observations that can be stored
/// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index
/// just before a mint/swap/burn.
/// @param observationCardinalityNextOld The previous value of the next observation cardinality
/// @param observationCardinalityNextNew The updated value of the next observation cardinality
event IncreaseObservationCardinalityNext(
uint16 observationCardinalityNextOld,
uint16 observationCardinalityNextNew
);
/// @notice Emitted when the protocol fee is changed by the pool
/// @param feeProtocol0Old The previous value of the token0 protocol fee
/// @param feeProtocol1Old The previous value of the token1 protocol fee
/// @param feeProtocol0New The updated value of the token0 protocol fee
/// @param feeProtocol1New The updated value of the token1 protocol fee
event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New);
/// @notice Emitted when the collected protocol fees are withdrawn by the factory owner
/// @param sender The address that collects the protocol fees
/// @param recipient The address that receives the collected protocol fees
/// @param amount0 The amount of token0 protocol fees that is withdrawn
/// @param amount0 The amount of token1 protocol fees that is withdrawn
event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.0;
/// @title Optimized overflow and underflow safe math operations
/// @notice Contains methods for doing math operations that revert on overflow or underflow for minimal gas cost
library LowGasSafeMath {
/// @notice Returns x + y, reverts if sum overflows uint256
/// @param x The augend
/// @param y The addend
/// @return z The sum of x and y
function add(uint256 x, uint256 y) internal pure returns (uint256 z) {
require((z = x + y) >= x);
}
/// @notice Returns x - y, reverts if underflows
/// @param x The minuend
/// @param y The subtrahend
/// @return z The difference of x and y
function sub(uint256 x, uint256 y) internal pure returns (uint256 z) {
require((z = x - y) <= x);
}
/// @notice Returns x * y, reverts if overflows
/// @param x The multiplicand
/// @param y The multiplier
/// @return z The product of x and y
function mul(uint256 x, uint256 y) internal pure returns (uint256 z) {
require(x == 0 || (z = x * y) / x == y);
}
/// @notice Returns x + y, reverts if overflows or underflows
/// @param x The augend
/// @param y The addend
/// @return z The sum of x and y
function add(int256 x, int256 y) internal pure returns (int256 z) {
require((z = x + y) >= x == (y >= 0));
}
/// @notice Returns x - y, reverts if overflows or underflows
/// @param x The minuend
/// @param y The subtrahend
/// @return z The difference of x and y
function sub(int256 x, int256 y) internal pure returns (int256 z) {
require((z = x - y) <= x == (y >= 0));
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity =0.7.6;
import "./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/contracts/token/ERC20/IERC20.sol";
import "../interfaces/external/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
pragma solidity =0.7.6;
import "./IERC20Permit.sol";
interface IERC20 is IERC20Permit {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transfer(address recipient, uint256 amount) external returns (bool);
function mint(address to, uint256 value) external;
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
function burn(uint256 value) external returns (bool);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over `owner`'s tokens,
* given `owner`'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for `permit`, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}{
"metadata": {
"bytecodeHash": "none"
},
"optimizer": {
"enabled": true,
"runs": 800
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"components":[{"internalType":"uint8","name":"swapPercentage","type":"uint8"},{"internalType":"uint24","name":"swapPriceThreshold","type":"uint24"},{"internalType":"uint256","name":"premium","type":"uint256"},{"internalType":"uint256","name":"gasPriceLimit","type":"uint256"},{"internalType":"uint256","name":"userPilotPercentage","type":"uint256"},{"internalType":"uint256","name":"feesPercentageIndexFund","type":"uint256"},{"internalType":"uint24","name":"readjustFrequencyTime","type":"uint24"},{"internalType":"uint16","name":"poolCardinalityDesired","type":"uint16"},{"internalType":"address","name":"pilotWethPair","type":"address"},{"internalType":"address","name":"oracle","type":"address"},{"internalType":"address","name":"indexFund","type":"address"},{"internalType":"address","name":"uniStrategy","type":"address"},{"internalType":"address","name":"unipilot","type":"address"}],"internalType":"struct IUniswapLiquidityManager.UnipilotProtocolDetails","name":"params","type":"tuple"},{"internalType":"address","name":"_uniswapFactory","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"userAmount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"userAmount1","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"pilotAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"pool","type":"address"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"}],"name":"Collect","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pool","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"liquidity","type":"uint256"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token0","type":"address"},{"indexed":true,"internalType":"address","name":"token1","type":"address"},{"indexed":true,"internalType":"address","name":"pool","type":"address"},{"indexed":false,"internalType":"uint24","name":"fee","type":"uint24"},{"indexed":false,"internalType":"uint160","name":"sqrtPriceX96","type":"uint160"}],"name":"PoolCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"pool","type":"address"},{"indexed":false,"internalType":"uint128","name":"baseLiquidity","type":"uint128"},{"indexed":false,"internalType":"uint128","name":"rangeLiquidity","type":"uint128"},{"indexed":false,"internalType":"int24","name":"newBaseTickLower","type":"int24"},{"indexed":false,"internalType":"int24","name":"newBaseTickUpper","type":"int24"},{"indexed":false,"internalType":"int24","name":"newRangeTickLower","type":"int24"},{"indexed":false,"internalType":"int24","name":"newRangeTickUpper","type":"int24"}],"name":"PoolReajusted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pool","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"Withdrawn","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[{"internalType":"bool","name":"pilotToken","type":"bool"},{"internalType":"bool","name":"wethToken","type":"bool"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"collect","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_token0","type":"address"},{"internalType":"address","name":"_token1","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"createPair","outputs":[{"internalType":"address","name":"_pool","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token0","type":"address"},{"internalType":"address","name":"token1","type":"address"},{"internalType":"uint256","name":"amount0Desired","type":"uint256"},{"internalType":"uint256","name":"amount1Desired","type":"uint256"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bool","name":"isTokenMinted","type":"bool"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"deposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"bytes[10]","name":"data","type":"bytes[10]"}],"name":"emergencyExit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token0","type":"address"},{"internalType":"address","name":"token1","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"getReserves","outputs":[{"internalType":"uint256","name":"totalAmount0","type":"uint256"},{"internalType":"uint256","name":"totalAmount1","type":"uint256"},{"internalType":"uint256","name":"totalLiquidity","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getUserFees","outputs":[{"internalType":"uint256","name":"fees0","type":"uint256"},{"internalType":"uint256","name":"fees1","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"pool","type":"address"}],"name":"poolPositions","outputs":[{"components":[{"internalType":"int24","name":"baseTickLower","type":"int24"},{"internalType":"int24","name":"baseTickUpper","type":"int24"},{"internalType":"uint128","name":"baseLiquidity","type":"uint128"},{"internalType":"int24","name":"rangeTickLower","type":"int24"},{"internalType":"int24","name":"rangeTickUpper","type":"int24"},{"internalType":"uint128","name":"rangeLiquidity","type":"uint128"},{"internalType":"uint256","name":"fees0","type":"uint256"},{"internalType":"uint256","name":"fees1","type":"uint256"},{"internalType":"uint256","name":"feeGrowthGlobal0","type":"uint256"},{"internalType":"uint256","name":"feeGrowthGlobal1","type":"uint256"},{"internalType":"uint256","name":"totalLiquidity","type":"uint256"},{"internalType":"bool","name":"feesInPilot","type":"bool"},{"internalType":"address","name":"oracle0","type":"address"},{"internalType":"address","name":"oracle1","type":"address"},{"internalType":"uint256","name":"timestamp","type":"uint256"},{"internalType":"uint8","name":"counter","type":"uint8"},{"internalType":"bool","name":"status","type":"bool"},{"internalType":"bool","name":"managed","type":"bool"}],"internalType":"struct IUniswapLiquidityManager.LiquidityPosition","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pool","type":"address"}],"name":"readjustFrequencyStatus","outputs":[{"internalType":"bool","name":"status","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token0","type":"address"},{"internalType":"address","name":"token1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"}],"name":"readjustLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint8","name":"swapPercentage","type":"uint8"},{"internalType":"uint24","name":"swapPriceThreshold","type":"uint24"},{"internalType":"uint256","name":"premium","type":"uint256"},{"internalType":"uint256","name":"gasPriceLimit","type":"uint256"},{"internalType":"uint256","name":"userPilotPercentage","type":"uint256"},{"internalType":"uint256","name":"feesPercentageIndexFund","type":"uint256"},{"internalType":"uint24","name":"readjustFrequencyTime","type":"uint24"},{"internalType":"uint16","name":"poolCardinalityDesired","type":"uint16"},{"internalType":"address","name":"pilotWethPair","type":"address"},{"internalType":"address","name":"oracle","type":"address"},{"internalType":"address","name":"indexFund","type":"address"},{"internalType":"address","name":"uniStrategy","type":"address"},{"internalType":"address","name":"unipilot","type":"address"}],"internalType":"struct IUniswapLiquidityManager.UnipilotProtocolDetails","name":"params","type":"tuple"}],"name":"setPilotProtocolDetails","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"pool","type":"address"},{"internalType":"bool","name":"feesInPilot_","type":"bool"},{"internalType":"bool","name":"managed_","type":"bool"},{"internalType":"address","name":"oracle0","type":"address"},{"internalType":"address","name":"oracle1","type":"address"}],"name":"setPoolIncentives","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"pool","type":"address"},{"internalType":"int24","name":"baseTickLower","type":"int24"},{"internalType":"int24","name":"baseTickUpper","type":"int24"}],"name":"shouldReadjust","outputs":[{"internalType":"bool","name":"readjust","type":"bool"}],"stateMutability":"view","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":"int256","name":"amount0Delta","type":"int256"},{"internalType":"int256","name":"amount1Delta","type":"int256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"uniswapV3SwapCallback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pool","type":"address"}],"name":"updatePositionTotalAmounts","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"},{"internalType":"uint256","name":"totalLiquidity","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"userPositions","outputs":[{"components":[{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"feeGrowth0","type":"uint256"},{"internalType":"uint256","name":"feeGrowth1","type":"uint256"},{"internalType":"uint256","name":"tokensOwed0","type":"uint256"},{"internalType":"uint256","name":"tokensOwed1","type":"uint256"}],"internalType":"struct IUniswapLiquidityManager.Position","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"pilotToken","type":"bool"},{"internalType":"bool","name":"wethToken","type":"bool"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"withdraw","outputs":[],"stateMutability":"payable","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
60a06040526000805460ff191660011790553480156200001e57600080fd5b50604051620061dc380380620061dc8339810160408190526200004191620001c1565b815160038054602085015160ff1990911660ff9093169290921763ffffff00191661010062ffffff938416810291909117909155604084015160045560608085015160055560808086015160065560a086015160075560c08601516008805460e08901519589015162ffffff19909116929096169190911764ffff0000001916630100000061ffff9095169490940293909317600160281b600160c81b031916650100000000006001600160a01b039586160217909255610120850151600980546001600160a01b0319908116928616929092179055610140860151600a80548316918616919091179055610160860151600b8054831691861691909117905561018090950151600c80549096169316929092179093551b6001600160601b031916905262000305565b80516001600160a01b03811681146200018357600080fd5b919050565b805161ffff811681146200018357600080fd5b805162ffffff811681146200018357600080fd5b805160ff811681146200018357600080fd5b6000808284036101c0811215620001d6578283fd5b6101a080821215620001e6578384fd5b620001f181620002e1565b9150620001fe85620001af565b82526200020e602086016200019b565b602083015260408501516040830152606085015160608301526080850151608083015260a085015160a08301526200024960c086016200019b565b60c08301526200025c60e0860162000188565b60e0830152610100620002718187016200016b565b90830152610120620002858682016200016b565b90830152610140620002998682016200016b565b90830152610160620002ad8682016200016b565b90830152610180620002c18682016200016b565b8184015250819350620002d68186016200016b565b925050509250929050565b6040518181016001600160401b0381118282101715620002fd57fe5b604052919050565b60805160601c615eb46200032860003980610b6e52806124ac5250615eb46000f3fe6080604052600436106101125760003560e01c8063602c231d116100a55780639b6c1dc611610074578063dea68ea011610059578063dea68ea014610300578063e14767b514610320578063fa461e331461034e57610119565b80639b6c1dc6146102cd578063d3487997146102e057610119565b8063602c231d14610240578063615837e814610260578063749b1d59146102805780639b12a1f7146102ad57610119565b806335dca703116100e157806335dca703146101a657806349acb5e0146101d3578063595e6f11146102005780635a18cc6b1461022057610119565b80630121240c1461011b578063026d1c8e1461012e5780630caa03af146101415780631e7f13701461017957610119565b3661011957005b005b6101196101293660046152f8565b61036e565b61011961013c36600461528e565b6104e0565b34801561014d57600080fd5b5061016161015c366004614f95565b61060c565b60405161017093929190615bd7565b60405180910390f35b34801561018557600080fd5b506101996101943660046156c3565b610649565b6040516101709190615b08565b3480156101b257600080fd5b506101c66101c1366004614eee565b6106bf565b604051610170919061598d565b3480156101df57600080fd5b506101f36101ee36600461524f565b6107f7565b604051610170919061595c565b34801561020c57600080fd5b506101f361021b366004614eee565b6108ca565b34801561022c57600080fd5b5061011961023b3660046151df565b61091c565b34801561024c57600080fd5b5061016161025b366004614eee565b6109c8565b34801561026c57600080fd5b5061011961027b366004615553565b610b1f565b34801561028c57600080fd5b506102a061029b366004614ff8565b610b39565b604051610170919061576c565b3480156102b957600080fd5b506101196102c836600461513c565b610cba565b6101196102db3660046150a2565b610eca565b3480156102ec57600080fd5b506101196102fb366004615431565b611178565b34801561030c57600080fd5b5061011961031b366004615058565b6111dc565b34801561032c57600080fd5b5061034061033b3660046156c3565b611a53565b604051610170929190615bc9565b34801561035a57600080fd5b50610119610369366004615431565b611c45565b610376611c9d565b60005460ff1660011461038857600080fd5b6000805460ff19168155828152600160205260409020836103a857600080fd5b80600201548411156103b957600080fd5b6103c1614aa7565b828060200190518101906103d59190614f0a565b6001600160a01b03908116825260018301546103f5916000911687611cb6565b604080840191825260208085019384528151610100810183528b151581528a15159181019190915260018601546001600160a01b0390811692820192909252845190911660608201526080810187905260a08101889052915160c08301525160e082015261046290611ef4565b60a08401526080830152606082015280516001830154602083015160408085015190516001600160a01b0394851694909316927f3cae9923fd3c2f468aa25a8ef687923e37f957459557c0380fd06526c0b8cdbc926104c2928a92615bd7565b60405180910390a350506000805460ff191660011790555050505050565b6104e8611c9d565b60005460ff166001146104fa57600080fd5b6000805460ff1916815582815260016020818152604092839020835160e08101855281548152928101546001600160a01b03169183019190915260028101549282018390526003810154606083015260048101546080830152600581015460a08301526006015460c08201529061057057600080fd5b6000828060200190518101906105869190614f0a565b9050610595826020015161222d565b6105f46040518061010001604052808815158152602001871515815260200184602001516001600160a01b03168152602001836001600160a01b0316815260200186815260200160008152602001600081526020016000815250611ef4565b50506000805460ff1916600117905550505050505050565b600080808061061d85870187615652565b9050600061062c898984612492565b9050610637816109c8565b919b909a509098509650505050505050565b610651614ae6565b50600081815260016020818152604092839020835160e08101855281548152928101546001600160a01b0316918301919091526002810154928201929092526003820154606082015260048201546080820152600582015460a082015260069091015460c08201525b919050565b6106c7614b2c565b506001600160a01b03908116600090815260026020818152604092839020835161024081018552815480850b850b850b825263010000008104850b850b850b938201939093526001600160801b03600160301b8404811695820195909552600160b01b8304840b840b840b6060820152600160c81b909204830b830b830b6080830152600181015490931660a08201529082015460c0820152600382015460e082015260048201546101008083019190915260058301546101208301526006830154610140830152600783015460ff808216151561016085015290829004851661018084015260088401549094166101a083015260098301546101c0830152600a909201548084166101e08301529182048316151561020082015262010000909104909116151561022082015290565b6000806108038561253f565b50600b54604051634ed8cf2760e01b8152919850600097506001600160a01b03169550634ed8cf27945061083f93508b9250600401905061576c565b60206040518083038186803b15801561085757600080fd5b505afa15801561086b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061088f919061536c565b905080850160020b8260020b12806108ae575080840360020b8260020b135b156108bc57600192506108c1565b600092505b50509392505050565b6001600160a01b0381166000908152600260205260408120600854600982015462ffffff9091164291909103111561090a57600a8101805461ffff191690555b600a0154610100900460ff1692915050565b61092461281f565b6001600160a01b039485166000908152600260205260409020600781018054600a83018054961515620100000262ff00001990971696909617909555928616610100027fffffffffffffffffffffff0000000000000000000000000000000000000000ff95151560ff199095169490941794909416929092179055600890910180549190921673ffffffffffffffffffffffffffffffffffffffff19909116179055565b6001600160a01b038082166000908152600260208181526040808420815161024081018352815480860b860b860b825263010000008104860b860b860b948201949094526001600160801b03600160301b8504811693820193909352600160b01b8404850b850b850b6060820152600160c81b909304840b840b840b6080840152600181015490911660a08301529182015460c0820152600382015460e0820152600482015461010080830191909152600583015461012083015260068301546101408301819052600784015460ff808216151561016086015290839004871661018085015260088501549096166101a084015260098401546101c0840152600a909301548086166101e08401529081048516151561020083015262010000900490931615156102208401529091829182919015610b1657610b0a81866128b9565b93509350935050610b18565b505b9193909250565b610b2761281f565b806003610b348282615c9a565b505050565b600080600083806020019051810190610b52919061568a565b60405163a167129560e01b815291935091506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063a167129590610ba790899089908790600401615845565b602060405180830381600087803b158015610bc157600080fd5b505af1158015610bd5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf99190614f0a565b60405163f637731d60e01b81529093506001600160a01b0384169063f637731d90610c2890849060040161576c565b600060405180830381600087803b158015610c4257600080fd5b505af1158015610c56573d6000803e3d6000fd5b50505050826001600160a01b0316856001600160a01b0316876001600160a01b03167f1e0ec922dce1f1a88ad6fca4aecc5eefbda9b5c760e9acc4e70e1672ed80760e8585604051610ca9929190615ba2565b60405180910390a450509392505050565b610cc261281f565b60005b600a811015610b345760008060008060008686600a8110610ce257fe5b6020020151806020019051810190610cfa9190614f26565b9398509196509450925090506001600160a01b03841615610e275760405163a34123a760e01b81526001600160a01b0385169063a34123a790610d4590869086908690600401615967565b6040805180830381600087803b158015610d5e57600080fd5b505af1158015610d72573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d96919061540e565b50506040516309e3d67b60e31b81526001600160a01b03851690634f1eb3d890610dd3908b90879087906001600160801b03908190600401615808565b6040805180830381600087803b158015610dec57600080fd5b505af1158015610e00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e249190615585565b50505b6040516370a0823160e01b81526000906001600160a01b038716906370a0823190610e5690309060040161576c565b60206040518083038186803b158015610e6e57600080fd5b505afa158015610e82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ea691906156db565b90508015610eb957610eb9868a83612952565b505050505050806001019050610cc5565b610ed2611c9d565b610eda614bc0565b81806020019051810190610eee919061566e565b62ffffff16808252610f03908a908a90612492565b6001600160a01b0316602080830182905260009182526002905260409020600681015415610f3857610f38826020015161222d565b610f6e604051806080016040528084602001516001600160a01b031681526020018a815260200189815260200188815250612ab5565b60a086015260808501526060840152604083015283611031576000858152600160208181526040909220908101549184015190916001600160a01b03918216911614610fb957600080fd5b610fd681600301548360040154038260020154600160801b613050565b816005016000828254019250508190555061100481600401548360050154038260020154600160801b613050565b600682018054909101905560028101805488019055600482810154600383015560058301549101556110fc565b6040518060e001604052806000815260200183602001516001600160a01b031681526020018781526020018260040154815260200182600501548152602001600081526020016000815250600160008781526020019081526020016000206000820151816000015560208201518160010160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060408201518160020155606082015181600301556080820151816004015560a0820151816005015560c082015181600601559050505b611121826020015183608001518460400151018460a001518560600151018b8b6130ff565b81602001516001600160a01b03167fe3b53cd1a44fbf11535e145d80b8ef1ed6d57a73bf5daa7e939b6b01657d6549868a8a8a6040516111649493929190615bed565b60405180910390a250505050505050505050565b3360006111878385018561546a565b90506111a08160200151826040015183606001516131a0565b85156111ba576111ba8160200151826000015184896131c8565b84156111d4576111d48160400151826000015184886131c8565b505050505050565b60005a90506111e9614c04565b6111f4858585612492565b6001600160a01b03166020808301828152600092835260029091526040909120905161121f906108ca565b1561122957600080fd5b602082015181546112499190600281810b9163010000009004900b6107f7565b61125257600080fd5b42600982015560208201516112669061253f565b50506001600160a01b0316606088015250505060208401516006840154611291935060019250611cb6565b61010084015260e0830181905215806112ad5750610100820151155b156114d45760008260e00151116112cb5760008261010001516112d3565b60018260e001515b61012084015215158252600354620f424090600290610100900462ffffff160462ffffff168360600151026001600160a01b03168161130e57fe5b046001600160a01b03166080830152815161133357816080015182606001510161133f565b81608001518260600151035b6001600160a01b031660a0830152610120820151600354611365919060ff166064613050565b61012083018190526020830151835160009283926001600160a01b03169163128acb089130919061139590613327565b8860a0015160405180606001604052808f6001600160a01b031681526020018e6001600160a01b031681526020018d62ffffff168152506040516020016113dc9190615b5f565b6040516020818303038152906040526040518663ffffffff1660e01b815260040161140b959493929190615780565b6040805180830381600087803b15801561142457600080fd5b505af1158015611438573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061145c919061540e565b91509150600181121561149f5760e08401516000919091039061147f908361333d565b60e08501526101008401516114949082613353565b6101008501526114d1565b60e0840151600092909203916114b59083613353565b60e08501526101008401516114ca908261333d565b6101008501525b50505b6114dc614cba565b6114e98360200151613363565b866000018760200188604001896060018a6080018b60a0018660020b60020b8152508660020b60020b8152508660020b60020b8152508660020b60020b8152508660020b60020b8152508660020b60020b8152505050505050506115ac6040518060e00160405280896001600160a01b03168152602001886001600160a01b031681526020018762ffffff168152602001836000015160020b8152602001836020015160020b81526020018560e001518152602001856101000151815250613406565b5061016086015261014085018190526001600160801b039190911660c0850181905282516020840151855465ffffff00000019166301000000600292830b62ffffff908116919091029190911762ffffff19169290910b161775ffffffffffffffffffffffffffffffff0000000000001916600160301b90910217835560e084015160009161163b919061333d565b9050600061165c85610160015186610100015161333d90919063ffffffff16565b9050600061167b84604001518560600151600086868b6020015161354f565b50509050600061169c85608001518660a00151600087878c6020015161354f565b50509050806001600160801b0316826001600160801b0316111561178d5761171a6040518060e001604052808d6001600160a01b031681526020018c6001600160a01b031681526020018b62ffffff168152602001876040015160020b8152602001876060015160020b815260200186815260200185815250613406565b506101a08a015261018089015250604085015160608601518754600292830b62ffffff908116600160b01b0262ffffff60b01b199390940b16600160c81b0262ffffff60c81b1990911617161786556001860180546001600160801b0384166001600160801b031990911617905561185c565b6117ed6040518060e001604052808d6001600160a01b031681526020018c6001600160a01b031681526020018b62ffffff168152602001876080015160020b81526020018760a0015160020b815260200186815260200185815250613406565b506101a08a015261018089015250608085015160a08601518754600292830b62ffffff908116600160b01b0262ffffff60b01b199390940b16600160c81b0262ffffff60c81b1990911617161786556001860180546001600160801b0383166001600160801b03199091161790555b600a8601805460ff198116600160ff9283160182161791829055166002141561189157600a8601805461ff0019166101001790555b600a86015462010000900460ff1615611996576005543a11156118b357600080fd5b6004546118d5906118cf6118c85a8c9061333d565b3a9061361a565b90613353565b6101e08801819052600954600854604051633ff01ddf60e01b81526001600160a01b0392831693633ff01ddf93611933937337c997b35c619c21323f3518b9357914e8b995259365010000000000909104909116919060040161586d565b60206040518083038186803b15801561194b57600080fd5b505afa15801561195f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061198391906156db565b610200880181905261199690339061363e565b6119c8876020015188610180015189610140015101896101a001518a6101600151018a60e001518b61010001516130ff565b6020870151865460018801546040517fa25b5d6734ecac8eab8efed28486b538d745cb1bd19e0d3ab3bcc1631669641193611a3e9390926001600160801b03600160301b8304811693911691600281810b9263010000008304820b92600160b01b8104830b92600160c81b909104900b906158cb565b60405180910390a15050505050505050505050565b6000818152600160208181526040808420815160e08101835281548152938101546001600160a01b03169284018390526002810154918401919091526003810154606084015260048101546080840152600581015460a08401526006015460c0830152829190611ac29061222d565b6020808201516001600160a01b03908116600090815260028084526040808320815161024081018352815480850b850b850b825263010000008104850b850b850b978201979097526001600160801b03600160301b8804811682850152600160b01b8804850b850b850b606080840191909152600160c81b909804850b850b850b608080840191909152600184015490911660a08301529382015460c0820152600382015460e08201526004820154610100808301829052600584015461012084018190526006850154610140850152600785015460ff8082161515610160870152908390048a1661018086015260088601549099166101a085015260098501546101c0850152600a909401548089166101e085015290810488161515610200840152620100009004909616151561022082015295870151928701519187015193948594611c1494939290919061369e565b60a08601519193509150611c289083613353565b60c0850151909650611c3a9082613353565b945050505050915091565b336000611c54838501856154e8565b9050611c6d8160000151826020015183604001516131a0565b6000861315611c84578051611c84903084896131c8565b60008513156111d4576111d481602001513084886131c8565b600c546001600160a01b03163314611cb457600080fd5b565b6001600160a01b0382166000908152600260205260408120600681015482919085908390611cef908790670de0b6b3a764000090613050565b8354909150600090611d2390600281810b916301000000810490910b90600160301b90046001600160801b031685876136d4565b84546001860154919250600091611d5c91600160b01b8104600290810b92600160c81b909204900b906001600160801b031686886136d4565b9050611d87611d7c8260600151846060015161335390919063ffffffff16565b600287015490613353565b600286015560808082015190830151611daf91611da49190613353565b600387015490613353565b8560030181905550611dd48160600151836060015101600160801b8760060154613050565b8560040160008282540192505081905550611e028160800151836080015101600160801b8760060154613050565b600586018054909101905580518251611e1a91613353565b9650611e378160200151836020015161335390919063ffffffff16565b955089611e53576006850154611e4d908961333d565b60068601555b60408083015186546001600160801b03600160301b808304821693909303811690920275ffffffffffffffffffffffffffffffff0000000000001990911617875590820151600187018054808416929092039092166001600160801b03199091161790556006850154611ee75784547fffffffff000000000000ffffffffffffffffffffffffffffffff0000000000001685555b5050505050935093915050565b6000806000611f01614cef565b604080860180516001600160a01b031660009081526002602090815283822060808a0151835260019091529290209051611f3a9061253f565b5050506001600160a01b03938416602089015250505016835260038101546004808301546002840154918501546005860154611f789493919061369e565b606085018190526040850182905260058084018054909301909255600683018054909101905560048084015460038401559083015490820155600782015460ff168015611fc3575086515b156121285782516001600160a01b031673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21480612014575060208301516001600160a01b031673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2145b156120e05760008060008060008073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031689600001516001600160a01b031614612085578851600588015460078a015460208c015160068b015460088d01546001600160a01b03610100909404841693166120b4565b6020890151600688015460088a01548b5160058b015460078d01546001600160a01b0393841693610100909104165b9550955095509550955095506120d38d6060015184888589868a61389b565b9950505050505050612123565b60608701518351602085015160058401546006850154600787015460088801546121209695949392916001600160a01b036101009091048116911661389b565b93505b61214e565b61214e876020015188606001518560000151866020015185600501548660060154613a3d565b6121748360000151846020015189602001518a606001518b60c001518c60e00151613c0a565b6005810154600682015460028401549197509550612192908761333d565b6002830155600681015460038301546121aa9161333d565b6003830155600060058201819055600682015560a087015160028201546121d09161333d565b6002820155608087015160408089015160608a015191517fb543e95af3893fca952f2096ca5e34bcca256c05358f31373b6e645087610ea89361221b9390928b928b928b9291615c08565b60405180910390a15050509193909250565b6001600160a01b03811660009081526002602081905260409091208054909183916122779181810b916301000000810490910b90600160301b90046001600160801b031684613d77565b815460018301546122a991600160b01b8104600290810b92600160c81b909204900b906001600160801b031684613d77565b81546040516309e3d67b60e31b815260009182916001600160a01b03851691634f1eb3d8916122f7913091600282810b9263010000009004900b906001600160801b03908190600401615808565b6040805180830381600087803b15801561231057600080fd5b505af1158015612324573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123489190615585565b85546040516309e3d67b60e31b81526001600160801b039384169550918316935060009283926001600160a01b03881692634f1eb3d8926123a7923092600160b01b8104600290810b93600160c81b909204900b918190600401615808565b6040805180830381600087803b1580156123c057600080fd5b505af11580156123d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123f89190615585565b6001600160801b0391821693501690506124206124158584613353565b600288015490613353565b600287015561243d6124328483613353565b600388015490613353565b866003018190555061245a828501600160801b8860060154613050565b6004870180549091019055600686015461247d9084830190600160801b90613050565b60059096018054909601909555505050505050565b604051630b4c774160e11b81526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690631698ee82906124e590879087908790600401615845565b60206040518083038186803b1580156124fd57600080fd5b505afa158015612511573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125359190614f0a565b90505b9392505050565b6000806000806000806000806000899050806001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b15801561258957600080fd5b505afa15801561259d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125c19190614f0a565b9850806001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b1580156125fc57600080fd5b505afa158015612610573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126349190614f0a565b9750806001600160a01b031663ddca3f436040518163ffffffff1660e01b815260040160206040518083038186803b15801561266f57600080fd5b505afa158015612683573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126a7919061566e565b9650806001600160a01b0316631a6865026040518163ffffffff1660e01b815260040160206040518083038186803b1580156126e257600080fd5b505afa1580156126f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061271a919061556b565b9450806001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561275557600080fd5b505afa158015612769573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061278d91906155b7565b5050604080516334324e9f60e21b81529051929b509498509296506001600160a01b0385169363d0c93a7c93506004808201935060209291829003018186803b1580156127d957600080fd5b505afa1580156127ed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612811919061536c565b915050919395975091939597565b600c5460408051635aa6e67560e01b815290516001600160a01b0390921691635aa6e67591600480820192602092909190829003018186803b15801561286457600080fd5b505afa158015612878573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061289c9190614f0a565b6001600160a01b0316336001600160a01b031614611cb457600080fd5b60008080836128c6614d29565b6128de87600001518860200151848a60400151613e08565b61010083015260e08201526060870151608088015160a08901516129059291908590613e08565b610140830152610120820181905260e082015161292191613353565b945061294081610140015182610100015161335390919063ffffffff16565b61014090970151949794955050505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1663a9059cbb60e01b1781529251825160009485949389169392918291908083835b602083106129e35780518252601f1990920191602091820191016129c4565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612a45576040519150601f19603f3d011682016040523d82523d6000602084013e612a4a565b606091505b5091509150818015612a78575080511580612a785750808060200190516020811015612a7557600080fd5b50515b612aae576040805162461bcd60e51b815260206004820152600260248201526114d560f21b604482015290519081900360640190fd5b5050505050565b600080600080612ac3614d8f565b8551612ace9061253f565b50600290810b810b606089015261ffff9093166080880152505062ffffff9091166040808601919091526001600160a01b0392831660208087019190915293831685528951909216600090815292529020600681015415612b5457612b458760000151886020015189604001518a60600151613e28565b92985090965094509250613047565b600854608083015161ffff6301000000909204821691161015612be15786516008546040516332148f6760e01b81526001600160a01b03909216916332148f6791612bae91630100000090910461ffff1690600401615b93565b600060405180830381600087803b158015612bc857600080fd5b505af1158015612bdc573d6000803e3d6000fd5b505050505b612be9614cba565b8751612bf490613363565b600290810b810b60a088015290810b810b608087015290810b810b606086015290810b810b604085015290810b810b602084015290810b810b82528254810b900b15801590612c515750815463010000009004600290810b900b15155b15612cb45781546060840151600291820b820b910b1280612c885750815460608401516301000000909104600290810b810b91900b135b15612caf57612ca9886000015189602001518a604001518b606001516140f9565b90955093505b613045565b612d286040518060e0016040528085600001516001600160a01b0316815260200185602001516001600160a01b03168152602001856040015162ffffff168152602001836000015160020b8152602001836020015160020b81526020018a6020015181526020018a60400151815250613406565b5061012086015261010085018190526001600160801b039190911660a085018190528251602084810151865465ffffff00000019166301000000600292830b62ffffff908116919091029190911762ffffff19169390910b169190911775ffffffffffffffffffffffffffffffff0000000000001916600160301b909202919091178455890151600091612dbc919061333d565b90506000612ddc8561012001518b6040015161333d90919063ffffffff16565b9050612df983604001518460600151600085858f6000015161354f565b50506001600160801b031660c0860152608083015160a08401518b51612e279291906000908690869061354f565b50506001600160801b0390811660e0870181905260c08701519091161115612f3c57612eb56040518060e0016040528087600001516001600160a01b0316815260200187602001516001600160a01b03168152602001876040015162ffffff168152602001856040015160020b8152602001856060015160020b815260200184815260200183815250613406565b5060c0880151604087015160608801518954600292830b62ffffff908116600160b01b0262ffffff60b01b199390940b16600160c81b0262ffffff60c81b1990911617161788556001880180546001600160801b039092166001600160801b0319909216919091179055610100880151610120890151909c509a50909850965061302a9050565b612fa86040518060e0016040528087600001516001600160a01b0316815260200187602001516001600160a01b03168152602001876040015162ffffff168152602001856080015160020b81526020018560a0015160020b815260200184815260200183815250613406565b5060e0880151608087015160a08801518954600292830b62ffffff908116600160b01b0262ffffff60b01b199390940b16600160c81b0262ffffff60c81b1990911617161788556001880180546001600160801b039092166001600160801b0319909216919091179055610100880151610120890151909c509a509098509650505b50506060880151600683015461303f91613353565b60068301555b505b50509193509193565b6000808060001985870986860292508281109083900303905080613086576000841161307b57600080fd5b508290049050612538565b80841161309257600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b6001600160a01b038516600090815260026020526040812090613122848761333d565b90506000613130848761333d565b9050811561316457600283018054830190556006830154613158908390600160801b90613050565b60048401805490910190555b80156131965760038301805482019055600683015461318a908290600160801b90613050565b60058401805490910190555b5050505050505050565b6131ab838383612492565b6001600160a01b0316336001600160a01b031614610b3457600080fd5b6001600160a01b03841673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21480156131f45750804710155b156132f45773c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b15801561324857600080fd5b505af115801561325c573d6000803e3d6000fd5b50506040805163a9059cbb60e01b81526001600160a01b038716600482015260248101869052905173c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2945063a9059cbb9350604480830193506020928290030181600087803b1580156132c257600080fd5b505af11580156132d6573d6000803e3d6000fd5b505050506040513d60208110156132ec57600080fd5b506133219050565b6001600160a01b03831630141561331557613310848383612952565b613321565b61332184848484614209565b50505050565b6000600160ff1b821061333957600080fd5b5090565b8082038281111561334d57600080fd5b92915050565b8082018281101561334d57600080fd5b600b5460405163802036f560e01b8152600091829182918291829182916001600160a01b039091169063802036f5906133a0908a9060040161576c565b60c060405180830381600087803b1580156133ba57600080fd5b505af11580156133ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133f29190615388565b949c939b5091995097509550909350915050565b600080600080613423856000015186602001518760400151612492565b90506134448560600151866080015160008860a001518960c001518661354f565b90505080945050806001600160a01b0316633c8a7d8d3087606001518860800151886040518060800160405280306001600160a01b031681526020018c600001516001600160a01b031681526020018c602001516001600160a01b031681526020018c6040015162ffffff168152506040516020016134c39190615ac4565b6040516020818303038152906040526040518663ffffffff1660e01b81526004016134f29594939291906157c5565b6040805180830381600087803b15801561350b57600080fd5b505af115801561351f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613543919061540e565b94969095509092509050565b600080600080846001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561358e57600080fd5b505afa1580156135a2573d6000803e3d6000fd5b505050506040513d60e08110156135b857600080fd5b5051905060006135c78b61436e565b905060006135d48b61436e565b90506001600160801b038a16156135fb576135f18383838d6146a0565b909550935061360b565b6136088383838c8c61473c565b95505b50505096509650969350505050565b60008215806136355750508181028183828161363257fe5b04145b61334d57600080fd5b600c546040516329bb7ba160e11b81526001600160a01b0390911690635376f742906136709085908590600401615918565b600060405180830381600087803b15801561368a57600080fd5b505af11580156111d4573d6000803e3d6000fd5b6000806136b96136ae858961333d565b86600160801b613050565b91506136c86136ae848861333d565b90509550959350505050565b6136dc614de3565b6000806000613705613700886001600160801b031688670de0b6b3a7640000613050565b614800565b90506001600160801b0387161561379d5760405163a34123a760e01b81526001600160a01b0386169063a34123a790613746908c908c908690600401615967565b6040805180830381600087803b15801561375f57600080fd5b505af1158015613773573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613797919061540e565b90935091505b600080866001600160a01b0316634f1eb3d8308d8d6001600160801b03806040518663ffffffff1660e01b81526004016137db959493929190615808565b6040805180830381600087803b1580156137f457600080fd5b505af1158015613808573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061382c9190615585565b6001600160801b031691506001600160801b031691506040518060a00160405280868152602001858152602001846001600160801b0316815260200161387b878561333d90919063ffffffff16565b815260200161388a838761333d565b90529b9a5050505050505050505050565b6000806001600160a01b03881673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2146139515760095460405163f592d4f960e01b81526001600160a01b039091169063f592d4f9906138fc908b908b908b908b908b908b90600401615891565b60206040518083038186803b15801561391457600080fd5b505afa158015613928573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061394c91906156db565b6139d7565b600954604051634e757bad60e01b81526001600160a01b0390911690634e757bad90613987908a9089908b908990600401615931565b60206040518083038186803b15801561399f57600080fd5b505afa1580156139b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139d791906156db565b90506139e98160038001546064613050565b91506139f5898361363e565b8515613a1357600a54613a139089906001600160a01b031688612952565b8415613a3157600a54613a319088906001600160a01b031687612952565b50979650505050505050565b600080600080613a538686600360040154614813565b93509350935093506000861115613b2e576001600160a01b03881673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2148015613a8e575089155b15613b0b57604051632e1a7d4d60e01b815273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc290632e1a7d4d90613aca908590600401615bc0565b600060405180830381600087803b158015613ae457600080fd5b505af1158015613af8573d6000803e3d6000fd5b50505050613b068983614856565b613b16565b613b16888a84612952565b600a54613b2e9089906001600160a01b031686612952565b8415613bfe576001600160a01b03871673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2148015613b5e575089155b15613bdb57604051632e1a7d4d60e01b815273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc290632e1a7d4d90613b9a908490600401615bc0565b600060405180830381600087803b158015613bb457600080fd5b505af1158015613bc8573d6000803e3d6000fd5b50505050613bd68982614856565b613be6565b613be6878a83612952565b600a54613bfe9088906001600160a01b031685612952565b50505050505050505050565b6001600160a01b03861673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21480613c5157506001600160a01b03851673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2145b15613d555760008080806001600160a01b038a1673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc214613c885789868a87613c8d565b88858b885b93509350935093508715613cc2578515613cac57613cac828883612952565b8415613cbd57613cbd848885612952565b613d4c565b8015613d3b57604051632e1a7d4d60e01b815273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc290632e1a7d4d90613cff908490600401615bc0565b600060405180830381600087803b158015613d1957600080fd5b505af1158015613d2d573d6000803e3d6000fd5b50505050613d3b8782614856565b8215613d4c57613d4c848885612952565b505050506111d4565b8115613d6657613d66868484612952565b80156111d4576111d4858483612952565b6001600160801b038216156133215760405163a34123a760e01b81526001600160a01b0382169063a34123a790613db79087908790600090600401615967565b6040805180830381600087803b158015613dd057600080fd5b505af1158015613de4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111d4919061540e565b600080613e1a8686856000808961354f565b909890975095505050505050565b6001600160a01b0384166000908152600260205260408120819081908190613e4e614d8f565b613e578a61253f565b50600290810b810b6060890181905262ffffff90951660408901526001600160a01b03958616602089015295909416865250508454830b830b920b91909112905080613eb95750815460608201516301000000909104600290810b810b91900b135b15613ed457613eca8a8a8a8a6140f9565b90945092506140ec565b81546060820151600091600160b01b9004600290810b810b91900b12801590613f14575082546060830151600160c81b909104600290810b810b91900b13155b613f1f576000613f22565b60015b6040805160e08101825284516001600160a01b039081168252602080870151909116908201528482015162ffffff16918101919091528454600281810b810b60608401526301000000909104810b900b608082015260ff919091169150613fa79060a08101613f918d8561333d565b8152602001613fa08c8561333d565b9052613406565b5060c085015260a08085019182526001600160801b039092166080808601919091526040805160e08101825286516001600160a01b039081168252602080890151909116908201528187015162ffffff16918101919091528654600160b01b8104600290810b810b6060840152600160c81b909104810b900b9181019190915290516140579282019061403b908e9061333d565b8152602001613fa08560c001518d61333d90919063ffffffff16565b50610120850181905261010085018290526001600160801b0392831660e086018190526080860151875475ffffffffffffffffffffffffffffffff000000000000198116600160301b9182900487169092018616021787556001870180546001600160801b03198116908616909201909416179092556006850180548b01905560a084015160c0850151909950975095509350505b5050945094509450949050565b600080614104614cba565b61410d8761253f565b50505062ffffff92831660408088019182526001600160a01b039586166020808a0191825297871689528e871660009081526002808a5290839020835160e0810185528b518a16815292519098169882019890985291519094169381019390935250508154600160b01b8104840b840b6060830152600160c81b9004830b90920b608083015260a0820188905260c08201879052906141ab90613406565b5060a08501819052608085018290526001600160801b0392831660609095018590526001840180548085169096019093166001600160801b031990951694909417909155600690910180549095019094559296929550919350505050565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166323b872dd60e01b178152925182516000948594938a169392918291908083835b602083106142a25780518252601f199092019160209182019101614283565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114614304576040519150601f19603f3d011682016040523d82523d6000602084013e614309565b606091505b5091509150818015614337575080511580614337575080806020019051602081101561433457600080fd5b50515b6111d4576040805162461bcd60e51b815260206004820152600360248201526229aa2360e91b604482015290519081900360640190fd5b60008060008360020b12614385578260020b61438d565b8260020b6000035b9050620d89e88111156143cb576040805162461bcd60e51b81526020600482015260016024820152601560fa1b604482015290519081900360640190fd5b6000600182166143df57600160801b6143f1565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff1690506002821615614425576ffff97272373d413259a46990580e213a0260801c5b6004821615614444576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b6008821615614463576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615614482576fffcb9843d60f6159c9db58835c9266440260801c5b60208216156144a1576fff973b41fa98c081472e6896dfb254c00260801c5b60408216156144c0576fff2ea16466c96a3843ec78b326b528610260801c5b60808216156144df576ffe5dee046a99a2a811c461f1969c30530260801c5b6101008216156144ff576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b61020082161561451f576ff987a7253ac413176f2b074cf7815e540260801c5b61040082161561453f576ff3392b0822b70005940c7a398e4b70f30260801c5b61080082161561455f576fe7159475a2c29b7443b29c7fa6e889d90260801c5b61100082161561457f576fd097f3bdfd2022b8845ad8f792aa58250260801c5b61200082161561459f576fa9f746462d870fdf8a65dc1f90e061e50260801c5b6140008216156145bf576f70d869a156d2a1b890bb3df62baf32f70260801c5b6180008216156145df576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615614600576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b62020000821615614620576e5d6af8dedb81196699c329225ee6040260801c5b6204000082161561463f576d2216e584f5fa1ea926041bedfe980260801c5b6208000082161561465c576b048a170391f7dc42444e8fa20260801c5b60008460020b131561467757806000198161467357fe5b0490505b64010000000081061561468b57600161468e565b60005b60ff16602082901c0192505050919050565b600080836001600160a01b0316856001600160a01b031611156146c1579293925b846001600160a01b0316866001600160a01b0316116146ec576146e5858585614945565b9150614733565b836001600160a01b0316866001600160a01b0316101561472557614711868585614945565b915061471e8587856149ae565b9050614733565b6147308585856149ae565b90505b94509492505050565b6000836001600160a01b0316856001600160a01b0316111561475c579293925b846001600160a01b0316866001600160a01b031611614787576147808585856149f1565b90506147f7565b836001600160a01b0316866001600160a01b031610156147e95760006147ae8786866149f1565b905060006147bd878986614a54565b9050806001600160801b0316826001600160801b0316106147de57806147e0565b815b925050506147f7565b6147f4858584614a54565b90505b95945050505050565b60006001600160801b0382111561333957fe5b60008060008061482587866064613050565b935061483386866064613050565b925061483f878561333d565b915061484b868461333d565b905093509350935093565b604080516000808252602082019092526001600160a01b0384169083906040518082805190602001908083835b602083106148a25780518252601f199092019160209182019101614883565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114614904576040519150601f19603f3d011682016040523d82523d6000602084013e614909565b606091505b5050905080610b34576040805162461bcd60e51b815260206004820152600360248201526253544560e81b604482015290519081900360640190fd5b6000826001600160a01b0316846001600160a01b03161115614965579192915b836001600160a01b031661499e606060ff16846001600160801b0316901b8686036001600160a01b0316866001600160a01b0316613050565b816149a557fe5b04949350505050565b6000826001600160a01b0316846001600160a01b031611156149ce579192915b612535826001600160801b03168585036001600160a01b0316600160601b613050565b6000826001600160a01b0316846001600160a01b03161115614a11579192915b6000614a34856001600160a01b0316856001600160a01b0316600160601b613050565b90506147f7614a4f84838888036001600160a01b0316613050565b614a91565b6000826001600160a01b0316846001600160a01b03161115614a74579192915b612535614a4f83600160601b8787036001600160a01b0316613050565b806001600160801b03811681146106ba57600080fd5b6040518060c0016040528060006001600160a01b0316815260200160008152602001600081526020016000815260200160008152602001600081525090565b6040518060e001604052806000815260200160006001600160a01b0316815260200160008152602001600081526020016000815260200160008152602001600081525090565b6040805161024081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101829052610100810182905261012081018290526101408101829052610160810182905261018081018290526101a081018290526101c081018290526101e08101829052610200810182905261022081019190915290565b6040518060c00160405280600062ffffff16815260200160006001600160a01b03168152602001600081526020016000815260200160008152602001600081525090565b60405180610220016040528060001515815260200160006001600160a01b03168152602001600060020b815260200160006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160801b03168152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a081019190915290565b604051806080016040528060006001600160a01b0316815260200160006001600160a01b0316815260200160008152602001600081525090565b604051806101600160405280600060020b8152602001600060020b8152602001600060020b8152602001600060020b8152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6040805161014081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101829052610100810182905261012081019190915290565b6040518060a00160405280600081526020016000815260200160006001600160801b0316815260200160008152602001600081525090565b60008083601f840112614e2c578182fd5b50813567ffffffffffffffff811115614e43578182fd5b602083019150836020828501011115614e5b57600080fd5b9250929050565b600082601f830112614e72578081fd5b813567ffffffffffffffff80821115614e8757fe5b604051601f8301601f191681016020018281118282101715614ea557fe5b604052828152848301602001861015614ebc578384fd5b82602086016020830137918201602001929092529392505050565b80516001600160801b03811681146106ba57600080fd5b600060208284031215614eff578081fd5b813561253881615e42565b600060208284031215614f1b578081fd5b815161253881615e42565b600080600080600060a08688031215614f3d578081fd5b8551614f4881615e42565b6020870151909550614f5981615e42565b6040870151909450614f6a81615e68565b6060870151909350614f7b81615e68565b9150614f8960808701614ed7565b90509295509295909350565b60008060008060608587031215614faa578182fd5b8435614fb581615e42565b93506020850135614fc581615e42565b9250604085013567ffffffffffffffff811115614fe0578283fd5b614fec87828801614e1b565b95989497509550505050565b60008060006060848603121561500c578081fd5b833561501781615e42565b9250602084013561502781615e42565b9150604084013567ffffffffffffffff811115615042578182fd5b61504e86828701614e62565b9150509250925092565b60008060006060848603121561506c578081fd5b833561507781615e42565b9250602084013561508781615e42565b9150604084013561509781615e87565b809150509250925092565b600080600080600080600080610100898b0312156150be578586fd5b88356150c981615e42565b975060208901356150d981615e42565b965060408901359550606089013594506080890135935060a0890135925060c089013561510581615e5a565b915060e089013567ffffffffffffffff811115615120578182fd5b61512c8b828c01614e62565b9150509295985092959890939650565b6000806040838503121561514e578182fd5b823561515981615e42565b915060208381013567ffffffffffffffff80821115615176578384fd5b818601915086601f830112615189578384fd5b6040516101408101818110838211171561519f57fe5b60405290508082855b600a8110156151d0576151be8a83358701614e62565b845292850192908501906001016151a8565b50959890975095505050505050565b600080600080600060a086880312156151f6578283fd5b853561520181615e42565b9450602086013561521181615e5a565b9350604086013561522181615e5a565b9250606086013561523181615e42565b9150608086013561524181615e42565b809150509295509295909350565b600080600060608486031215615263578081fd5b833561526e81615e42565b9250602084013561527e81615e68565b9150604084013561509781615e68565b600080600080608085870312156152a3578182fd5b84356152ae81615e5a565b935060208501356152be81615e5a565b925060408501359150606085013567ffffffffffffffff8111156152e0578182fd5b6152ec87828801614e62565b91505092959194509250565b600080600080600060a0868803121561530f578283fd5b853561531a81615e5a565b9450602086013561532a81615e5a565b93506040860135925060608601359150608086013567ffffffffffffffff811115615353578182fd5b61535f88828901614e62565b9150509295509295909350565b60006020828403121561537d578081fd5b815161253881615e68565b60008060008060008060c087890312156153a0578384fd5b86516153ab81615e68565b60208801519096506153bc81615e68565b60408801519095506153cd81615e68565b60608801519094506153de81615e68565b60808801519093506153ef81615e68565b60a088015190925061540081615e68565b809150509295509295509295565b60008060408385031215615420578182fd5b505080516020909101519092909150565b60008060008060608587031215615446578182fd5b8435935060208501359250604085013567ffffffffffffffff811115614fe0578283fd5b60006080828403121561547b578081fd5b6040516080810181811067ffffffffffffffff8211171561549857fe5b60405282356154a681615e42565b815260208301356154b681615e42565b602082015260408301356154c981615e42565b604082015260608301356154dc81615e87565b60608201529392505050565b6000606082840312156154f9578081fd5b6040516060810181811067ffffffffffffffff8211171561551657fe5b604052823561552481615e42565b8152602083013561553481615e42565b6020820152604083013561554781615e87565b60408201529392505050565b60006101a08284031215615565578081fd5b50919050565b60006020828403121561557c578081fd5b61253882614ed7565b60008060408385031215615597578182fd5b6155a083614ed7565b91506155ae60208401614ed7565b90509250929050565b600080600080600080600060e0888a0312156155d1578081fd5b87516155dc81615e42565b60208901519097506155ed81615e68565b60408901519096506155fe81615e77565b606089015190955061560f81615e77565b608089015190945061562081615e77565b60a089015190935061563181615e98565b60c089015190925061564281615e5a565b8091505092959891949750929550565b600060208284031215615663578081fd5b813561253881615e87565b60006020828403121561567f578081fd5b815161253881615e87565b6000806040838503121561569c578182fd5b82516156a781615e87565b60208401519092506156b881615e42565b809150509250929050565b6000602082840312156156d4578081fd5b5035919050565b6000602082840312156156ec578081fd5b5051919050565b6001600160a01b03169052565b15159052565b60008151808452815b8181101561572b5760208185018101518683018201520161570f565b8181111561573c5782602083870101525b50601f01601f19169290920160200192915050565b60020b9052565b6001600160801b03169052565b60ff169052565b6001600160a01b0391909116815260200190565b60006001600160a01b038088168352861515602084015285604084015280851660608401525060a060808301526157ba60a0830184615706565b979650505050505050565b60006001600160a01b03871682528560020b60208301528460020b60408301526001600160801b038416606083015260a060808301526157ba60a0830184615706565b6001600160a01b03959095168552600293840b60208601529190920b60408401526001600160801b03918216606084015216608082015260a00190565b6001600160a01b03938416815291909216602082015262ffffff909116604082015260600190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0396871681529486166020860152604085019390935260608401919091528316608083015290911660a082015260c00190565b6001600160a01b039790971687526001600160801b039586166020880152939094166040860152600291820b6060860152810b608085015291820b60a0840152900b60c082015260e00190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b03948516815260208101939093526040830191909152909116606082015260800190565b901515815260200190565b600293840b81529190920b60208201526001600160801b03909116604082015260600190565b6000610240820190506159a1828451615751565b60208301516159b36020840182615751565b5060408301516159c66040840182615758565b5060608301516159d96060840182615751565b5060808301516159ec6080840182615751565b5060a08301516159ff60a0840182615758565b5060c0838101519083015260e0808401519083015261010080840151908301526101208084015190830152610140808401519083015261016080840151615a4882850182615700565b505061018080840151615a5d828501826156f3565b50506101a080840151615a72828501826156f3565b50506101c083810151908301526101e080840151615a9282850182615765565b505061020080840151615aa782850182615700565b505061022080840151615abc82850182615700565b505092915050565b60006080820190506001600160a01b038084511683528060208501511660208401528060408501511660408401525062ffffff606084015116606083015292915050565b600060e082019050825182526001600160a01b03602084015116602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015260c083015160c083015292915050565b81516001600160a01b0390811682526020808401519091169082015260409182015162ffffff169181019190915260600190565b61ffff91909116815260200190565b62ffffff9290921682526001600160a01b0316602082015260400190565b90815260200190565b918252602082015260400190565b9283526020830191909152604082015260600190565b93845260208401929092526040830152606082015260800190565b9586526020860194909452604085019290925260608401526001600160a01b0390811660808401521660a082015260c00190565b6000813561334d81615e42565b6000813561334d81615e77565b6000813561334d81615e87565b6000813561334d81615e98565b6001600160a01b03821673ffffffffffffffffffffffffffffffffffffffff198254161781555050565b615cac615ca683615c63565b82615dab565b615cc1615cbb60208401615c56565b82615dbc565b60408201356001820155606082013560028201556080820135600382015560a0820135600482015560058101615d02615cfc60c08501615c56565b82615d96565b615d17615d1160e08501615c49565b82615dd8565b615d2d615d276101008501615c3c565b82615df6565b50615d47615d3e6101208401615c3c565b60068301615c70565b615d60615d576101408401615c3c565b60078301615c70565b615d79615d706101608401615c3c565b60088301615c70565b615d92615d896101808401615c3c565b60098301615c70565b5050565b62ffffff821662ffffff198254161781555050565b60ff821660ff198254161781555050565b805463ffffff008360081b1663ffffff00198216178255505050565b805464ffff0000008360181b1664ffff000000198216178255505050565b805478ffffffffffffffffffffffffffffffffffffffff00000000008360281b167fffffffffffffff0000000000000000000000000000000000000000ffffffffff8216178255505050565b6001600160a01b0381168114615e5757600080fd5b50565b8015158114615e5757600080fd5b8060020b8114615e5757600080fd5b61ffff81168114615e5757600080fd5b62ffffff81168114615e5757600080fd5b60ff81168114615e5757600080fdfea164736f6c6343000706000a000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000186a0000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000000000000000000000000000000000003a35294400000000000000000000000000000000000000000000000000000000000000005f000000000000000000000000000000000000000000000000000000000000000f0000000000000000000000000000000000000000000000000000000000000e100000000000000000000000000000000000000000000000000000000000000050000000000000000000000000fc9f572124d8f469960b94537b493f2676776c03000000000000000000000000458766536f95b9333d48a78a91ab1aaf4226221a00000000000000000000000095477f96f78ec38916b5457030387d844e886ab30000000000000000000000007b0909218ad3f30d49caa711b8274819281b21fd000000000000000000000000de5bf92e3372aa59c73ca7dfc6cec599e1b2b08c0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f984
Deployed Bytecode
0x6080604052600436106101125760003560e01c8063602c231d116100a55780639b6c1dc611610074578063dea68ea011610059578063dea68ea014610300578063e14767b514610320578063fa461e331461034e57610119565b80639b6c1dc6146102cd578063d3487997146102e057610119565b8063602c231d14610240578063615837e814610260578063749b1d59146102805780639b12a1f7146102ad57610119565b806335dca703116100e157806335dca703146101a657806349acb5e0146101d3578063595e6f11146102005780635a18cc6b1461022057610119565b80630121240c1461011b578063026d1c8e1461012e5780630caa03af146101415780631e7f13701461017957610119565b3661011957005b005b6101196101293660046152f8565b61036e565b61011961013c36600461528e565b6104e0565b34801561014d57600080fd5b5061016161015c366004614f95565b61060c565b60405161017093929190615bd7565b60405180910390f35b34801561018557600080fd5b506101996101943660046156c3565b610649565b6040516101709190615b08565b3480156101b257600080fd5b506101c66101c1366004614eee565b6106bf565b604051610170919061598d565b3480156101df57600080fd5b506101f36101ee36600461524f565b6107f7565b604051610170919061595c565b34801561020c57600080fd5b506101f361021b366004614eee565b6108ca565b34801561022c57600080fd5b5061011961023b3660046151df565b61091c565b34801561024c57600080fd5b5061016161025b366004614eee565b6109c8565b34801561026c57600080fd5b5061011961027b366004615553565b610b1f565b34801561028c57600080fd5b506102a061029b366004614ff8565b610b39565b604051610170919061576c565b3480156102b957600080fd5b506101196102c836600461513c565b610cba565b6101196102db3660046150a2565b610eca565b3480156102ec57600080fd5b506101196102fb366004615431565b611178565b34801561030c57600080fd5b5061011961031b366004615058565b6111dc565b34801561032c57600080fd5b5061034061033b3660046156c3565b611a53565b604051610170929190615bc9565b34801561035a57600080fd5b50610119610369366004615431565b611c45565b610376611c9d565b60005460ff1660011461038857600080fd5b6000805460ff19168155828152600160205260409020836103a857600080fd5b80600201548411156103b957600080fd5b6103c1614aa7565b828060200190518101906103d59190614f0a565b6001600160a01b03908116825260018301546103f5916000911687611cb6565b604080840191825260208085019384528151610100810183528b151581528a15159181019190915260018601546001600160a01b0390811692820192909252845190911660608201526080810187905260a08101889052915160c08301525160e082015261046290611ef4565b60a08401526080830152606082015280516001830154602083015160408085015190516001600160a01b0394851694909316927f3cae9923fd3c2f468aa25a8ef687923e37f957459557c0380fd06526c0b8cdbc926104c2928a92615bd7565b60405180910390a350506000805460ff191660011790555050505050565b6104e8611c9d565b60005460ff166001146104fa57600080fd5b6000805460ff1916815582815260016020818152604092839020835160e08101855281548152928101546001600160a01b03169183019190915260028101549282018390526003810154606083015260048101546080830152600581015460a08301526006015460c08201529061057057600080fd5b6000828060200190518101906105869190614f0a565b9050610595826020015161222d565b6105f46040518061010001604052808815158152602001871515815260200184602001516001600160a01b03168152602001836001600160a01b0316815260200186815260200160008152602001600081526020016000815250611ef4565b50506000805460ff1916600117905550505050505050565b600080808061061d85870187615652565b9050600061062c898984612492565b9050610637816109c8565b919b909a509098509650505050505050565b610651614ae6565b50600081815260016020818152604092839020835160e08101855281548152928101546001600160a01b0316918301919091526002810154928201929092526003820154606082015260048201546080820152600582015460a082015260069091015460c08201525b919050565b6106c7614b2c565b506001600160a01b03908116600090815260026020818152604092839020835161024081018552815480850b850b850b825263010000008104850b850b850b938201939093526001600160801b03600160301b8404811695820195909552600160b01b8304840b840b840b6060820152600160c81b909204830b830b830b6080830152600181015490931660a08201529082015460c0820152600382015460e082015260048201546101008083019190915260058301546101208301526006830154610140830152600783015460ff808216151561016085015290829004851661018084015260088401549094166101a083015260098301546101c0830152600a909201548084166101e08301529182048316151561020082015262010000909104909116151561022082015290565b6000806108038561253f565b50600b54604051634ed8cf2760e01b8152919850600097506001600160a01b03169550634ed8cf27945061083f93508b9250600401905061576c565b60206040518083038186803b15801561085757600080fd5b505afa15801561086b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061088f919061536c565b905080850160020b8260020b12806108ae575080840360020b8260020b135b156108bc57600192506108c1565b600092505b50509392505050565b6001600160a01b0381166000908152600260205260408120600854600982015462ffffff9091164291909103111561090a57600a8101805461ffff191690555b600a0154610100900460ff1692915050565b61092461281f565b6001600160a01b039485166000908152600260205260409020600781018054600a83018054961515620100000262ff00001990971696909617909555928616610100027fffffffffffffffffffffff0000000000000000000000000000000000000000ff95151560ff199095169490941794909416929092179055600890910180549190921673ffffffffffffffffffffffffffffffffffffffff19909116179055565b6001600160a01b038082166000908152600260208181526040808420815161024081018352815480860b860b860b825263010000008104860b860b860b948201949094526001600160801b03600160301b8504811693820193909352600160b01b8404850b850b850b6060820152600160c81b909304840b840b840b6080840152600181015490911660a08301529182015460c0820152600382015460e0820152600482015461010080830191909152600583015461012083015260068301546101408301819052600784015460ff808216151561016086015290839004871661018085015260088501549096166101a084015260098401546101c0840152600a909301548086166101e08401529081048516151561020083015262010000900490931615156102208401529091829182919015610b1657610b0a81866128b9565b93509350935050610b18565b505b9193909250565b610b2761281f565b806003610b348282615c9a565b505050565b600080600083806020019051810190610b52919061568a565b60405163a167129560e01b815291935091506001600160a01b037f0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f984169063a167129590610ba790899089908790600401615845565b602060405180830381600087803b158015610bc157600080fd5b505af1158015610bd5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf99190614f0a565b60405163f637731d60e01b81529093506001600160a01b0384169063f637731d90610c2890849060040161576c565b600060405180830381600087803b158015610c4257600080fd5b505af1158015610c56573d6000803e3d6000fd5b50505050826001600160a01b0316856001600160a01b0316876001600160a01b03167f1e0ec922dce1f1a88ad6fca4aecc5eefbda9b5c760e9acc4e70e1672ed80760e8585604051610ca9929190615ba2565b60405180910390a450509392505050565b610cc261281f565b60005b600a811015610b345760008060008060008686600a8110610ce257fe5b6020020151806020019051810190610cfa9190614f26565b9398509196509450925090506001600160a01b03841615610e275760405163a34123a760e01b81526001600160a01b0385169063a34123a790610d4590869086908690600401615967565b6040805180830381600087803b158015610d5e57600080fd5b505af1158015610d72573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d96919061540e565b50506040516309e3d67b60e31b81526001600160a01b03851690634f1eb3d890610dd3908b90879087906001600160801b03908190600401615808565b6040805180830381600087803b158015610dec57600080fd5b505af1158015610e00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e249190615585565b50505b6040516370a0823160e01b81526000906001600160a01b038716906370a0823190610e5690309060040161576c565b60206040518083038186803b158015610e6e57600080fd5b505afa158015610e82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ea691906156db565b90508015610eb957610eb9868a83612952565b505050505050806001019050610cc5565b610ed2611c9d565b610eda614bc0565b81806020019051810190610eee919061566e565b62ffffff16808252610f03908a908a90612492565b6001600160a01b0316602080830182905260009182526002905260409020600681015415610f3857610f38826020015161222d565b610f6e604051806080016040528084602001516001600160a01b031681526020018a815260200189815260200188815250612ab5565b60a086015260808501526060840152604083015283611031576000858152600160208181526040909220908101549184015190916001600160a01b03918216911614610fb957600080fd5b610fd681600301548360040154038260020154600160801b613050565b816005016000828254019250508190555061100481600401548360050154038260020154600160801b613050565b600682018054909101905560028101805488019055600482810154600383015560058301549101556110fc565b6040518060e001604052806000815260200183602001516001600160a01b031681526020018781526020018260040154815260200182600501548152602001600081526020016000815250600160008781526020019081526020016000206000820151816000015560208201518160010160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060408201518160020155606082015181600301556080820151816004015560a0820151816005015560c082015181600601559050505b611121826020015183608001518460400151018460a001518560600151018b8b6130ff565b81602001516001600160a01b03167fe3b53cd1a44fbf11535e145d80b8ef1ed6d57a73bf5daa7e939b6b01657d6549868a8a8a6040516111649493929190615bed565b60405180910390a250505050505050505050565b3360006111878385018561546a565b90506111a08160200151826040015183606001516131a0565b85156111ba576111ba8160200151826000015184896131c8565b84156111d4576111d48160400151826000015184886131c8565b505050505050565b60005a90506111e9614c04565b6111f4858585612492565b6001600160a01b03166020808301828152600092835260029091526040909120905161121f906108ca565b1561122957600080fd5b602082015181546112499190600281810b9163010000009004900b6107f7565b61125257600080fd5b42600982015560208201516112669061253f565b50506001600160a01b0316606088015250505060208401516006840154611291935060019250611cb6565b61010084015260e0830181905215806112ad5750610100820151155b156114d45760008260e00151116112cb5760008261010001516112d3565b60018260e001515b61012084015215158252600354620f424090600290610100900462ffffff160462ffffff168360600151026001600160a01b03168161130e57fe5b046001600160a01b03166080830152815161133357816080015182606001510161133f565b81608001518260600151035b6001600160a01b031660a0830152610120820151600354611365919060ff166064613050565b61012083018190526020830151835160009283926001600160a01b03169163128acb089130919061139590613327565b8860a0015160405180606001604052808f6001600160a01b031681526020018e6001600160a01b031681526020018d62ffffff168152506040516020016113dc9190615b5f565b6040516020818303038152906040526040518663ffffffff1660e01b815260040161140b959493929190615780565b6040805180830381600087803b15801561142457600080fd5b505af1158015611438573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061145c919061540e565b91509150600181121561149f5760e08401516000919091039061147f908361333d565b60e08501526101008401516114949082613353565b6101008501526114d1565b60e0840151600092909203916114b59083613353565b60e08501526101008401516114ca908261333d565b6101008501525b50505b6114dc614cba565b6114e98360200151613363565b866000018760200188604001896060018a6080018b60a0018660020b60020b8152508660020b60020b8152508660020b60020b8152508660020b60020b8152508660020b60020b8152508660020b60020b8152505050505050506115ac6040518060e00160405280896001600160a01b03168152602001886001600160a01b031681526020018762ffffff168152602001836000015160020b8152602001836020015160020b81526020018560e001518152602001856101000151815250613406565b5061016086015261014085018190526001600160801b039190911660c0850181905282516020840151855465ffffff00000019166301000000600292830b62ffffff908116919091029190911762ffffff19169290910b161775ffffffffffffffffffffffffffffffff0000000000001916600160301b90910217835560e084015160009161163b919061333d565b9050600061165c85610160015186610100015161333d90919063ffffffff16565b9050600061167b84604001518560600151600086868b6020015161354f565b50509050600061169c85608001518660a00151600087878c6020015161354f565b50509050806001600160801b0316826001600160801b0316111561178d5761171a6040518060e001604052808d6001600160a01b031681526020018c6001600160a01b031681526020018b62ffffff168152602001876040015160020b8152602001876060015160020b815260200186815260200185815250613406565b506101a08a015261018089015250604085015160608601518754600292830b62ffffff908116600160b01b0262ffffff60b01b199390940b16600160c81b0262ffffff60c81b1990911617161786556001860180546001600160801b0384166001600160801b031990911617905561185c565b6117ed6040518060e001604052808d6001600160a01b031681526020018c6001600160a01b031681526020018b62ffffff168152602001876080015160020b81526020018760a0015160020b815260200186815260200185815250613406565b506101a08a015261018089015250608085015160a08601518754600292830b62ffffff908116600160b01b0262ffffff60b01b199390940b16600160c81b0262ffffff60c81b1990911617161786556001860180546001600160801b0383166001600160801b03199091161790555b600a8601805460ff198116600160ff9283160182161791829055166002141561189157600a8601805461ff0019166101001790555b600a86015462010000900460ff1615611996576005543a11156118b357600080fd5b6004546118d5906118cf6118c85a8c9061333d565b3a9061361a565b90613353565b6101e08801819052600954600854604051633ff01ddf60e01b81526001600160a01b0392831693633ff01ddf93611933937337c997b35c619c21323f3518b9357914e8b995259365010000000000909104909116919060040161586d565b60206040518083038186803b15801561194b57600080fd5b505afa15801561195f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061198391906156db565b610200880181905261199690339061363e565b6119c8876020015188610180015189610140015101896101a001518a6101600151018a60e001518b61010001516130ff565b6020870151865460018801546040517fa25b5d6734ecac8eab8efed28486b538d745cb1bd19e0d3ab3bcc1631669641193611a3e9390926001600160801b03600160301b8304811693911691600281810b9263010000008304820b92600160b01b8104830b92600160c81b909104900b906158cb565b60405180910390a15050505050505050505050565b6000818152600160208181526040808420815160e08101835281548152938101546001600160a01b03169284018390526002810154918401919091526003810154606084015260048101546080840152600581015460a08401526006015460c0830152829190611ac29061222d565b6020808201516001600160a01b03908116600090815260028084526040808320815161024081018352815480850b850b850b825263010000008104850b850b850b978201979097526001600160801b03600160301b8804811682850152600160b01b8804850b850b850b606080840191909152600160c81b909804850b850b850b608080840191909152600184015490911660a08301529382015460c0820152600382015460e08201526004820154610100808301829052600584015461012084018190526006850154610140850152600785015460ff8082161515610160870152908390048a1661018086015260088601549099166101a085015260098501546101c0850152600a909401548089166101e085015290810488161515610200840152620100009004909616151561022082015295870151928701519187015193948594611c1494939290919061369e565b60a08601519193509150611c289083613353565b60c0850151909650611c3a9082613353565b945050505050915091565b336000611c54838501856154e8565b9050611c6d8160000151826020015183604001516131a0565b6000861315611c84578051611c84903084896131c8565b60008513156111d4576111d481602001513084886131c8565b600c546001600160a01b03163314611cb457600080fd5b565b6001600160a01b0382166000908152600260205260408120600681015482919085908390611cef908790670de0b6b3a764000090613050565b8354909150600090611d2390600281810b916301000000810490910b90600160301b90046001600160801b031685876136d4565b84546001860154919250600091611d5c91600160b01b8104600290810b92600160c81b909204900b906001600160801b031686886136d4565b9050611d87611d7c8260600151846060015161335390919063ffffffff16565b600287015490613353565b600286015560808082015190830151611daf91611da49190613353565b600387015490613353565b8560030181905550611dd48160600151836060015101600160801b8760060154613050565b8560040160008282540192505081905550611e028160800151836080015101600160801b8760060154613050565b600586018054909101905580518251611e1a91613353565b9650611e378160200151836020015161335390919063ffffffff16565b955089611e53576006850154611e4d908961333d565b60068601555b60408083015186546001600160801b03600160301b808304821693909303811690920275ffffffffffffffffffffffffffffffff0000000000001990911617875590820151600187018054808416929092039092166001600160801b03199091161790556006850154611ee75784547fffffffff000000000000ffffffffffffffffffffffffffffffff0000000000001685555b5050505050935093915050565b6000806000611f01614cef565b604080860180516001600160a01b031660009081526002602090815283822060808a0151835260019091529290209051611f3a9061253f565b5050506001600160a01b03938416602089015250505016835260038101546004808301546002840154918501546005860154611f789493919061369e565b606085018190526040850182905260058084018054909301909255600683018054909101905560048084015460038401559083015490820155600782015460ff168015611fc3575086515b156121285782516001600160a01b031673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21480612014575060208301516001600160a01b031673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2145b156120e05760008060008060008073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031689600001516001600160a01b031614612085578851600588015460078a015460208c015160068b015460088d01546001600160a01b03610100909404841693166120b4565b6020890151600688015460088a01548b5160058b015460078d01546001600160a01b0393841693610100909104165b9550955095509550955095506120d38d6060015184888589868a61389b565b9950505050505050612123565b60608701518351602085015160058401546006850154600787015460088801546121209695949392916001600160a01b036101009091048116911661389b565b93505b61214e565b61214e876020015188606001518560000151866020015185600501548660060154613a3d565b6121748360000151846020015189602001518a606001518b60c001518c60e00151613c0a565b6005810154600682015460028401549197509550612192908761333d565b6002830155600681015460038301546121aa9161333d565b6003830155600060058201819055600682015560a087015160028201546121d09161333d565b6002820155608087015160408089015160608a015191517fb543e95af3893fca952f2096ca5e34bcca256c05358f31373b6e645087610ea89361221b9390928b928b928b9291615c08565b60405180910390a15050509193909250565b6001600160a01b03811660009081526002602081905260409091208054909183916122779181810b916301000000810490910b90600160301b90046001600160801b031684613d77565b815460018301546122a991600160b01b8104600290810b92600160c81b909204900b906001600160801b031684613d77565b81546040516309e3d67b60e31b815260009182916001600160a01b03851691634f1eb3d8916122f7913091600282810b9263010000009004900b906001600160801b03908190600401615808565b6040805180830381600087803b15801561231057600080fd5b505af1158015612324573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123489190615585565b85546040516309e3d67b60e31b81526001600160801b039384169550918316935060009283926001600160a01b03881692634f1eb3d8926123a7923092600160b01b8104600290810b93600160c81b909204900b918190600401615808565b6040805180830381600087803b1580156123c057600080fd5b505af11580156123d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123f89190615585565b6001600160801b0391821693501690506124206124158584613353565b600288015490613353565b600287015561243d6124328483613353565b600388015490613353565b866003018190555061245a828501600160801b8860060154613050565b6004870180549091019055600686015461247d9084830190600160801b90613050565b60059096018054909601909555505050505050565b604051630b4c774160e11b81526000906001600160a01b037f0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f9841690631698ee82906124e590879087908790600401615845565b60206040518083038186803b1580156124fd57600080fd5b505afa158015612511573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125359190614f0a565b90505b9392505050565b6000806000806000806000806000899050806001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b15801561258957600080fd5b505afa15801561259d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125c19190614f0a565b9850806001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b1580156125fc57600080fd5b505afa158015612610573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126349190614f0a565b9750806001600160a01b031663ddca3f436040518163ffffffff1660e01b815260040160206040518083038186803b15801561266f57600080fd5b505afa158015612683573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126a7919061566e565b9650806001600160a01b0316631a6865026040518163ffffffff1660e01b815260040160206040518083038186803b1580156126e257600080fd5b505afa1580156126f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061271a919061556b565b9450806001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561275557600080fd5b505afa158015612769573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061278d91906155b7565b5050604080516334324e9f60e21b81529051929b509498509296506001600160a01b0385169363d0c93a7c93506004808201935060209291829003018186803b1580156127d957600080fd5b505afa1580156127ed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612811919061536c565b915050919395975091939597565b600c5460408051635aa6e67560e01b815290516001600160a01b0390921691635aa6e67591600480820192602092909190829003018186803b15801561286457600080fd5b505afa158015612878573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061289c9190614f0a565b6001600160a01b0316336001600160a01b031614611cb457600080fd5b60008080836128c6614d29565b6128de87600001518860200151848a60400151613e08565b61010083015260e08201526060870151608088015160a08901516129059291908590613e08565b610140830152610120820181905260e082015161292191613353565b945061294081610140015182610100015161335390919063ffffffff16565b61014090970151949794955050505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1663a9059cbb60e01b1781529251825160009485949389169392918291908083835b602083106129e35780518252601f1990920191602091820191016129c4565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612a45576040519150601f19603f3d011682016040523d82523d6000602084013e612a4a565b606091505b5091509150818015612a78575080511580612a785750808060200190516020811015612a7557600080fd5b50515b612aae576040805162461bcd60e51b815260206004820152600260248201526114d560f21b604482015290519081900360640190fd5b5050505050565b600080600080612ac3614d8f565b8551612ace9061253f565b50600290810b810b606089015261ffff9093166080880152505062ffffff9091166040808601919091526001600160a01b0392831660208087019190915293831685528951909216600090815292529020600681015415612b5457612b458760000151886020015189604001518a60600151613e28565b92985090965094509250613047565b600854608083015161ffff6301000000909204821691161015612be15786516008546040516332148f6760e01b81526001600160a01b03909216916332148f6791612bae91630100000090910461ffff1690600401615b93565b600060405180830381600087803b158015612bc857600080fd5b505af1158015612bdc573d6000803e3d6000fd5b505050505b612be9614cba565b8751612bf490613363565b600290810b810b60a088015290810b810b608087015290810b810b606086015290810b810b604085015290810b810b602084015290810b810b82528254810b900b15801590612c515750815463010000009004600290810b900b15155b15612cb45781546060840151600291820b820b910b1280612c885750815460608401516301000000909104600290810b810b91900b135b15612caf57612ca9886000015189602001518a604001518b606001516140f9565b90955093505b613045565b612d286040518060e0016040528085600001516001600160a01b0316815260200185602001516001600160a01b03168152602001856040015162ffffff168152602001836000015160020b8152602001836020015160020b81526020018a6020015181526020018a60400151815250613406565b5061012086015261010085018190526001600160801b039190911660a085018190528251602084810151865465ffffff00000019166301000000600292830b62ffffff908116919091029190911762ffffff19169390910b169190911775ffffffffffffffffffffffffffffffff0000000000001916600160301b909202919091178455890151600091612dbc919061333d565b90506000612ddc8561012001518b6040015161333d90919063ffffffff16565b9050612df983604001518460600151600085858f6000015161354f565b50506001600160801b031660c0860152608083015160a08401518b51612e279291906000908690869061354f565b50506001600160801b0390811660e0870181905260c08701519091161115612f3c57612eb56040518060e0016040528087600001516001600160a01b0316815260200187602001516001600160a01b03168152602001876040015162ffffff168152602001856040015160020b8152602001856060015160020b815260200184815260200183815250613406565b5060c0880151604087015160608801518954600292830b62ffffff908116600160b01b0262ffffff60b01b199390940b16600160c81b0262ffffff60c81b1990911617161788556001880180546001600160801b039092166001600160801b0319909216919091179055610100880151610120890151909c509a50909850965061302a9050565b612fa86040518060e0016040528087600001516001600160a01b0316815260200187602001516001600160a01b03168152602001876040015162ffffff168152602001856080015160020b81526020018560a0015160020b815260200184815260200183815250613406565b5060e0880151608087015160a08801518954600292830b62ffffff908116600160b01b0262ffffff60b01b199390940b16600160c81b0262ffffff60c81b1990911617161788556001880180546001600160801b039092166001600160801b0319909216919091179055610100880151610120890151909c509a509098509650505b50506060880151600683015461303f91613353565b60068301555b505b50509193509193565b6000808060001985870986860292508281109083900303905080613086576000841161307b57600080fd5b508290049050612538565b80841161309257600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b6001600160a01b038516600090815260026020526040812090613122848761333d565b90506000613130848761333d565b9050811561316457600283018054830190556006830154613158908390600160801b90613050565b60048401805490910190555b80156131965760038301805482019055600683015461318a908290600160801b90613050565b60058401805490910190555b5050505050505050565b6131ab838383612492565b6001600160a01b0316336001600160a01b031614610b3457600080fd5b6001600160a01b03841673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21480156131f45750804710155b156132f45773c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b15801561324857600080fd5b505af115801561325c573d6000803e3d6000fd5b50506040805163a9059cbb60e01b81526001600160a01b038716600482015260248101869052905173c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2945063a9059cbb9350604480830193506020928290030181600087803b1580156132c257600080fd5b505af11580156132d6573d6000803e3d6000fd5b505050506040513d60208110156132ec57600080fd5b506133219050565b6001600160a01b03831630141561331557613310848383612952565b613321565b61332184848484614209565b50505050565b6000600160ff1b821061333957600080fd5b5090565b8082038281111561334d57600080fd5b92915050565b8082018281101561334d57600080fd5b600b5460405163802036f560e01b8152600091829182918291829182916001600160a01b039091169063802036f5906133a0908a9060040161576c565b60c060405180830381600087803b1580156133ba57600080fd5b505af11580156133ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133f29190615388565b949c939b5091995097509550909350915050565b600080600080613423856000015186602001518760400151612492565b90506134448560600151866080015160008860a001518960c001518661354f565b90505080945050806001600160a01b0316633c8a7d8d3087606001518860800151886040518060800160405280306001600160a01b031681526020018c600001516001600160a01b031681526020018c602001516001600160a01b031681526020018c6040015162ffffff168152506040516020016134c39190615ac4565b6040516020818303038152906040526040518663ffffffff1660e01b81526004016134f29594939291906157c5565b6040805180830381600087803b15801561350b57600080fd5b505af115801561351f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613543919061540e565b94969095509092509050565b600080600080846001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561358e57600080fd5b505afa1580156135a2573d6000803e3d6000fd5b505050506040513d60e08110156135b857600080fd5b5051905060006135c78b61436e565b905060006135d48b61436e565b90506001600160801b038a16156135fb576135f18383838d6146a0565b909550935061360b565b6136088383838c8c61473c565b95505b50505096509650969350505050565b60008215806136355750508181028183828161363257fe5b04145b61334d57600080fd5b600c546040516329bb7ba160e11b81526001600160a01b0390911690635376f742906136709085908590600401615918565b600060405180830381600087803b15801561368a57600080fd5b505af11580156111d4573d6000803e3d6000fd5b6000806136b96136ae858961333d565b86600160801b613050565b91506136c86136ae848861333d565b90509550959350505050565b6136dc614de3565b6000806000613705613700886001600160801b031688670de0b6b3a7640000613050565b614800565b90506001600160801b0387161561379d5760405163a34123a760e01b81526001600160a01b0386169063a34123a790613746908c908c908690600401615967565b6040805180830381600087803b15801561375f57600080fd5b505af1158015613773573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613797919061540e565b90935091505b600080866001600160a01b0316634f1eb3d8308d8d6001600160801b03806040518663ffffffff1660e01b81526004016137db959493929190615808565b6040805180830381600087803b1580156137f457600080fd5b505af1158015613808573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061382c9190615585565b6001600160801b031691506001600160801b031691506040518060a00160405280868152602001858152602001846001600160801b0316815260200161387b878561333d90919063ffffffff16565b815260200161388a838761333d565b90529b9a5050505050505050505050565b6000806001600160a01b03881673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2146139515760095460405163f592d4f960e01b81526001600160a01b039091169063f592d4f9906138fc908b908b908b908b908b908b90600401615891565b60206040518083038186803b15801561391457600080fd5b505afa158015613928573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061394c91906156db565b6139d7565b600954604051634e757bad60e01b81526001600160a01b0390911690634e757bad90613987908a9089908b908990600401615931565b60206040518083038186803b15801561399f57600080fd5b505afa1580156139b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139d791906156db565b90506139e98160038001546064613050565b91506139f5898361363e565b8515613a1357600a54613a139089906001600160a01b031688612952565b8415613a3157600a54613a319088906001600160a01b031687612952565b50979650505050505050565b600080600080613a538686600360040154614813565b93509350935093506000861115613b2e576001600160a01b03881673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2148015613a8e575089155b15613b0b57604051632e1a7d4d60e01b815273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc290632e1a7d4d90613aca908590600401615bc0565b600060405180830381600087803b158015613ae457600080fd5b505af1158015613af8573d6000803e3d6000fd5b50505050613b068983614856565b613b16565b613b16888a84612952565b600a54613b2e9089906001600160a01b031686612952565b8415613bfe576001600160a01b03871673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2148015613b5e575089155b15613bdb57604051632e1a7d4d60e01b815273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc290632e1a7d4d90613b9a908490600401615bc0565b600060405180830381600087803b158015613bb457600080fd5b505af1158015613bc8573d6000803e3d6000fd5b50505050613bd68982614856565b613be6565b613be6878a83612952565b600a54613bfe9088906001600160a01b031685612952565b50505050505050505050565b6001600160a01b03861673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21480613c5157506001600160a01b03851673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2145b15613d555760008080806001600160a01b038a1673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc214613c885789868a87613c8d565b88858b885b93509350935093508715613cc2578515613cac57613cac828883612952565b8415613cbd57613cbd848885612952565b613d4c565b8015613d3b57604051632e1a7d4d60e01b815273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc290632e1a7d4d90613cff908490600401615bc0565b600060405180830381600087803b158015613d1957600080fd5b505af1158015613d2d573d6000803e3d6000fd5b50505050613d3b8782614856565b8215613d4c57613d4c848885612952565b505050506111d4565b8115613d6657613d66868484612952565b80156111d4576111d4858483612952565b6001600160801b038216156133215760405163a34123a760e01b81526001600160a01b0382169063a34123a790613db79087908790600090600401615967565b6040805180830381600087803b158015613dd057600080fd5b505af1158015613de4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111d4919061540e565b600080613e1a8686856000808961354f565b909890975095505050505050565b6001600160a01b0384166000908152600260205260408120819081908190613e4e614d8f565b613e578a61253f565b50600290810b810b6060890181905262ffffff90951660408901526001600160a01b03958616602089015295909416865250508454830b830b920b91909112905080613eb95750815460608201516301000000909104600290810b810b91900b135b15613ed457613eca8a8a8a8a6140f9565b90945092506140ec565b81546060820151600091600160b01b9004600290810b810b91900b12801590613f14575082546060830151600160c81b909104600290810b810b91900b13155b613f1f576000613f22565b60015b6040805160e08101825284516001600160a01b039081168252602080870151909116908201528482015162ffffff16918101919091528454600281810b810b60608401526301000000909104810b900b608082015260ff919091169150613fa79060a08101613f918d8561333d565b8152602001613fa08c8561333d565b9052613406565b5060c085015260a08085019182526001600160801b039092166080808601919091526040805160e08101825286516001600160a01b039081168252602080890151909116908201528187015162ffffff16918101919091528654600160b01b8104600290810b810b6060840152600160c81b909104810b900b9181019190915290516140579282019061403b908e9061333d565b8152602001613fa08560c001518d61333d90919063ffffffff16565b50610120850181905261010085018290526001600160801b0392831660e086018190526080860151875475ffffffffffffffffffffffffffffffff000000000000198116600160301b9182900487169092018616021787556001870180546001600160801b03198116908616909201909416179092556006850180548b01905560a084015160c0850151909950975095509350505b5050945094509450949050565b600080614104614cba565b61410d8761253f565b50505062ffffff92831660408088019182526001600160a01b039586166020808a0191825297871689528e871660009081526002808a5290839020835160e0810185528b518a16815292519098169882019890985291519094169381019390935250508154600160b01b8104840b840b6060830152600160c81b9004830b90920b608083015260a0820188905260c08201879052906141ab90613406565b5060a08501819052608085018290526001600160801b0392831660609095018590526001840180548085169096019093166001600160801b031990951694909417909155600690910180549095019094559296929550919350505050565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166323b872dd60e01b178152925182516000948594938a169392918291908083835b602083106142a25780518252601f199092019160209182019101614283565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114614304576040519150601f19603f3d011682016040523d82523d6000602084013e614309565b606091505b5091509150818015614337575080511580614337575080806020019051602081101561433457600080fd5b50515b6111d4576040805162461bcd60e51b815260206004820152600360248201526229aa2360e91b604482015290519081900360640190fd5b60008060008360020b12614385578260020b61438d565b8260020b6000035b9050620d89e88111156143cb576040805162461bcd60e51b81526020600482015260016024820152601560fa1b604482015290519081900360640190fd5b6000600182166143df57600160801b6143f1565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff1690506002821615614425576ffff97272373d413259a46990580e213a0260801c5b6004821615614444576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b6008821615614463576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615614482576fffcb9843d60f6159c9db58835c9266440260801c5b60208216156144a1576fff973b41fa98c081472e6896dfb254c00260801c5b60408216156144c0576fff2ea16466c96a3843ec78b326b528610260801c5b60808216156144df576ffe5dee046a99a2a811c461f1969c30530260801c5b6101008216156144ff576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b61020082161561451f576ff987a7253ac413176f2b074cf7815e540260801c5b61040082161561453f576ff3392b0822b70005940c7a398e4b70f30260801c5b61080082161561455f576fe7159475a2c29b7443b29c7fa6e889d90260801c5b61100082161561457f576fd097f3bdfd2022b8845ad8f792aa58250260801c5b61200082161561459f576fa9f746462d870fdf8a65dc1f90e061e50260801c5b6140008216156145bf576f70d869a156d2a1b890bb3df62baf32f70260801c5b6180008216156145df576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615614600576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b62020000821615614620576e5d6af8dedb81196699c329225ee6040260801c5b6204000082161561463f576d2216e584f5fa1ea926041bedfe980260801c5b6208000082161561465c576b048a170391f7dc42444e8fa20260801c5b60008460020b131561467757806000198161467357fe5b0490505b64010000000081061561468b57600161468e565b60005b60ff16602082901c0192505050919050565b600080836001600160a01b0316856001600160a01b031611156146c1579293925b846001600160a01b0316866001600160a01b0316116146ec576146e5858585614945565b9150614733565b836001600160a01b0316866001600160a01b0316101561472557614711868585614945565b915061471e8587856149ae565b9050614733565b6147308585856149ae565b90505b94509492505050565b6000836001600160a01b0316856001600160a01b0316111561475c579293925b846001600160a01b0316866001600160a01b031611614787576147808585856149f1565b90506147f7565b836001600160a01b0316866001600160a01b031610156147e95760006147ae8786866149f1565b905060006147bd878986614a54565b9050806001600160801b0316826001600160801b0316106147de57806147e0565b815b925050506147f7565b6147f4858584614a54565b90505b95945050505050565b60006001600160801b0382111561333957fe5b60008060008061482587866064613050565b935061483386866064613050565b925061483f878561333d565b915061484b868461333d565b905093509350935093565b604080516000808252602082019092526001600160a01b0384169083906040518082805190602001908083835b602083106148a25780518252601f199092019160209182019101614883565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114614904576040519150601f19603f3d011682016040523d82523d6000602084013e614909565b606091505b5050905080610b34576040805162461bcd60e51b815260206004820152600360248201526253544560e81b604482015290519081900360640190fd5b6000826001600160a01b0316846001600160a01b03161115614965579192915b836001600160a01b031661499e606060ff16846001600160801b0316901b8686036001600160a01b0316866001600160a01b0316613050565b816149a557fe5b04949350505050565b6000826001600160a01b0316846001600160a01b031611156149ce579192915b612535826001600160801b03168585036001600160a01b0316600160601b613050565b6000826001600160a01b0316846001600160a01b03161115614a11579192915b6000614a34856001600160a01b0316856001600160a01b0316600160601b613050565b90506147f7614a4f84838888036001600160a01b0316613050565b614a91565b6000826001600160a01b0316846001600160a01b03161115614a74579192915b612535614a4f83600160601b8787036001600160a01b0316613050565b806001600160801b03811681146106ba57600080fd5b6040518060c0016040528060006001600160a01b0316815260200160008152602001600081526020016000815260200160008152602001600081525090565b6040518060e001604052806000815260200160006001600160a01b0316815260200160008152602001600081526020016000815260200160008152602001600081525090565b6040805161024081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101829052610100810182905261012081018290526101408101829052610160810182905261018081018290526101a081018290526101c081018290526101e08101829052610200810182905261022081019190915290565b6040518060c00160405280600062ffffff16815260200160006001600160a01b03168152602001600081526020016000815260200160008152602001600081525090565b60405180610220016040528060001515815260200160006001600160a01b03168152602001600060020b815260200160006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160801b03168152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a081019190915290565b604051806080016040528060006001600160a01b0316815260200160006001600160a01b0316815260200160008152602001600081525090565b604051806101600160405280600060020b8152602001600060020b8152602001600060020b8152602001600060020b8152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6040805161014081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101829052610100810182905261012081019190915290565b6040518060a00160405280600081526020016000815260200160006001600160801b0316815260200160008152602001600081525090565b60008083601f840112614e2c578182fd5b50813567ffffffffffffffff811115614e43578182fd5b602083019150836020828501011115614e5b57600080fd5b9250929050565b600082601f830112614e72578081fd5b813567ffffffffffffffff80821115614e8757fe5b604051601f8301601f191681016020018281118282101715614ea557fe5b604052828152848301602001861015614ebc578384fd5b82602086016020830137918201602001929092529392505050565b80516001600160801b03811681146106ba57600080fd5b600060208284031215614eff578081fd5b813561253881615e42565b600060208284031215614f1b578081fd5b815161253881615e42565b600080600080600060a08688031215614f3d578081fd5b8551614f4881615e42565b6020870151909550614f5981615e42565b6040870151909450614f6a81615e68565b6060870151909350614f7b81615e68565b9150614f8960808701614ed7565b90509295509295909350565b60008060008060608587031215614faa578182fd5b8435614fb581615e42565b93506020850135614fc581615e42565b9250604085013567ffffffffffffffff811115614fe0578283fd5b614fec87828801614e1b565b95989497509550505050565b60008060006060848603121561500c578081fd5b833561501781615e42565b9250602084013561502781615e42565b9150604084013567ffffffffffffffff811115615042578182fd5b61504e86828701614e62565b9150509250925092565b60008060006060848603121561506c578081fd5b833561507781615e42565b9250602084013561508781615e42565b9150604084013561509781615e87565b809150509250925092565b600080600080600080600080610100898b0312156150be578586fd5b88356150c981615e42565b975060208901356150d981615e42565b965060408901359550606089013594506080890135935060a0890135925060c089013561510581615e5a565b915060e089013567ffffffffffffffff811115615120578182fd5b61512c8b828c01614e62565b9150509295985092959890939650565b6000806040838503121561514e578182fd5b823561515981615e42565b915060208381013567ffffffffffffffff80821115615176578384fd5b818601915086601f830112615189578384fd5b6040516101408101818110838211171561519f57fe5b60405290508082855b600a8110156151d0576151be8a83358701614e62565b845292850192908501906001016151a8565b50959890975095505050505050565b600080600080600060a086880312156151f6578283fd5b853561520181615e42565b9450602086013561521181615e5a565b9350604086013561522181615e5a565b9250606086013561523181615e42565b9150608086013561524181615e42565b809150509295509295909350565b600080600060608486031215615263578081fd5b833561526e81615e42565b9250602084013561527e81615e68565b9150604084013561509781615e68565b600080600080608085870312156152a3578182fd5b84356152ae81615e5a565b935060208501356152be81615e5a565b925060408501359150606085013567ffffffffffffffff8111156152e0578182fd5b6152ec87828801614e62565b91505092959194509250565b600080600080600060a0868803121561530f578283fd5b853561531a81615e5a565b9450602086013561532a81615e5a565b93506040860135925060608601359150608086013567ffffffffffffffff811115615353578182fd5b61535f88828901614e62565b9150509295509295909350565b60006020828403121561537d578081fd5b815161253881615e68565b60008060008060008060c087890312156153a0578384fd5b86516153ab81615e68565b60208801519096506153bc81615e68565b60408801519095506153cd81615e68565b60608801519094506153de81615e68565b60808801519093506153ef81615e68565b60a088015190925061540081615e68565b809150509295509295509295565b60008060408385031215615420578182fd5b505080516020909101519092909150565b60008060008060608587031215615446578182fd5b8435935060208501359250604085013567ffffffffffffffff811115614fe0578283fd5b60006080828403121561547b578081fd5b6040516080810181811067ffffffffffffffff8211171561549857fe5b60405282356154a681615e42565b815260208301356154b681615e42565b602082015260408301356154c981615e42565b604082015260608301356154dc81615e87565b60608201529392505050565b6000606082840312156154f9578081fd5b6040516060810181811067ffffffffffffffff8211171561551657fe5b604052823561552481615e42565b8152602083013561553481615e42565b6020820152604083013561554781615e87565b60408201529392505050565b60006101a08284031215615565578081fd5b50919050565b60006020828403121561557c578081fd5b61253882614ed7565b60008060408385031215615597578182fd5b6155a083614ed7565b91506155ae60208401614ed7565b90509250929050565b600080600080600080600060e0888a0312156155d1578081fd5b87516155dc81615e42565b60208901519097506155ed81615e68565b60408901519096506155fe81615e77565b606089015190955061560f81615e77565b608089015190945061562081615e77565b60a089015190935061563181615e98565b60c089015190925061564281615e5a565b8091505092959891949750929550565b600060208284031215615663578081fd5b813561253881615e87565b60006020828403121561567f578081fd5b815161253881615e87565b6000806040838503121561569c578182fd5b82516156a781615e87565b60208401519092506156b881615e42565b809150509250929050565b6000602082840312156156d4578081fd5b5035919050565b6000602082840312156156ec578081fd5b5051919050565b6001600160a01b03169052565b15159052565b60008151808452815b8181101561572b5760208185018101518683018201520161570f565b8181111561573c5782602083870101525b50601f01601f19169290920160200192915050565b60020b9052565b6001600160801b03169052565b60ff169052565b6001600160a01b0391909116815260200190565b60006001600160a01b038088168352861515602084015285604084015280851660608401525060a060808301526157ba60a0830184615706565b979650505050505050565b60006001600160a01b03871682528560020b60208301528460020b60408301526001600160801b038416606083015260a060808301526157ba60a0830184615706565b6001600160a01b03959095168552600293840b60208601529190920b60408401526001600160801b03918216606084015216608082015260a00190565b6001600160a01b03938416815291909216602082015262ffffff909116604082015260600190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0396871681529486166020860152604085019390935260608401919091528316608083015290911660a082015260c00190565b6001600160a01b039790971687526001600160801b039586166020880152939094166040860152600291820b6060860152810b608085015291820b60a0840152900b60c082015260e00190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b03948516815260208101939093526040830191909152909116606082015260800190565b901515815260200190565b600293840b81529190920b60208201526001600160801b03909116604082015260600190565b6000610240820190506159a1828451615751565b60208301516159b36020840182615751565b5060408301516159c66040840182615758565b5060608301516159d96060840182615751565b5060808301516159ec6080840182615751565b5060a08301516159ff60a0840182615758565b5060c0838101519083015260e0808401519083015261010080840151908301526101208084015190830152610140808401519083015261016080840151615a4882850182615700565b505061018080840151615a5d828501826156f3565b50506101a080840151615a72828501826156f3565b50506101c083810151908301526101e080840151615a9282850182615765565b505061020080840151615aa782850182615700565b505061022080840151615abc82850182615700565b505092915050565b60006080820190506001600160a01b038084511683528060208501511660208401528060408501511660408401525062ffffff606084015116606083015292915050565b600060e082019050825182526001600160a01b03602084015116602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015260c083015160c083015292915050565b81516001600160a01b0390811682526020808401519091169082015260409182015162ffffff169181019190915260600190565b61ffff91909116815260200190565b62ffffff9290921682526001600160a01b0316602082015260400190565b90815260200190565b918252602082015260400190565b9283526020830191909152604082015260600190565b93845260208401929092526040830152606082015260800190565b9586526020860194909452604085019290925260608401526001600160a01b0390811660808401521660a082015260c00190565b6000813561334d81615e42565b6000813561334d81615e77565b6000813561334d81615e87565b6000813561334d81615e98565b6001600160a01b03821673ffffffffffffffffffffffffffffffffffffffff198254161781555050565b615cac615ca683615c63565b82615dab565b615cc1615cbb60208401615c56565b82615dbc565b60408201356001820155606082013560028201556080820135600382015560a0820135600482015560058101615d02615cfc60c08501615c56565b82615d96565b615d17615d1160e08501615c49565b82615dd8565b615d2d615d276101008501615c3c565b82615df6565b50615d47615d3e6101208401615c3c565b60068301615c70565b615d60615d576101408401615c3c565b60078301615c70565b615d79615d706101608401615c3c565b60088301615c70565b615d92615d896101808401615c3c565b60098301615c70565b5050565b62ffffff821662ffffff198254161781555050565b60ff821660ff198254161781555050565b805463ffffff008360081b1663ffffff00198216178255505050565b805464ffff0000008360181b1664ffff000000198216178255505050565b805478ffffffffffffffffffffffffffffffffffffffff00000000008360281b167fffffffffffffff0000000000000000000000000000000000000000ffffffffff8216178255505050565b6001600160a01b0381168114615e5757600080fd5b50565b8015158114615e5757600080fd5b8060020b8114615e5757600080fd5b61ffff81168114615e5757600080fd5b62ffffff81168114615e5757600080fd5b60ff81168114615e5757600080fdfea164736f6c6343000706000a
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000186a0000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000000000000000000000000000000000003a35294400000000000000000000000000000000000000000000000000000000000000005f000000000000000000000000000000000000000000000000000000000000000f0000000000000000000000000000000000000000000000000000000000000e100000000000000000000000000000000000000000000000000000000000000050000000000000000000000000fc9f572124d8f469960b94537b493f2676776c03000000000000000000000000458766536f95b9333d48a78a91ab1aaf4226221a00000000000000000000000095477f96f78ec38916b5457030387d844e886ab30000000000000000000000007b0909218ad3f30d49caa711b8274819281b21fd000000000000000000000000de5bf92e3372aa59c73ca7dfc6cec599e1b2b08c0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f984
-----Decoded View---------------
Arg [0] : params (tuple):
Arg [1] : swapPercentage (uint8): 1
Arg [2] : swapPriceThreshold (uint24): 100000
Arg [3] : premium (uint256): 10000000000000000
Arg [4] : gasPriceLimit (uint256): 250000000000
Arg [5] : userPilotPercentage (uint256): 95
Arg [6] : feesPercentageIndexFund (uint256): 15
Arg [7] : readjustFrequencyTime (uint24): 3600
Arg [8] : poolCardinalityDesired (uint16): 80
Arg [9] : pilotWethPair (address): 0xFC9F572124d8f469960b94537b493F2676776c03
Arg [10] : oracle (address): 0x458766536f95B9333D48A78A91AB1aaF4226221a
Arg [11] : indexFund (address): 0x95477F96F78EC38916B5457030387D844E886ab3
Arg [12] : uniStrategy (address): 0x7B0909218Ad3f30d49cAA711B8274819281b21Fd
Arg [13] : unipilot (address): 0xde5bF92E3372AA59C73Ca7dFc6CEc599E1B2b08C
Arg [1] : _uniswapFactory (address): 0x1F98431c8aD98523631AE4a59f267346ea31F984
-----Encoded View---------------
14 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [1] : 00000000000000000000000000000000000000000000000000000000000186a0
Arg [2] : 000000000000000000000000000000000000000000000000002386f26fc10000
Arg [3] : 0000000000000000000000000000000000000000000000000000003a35294400
Arg [4] : 000000000000000000000000000000000000000000000000000000000000005f
Arg [5] : 000000000000000000000000000000000000000000000000000000000000000f
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000e10
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000050
Arg [8] : 000000000000000000000000fc9f572124d8f469960b94537b493f2676776c03
Arg [9] : 000000000000000000000000458766536f95b9333d48a78a91ab1aaf4226221a
Arg [10] : 00000000000000000000000095477f96f78ec38916b5457030387d844e886ab3
Arg [11] : 0000000000000000000000007b0909218ad3f30d49caa711b8274819281b21fd
Arg [12] : 000000000000000000000000de5bf92e3372aa59c73ca7dfc6cec599e1b2b08c
Arg [13] : 0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f984
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|---|---|---|---|---|
| ETH | 73.48% | $3,382.42 | 1.6023 | $5,419.69 | |
| ETH | 16.09% | $0.999746 | 1,187.1552 | $1,186.85 | |
| ETH | 4.58% | $103,114 | 0.00327394 | $337.59 | |
| ETH | 4.06% | $0.000009 | 33,215,135.7069 | $299.6 | |
| ETH | 1.00% | $5.27 | 14.0478 | $74.03 | |
| ETH | 0.29% | $14.93 | 1.4456 | $21.58 | |
| ETH | 0.27% | $0.427563 | 46.6576 | $19.95 | |
| ETH | 0.22% | $12.73 | 1.2658 | $16.11 | |
| ETH | <0.01% | $0.134779 | 3.9461 | $0.5318 | |
| ETH | <0.01% | $0.002352 | 85.4245 | $0.2009 |
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.