Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
0x60a06040 | 12952920 | 1207 days ago | IN | 0 ETH | 0.27236407 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
GUniPool
Compiler Version
v0.8.4+commit.c7e474f2
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.4; import { IUniswapV3MintCallback } from "@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3MintCallback.sol"; import { IUniswapV3SwapCallback } from "@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol"; import {GUniPoolStorage} from "./abstract/GUniPoolStorage.sol"; import { IUniswapV3Pool } from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol"; import {TickMath} from "./vendor/uniswap/TickMath.sol"; import { IERC20, SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol"; import { FullMath, LiquidityAmounts } from "./vendor/uniswap/LiquidityAmounts.sol"; contract GUniPool is IUniswapV3MintCallback, IUniswapV3SwapCallback, GUniPoolStorage { using SafeERC20 for IERC20; using TickMath for int24; event Minted( address receiver, uint256 mintAmount, uint256 amount0In, uint256 amount1In, uint128 liquidityMinted ); event Burned( address receiver, uint256 burnAmount, uint256 amount0Out, uint256 amount1Out, uint128 liquidityBurned ); event Rebalance( int24 lowerTick_, int24 upperTick_, uint128 liquidityBefore, uint128 liquidityAfter ); event FeesEarned(uint256 feesEarned0, uint256 feesEarned1); // solhint-disable-next-line max-line-length constructor(address payable _gelato) GUniPoolStorage(_gelato) {} // solhint-disable-line no-empty-blocks /// @notice Uniswap V3 callback fn, called back on pool.mint function uniswapV3MintCallback( uint256 amount0Owed, uint256 amount1Owed, bytes calldata /*_data*/ ) external override { require(msg.sender == address(pool), "callback caller"); if (amount0Owed > 0) token0.safeTransfer(msg.sender, amount0Owed); if (amount1Owed > 0) token1.safeTransfer(msg.sender, amount1Owed); } /// @notice Uniswap v3 callback fn, called back on pool.swap function uniswapV3SwapCallback( int256 amount0Delta, int256 amount1Delta, bytes calldata /*data*/ ) external override { require(msg.sender == address(pool), "callback caller"); if (amount0Delta > 0) token0.safeTransfer(msg.sender, uint256(amount0Delta)); else if (amount1Delta > 0) token1.safeTransfer(msg.sender, uint256(amount1Delta)); } // User functions => Should be called via a Router /// @notice mint fungible G-UNI tokens, fractional shares of a Uniswap V3 position /// @dev to compute the amouint of tokens necessary to mint `mintAmount` see getMintAmounts /// @param mintAmount The number of G-UNI tokens to mint /// @param receiver The account to receive the minted tokens /// @return amount0 amount of token0 transferred from msg.sender to mint `mintAmount` /// @return amount1 amount of token1 transferred from msg.sender to mint `mintAmount` /// @return liquidityMinted amount of liquidity added to the underlying Uniswap V3 position // solhint-disable-next-line function-max-lines, code-complexity function mint(uint256 mintAmount, address receiver) external nonReentrant returns ( uint256 amount0, uint256 amount1, uint128 liquidityMinted ) { require(mintAmount > 0, "mint 0"); uint256 totalSupply = totalSupply(); (uint160 sqrtRatioX96, , , , , , ) = pool.slot0(); if (totalSupply > 0) { (uint256 amount0Current, uint256 amount1Current) = getUnderlyingBalances(); amount0 = FullMath.mulDivRoundingUp( amount0Current, mintAmount, totalSupply ); amount1 = FullMath.mulDivRoundingUp( amount1Current, mintAmount, totalSupply ); } else { // if supply is 0 mintAmount == liquidity to deposit (amount0, amount1) = LiquidityAmounts.getAmountsForLiquidity( sqrtRatioX96, lowerTick.getSqrtRatioAtTick(), upperTick.getSqrtRatioAtTick(), SafeCast.toUint128(mintAmount) ); } // transfer amounts owed to contract if (amount0 > 0) { token0.safeTransferFrom(msg.sender, address(this), amount0); } if (amount1 > 0) { token1.safeTransferFrom(msg.sender, address(this), amount1); } // deposit as much new liquidity as possible liquidityMinted = LiquidityAmounts.getLiquidityForAmounts( sqrtRatioX96, lowerTick.getSqrtRatioAtTick(), upperTick.getSqrtRatioAtTick(), amount0, amount1 ); pool.mint(address(this), lowerTick, upperTick, liquidityMinted, ""); _mint(receiver, mintAmount); emit Minted(receiver, mintAmount, amount0, amount1, liquidityMinted); } /// @notice burn G-UNI tokens (fractional shares of a Uniswap V3 position) and receive tokens /// @param burnAmount The number of G-UNI tokens to burn /// @param receiver The account to receive the underlying amounts of token0 and token1 /// @return amount0 amount of token0 transferred to receiver for burning `burnAmount` /// @return amount1 amount of token1 transferred to receiver for burning `burnAmount` /// @return liquidityBurned amount of liquidity removed from the underlying Uniswap V3 position // solhint-disable-next-line function-max-lines function burn(uint256 burnAmount, address receiver) external nonReentrant returns ( uint256 amount0, uint256 amount1, uint128 liquidityBurned ) { require(burnAmount > 0, "burn 0"); uint256 totalSupply = totalSupply(); (uint128 liquidity, , , , ) = pool.positions(_getPositionID()); _burn(msg.sender, burnAmount); uint256 liquidityBurned_ = FullMath.mulDiv(burnAmount, liquidity, totalSupply); liquidityBurned = SafeCast.toUint128(liquidityBurned_); (uint256 burn0, uint256 burn1, uint256 fee0, uint256 fee1) = _withdraw(lowerTick, upperTick, liquidityBurned); _applyFees(fee0, fee1); (fee0, fee1) = _subtractAdminFees(fee0, fee1); emit FeesEarned(fee0, fee1); amount0 = burn0 + FullMath.mulDiv( token0.balanceOf(address(this)) - burn0 - managerBalance0 - gelatoBalance0, burnAmount, totalSupply ); amount1 = burn1 + FullMath.mulDiv( token1.balanceOf(address(this)) - burn1 - managerBalance1 - gelatoBalance1, burnAmount, totalSupply ); if (amount0 > 0) { token0.safeTransfer(receiver, amount0); } if (amount1 > 0) { token1.safeTransfer(receiver, amount1); } emit Burned(receiver, burnAmount, amount0, amount1, liquidityBurned); } // Manager Functions => Called by Pool Manager /// @notice Change the range of underlying UniswapV3 position, only manager can call /// @dev When changing the range the inventory of token0 and token1 may be rebalanced /// with a swap to deposit as much liquidity as possible into the new position. Swap parameters /// can be computed by simulating the whole operation: remove all liquidity, deposit as much /// as possible into new position, then observe how much of token0 or token1 is leftover. /// Swap a proportion of this leftover to deposit more liquidity into the position, since /// any leftover will be unused and sit idle until the next rebalance. /// @param newLowerTick The new lower bound of the position's range /// @param newUpperTick The new upper bound of the position's range /// @param swapThresholdPrice slippage parameter on the swap as a max or min sqrtPriceX96 /// @param swapAmountBPS amount of token to swap as proportion of total. Pass 0 to ignore swap. /// @param zeroForOne Which token to input into the swap (true = token0, false = token1) function executiveRebalance( int24 newLowerTick, int24 newUpperTick, uint160 swapThresholdPrice, uint256 swapAmountBPS, bool zeroForOne ) external onlyManager { (uint128 liquidity, , , , ) = pool.positions(_getPositionID()); if (liquidity > 0) { (, , uint256 fee0, uint256 fee1) = _withdraw(lowerTick, upperTick, liquidity); _applyFees(fee0, fee1); (fee0, fee1) = _subtractAdminFees(fee0, fee1); emit FeesEarned(fee0, fee1); } lowerTick = newLowerTick; upperTick = newUpperTick; uint256 reinvest0 = token0.balanceOf(address(this)) - managerBalance0 - gelatoBalance0; uint256 reinvest1 = token1.balanceOf(address(this)) - managerBalance1 - gelatoBalance1; _deposit( newLowerTick, newUpperTick, reinvest0, reinvest1, swapThresholdPrice, swapAmountBPS, zeroForOne ); (uint128 newLiquidity, , , , ) = pool.positions(_getPositionID()); require(newLiquidity > 0, "new position 0"); emit Rebalance(newLowerTick, newUpperTick, liquidity, newLiquidity); } // Gelatofied functions => Automatically called by Gelato /// @notice Reinvest fees earned into underlying position, only gelato executors can call /// Position bounds CANNOT be altered by gelato, only manager may via executiveRebalance. /// Frequency of rebalance configured with gelatoRebalanceBPS, alterable by manager. function rebalance( uint160 swapThresholdPrice, uint256 swapAmountBPS, bool zeroForOne, uint256 feeAmount, address paymentToken ) external gelatofy(feeAmount, paymentToken) { if (swapAmountBPS > 0) { _checkSlippage(swapThresholdPrice, zeroForOne); } (uint128 liquidity, , , , ) = pool.positions(_getPositionID()); _rebalance( liquidity, swapThresholdPrice, swapAmountBPS, zeroForOne, feeAmount, paymentToken ); (uint128 newLiquidity, , , , ) = pool.positions(_getPositionID()); require(newLiquidity >= liquidity, "liquidity decrease"); emit Rebalance(lowerTick, upperTick, liquidity, newLiquidity); } /// @notice withdraw manager fees accrued, only gelato executors can call. /// Target account to receive fees is managerTreasury, alterable by manager. /// Frequency of withdrawals configured with gelatoWithdrawBPS, alterable by manager. function withdrawManagerBalance(uint256 feeAmount, address feeToken) external gelatofy(feeAmount, feeToken) { (uint256 amount0, uint256 amount1) = _balancesToWithdraw( managerBalance0, managerBalance1, feeAmount, feeToken ); managerBalance0 = 0; managerBalance1 = 0; if (amount0 > 0) { token0.safeTransfer(managerTreasury, amount0); } if (amount1 > 0) { token1.safeTransfer(managerTreasury, amount1); } } /// @notice withdraw gelato fees accrued, only gelato executors can call. /// Frequency of withdrawals configured with gelatoWithdrawBPS, alterable by manager. function withdrawGelatoBalance(uint256 feeAmount, address feeToken) external gelatofy(feeAmount, feeToken) { (uint256 amount0, uint256 amount1) = _balancesToWithdraw( gelatoBalance0, gelatoBalance1, feeAmount, feeToken ); gelatoBalance0 = 0; gelatoBalance1 = 0; if (amount0 > 0) { token0.safeTransfer(GELATO, amount0); } if (amount1 > 0) { token1.safeTransfer(GELATO, amount1); } } function _balancesToWithdraw( uint256 balance0, uint256 balance1, uint256 feeAmount, address feeToken ) internal view returns (uint256 amount0, uint256 amount1) { if (feeToken == address(token0)) { require( (balance0 * gelatoWithdrawBPS) / 10000 >= feeAmount, "high fee" ); amount0 = balance0 - feeAmount; amount1 = balance1; } else if (feeToken == address(token1)) { require( (balance1 * gelatoWithdrawBPS) / 10000 >= feeAmount, "high fee" ); amount1 = balance1 - feeAmount; amount0 = balance0; } else { revert("wrong token"); } } // View functions /// @notice compute maximum G-UNI tokens that can be minted from `amount0Max` and `amount1Max` /// @param amount0Max The maximum amount of token0 to forward on mint /// @param amount0Max The maximum amount of token1 to forward on mint /// @return amount0 actual amount of token0 to forward when minting `mintAmount` /// @return amount1 actual amount of token1 to forward when minting `mintAmount` /// @return mintAmount maximum number of G-UNI tokens to mint function getMintAmounts(uint256 amount0Max, uint256 amount1Max) external view returns ( uint256 amount0, uint256 amount1, uint256 mintAmount ) { uint256 totalSupply = totalSupply(); if (totalSupply > 0) { (amount0, amount1, mintAmount) = _computeMintAmounts( totalSupply, amount0Max, amount1Max ); } else { (uint160 sqrtRatioX96, , , , , , ) = pool.slot0(); uint128 newLiquidity = LiquidityAmounts.getLiquidityForAmounts( sqrtRatioX96, lowerTick.getSqrtRatioAtTick(), upperTick.getSqrtRatioAtTick(), amount0Max, amount1Max ); mintAmount = uint256(newLiquidity); (amount0, amount1) = LiquidityAmounts.getAmountsForLiquidity( sqrtRatioX96, lowerTick.getSqrtRatioAtTick(), upperTick.getSqrtRatioAtTick(), newLiquidity ); } } /// @notice compute total underlying holdings of the G-UNI token supply /// includes current liquidity invested in uniswap position, current fees earned /// and any uninvested leftover (but does not include manager or gelato fees accrued) /// @return amount0Current current total underlying balance of token0 /// @return amount1Current current total underlying balance of token1 function getUnderlyingBalances() public view returns (uint256 amount0Current, uint256 amount1Current) { (uint160 sqrtRatioX96, int24 tick, , , , , ) = pool.slot0(); return _getUnderlyingBalances(sqrtRatioX96, tick); } function getUnderlyingBalancesAtPrice(uint160 sqrtRatioX96) external view returns (uint256 amount0Current, uint256 amount1Current) { (, int24 tick, , , , , ) = pool.slot0(); return _getUnderlyingBalances(sqrtRatioX96, tick); } // solhint-disable-next-line function-max-lines function _getUnderlyingBalances(uint160 sqrtRatioX96, int24 tick) internal view returns (uint256 amount0Current, uint256 amount1Current) { ( uint128 liquidity, uint256 feeGrowthInside0Last, uint256 feeGrowthInside1Last, uint128 tokensOwed0, uint128 tokensOwed1 ) = pool.positions(_getPositionID()); // compute current holdings from liquidity (amount0Current, amount1Current) = LiquidityAmounts .getAmountsForLiquidity( sqrtRatioX96, lowerTick.getSqrtRatioAtTick(), upperTick.getSqrtRatioAtTick(), liquidity ); // compute current fees earned uint256 fee0 = _computeFeesEarned(true, feeGrowthInside0Last, tick, liquidity) + uint256(tokensOwed0); uint256 fee1 = _computeFeesEarned(false, feeGrowthInside1Last, tick, liquidity) + uint256(tokensOwed1); (fee0, fee1) = _subtractAdminFees(fee0, fee1); // add any leftover in contract to current holdings amount0Current += fee0 + token0.balanceOf(address(this)) - managerBalance0 - gelatoBalance0; amount1Current += fee1 + token1.balanceOf(address(this)) - managerBalance1 - gelatoBalance1; } // Private functions // solhint-disable-next-line function-max-lines function _rebalance( uint128 liquidity, uint160 swapThresholdPrice, uint256 swapAmountBPS, bool zeroForOne, uint256 feeAmount, address paymentToken ) private { uint256 leftover0 = token0.balanceOf(address(this)) - managerBalance0 - gelatoBalance0; uint256 leftover1 = token1.balanceOf(address(this)) - managerBalance1 - gelatoBalance1; (, , uint256 feesEarned0, uint256 feesEarned1) = _withdraw(lowerTick, upperTick, liquidity); _applyFees(feesEarned0, feesEarned1); (feesEarned0, feesEarned1) = _subtractAdminFees( feesEarned0, feesEarned1 ); emit FeesEarned(feesEarned0, feesEarned1); feesEarned0 += leftover0; feesEarned1 += leftover1; if (paymentToken == address(token0)) { require( (feesEarned0 * gelatoRebalanceBPS) / 10000 >= feeAmount, "high fee" ); leftover0 = token0.balanceOf(address(this)) - managerBalance0 - gelatoBalance0 - feeAmount; leftover1 = token1.balanceOf(address(this)) - managerBalance1 - gelatoBalance1; } else if (paymentToken == address(token1)) { require( (feesEarned1 * gelatoRebalanceBPS) / 10000 >= feeAmount, "high fee" ); leftover0 = token0.balanceOf(address(this)) - managerBalance0 - gelatoBalance0; leftover1 = token1.balanceOf(address(this)) - managerBalance1 - gelatoBalance1 - feeAmount; } else { revert("wrong token"); } _deposit( lowerTick, upperTick, leftover0, leftover1, swapThresholdPrice, swapAmountBPS, zeroForOne ); } // solhint-disable-next-line function-max-lines function _withdraw( int24 lowerTick_, int24 upperTick_, uint128 liquidity ) private returns ( uint256 burn0, uint256 burn1, uint256 fee0, uint256 fee1 ) { uint256 preBalance0 = token0.balanceOf(address(this)); uint256 preBalance1 = token1.balanceOf(address(this)); (burn0, burn1) = pool.burn(lowerTick_, upperTick_, liquidity); pool.collect( address(this), lowerTick_, upperTick_, type(uint128).max, type(uint128).max ); fee0 = token0.balanceOf(address(this)) - preBalance0 - burn0; fee1 = token1.balanceOf(address(this)) - preBalance1 - burn1; } // solhint-disable-next-line function-max-lines function _deposit( int24 lowerTick_, int24 upperTick_, uint256 amount0, uint256 amount1, uint160 swapThresholdPrice, uint256 swapAmountBPS, bool zeroForOne ) private { (uint160 sqrtRatioX96, , , , , , ) = pool.slot0(); // First, deposit as much as we can uint128 baseLiquidity = LiquidityAmounts.getLiquidityForAmounts( sqrtRatioX96, lowerTick_.getSqrtRatioAtTick(), upperTick_.getSqrtRatioAtTick(), amount0, amount1 ); if (baseLiquidity > 0) { (uint256 amountDeposited0, uint256 amountDeposited1) = pool.mint( address(this), lowerTick_, upperTick_, baseLiquidity, "" ); amount0 -= amountDeposited0; amount1 -= amountDeposited1; } int256 swapAmount = SafeCast.toInt256( ((zeroForOne ? amount0 : amount1) * swapAmountBPS) / 10000 ); if (swapAmount > 0) { _swapAndDeposit( lowerTick_, upperTick_, amount0, amount1, swapAmount, swapThresholdPrice, zeroForOne ); } } function _swapAndDeposit( int24 lowerTick_, int24 upperTick_, uint256 amount0, uint256 amount1, int256 swapAmount, uint160 swapThresholdPrice, bool zeroForOne ) private returns (uint256 finalAmount0, uint256 finalAmount1) { (int256 amount0Delta, int256 amount1Delta) = pool.swap( address(this), zeroForOne, swapAmount, swapThresholdPrice, "" ); finalAmount0 = uint256(SafeCast.toInt256(amount0) - amount0Delta); finalAmount1 = uint256(SafeCast.toInt256(amount1) - amount1Delta); // Add liquidity a second time (uint160 sqrtRatioX96, , , , , , ) = pool.slot0(); uint128 liquidityAfterSwap = LiquidityAmounts.getLiquidityForAmounts( sqrtRatioX96, lowerTick_.getSqrtRatioAtTick(), upperTick_.getSqrtRatioAtTick(), finalAmount0, finalAmount1 ); if (liquidityAfterSwap > 0) { pool.mint( address(this), lowerTick_, upperTick_, liquidityAfterSwap, "" ); } } // solhint-disable-next-line function-max-lines, code-complexity function _computeMintAmounts( uint256 totalSupply, uint256 amount0Max, uint256 amount1Max ) private view returns ( uint256 amount0, uint256 amount1, uint256 mintAmount ) { (uint256 amount0Current, uint256 amount1Current) = getUnderlyingBalances(); // compute proportional amount of tokens to mint if (amount0Current == 0 && amount1Current > 0) { mintAmount = FullMath.mulDiv( amount1Max, totalSupply, amount1Current ); } else if (amount1Current == 0 && amount0Current > 0) { mintAmount = FullMath.mulDiv( amount0Max, totalSupply, amount0Current ); } else if (amount0Current == 0 && amount1Current == 0) { revert(""); } else { // only if both are non-zero uint256 amount0Mint = FullMath.mulDiv(amount0Max, totalSupply, amount0Current); uint256 amount1Mint = FullMath.mulDiv(amount1Max, totalSupply, amount1Current); require(amount0Mint > 0 && amount1Mint > 0, "mint 0"); mintAmount = amount0Mint < amount1Mint ? amount0Mint : amount1Mint; } // compute amounts owed to contract amount0 = FullMath.mulDivRoundingUp( mintAmount, amount0Current, totalSupply ); amount1 = FullMath.mulDivRoundingUp( mintAmount, amount1Current, totalSupply ); } // solhint-disable-next-line function-max-lines function _computeFeesEarned( bool isZero, uint256 feeGrowthInsideLast, int24 tick, uint128 liquidity ) private view returns (uint256 fee) { uint256 feeGrowthOutsideLower; uint256 feeGrowthOutsideUpper; uint256 feeGrowthGlobal; if (isZero) { feeGrowthGlobal = pool.feeGrowthGlobal0X128(); (, , feeGrowthOutsideLower, , , , , ) = pool.ticks(lowerTick); (, , feeGrowthOutsideUpper, , , , , ) = pool.ticks(upperTick); } else { feeGrowthGlobal = pool.feeGrowthGlobal1X128(); (, , , feeGrowthOutsideLower, , , , ) = pool.ticks(lowerTick); (, , , feeGrowthOutsideUpper, , , , ) = pool.ticks(upperTick); } unchecked { // calculate fee growth below uint256 feeGrowthBelow; if (tick >= lowerTick) { feeGrowthBelow = feeGrowthOutsideLower; } else { feeGrowthBelow = feeGrowthGlobal - feeGrowthOutsideLower; } // calculate fee growth above uint256 feeGrowthAbove; if (tick < upperTick) { feeGrowthAbove = feeGrowthOutsideUpper; } else { feeGrowthAbove = feeGrowthGlobal - feeGrowthOutsideUpper; } uint256 feeGrowthInside = feeGrowthGlobal - feeGrowthBelow - feeGrowthAbove; fee = FullMath.mulDiv( liquidity, feeGrowthInside - feeGrowthInsideLast, 0x100000000000000000000000000000000 ); } } function _applyFees(uint256 _fee0, uint256 _fee1) private { gelatoBalance0 += (_fee0 * gelatoFeeBPS) / 10000; gelatoBalance1 += (_fee1 * gelatoFeeBPS) / 10000; managerBalance0 += (_fee0 * managerFeeBPS) / 10000; managerBalance1 += (_fee1 * managerFeeBPS) / 10000; } function _subtractAdminFees(uint256 rawFee0, uint256 rawFee1) private view returns (uint256 fee0, uint256 fee1) { uint256 deduct0 = (rawFee0 * (gelatoFeeBPS + managerFeeBPS)) / 10000; uint256 deduct1 = (rawFee1 * (gelatoFeeBPS + managerFeeBPS)) / 10000; fee0 = rawFee0 - deduct0; fee1 = rawFee1 - deduct1; } function _checkSlippage(uint160 swapThresholdPrice, bool zeroForOne) private view { uint32[] memory secondsAgo = new uint32[](2); secondsAgo[0] = gelatoSlippageInterval; secondsAgo[1] = 0; (int56[] memory tickCumulatives, ) = pool.observe(secondsAgo); require(tickCumulatives.length == 2, "array len"); uint160 avgSqrtRatioX96; unchecked { int24 avgTick = int24( (tickCumulatives[1] - tickCumulatives[0]) / int56(uint56(gelatoSlippageInterval)) ); avgSqrtRatioX96 = avgTick.getSqrtRatioAtTick(); } uint160 maxSlippage = (avgSqrtRatioX96 * gelatoSlippageBPS) / 10000; if (zeroForOne) { require( swapThresholdPrice >= avgSqrtRatioX96 - maxSlippage, "high slippage" ); } else { require( swapThresholdPrice <= avgSqrtRatioX96 + maxSlippage, "high slippage" ); } } }
// SPDX-License-Identifier: MIT // solhint-disable-next-line compiler-version pragma solidity ^0.8.0; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; function __ReentrancyGuard_init() internal initializer { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal initializer { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } uint256[49] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC20Upgradeable.sol"; import "./extensions/IERC20MetadataUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable { mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The defaut value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ function __ERC20_init(string memory name_, string memory symbol_) internal initializer { __Context_init_unchained(); __ERC20_init_unchained(name_, symbol_); } function __ERC20_init_unchained(string memory name_, string memory symbol_) internal initializer { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); _approve(sender, _msgSender(), currentAllowance - amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); _approve(_msgSender(), spender, currentAllowance - subtractedValue); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); _balances[account] = accountBalance - amount; _totalSupply -= amount; emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } uint256[45] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20MetadataUpgradeable is IERC20Upgradeable { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } uint256[50] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. * * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing * all math on `uint256` and `int256` and then downcasting. */ library SafeCast { /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { require(value < 2**128, "SafeCast: value doesn\'t fit in 128 bits"); return uint128(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { require(value < 2**64, "SafeCast: value doesn\'t fit in 64 bits"); return uint64(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { require(value < 2**32, "SafeCast: value doesn\'t fit in 32 bits"); return uint32(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { require(value < 2**16, "SafeCast: value doesn\'t fit in 16 bits"); return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits. */ function toUint8(uint256 value) internal pure returns (uint8) { require(value < 2**8, "SafeCast: value doesn\'t fit in 8 bits"); return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { require(value >= 0, "SafeCast: value must be positive"); return uint256(value); } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v3.1._ */ function toInt128(int256 value) internal pure returns (int128) { require(value >= -2**127 && value < 2**127, "SafeCast: value doesn\'t fit in 128 bits"); return int128(value); } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v3.1._ */ function toInt64(int256 value) internal pure returns (int64) { require(value >= -2**63 && value < 2**63, "SafeCast: value doesn\'t fit in 64 bits"); return int64(value); } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v3.1._ */ function toInt32(int256 value) internal pure returns (int32) { require(value >= -2**31 && value < 2**31, "SafeCast: value doesn\'t fit in 32 bits"); return int32(value); } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v3.1._ */ function toInt16(int256 value) internal pure returns (int16) { require(value >= -2**15 && value < 2**15, "SafeCast: value doesn\'t fit in 16 bits"); return int16(value); } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits. * * _Available since v3.1._ */ function toInt8(int256 value) internal pure returns (int8) { require(value >= -2**7 && value < 2**7, "SafeCast: value doesn\'t fit in 8 bits"); return int8(value); } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { require(value < 2**255, "SafeCast: value doesn't fit in an int256"); return int256(value); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; import './pool/IUniswapV3PoolImmutables.sol'; import './pool/IUniswapV3PoolState.sol'; import './pool/IUniswapV3PoolDerivedState.sol'; import './pool/IUniswapV3PoolActions.sol'; import './pool/IUniswapV3PoolOwnerActions.sol'; import './pool/IUniswapV3PoolEvents.sol'; /// @title The interface for a Uniswap V3 Pool /// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform /// to the ERC20 specification /// @dev The pool interface is broken up into many smaller pieces interface IUniswapV3Pool is IUniswapV3PoolImmutables, IUniswapV3PoolState, IUniswapV3PoolDerivedState, IUniswapV3PoolActions, IUniswapV3PoolOwnerActions, IUniswapV3PoolEvents { }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Callback for IUniswapV3PoolActions#mint /// @notice Any contract that calls IUniswapV3PoolActions#mint must implement this interface interface IUniswapV3MintCallback { /// @notice Called to `msg.sender` after minting liquidity to a position from IUniswapV3Pool#mint. /// @dev In the implementation you must pay the pool tokens owed for the minted liquidity. /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory. /// @param amount0Owed The amount of token0 due to the pool for the minted liquidity /// @param amount1Owed The amount of token1 due to the pool for the minted liquidity /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#mint call function uniswapV3MintCallback( uint256 amount0Owed, uint256 amount1Owed, bytes calldata data ) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Callback for IUniswapV3PoolActions#swap /// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface interface IUniswapV3SwapCallback { /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap. /// @dev In the implementation you must pay the pool tokens owed for the swap. /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory. /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped. /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by /// the end of the swap. If positive, the callback must send that amount of token0 to the pool. /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by /// the end of the swap. If positive, the callback must send that amount of token1 to the pool. /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call function uniswapV3SwapCallback( int256 amount0Delta, int256 amount1Delta, bytes calldata data ) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Permissionless pool actions /// @notice Contains pool methods that can be called by anyone interface IUniswapV3PoolActions { /// @notice Sets the initial price for the pool /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96 function initialize(uint160 sqrtPriceX96) external; /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends /// on tickLower, tickUpper, the amount of liquidity, and the current price. /// @param recipient The address for which the liquidity will be created /// @param tickLower The lower tick of the position in which to add liquidity /// @param tickUpper The upper tick of the position in which to add liquidity /// @param amount The amount of liquidity to mint /// @param data Any data that should be passed through to the callback /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback function mint( address recipient, int24 tickLower, int24 tickUpper, uint128 amount, bytes calldata data ) external returns (uint256 amount0, uint256 amount1); /// @notice Collects tokens owed to a position /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity. /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity. /// @param recipient The address which should receive the fees collected /// @param tickLower The lower tick of the position for which to collect fees /// @param tickUpper The upper tick of the position for which to collect fees /// @param amount0Requested How much token0 should be withdrawn from the fees owed /// @param amount1Requested How much token1 should be withdrawn from the fees owed /// @return amount0 The amount of fees collected in token0 /// @return amount1 The amount of fees collected in token1 function collect( address recipient, int24 tickLower, int24 tickUpper, uint128 amount0Requested, uint128 amount1Requested ) external returns (uint128 amount0, uint128 amount1); /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0 /// @dev Fees must be collected separately via a call to #collect /// @param tickLower The lower tick of the position for which to burn liquidity /// @param tickUpper The upper tick of the position for which to burn liquidity /// @param amount How much liquidity to burn /// @return amount0 The amount of token0 sent to the recipient /// @return amount1 The amount of token1 sent to the recipient function burn( int24 tickLower, int24 tickUpper, uint128 amount ) external returns (uint256 amount0, uint256 amount1); /// @notice Swap token0 for token1, or token1 for token0 /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback /// @param recipient The address to receive the output of the swap /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0 /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative) /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this /// value after the swap. If one for zero, the price cannot be greater than this value after the swap /// @param data Any data to be passed through to the callback /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive function swap( address recipient, bool zeroForOne, int256 amountSpecified, uint160 sqrtPriceLimitX96, bytes calldata data ) external returns (int256 amount0, int256 amount1); /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling /// with 0 amount{0,1} and sending the donation amount(s) from the callback /// @param recipient The address which will receive the token0 and token1 amounts /// @param amount0 The amount of token0 to send /// @param amount1 The amount of token1 to send /// @param data Any data to be passed through to the callback function flash( address recipient, uint256 amount0, uint256 amount1, bytes calldata data ) external; /// @notice Increase the maximum number of price and liquidity observations that this pool will store /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to /// the input observationCardinalityNext. /// @param observationCardinalityNext The desired minimum number of observations for the pool to store function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that is not stored /// @notice Contains view functions to provide information about the pool that is computed rather than stored on the /// blockchain. The functions here may have variable gas costs. interface IUniswapV3PoolDerivedState { /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick, /// you must call it with secondsAgos = [3600, 0]. /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio. /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block /// timestamp function observe(uint32[] calldata secondsAgos) external view returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s); /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed. /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first /// snapshot is taken and the second snapshot is taken. /// @param tickLower The lower tick of the range /// @param tickUpper The upper tick of the range /// @return tickCumulativeInside The snapshot of the tick accumulator for the range /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range /// @return secondsInside The snapshot of seconds per liquidity for the range function snapshotCumulativesInside(int24 tickLower, int24 tickUpper) external view returns ( int56 tickCumulativeInside, uint160 secondsPerLiquidityInsideX128, uint32 secondsInside ); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Events emitted by a pool /// @notice Contains all events emitted by the pool interface IUniswapV3PoolEvents { /// @notice Emitted exactly once by a pool when #initialize is first called on the pool /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96 /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool event Initialize(uint160 sqrtPriceX96, int24 tick); /// @notice Emitted when liquidity is minted for a given position /// @param sender The address that minted the liquidity /// @param owner The owner of the position and recipient of any minted liquidity /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity minted to the position range /// @param amount0 How much token0 was required for the minted liquidity /// @param amount1 How much token1 was required for the minted liquidity event Mint( address sender, address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted when fees are collected by the owner of a position /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees /// @param owner The owner of the position for which fees are collected /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount0 The amount of token0 fees collected /// @param amount1 The amount of token1 fees collected event Collect( address indexed owner, address recipient, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount0, uint128 amount1 ); /// @notice Emitted when a position's liquidity is removed /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect /// @param owner The owner of the position for which liquidity is removed /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity to remove /// @param amount0 The amount of token0 withdrawn /// @param amount1 The amount of token1 withdrawn event Burn( address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted by the pool for any swaps between token0 and token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the output of the swap /// @param amount0 The delta of the token0 balance of the pool /// @param amount1 The delta of the token1 balance of the pool /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96 /// @param liquidity The liquidity of the pool after the swap /// @param tick The log base 1.0001 of price of the pool after the swap event Swap( address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick ); /// @notice Emitted by the pool for any flashes of token0/token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the tokens from flash /// @param amount0 The amount of token0 that was flashed /// @param amount1 The amount of token1 that was flashed /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee event Flash( address indexed sender, address indexed recipient, uint256 amount0, uint256 amount1, uint256 paid0, uint256 paid1 ); /// @notice Emitted by the pool for increases to the number of observations that can be stored /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index /// just before a mint/swap/burn. /// @param observationCardinalityNextOld The previous value of the next observation cardinality /// @param observationCardinalityNextNew The updated value of the next observation cardinality event IncreaseObservationCardinalityNext( uint16 observationCardinalityNextOld, uint16 observationCardinalityNextNew ); /// @notice Emitted when the protocol fee is changed by the pool /// @param feeProtocol0Old The previous value of the token0 protocol fee /// @param feeProtocol1Old The previous value of the token1 protocol fee /// @param feeProtocol0New The updated value of the token0 protocol fee /// @param feeProtocol1New The updated value of the token1 protocol fee event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New); /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner /// @param sender The address that collects the protocol fees /// @param recipient The address that receives the collected protocol fees /// @param amount0 The amount of token0 protocol fees that is withdrawn /// @param amount0 The amount of token1 protocol fees that is withdrawn event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that never changes /// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values interface IUniswapV3PoolImmutables { /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface /// @return The contract address function factory() external view returns (address); /// @notice The first of the two tokens of the pool, sorted by address /// @return The token contract address function token0() external view returns (address); /// @notice The second of the two tokens of the pool, sorted by address /// @return The token contract address function token1() external view returns (address); /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6 /// @return The fee function fee() external view returns (uint24); /// @notice The pool tick spacing /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ... /// This value is an int24 to avoid casting even though it is always positive. /// @return The tick spacing function tickSpacing() external view returns (int24); /// @notice The maximum amount of position liquidity that can use any tick in the range /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool /// @return The max amount of liquidity per tick function maxLiquidityPerTick() external view returns (uint128); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Permissioned pool actions /// @notice Contains pool methods that may only be called by the factory owner interface IUniswapV3PoolOwnerActions { /// @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 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.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-3.0 pragma solidity 0.8.4; import {Gelatofied} from "./Gelatofied.sol"; import {OwnableUninitialized} from "./OwnableUninitialized.sol"; import { IUniswapV3Pool } from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import { ERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; /// @dev Single Global upgradeable state var storage base: APPEND ONLY /// @dev Add all inherited contracts with state vars here: APPEND ONLY /// @dev ERC20Upgradable Includes Initialize // solhint-disable-next-line max-states-count abstract contract GUniPoolStorage is ERC20Upgradeable, /* XXXX DONT MODIFY ORDERING XXXX */ ReentrancyGuardUpgradeable, OwnableUninitialized, Gelatofied // APPEND ADDITIONAL BASE WITH STATE VARS BELOW: // XXXX DONT MODIFY ORDERING XXXX { // solhint-disable-next-line const-name-snakecase string public constant version = "1.0.0"; // solhint-disable-next-line const-name-snakecase uint16 public constant gelatoFeeBPS = 100; // XXXXXXXX DO NOT MODIFY ORDERING XXXXXXXX int24 public lowerTick; int24 public upperTick; uint16 public gelatoRebalanceBPS; uint16 public gelatoWithdrawBPS; uint16 public gelatoSlippageBPS; uint32 public gelatoSlippageInterval; uint16 public managerFeeBPS; address public managerTreasury; uint256 public managerBalance0; uint256 public managerBalance1; uint256 public gelatoBalance0; uint256 public gelatoBalance1; IUniswapV3Pool public pool; IERC20 public token0; IERC20 public token1; // APPPEND ADDITIONAL STATE VARS BELOW: // XXXXXXXX DO NOT MODIFY ORDERING XXXXXXXX event UpdateAdminTreasury( address oldAdminTreasury, address newAdminTreasury ); event UpdateGelatoParams( uint16 gelatoRebalanceBPS, uint16 gelatoWithdrawBPS, uint16 gelatoSlippageBPS, uint32 gelatoSlippageInterval ); event SetManagerFee(uint16 managerFee); // solhint-disable-next-line max-line-length constructor(address payable _gelato) Gelatofied(_gelato) {} // solhint-disable-line no-empty-blocks /// @notice initialize storage variables on a new G-UNI pool, only called once /// @param _name name of G-UNI token /// @param _symbol symbol of G-UNI token /// @param _pool address of Uniswap V3 pool /// @param _managerFeeBPS proportion of fees earned that go to manager treasury /// note that the 4 above params are NOT UPDATEABLE AFTER INILIALIZATION /// @param _lowerTick initial lowerTick (only changeable with executiveRebalance) /// @param _lowerTick initial upperTick (only changeable with executiveRebalance) /// @param _manager_ address of manager (ownership can be transferred) function initialize( string memory _name, string memory _symbol, address _pool, uint16 _managerFeeBPS, int24 _lowerTick, int24 _upperTick, address _manager_ ) external initializer { require(_managerFeeBPS <= 10000 - gelatoFeeBPS, "mBPS"); // these variables are immutable after initialization pool = IUniswapV3Pool(_pool); token0 = IERC20(pool.token0()); token1 = IERC20(pool.token1()); managerFeeBPS = _managerFeeBPS; // if set to 0 here manager can still initialize later // these variables can be udpated by the manager gelatoSlippageInterval = 5 minutes; // default: last five minutes; gelatoSlippageBPS = 500; // default: 5% slippage gelatoWithdrawBPS = 100; // default: only auto withdraw if tx fee is lt 1% withdrawn gelatoRebalanceBPS = 200; // default: only rebalance if tx fee is lt 2% reinvested managerTreasury = _manager_; // default: treasury is admin lowerTick = _lowerTick; upperTick = _upperTick; _manager = _manager_; // e.g. "Gelato Uniswap V3 USDC/DAI LP" and "G-UNI" __ERC20_init(_name, _symbol); __ReentrancyGuard_init(); } /// @notice change configurable parameters, only manager can call /// @param newRebalanceBPS controls frequency of gelato rebalances: gas fee to execute /// rebalance can be gelatoRebalanceBPS proportion of fees earned since last rebalance /// @param newWithdrawBPS controls frequency of gelato withdrawals: gas fee to execute /// withdrawal can be gelatoWithdrawBPS proportion of fees accrued since last withdraw /// @param newSlippageBPS maximum slippage on swaps during gelato rebalance /// @param newSlippageInterval length of time for TWAP used in computing slippage on swaps /// @param newTreasury address where managerFee withdrawals are sent // solhint-disable-next-line code-complexity function updateGelatoParams( uint16 newRebalanceBPS, uint16 newWithdrawBPS, uint16 newSlippageBPS, uint32 newSlippageInterval, address newTreasury ) external onlyManager { require(newWithdrawBPS <= 10000, "BPS"); require(newRebalanceBPS <= 10000, "BPS"); require(newSlippageBPS <= 10000, "BPS"); emit UpdateGelatoParams( newRebalanceBPS, newWithdrawBPS, newSlippageBPS, newSlippageInterval ); if (newRebalanceBPS != 0) gelatoRebalanceBPS = newRebalanceBPS; if (newWithdrawBPS != 0) gelatoWithdrawBPS = newWithdrawBPS; if (newSlippageBPS != 0) gelatoSlippageBPS = newSlippageBPS; if (newSlippageInterval != 0) gelatoSlippageInterval = newSlippageInterval; if (newTreasury != address(0)) managerTreasury = newTreasury; } /// @notice initializeManagerFee sets a managerFee, only manager can call. /// If a manager fee was not set in the initialize function it can be set here /// but ONLY ONCE- after it is set to a non-zero value, managerFee can never be set again. /// @param _managerFeeBPS proportion of fees earned that are credited to manager in Basis Points function initializeManagerFee(uint16 _managerFeeBPS) external onlyManager { require(managerFeeBPS == 0, "fee"); require( _managerFeeBPS > 0 && _managerFeeBPS <= 10000 - gelatoFeeBPS, "mBPS" ); emit SetManagerFee(_managerFeeBPS); managerFeeBPS = _managerFeeBPS; } function renounceOwnership() public virtual override onlyManager { managerTreasury = address(0); managerFeeBPS = 0; managerBalance0 = 0; managerBalance1 = 0; super.renounceOwnership(); } function getPositionID() external view returns (bytes32 positionID) { return _getPositionID(); } function _getPositionID() internal view returns (bytes32 positionID) { return keccak256(abi.encodePacked(address(this), lowerTick, upperTick)); } }
// SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.4; import {Address} from "@openzeppelin/contracts/utils/Address.sol"; import { IERC20, SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; /// @dev DO NOT ADD STATE VARIABLES - APPEND THEM TO GelatoUniV3PoolStorage /// @dev DO NOT ADD BASE CONTRACTS WITH STATE VARS - APPEND THEM TO GelatoUniV3PoolStorage abstract contract Gelatofied { using Address for address payable; using SafeERC20 for IERC20; // solhint-disable-next-line var-name-mixedcase address payable public immutable GELATO; address private constant _ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; constructor(address payable _gelato) { GELATO = _gelato; } modifier gelatofy(uint256 _amount, address _paymentToken) { require(msg.sender == GELATO, "Gelatofied: Only gelato"); _; if (_paymentToken == _ETH) GELATO.sendValue(_amount); else IERC20(_paymentToken).safeTransfer(GELATO, _amount); } }
// SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.4; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an manager) that can be granted exclusive access to * specific functions. * * By default, the manager account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyManager`, which can be applied to your functions to restrict their use to * the manager. */ /// @dev DO NOT ADD STATE VARIABLES - APPEND THEM TO GelatoUniV3PoolStorage /// @dev DO NOT ADD BASE CONTRACTS WITH STATE VARS - APPEND THEM TO GelatoUniV3PoolStorage abstract contract OwnableUninitialized { address internal _manager; event OwnershipTransferred( address indexed previousManager, address indexed newManager ); /// @dev Initializes the contract setting the deployer as the initial manager. /// CONSTRUCTOR EMPTY - USE INITIALIZIABLE INSTEAD // solhint-disable-next-line no-empty-blocks constructor() {} /** * @dev Returns the address of the current manager. */ function manager() public view virtual returns (address) { return _manager; } /** * @dev Throws if called by any account other than the manager. */ modifier onlyManager() { require(manager() == msg.sender, "Ownable: caller is not the manager"); _; } /** * @dev Leaves the contract without manager. It will not be possible to call * `onlyManager` functions anymore. Can only be called by the current manager. * * NOTE: Renouncing ownership will leave the contract without an manager, * thereby removing any functionality that is only available to the manager. */ function renounceOwnership() public virtual onlyManager { emit OwnershipTransferred(_manager, address(0)); _manager = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current manager. */ function transferOwnership(address newOwner) public virtual onlyManager { require( newOwner != address(0), "Ownable: new manager is the zero address" ); emit OwnershipTransferred(_manager, newOwner); _manager = newOwner; } }
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.4; /// @title Contains 512-bit math functions /// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision /// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits library FullMath { /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv function mulDiv( uint256 a, uint256 b, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = a * b // Compute the product mod 2**256 and mod 2**256 - 1 // then use the Chinese Remainder Theorem to reconstruct // the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2**256 + prod0 uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(a, b, not(0)) prod0 := mul(a, b) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division if (prod1 == 0) { require(denominator > 0); assembly { result := div(prod0, denominator) } return result; } // Make sure the result is less than 2**256. // Also prevents denominator == 0 require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0] // Compute remainder using mulmod uint256 remainder; assembly { remainder := mulmod(a, b, denominator) } // Subtract 256 bit number from 512 bit number assembly { prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator // Compute largest power of two divisor of denominator. // Always >= 1. // EDIT for 0.8 compatibility: // see: https://ethereum.stackexchange.com/questions/96642/unary-operator-cannot-be-applied-to-type-uint256 uint256 twos = denominator & (~denominator + 1); // 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-3.0 pragma solidity >=0.5.0; import {FullMath} from "./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 { 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 /// @param sqrtRatioBX96 Another sqrt price /// @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 /// @param sqrtRatioBX96 Another sqrt price /// @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 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 /// @param sqrtRatioBX96 Another sqrt price /// @param liquidity The liquidity being valued /// @return amount0 The amount0 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 /// @param sqrtRatioBX96 Another sqrt price /// @param liquidity The liquidity being valued /// @return amount1 The amount1 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 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-3.0 pragma solidity 0.8.4; /// @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)); // EDIT: 0.8 compatibility require(absTick <= uint256(int256(MAX_TICK)), "T"); uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000; if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128; if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128; if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128; if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128; if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128; if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128; if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128; if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128; if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128; if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128; if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128; if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128; if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128; if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128; if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128; if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128; if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128; if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128; if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128; if (tick > 0) ratio = type(uint256).max / ratio; // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96. // we then downcast because we know the result always fits within 160 bits due to our tick input constraint // we round up in the division so getTickAtSqrtRatio of the output price is always consistent sqrtPriceX96 = uint160( (ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1) ); } /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may /// ever return. /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96 /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) { // second inequality must be < because the price can never reach the price at the max tick require( sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO, "R" ); uint256 ratio = uint256(sqrtPriceX96) << 32; uint256 r = ratio; uint256 msb = 0; assembly { let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(5, gt(r, 0xFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(4, gt(r, 0xFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(3, gt(r, 0xFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(2, gt(r, 0xF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(1, gt(r, 0x3)) msb := or(msb, f) r := shr(f, r) } assembly { let f := gt(r, 0x1) msb := or(msb, f) } if (msb >= 128) r = ratio >> (msb - 127); else r = ratio << (127 - msb); int256 log_2 = (int256(msb) - 128) << 64; assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(63, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(62, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(61, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(60, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(59, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(58, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(57, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(56, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(55, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(54, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(53, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(52, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(51, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(50, f)) } int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number int24 tickLow = int24( (log_sqrt10001 - 3402992956809132418596140100660247210) >> 128 ); int24 tickHi = int24( (log_sqrt10001 + 291339464771989622907027621153398088495) >> 128 ); tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow; } }
{ "evmVersion": "istanbul", "libraries": {}, "metadata": { "bytecodeHash": "ipfs", "useLiteralContent": true }, "optimizer": { "enabled": true, "runs": 1 }, "remappings": [], "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address payable","name":"_gelato","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"burnAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount0Out","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1Out","type":"uint256"},{"indexed":false,"internalType":"uint128","name":"liquidityBurned","type":"uint128"}],"name":"Burned","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"feesEarned0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feesEarned1","type":"uint256"}],"name":"FeesEarned","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"mintAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount0In","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1In","type":"uint256"},{"indexed":false,"internalType":"uint128","name":"liquidityMinted","type":"uint128"}],"name":"Minted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousManager","type":"address"},{"indexed":true,"internalType":"address","name":"newManager","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"int24","name":"lowerTick_","type":"int24"},{"indexed":false,"internalType":"int24","name":"upperTick_","type":"int24"},{"indexed":false,"internalType":"uint128","name":"liquidityBefore","type":"uint128"},{"indexed":false,"internalType":"uint128","name":"liquidityAfter","type":"uint128"}],"name":"Rebalance","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"managerFee","type":"uint16"}],"name":"SetManagerFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldAdminTreasury","type":"address"},{"indexed":false,"internalType":"address","name":"newAdminTreasury","type":"address"}],"name":"UpdateAdminTreasury","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"gelatoRebalanceBPS","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"gelatoWithdrawBPS","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"gelatoSlippageBPS","type":"uint16"},{"indexed":false,"internalType":"uint32","name":"gelatoSlippageInterval","type":"uint32"}],"name":"UpdateGelatoParams","type":"event"},{"inputs":[],"name":"GELATO","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"burnAmount","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"burn","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"},{"internalType":"uint128","name":"liquidityBurned","type":"uint128"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"int24","name":"newLowerTick","type":"int24"},{"internalType":"int24","name":"newUpperTick","type":"int24"},{"internalType":"uint160","name":"swapThresholdPrice","type":"uint160"},{"internalType":"uint256","name":"swapAmountBPS","type":"uint256"},{"internalType":"bool","name":"zeroForOne","type":"bool"}],"name":"executiveRebalance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"gelatoBalance0","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gelatoBalance1","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gelatoFeeBPS","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gelatoRebalanceBPS","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gelatoSlippageBPS","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gelatoSlippageInterval","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gelatoWithdrawBPS","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount0Max","type":"uint256"},{"internalType":"uint256","name":"amount1Max","type":"uint256"}],"name":"getMintAmounts","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"},{"internalType":"uint256","name":"mintAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPositionID","outputs":[{"internalType":"bytes32","name":"positionID","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getUnderlyingBalances","outputs":[{"internalType":"uint256","name":"amount0Current","type":"uint256"},{"internalType":"uint256","name":"amount1Current","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint160","name":"sqrtRatioX96","type":"uint160"}],"name":"getUnderlyingBalancesAtPrice","outputs":[{"internalType":"uint256","name":"amount0Current","type":"uint256"},{"internalType":"uint256","name":"amount1Current","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"address","name":"_pool","type":"address"},{"internalType":"uint16","name":"_managerFeeBPS","type":"uint16"},{"internalType":"int24","name":"_lowerTick","type":"int24"},{"internalType":"int24","name":"_upperTick","type":"int24"},{"internalType":"address","name":"_manager_","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_managerFeeBPS","type":"uint16"}],"name":"initializeManagerFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lowerTick","outputs":[{"internalType":"int24","name":"","type":"int24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"managerBalance0","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"managerBalance1","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"managerFeeBPS","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"managerTreasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"mintAmount","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"mint","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"},{"internalType":"uint128","name":"liquidityMinted","type":"uint128"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pool","outputs":[{"internalType":"contract IUniswapV3Pool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint160","name":"swapThresholdPrice","type":"uint160"},{"internalType":"uint256","name":"swapAmountBPS","type":"uint256"},{"internalType":"bool","name":"zeroForOne","type":"bool"},{"internalType":"uint256","name":"feeAmount","type":"uint256"},{"internalType":"address","name":"paymentToken","type":"address"}],"name":"rebalance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token0","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token1","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount0Owed","type":"uint256"},{"internalType":"uint256","name":"amount1Owed","type":"uint256"},{"internalType":"bytes","name":"","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":"","type":"bytes"}],"name":"uniswapV3SwapCallback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"newRebalanceBPS","type":"uint16"},{"internalType":"uint16","name":"newWithdrawBPS","type":"uint16"},{"internalType":"uint16","name":"newSlippageBPS","type":"uint16"},{"internalType":"uint32","name":"newSlippageInterval","type":"uint32"},{"internalType":"address","name":"newTreasury","type":"address"}],"name":"updateGelatoParams","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"upperTick","outputs":[{"internalType":"int24","name":"","type":"int24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"feeAmount","type":"uint256"},{"internalType":"address","name":"feeToken","type":"address"}],"name":"withdrawGelatoBalance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"feeAmount","type":"uint256"},{"internalType":"address","name":"feeToken","type":"address"}],"name":"withdrawManagerBalance","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60a06040523480156200001157600080fd5b50604051620060783803806200607883398101604081905262000034916200004a565b60601b6001600160601b0319166080526200007a565b6000602082840312156200005c578081fd5b81516001600160a01b038116811462000073578182fd5b9392505050565b60805160601c615fa0620000d8600039600081816105f801528181610cea01528181610dd301528181610e0d015281816114f40152818161173c0152818161177601528181611858015281816118cf015261190c0152615fa06000f3fe608060405234801561001057600080fd5b50600436106102255760003560e01c8063065756db1461022a57806306fdde0314610246578063095ea7b31461025b5780630dfe16811461027e5780631322d9541461029e57806316f0115b146102b457806318160ddd146102c757806323b872dd146102cf57806324b8fd1b146102e257806331366be4146102f7578063313ce5671461031257806339509351146103215780633d8b30e11461033457806342fb9d4414610349578063481c6a751461035257806354fd4d501461035a578063672152bd1461037e57806370a08231146103a3578063715018a6146103cc578063727dd228146103d457806378ac6357146103f557806394bf804d1461040857806395d89b411461043f5780639894f21a1461044757806399fd808c146104755780639b1344ac14610488578063a457c2d71461049c578063a50b1fe7146104af578063a9059cbb146104c4578063b135c99f146104d7578063b536bd12146104ea578063b670ed7d146104f3578063be93dd5f14610506578063c345445914610519578063cc95353e14610522578063ccdf7a021461053c578063d21220a714610551578063d348799714610564578063d6e7ff3914610577578063dd62ed3e1461058c578063df28408a146105c5578063e25e15e3146105cd578063e4077894146105e0578063eff557a7146105f3578063f2fde38b1461061a578063fa461e331461062d578063fcd3533c14610640575b600080fd5b61023360995481565b6040519081526020015b60405180910390f35b61024e610653565b60405161023d91906159a9565b61026e6102693660046152fa565b6106e5565b604051901515815260200161023d565b609e54610291906001600160a01b031681565b60405161023d9190615896565b6102a66106fb565b60405161023d929190615ba1565b609d54610291906001600160a01b031681565b603554610233565b61026e6102dd3660046152ba565b6107a4565b6102f56102f0366004615404565b61085c565b005b6102ff606481565b60405161ffff909116815260200161023d565b6040516012815260200161023d565b61026e61032f3660046152fa565b610c41565b6097546102ff90600160e01b900461ffff1681565b610233609a5481565b610291610c78565b61024e604051806040016040528060058152602001640312e302e360dc1b81525081565b60985461038e9063ffffffff1681565b60405163ffffffff909116815260200161023d565b6102336103b136600461524a565b6001600160a01b031660009081526033602052604090205490565b6102f5610c87565b6097546103e890600160b81b900460020b81565b60405161023d919061596d565b6102f5610403366004615835565b610cdd565b61041b610416366004615835565b610e38565b6040805193845260208401929092526001600160801b03169082015260600161023d565b61024e61111e565b61045a610455366004615859565b61112d565b6040805193845260208401929092529082015260600161023d565b6102f56104833660046157bb565b61127f565b6097546103e890600160a01b900460020b81565b61026e6104aa3660046152fa565b61143f565b6097546102ff90600160d01b900461ffff1681565b61026e6104d23660046152fa565b6114da565b6102f56104e536600461576b565b6114e7565b610233609b5481565b6102a661050136600461524a565b6117a4565b6102f5610514366004615835565b61184b565b610233609c5481565b60985461029190600160301b90046001600160a01b031681565b6098546102ff90600160201b900461ffff1681565b609f54610291906001600160a01b031681565b6102f561057236600461548e565b611931565b6097546102ff90600160f01b900461ffff1681565b61023361059a366004615282565b6001600160a01b03918216600090815260346020908152604080832093909416825291909152205490565b610233611995565b6102f56105db3660046154de565b6119a4565b6102f56105ee3660046156bf565b611c41565b6102917f000000000000000000000000000000000000000000000000000000000000000081565b6102f561062836600461524a565b611d4e565b6102f561063b36600461548e565b611e2e565b61041b61064e366004615835565b611e98565b60606036805461066290615daf565b80601f016020809104026020016040519081016040528092919081815260200182805461068e90615daf565b80156106db5780601f106106b0576101008083540402835291602001916106db565b820191906000526020600020905b8154815290600101906020018083116106be57829003601f168201915b5050505050905090565b60006106f23384846121d1565b50600192915050565b600080600080609d60009054906101000a90046001600160a01b03166001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561074f57600080fd5b505afa158015610763573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061078791906156db565b50505050509150915061079a82826122f6565b9350935050509091565b60006107b18484846125a7565b6001600160a01b03841660009081526034602090815260408083203384529091529020548281101561083b5760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b61084f853361084a8685615d6c565b6121d1565b60019150505b9392505050565b33610865610c78565b6001600160a01b03161461088b5760405162461bcd60e51b815260040161083290615b08565b609d546000906001600160a01b031663514ea4bf6108a761276d565b6040518263ffffffff1660e01b81526004016108c591815260200190565b60a06040518083038186803b1580156108dd57600080fd5b505afa1580156108f1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109159190615669565b5050505090506000816001600160801b0316111561099f57609754600090819061095590600160a01b8104600290810b91600160b81b9004900b856127d3565b9350935050506109658282612b60565b61096f8282612c39565b6040519193509150600080516020615f4b833981519152906109949084908490615ba1565b60405180910390a150505b60978054600287810b62ffffff908116600160b81b0262ffffff60b81b19928b900b909116600160a01b029190911665ffffffffffff60a01b1990921691909117179055609b54609954609e546040516370a0823160e01b815260009392916001600160a01b0316906370a0823190610a1c903090600401615896565b60206040518083038186803b158015610a3457600080fd5b505afa158015610a48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a6c919061581d565b610a769190615d6c565b610a809190615d6c565b609c54609a54609f546040516370a0823160e01b81529394506000936001600160a01b03909116906370a0823190610abc903090600401615896565b60206040518083038186803b158015610ad457600080fd5b505afa158015610ae8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b0c919061581d565b610b169190615d6c565b610b209190615d6c565b9050610b31888884848a8a8a612cd4565b609d546000906001600160a01b031663514ea4bf610b4d61276d565b6040518263ffffffff1660e01b8152600401610b6b91815260200190565b60a06040518083038186803b158015610b8357600080fd5b505afa158015610b97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bbb9190615669565b5050505090506000816001600160801b031611610c0b5760405162461bcd60e51b815260206004820152600e60248201526d06e657720706f736974696f6e20360941b6044820152606401610832565b600080516020615eeb83398151915289898684604051610c2e949392919061597b565b60405180910390a1505050505050505050565b3360008181526034602090815260408083206001600160a01b038716845290915281205490916106f291859061084a908690615c4a565b6097546001600160a01b031690565b33610c90610c78565b6001600160a01b031614610cb65760405162461bcd60e51b815260040161083290615b08565b60988054600160201b600160d01b031916905560006099819055609a55610cdb612e93565b565b8181336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610d275760405162461bcd60e51b8152600401610832906159dc565b600080610d3a609954609a548888612efa565b60006099819055609a5590925090508115610d7457609854609e54610d74916001600160a01b0391821691600160301b909104168461301e565b8015610d9f57609854609f54610d9f916001600160a01b0391821691600160301b909104168361301e565b50506001600160a01b03811673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415610dfe57610df96001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001683613086565b610e32565b610e326001600160a01b0382167f00000000000000000000000000000000000000000000000000000000000000008461301e565b50505050565b600080600060026065541415610e605760405162461bcd60e51b815260040161083290615b6a565b600260655584610e825760405162461bcd60e51b815260040161083290615b4a565b6000610e8d60355490565b90506000609d60009054906101000a90046001600160a01b03166001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b158015610edf57600080fd5b505afa158015610ef3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f1791906156db565b50505050505090506000821115610f5857600080610f336106fb565b91509150610f42828a8661319c565b9650610f4f818a8661319c565b95505050610fa5565b610f9f81610f77609760149054906101000a900460020b60020b6131f3565b609754610f9190600160b81b9004600290810b900b6131f3565b610f9a8b613605565b61366e565b90955093505b8415610fc357609e54610fc3906001600160a01b0316333088613709565b8315610fe157609f54610fe1906001600160a01b0316333087613709565b61102181611000609760149054906101000a900460020b60020b6131f3565b60975461101a90600160b81b9004600290810b900b6131f3565b8888613741565b609d54609754604051633c8a7d8d60e01b81529295506001600160a01b0390911691633c8a7d8d91611071913091600160a01b8104600290810b92600160b81b909204900b9089906004016158aa565b6040805180830381600087803b15801561108a57600080fd5b505af115801561109e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110c2919061546b565b50506110ce8688613803565b7f55801cfe493000b734571da1694b21e7f66b11e8ce9fdaa0524ecb59105e73e786888787876040516111059594939291906158ec565b60405180910390a1505060016065819055509250925092565b60606037805461066290615daf565b60008060008061113c60355490565b9050801561115b5761114f8187876138d0565b91955093509150611277565b609d5460408051633850c7bd60e01b815290516000926001600160a01b031691633850c7bd9160048083019260e0929190829003018186803b1580156111a057600080fd5b505afa1580156111b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111d891906156db565b5050505050509050600061122282611201609760149054906101000a900460020b60020b6131f3565b60975461121b90600160b81b9004600290810b900b6131f3565b8b8b613741565b9050806001600160801b0316935061126f8261124f609760149054906101000a900460020b60020b6131f3565b60975461126990600160b81b9004600290810b900b6131f3565b8461366e565b909650945050505b509250925092565b33611288610c78565b6001600160a01b0316146112ae5760405162461bcd60e51b815260040161083290615b08565b6127108461ffff1611156112d45760405162461bcd60e51b815260040161083290615aeb565b6127108561ffff1611156112fa5760405162461bcd60e51b815260040161083290615aeb565b6127108361ffff1611156113205760405162461bcd60e51b815260040161083290615aeb565b6040805161ffff8781168252868116602083015285168183015263ffffffff8416606082015290517f0b7615006627cf7664941bc288d4641731f895e102f95cb8690583ad7508faa89181900360800190a161ffff851615611397576097805461ffff60d01b1916600160d01b61ffff8816021790555b61ffff8416156113bc576097805461ffff60e01b1916600160e01b61ffff8716021790555b61ffff8316156113e257609780546001600160f01b0316600160f01b61ffff8616021790555b63ffffffff821615611404576098805463ffffffff191663ffffffff84161790555b6001600160a01b038116156114385760988054600160301b600160d01b031916600160301b6001600160a01b038416021790555b5050505050565b3360009081526034602090815260408083206001600160a01b0386168452909152812054828110156114c15760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610832565b6114d0338561084a8685615d6c565b5060019392505050565b60006106f23384846125a7565b8181336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146115315760405162461bcd60e51b8152600401610832906159dc565b85156115415761154187866139df565b609d546000906001600160a01b031663514ea4bf61155d61276d565b6040518263ffffffff1660e01b815260040161157b91815260200190565b60a06040518083038186803b15801561159357600080fd5b505afa1580156115a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115cb9190615669565b5050505090506115df818989898989613c8d565b609d546000906001600160a01b031663514ea4bf6115fb61276d565b6040518263ffffffff1660e01b815260040161161991815260200190565b60a06040518083038186803b15801561163157600080fd5b505afa158015611645573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116699190615669565b505050509050816001600160801b0316816001600160801b031610156116c65760405162461bcd60e51b81526020600482015260126024820152716c697175696469747920646563726561736560701b6044820152606401610832565b609754604051600080516020615eeb8339815191529161170091600160a01b8204600290810b92600160b81b9004900b908690869061597b565b60405180910390a150506001600160a01b03811673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415611767576117626001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001683613086565b61179b565b61179b6001600160a01b0382167f00000000000000000000000000000000000000000000000000000000000000008461301e565b50505050505050565b6000806000609d60009054906101000a90046001600160a01b03166001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b1580156117f757600080fd5b505afa15801561180b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061182f91906156db565b505050505091505061184184826122f6565b9250925050915091565b8181336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146118955760405162461bcd60e51b8152600401610832906159dc565b6000806118a8609b54609c548888612efa565b6000609b819055609c55909250905081156118f457609e546118f4906001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000008461301e565b8015610d9f57609f54610d9f906001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000008361301e565b609d546001600160a01b0316331461195b5760405162461bcd60e51b815260040161083290615a2b565b831561197857609e54611978906001600160a01b0316338661301e565b8215610e3257609f54610e32906001600160a01b0316338561301e565b600061199f61276d565b905090565b600054610100900460ff16806119bd575060005460ff16155b6119d95760405162461bcd60e51b815260040161083290615a54565b600054610100900460ff161580156119fb576000805461ffff19166101011790555b611a086064612710615d29565b61ffff168561ffff161115611a2f5760405162461bcd60e51b815260040161083290615a0d565b609d80546001600160a01b0319166001600160a01b03881690811790915560408051630dfe168160e01b81529051630dfe168191600480820192602092909190829003018186803b158015611a8357600080fd5b505afa158015611a97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611abb9190615266565b609e80546001600160a01b0319166001600160a01b03928316179055609d546040805163d21220a760e01b81529051919092169163d21220a7916004808301926020929190829003018186803b158015611b1457600080fd5b505afa158015611b28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b4c9190615266565b609f80546001600160a01b03199081166001600160a01b0393841617909155609880546097805461012c65ffffffffffff19909316600160201b61ffff8d160263ffffffff19161792909217600160301b600160d01b031916600160301b95881695860217909255643e800c801960d31b600165ffffff00000160a01b03909116600160a01b60028a810b62ffffff908116929092029290921792909217600165ffffff00000160a01b031916600160b81b9189900b9290921602909216919091179091179055611c1d88886141af565b611c2561422e565b8015611c37576000805461ff00191690555b5050505050505050565b33611c4a610c78565b6001600160a01b031614611c705760405162461bcd60e51b815260040161083290615b08565b609854600160201b900461ffff1615611cb15760405162461bcd60e51b815260206004820152600360248201526266656560e81b6044820152606401610832565b60008161ffff16118015611cd95750611ccd6064612710615d29565b61ffff168161ffff1611155b611cf55760405162461bcd60e51b815260040161083290615a0d565b60405161ffff821681527f8a1ffb520c943072e654fc414750dbefad5b6d6311339d041901c4752782fad39060200160405180910390a16098805461ffff909216600160201b0261ffff60201b19909216919091179055565b33611d57610c78565b6001600160a01b031614611d7d5760405162461bcd60e51b815260040161083290615b08565b6001600160a01b038116611de45760405162461bcd60e51b815260206004820152602860248201527f4f776e61626c653a206e6577206d616e6167657220697320746865207a65726f604482015267206164647265737360c01b6064820152608401610832565b6097546040516001600160a01b03808416921690600080516020615f0b83398151915290600090a3609780546001600160a01b0319166001600160a01b0392909216919091179055565b609d546001600160a01b03163314611e585760405162461bcd60e51b815260040161083290615a2b565b6000841315611e7857609e54610df9906001600160a01b0316338661301e565b6000831315610e3257609f54610e32906001600160a01b0316338561301e565b600080600060026065541415611ec05760405162461bcd60e51b815260040161083290615b6a565b600260655584611efb5760405162461bcd60e51b815260206004820152600660248201526506275726e20360d41b6044820152606401610832565b6000611f0660355490565b609d549091506000906001600160a01b031663514ea4bf611f2561276d565b6040518263ffffffff1660e01b8152600401611f4391815260200190565b60a06040518083038186803b158015611f5b57600080fd5b505afa158015611f6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f939190615669565b505050509050611fa333886142a2565b6000611fb988836001600160801b0316856143df565b9050611fc481613605565b609754909450600090819081908190611ff390600160a01b8104600290810b91600160b81b9004900b8a6127d3565b93509350935093506120058282612b60565b61200f8282612c39565b6040519193509150600080516020615f4b833981519152906120349084908490615ba1565b60405180910390a1609b54609954609e546040516370a0823160e01b81526120ef93929188916001600160a01b03909116906370a082319061207a903090600401615896565b60206040518083038186803b15801561209257600080fd5b505afa1580156120a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120ca919061581d565b6120d49190615d6c565b6120de9190615d6c565b6120e89190615d6c565b8d896143df565b6120f99085615c4a565b609c54609a54609f546040516370a0823160e01b8152939d506121369387916001600160a01b0316906370a082319061207a903090600401615896565b6121409084615c4a565b9850891561215f57609e5461215f906001600160a01b03168c8c61301e565b881561217c57609f5461217c906001600160a01b03168c8b61301e565b7f7239dff1718b550db7f36cbf69c665cfeb56d0e96b4fb76a5cba712961b655098b8d8c8c8c6040516121b39594939291906158ec565b60405180910390a15050505050505060016065819055509250925092565b6001600160a01b0383166122335760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610832565b6001600160a01b0382166122945760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610832565b6001600160a01b0383811660008181526034602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b609d546000908190819081908190819081906001600160a01b031663514ea4bf61231e61276d565b6040518263ffffffff1660e01b815260040161233c91815260200190565b60a06040518083038186803b15801561235457600080fd5b505afa158015612368573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061238c9190615669565b945094509450945094506123d5896123b5609760149054906101000a900460020b60020b6131f3565b6097546123cf90600160b81b9004600290810b900b6131f3565b8861366e565b909750955060006001600160801b0383166123f36001878c8a61448e565b6123fd9190615c4a565b90506000826001600160801b03166124186000878d8b61448e565b6124229190615c4a565b905061242e8282612c39565b609b54609954609e546040516370a0823160e01b8152949650929450909290916001600160a01b0316906370a082319061246c903090600401615896565b60206040518083038186803b15801561248457600080fd5b505afa158015612498573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124bc919061581d565b6124c69085615c4a565b6124d09190615d6c565b6124da9190615d6c565b6124e4908a615c4a565b609c54609a54609f546040516370a0823160e01b8152939c50919290916001600160a01b0316906370a082319061251f903090600401615896565b60206040518083038186803b15801561253757600080fd5b505afa15801561254b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061256f919061581d565b6125799084615c4a565b6125839190615d6c565b61258d9190615d6c565b6125979089615c4a565b9750505050505050509250929050565b6001600160a01b03831661260b5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610832565b6001600160a01b03821661266d5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610832565b6001600160a01b038316600090815260336020526040902054818110156126e55760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610832565b6126ef8282615d6c565b6001600160a01b038086166000908152603360205260408082209390935590851681529081208054849290612725908490615c4a565b92505081905550826001600160a01b0316846001600160a01b0316600080516020615f2b8339815191528460405161275f91815260200190565b60405180910390a350505050565b6097546040516001600160601b03193060601b166020820152600160a01b8204600290810b810b60e890811b6034840152600160b81b909304810b900b90911b6037820152600090603a0160405160208183030381529060405280519060200120905090565b609e546040516370a0823160e01b815260009182918291829182916001600160a01b0316906370a082319061280c903090600401615896565b60206040518083038186803b15801561282457600080fd5b505afa158015612838573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061285c919061581d565b609f546040516370a0823160e01b81529192506000916001600160a01b03909116906370a0823190612892903090600401615896565b60206040518083038186803b1580156128aa57600080fd5b505afa1580156128be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128e2919061581d565b609d5460405163a34123a760e01b815260028c810b60048301528b900b60248201526001600160801b038a1660448201529192506001600160a01b03169063a34123a7906064016040805180830381600087803b15801561294257600080fd5b505af1158015612956573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061297a919061546b565b609d546040516309e3d67b60e31b815230600482015260028d810b60248301528c900b60448201526001600160801b036064820181905260848201529298509096506001600160a01b031690634f1eb3d89060a4016040805180830381600087803b1580156129e857600080fd5b505af11580156129fc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a209190615637565b5050609e546040516370a0823160e01b8152879184916001600160a01b03909116906370a0823190612a56903090600401615896565b60206040518083038186803b158015612a6e57600080fd5b505afa158015612a82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612aa6919061581d565b612ab09190615d6c565b612aba9190615d6c565b609f546040516370a0823160e01b8152919550869183916001600160a01b0316906370a0823190612aef903090600401615896565b60206040518083038186803b158015612b0757600080fd5b505afa158015612b1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b3f919061581d565b612b499190615d6c565b612b539190615d6c565b9250505093509350935093565b612710612b6e606484615ccb565b612b789190615c88565b609b6000828254612b899190615c4a565b909155506127109050612b9d606483615ccb565b612ba79190615c88565b609c6000828254612bb89190615c4a565b909155505060985461271090612bd990600160201b900461ffff1684615ccb565b612be39190615c88565b60996000828254612bf49190615c4a565b909155505060985461271090612c1590600160201b900461ffff1683615ccb565b612c1f9190615c88565b609a6000828254612c309190615c4a565b90915550505050565b6000806000612710609860049054906101000a900461ffff166064612c5e9190615c02565b612c6c9061ffff1687615ccb565b612c769190615c88565b60985490915060009061271090612c9990600160201b900461ffff166064615c02565b612ca79061ffff1687615ccb565b612cb19190615c88565b9050612cbd8287615d6c565b9350612cc98186615d6c565b925050509250929050565b609d5460408051633850c7bd60e01b815290516000926001600160a01b031691633850c7bd9160048083019260e0929190829003018186803b158015612d1957600080fd5b505afa158015612d2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d5191906156db565b50505050505090506000612d7e82612d6b8b60020b6131f3565b612d778b60020b6131f3565b8a8a613741565b90506001600160801b03811615612e3b57609d54604051633c8a7d8d60e01b815260009182916001600160a01b0390911690633c8a7d8d90612dca9030908f908f9089906004016158aa565b6040805180830381600087803b158015612de357600080fd5b505af1158015612df7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e1b919061546b565b9092509050612e2a828a615d6c565b9850612e368189615d6c565b975050505b6000612e6a6127108686612e4f5789612e51565b8a5b612e5b9190615ccb565b612e659190615c88565b61489a565b90506000811315612e8757612e848a8a8a8a858b8a614900565b50505b50505050505050505050565b33612e9c610c78565b6001600160a01b031614612ec25760405162461bcd60e51b815260040161083290615b08565b6097546040516000916001600160a01b031690600080516020615f0b833981519152908390a3609780546001600160a01b0319169055565b609e5460009081906001600160a01b0384811691161415612f6f57609754849061271090612f3390600160e01b900461ffff1689615ccb565b612f3d9190615c88565b1015612f5b5760405162461bcd60e51b815260040161083290615aa2565b612f658487615d6c565b9150849050613015565b609f546001600160a01b0384811691161415612fdf57609754849061271090612fa390600160e01b900461ffff1688615ccb565b612fad9190615c88565b1015612fcb5760405162461bcd60e51b815260040161083290615aa2565b612fd58486615d6c565b9050859150613015565b60405162461bcd60e51b815260206004820152600b60248201526a3bb937b733903a37b5b2b760a91b6044820152606401610832565b94509492505050565b6040516001600160a01b03831660248201526044810182905261308190849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152614b49565b505050565b804710156130d65760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610832565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114613123576040519150601f19603f3d011682016040523d82523d6000602084013e613128565b606091505b50509050806130815760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c20726044820152791958da5c1a595b9d081b585e481a185d99481c995d995c9d195960321b6064820152608401610832565b60006131a98484846143df565b9050600082806131c957634e487b7160e01b600052601260045260246000fd5b84860911156108555760001981106131e057600080fd5b806131ea81615dea565b95945050505050565b60008060008360020b1261320a578260020b613217565b8260020b61321790615e3a565b9050613226620d89e719615e19565b60020b81111561325c5760405162461bcd60e51b81526020600482015260016024820152601560fa1b6044820152606401610832565b60006001821661327057600160801b613282565b6ffffcb933bd6fad37aa2d162d1a5940015b6001600160881b0316905060028216156132b75760806132b2826ffff97272373d413259a46990580e213a615ccb565b901c90505b60048216156132e15760806132dc826ffff2e50f5f656932ef12357cf3c7fdcc615ccb565b901c90505b600882161561330b576080613306826fffe5caca7e10e4e61c3624eaa0941cd0615ccb565b901c90505b6010821615613335576080613330826fffcb9843d60f6159c9db58835c926644615ccb565b901c90505b602082161561335f57608061335a826fff973b41fa98c081472e6896dfb254c0615ccb565b901c90505b6040821615613389576080613384826fff2ea16466c96a3843ec78b326b52861615ccb565b901c90505b60808216156133b35760806133ae826ffe5dee046a99a2a811c461f1969c3053615ccb565b901c90505b6101008216156133de5760806133d9826ffcbe86c7900a88aedcffc83b479aa3a4615ccb565b901c90505b610200821615613409576080613404826ff987a7253ac413176f2b074cf7815e54615ccb565b901c90505b61040082161561343457608061342f826ff3392b0822b70005940c7a398e4b70f3615ccb565b901c90505b61080082161561345f57608061345a826fe7159475a2c29b7443b29c7fa6e889d9615ccb565b901c90505b61100082161561348a576080613485826fd097f3bdfd2022b8845ad8f792aa5825615ccb565b901c90505b6120008216156134b55760806134b0826fa9f746462d870fdf8a65dc1f90e061e5615ccb565b901c90505b6140008216156134e05760806134db826f70d869a156d2a1b890bb3df62baf32f7615ccb565b901c90505b61800082161561350b576080613506826f31be135f97d08fd981231505542fcfa6615ccb565b901c90505b62010000821615613537576080613532826f09aa508b5b7a84e1c677de54f3e99bc9615ccb565b901c90505b6202000082161561356257608061355d826e5d6af8dedb81196699c329225ee604615ccb565b901c90505b6204000082161561358c576080613587826d2216e584f5fa1ea926041bedfe98615ccb565b901c90505b620800008216156135b45760806135af826b048a170391f7dc42444e8fa2615ccb565b901c90505b60008460020b13156135cf576135cc81600019615c88565b90505b6135dd600160201b82615e05565b156135e95760016135ec565b60005b6135fd9060ff16602083901c615c4a565b949350505050565b6000600160801b821061366a5760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20316044820152663238206269747360c81b6064820152608401610832565b5090565b600080836001600160a01b0316856001600160a01b0316111561368f579293925b846001600160a01b0316866001600160a01b0316116136ba576136b3858585614c1b565b9150613015565b836001600160a01b0316866001600160a01b031610156136f3576136df868585614c1b565b91506136ec858785614c85565b9050613015565b6136fe858585614c85565b905094509492505050565b6040516001600160a01b0380851660248301528316604482015260648101829052610e329085906323b872dd60e01b9060840161304a565b6000836001600160a01b0316856001600160a01b03161115613761579293925b846001600160a01b0316866001600160a01b03161161378c57613785858585614ccf565b90506131ea565b836001600160a01b0316866001600160a01b031610156137ee5760006137b3878686614ccf565b905060006137c2878986614d39565b9050806001600160801b0316826001600160801b0316106137e357806137e5565b815b925050506131ea565b6137f9858584614d39565b9695505050505050565b6001600160a01b0382166138595760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610832565b806035600082825461386b9190615c4a565b90915550506001600160a01b03821660009081526033602052604081208054839290613898908490615c4a565b90915550506040518181526001600160a01b03831690600090600080516020615f2b8339815191529060200160405180910390a35050565b60008060008060006138e06106fb565b915091508160001480156138f45750600081115b1561390b576139048689836143df565b92506139ba565b801580156139195750600082115b15613929576139048789846143df565b81158015613935575080155b1561395c5760405162461bcd60e51b81526020600482015260006024820152604401610832565b6000613969888a856143df565b90506000613978888b856143df565b905060008211801561398a5750600081115b6139a65760405162461bcd60e51b815260040161083290615b4a565b8082106139b357806139b5565b815b945050505b6139c583838a61319c565b94506139d283828a61319c565b9350505093509350939050565b6040805160028082526060820183526000926020830190803683375050609854825192935063ffffffff1691839150600090613a2b57634e487b7160e01b600052603260045260246000fd5b602002602001019063ffffffff16908163ffffffff1681525050600081600181518110613a6857634e487b7160e01b600052603260045260246000fd5b63ffffffff90921660209283029190910190910152609d5460405163883bdbfd60e01b81526000916001600160a01b03169063883bdbfd90613aae908590600401615923565b60006040518083038186803b158015613ac657600080fd5b505afa158015613ada573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052613b029190810190615325565b5090508051600214613b425760405162461bcd60e51b815260206004820152600960248201526830b93930bc903632b760b91b6044820152606401610832565b6098548151600091829163ffffffff90911660060b9084908390613b7657634e487b7160e01b600052603260045260246000fd5b602002602001015184600181518110613b9f57634e487b7160e01b600052603260045260246000fd5b60200260200101510360060b81613bc657634e487b7160e01b600052601260045260246000fd5b059050613bd58160020b6131f3565b6097549092506000915061271090613bf890600160f01b900461ffff1684615c9c565b613c029190615c62565b90508415613c4a57613c148183615d4c565b6001600160a01b0316866001600160a01b03161015613c455760405162461bcd60e51b815260040161083290615ac4565b613c85565b613c548183615c28565b6001600160a01b0316866001600160a01b03161115613c855760405162461bcd60e51b815260040161083290615ac4565b505050505050565b609b54609954609e546040516370a0823160e01b815260009392916001600160a01b0316906370a0823190613cc6903090600401615896565b60206040518083038186803b158015613cde57600080fd5b505afa158015613cf2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d16919061581d565b613d209190615d6c565b613d2a9190615d6c565b609c54609a54609f546040516370a0823160e01b81529394506000936001600160a01b03909116906370a0823190613d66903090600401615896565b60206040518083038186803b158015613d7e57600080fd5b505afa158015613d92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613db6919061581d565b613dc09190615d6c565b613dca9190615d6c565b6097549091506000908190613df590600160a01b8104600290810b91600160b81b9004900b8c6127d3565b935093505050613e058282612b60565b613e0f8282612c39565b6040519193509150600080516020615f4b83398151915290613e349084908490615ba1565b60405180910390a1613e468483615c4a565b9150613e528382615c4a565b609e549091506001600160a01b0386811691161415613ffd57609754869061271090613e8990600160d01b900461ffff1685615ccb565b613e939190615c88565b1015613eb15760405162461bcd60e51b815260040161083290615aa2565b609b54609954609e546040516370a0823160e01b8152899392916001600160a01b0316906370a0823190613ee9903090600401615896565b60206040518083038186803b158015613f0157600080fd5b505afa158015613f15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f39919061581d565b613f439190615d6c565b613f4d9190615d6c565b613f579190615d6c565b609c54609a54609f546040516370a0823160e01b8152939750919290916001600160a01b0316906370a0823190613f92903090600401615896565b60206040518083038186803b158015613faa57600080fd5b505afa158015613fbe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fe2919061581d565b613fec9190615d6c565b613ff69190615d6c565b9250614188565b609f546001600160a01b0386811691161415612fdf5760975486906127109061403190600160d01b900461ffff1684615ccb565b61403b9190615c88565b10156140595760405162461bcd60e51b815260040161083290615aa2565b609b54609954609e546040516370a0823160e01b81526001600160a01b03909116906370a082319061408f903090600401615896565b60206040518083038186803b1580156140a757600080fd5b505afa1580156140bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140df919061581d565b6140e99190615d6c565b6140f39190615d6c565b609c54609a54609f546040516370a0823160e01b815293975089936001600160a01b03909116906370a082319061412e903090600401615896565b60206040518083038186803b15801561414657600080fd5b505afa15801561415a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061417e919061581d565b613fe29190615d6c565b609754612e8790600160a01b8104600290810b91600160b81b9004900b86868d8d8d612cd4565b600054610100900460ff16806141c8575060005460ff16155b6141e45760405162461bcd60e51b815260040161083290615a54565b600054610100900460ff16158015614206576000805461ffff19166101011790555b61420e614d6f565b6142188383614dd9565b8015613081576000805461ff0019169055505050565b600054610100900460ff1680614247575060005460ff16155b6142635760405162461bcd60e51b815260040161083290615a54565b600054610100900460ff16158015614285576000805461ffff19166101011790555b61428d614e6e565b801561429f576000805461ff00191690555b50565b6001600160a01b0382166143025760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610832565b6001600160a01b038216600090815260336020526040902054818110156143765760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610832565b6143808282615d6c565b6001600160a01b038416600090815260336020526040812091909155603580548492906143ae908490615d6c565b90915550506040518281526000906001600160a01b03851690600080516020615f2b833981519152906020016122e9565b600080806000198587098587029250828110838203039150508060001415614419576000841161440e57600080fd5b508290049050610855565b80841161442557600080fd5b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b600080600080871561465b57609d60009054906101000a90046001600160a01b03166001600160a01b031663f30583996040518163ffffffff1660e01b815260040160206040518083038186803b1580156144e857600080fd5b505afa1580156144fc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614520919061581d565b609d5460975460405163f30dba9360e01b81529293506001600160a01b039091169163f30dba939161456091600160a01b90910460020b9060040161596d565b6101006040518083038186803b15801561457957600080fd5b505afa15801561458d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906145b1919061559d565b5050609d5460975460405163f30dba9360e01b8152959a506001600160a01b03909116965063f30dba9395506145fa94600160b81b90910460020b9350600401915061596d9050565b6101006040518083038186803b15801561461357600080fd5b505afa158015614627573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061464b919061559d565b5093975061481695505050505050565b609d60009054906101000a90046001600160a01b03166001600160a01b031663461413196040518163ffffffff1660e01b815260040160206040518083038186803b1580156146a957600080fd5b505afa1580156146bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906146e1919061581d565b609d5460975460405163f30dba9360e01b81529293506001600160a01b039091169163f30dba939161472191600160a01b90910460020b9060040161596d565b6101006040518083038186803b15801561473a57600080fd5b505afa15801561474e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614772919061559d565b5050609d5460975460405163f30dba9360e01b8152949a506001600160a01b03909116965063f30dba9395506147ba9450600160b81b900460020b92600401915061596d9050565b6101006040518083038186803b1580156147d357600080fd5b505afa1580156147e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061480b919061559d565b509297505050505050505b6000609760149054906101000a900460020b60020b8760020b1261483b575082614840565b508281035b6000609760179054906101000a900460020b60020b8860020b121561486657508261486b565b508282035b81830381900361488b6001600160801b0389168b8303600160801b6143df565b9b9a5050505050505050505050565b6000600160ff1b821061366a5760405162461bcd60e51b815260206004820152602860248201527f53616665436173743a2076616c756520646f65736e27742066697420696e2061604482015267371034b73a191a9b60c11b6064820152608401610832565b609d54604051630251596160e31b81523060048201528215156024820152604481018590526001600160a01b03848116606483015260a06084830152600060a4830181905292839283928392169063128acb089060c4016040805180830381600087803b15801561497057600080fd5b505af1158015614984573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906149a8919061546b565b91509150816149b68a61489a565b6149c09190615cea565b9350806149cc8961489a565b6149d69190615cea565b92506000609d60009054906101000a90046001600160a01b03166001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b158015614a2857600080fd5b505afa158015614a3c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614a6091906156db565b50505050505090506000614a8d82614a7a8f60020b6131f3565b614a868f60020b6131f3565b8989613741565b90506001600160801b03811615614b3957609d60009054906101000a90046001600160a01b03166001600160a01b0316633c8a7d8d308f8f856040518563ffffffff1660e01b8152600401614ae594939291906158aa565b6040805180830381600087803b158015614afe57600080fd5b505af1158015614b12573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614b36919061546b565b50505b5050505097509795505050505050565b6000614b9e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316614ede9092919063ffffffff16565b8051909150156130815780806020019051810190614bbc91906153e8565b6130815760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610832565b6000826001600160a01b0316846001600160a01b03161115614c3b579192915b6001600160a01b038416614c7b600160601b600160e01b03606085901b16614c638787615d4c565b6001600160a01b0316866001600160a01b03166143df565b6135fd9190615c88565b6000826001600160a01b0316846001600160a01b03161115614ca5579192915b6135fd6001600160801b038316614cbc8686615d4c565b6001600160a01b0316600160601b6143df565b6000826001600160a01b0316846001600160a01b03161115614cef579192915b6000614d12856001600160a01b0316856001600160a01b0316600160601b6143df565b90506131ea614d348483614d268989615d4c565b6001600160a01b03166143df565b614eed565b6000826001600160a01b0316846001600160a01b03161115614d59579192915b6135fd614d3483600160601b614d268888615d4c565b600054610100900460ff1680614d88575060005460ff16155b614da45760405162461bcd60e51b815260040161083290615a54565b600054610100900460ff1615801561428d576000805461ffff1916610101179055801561429f576000805461ff001916905550565b600054610100900460ff1680614df2575060005460ff16155b614e0e5760405162461bcd60e51b815260040161083290615a54565b600054610100900460ff16158015614e30576000805461ffff19166101011790555b8251614e43906036906020860190615069565b508151614e57906037906020850190615069565b508015613081576000805461ff0019169055505050565b600054610100900460ff1680614e87575060005460ff16155b614ea35760405162461bcd60e51b815260040161083290615a54565b600054610100900460ff16158015614ec5576000805461ffff19166101011790555b6001606555801561429f576000805461ff001916905550565b60606135fd8484600085614f08565b806001600160801b0381168114614f0357600080fd5b919050565b606082471015614f695760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610832565b843b614fb75760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610832565b600080866001600160a01b03168587604051614fd3919061587a565b60006040518083038185875af1925050503d8060008114615010576040519150601f19603f3d011682016040523d82523d6000602084013e615015565b606091505b5091509150615025828286615030565b979650505050505050565b6060831561503f575081610855565b82511561504f5782518084602001fd5b8160405162461bcd60e51b815260040161083291906159a9565b82805461507590615daf565b90600052602060002090601f01602090048101928261509757600085556150dd565b82601f106150b057805160ff19168380011785556150dd565b828001600101855582156150dd579182015b828111156150dd5782518255916020019190600101906150c2565b5061366a9291505b8082111561366a57600081556001016150e5565b600082601f830112615109578081fd5b8151602061511e61511983615bdf565b615baf565b80838252828201915082860187848660051b890101111561513d578586fd5b855b8581101561516457815161515281615e96565b8452928401929084019060010161513f565b5090979650505050505050565b60008083601f840112615182578182fd5b5081356001600160401b03811115615198578182fd5b6020830191508360208285010111156151b057600080fd5b9250929050565b8051600681900b8114614f0357600080fd5b600082601f8301126151d9578081fd5b81356001600160401b038111156151f2576151f2615e80565b615205601f8201601f1916602001615baf565b818152846020838601011115615219578283fd5b816020850160208301379081016020019190915292915050565b80516001600160801b0381168114614f0357600080fd5b60006020828403121561525b578081fd5b813561085581615e96565b600060208284031215615277578081fd5b815161085581615e96565b60008060408385031215615294578081fd5b823561529f81615e96565b915060208301356152af81615e96565b809150509250929050565b6000806000606084860312156152ce578081fd5b83356152d981615e96565b925060208401356152e981615e96565b929592945050506040919091013590565b6000806040838503121561530c578182fd5b823561531781615e96565b946020939093013593505050565b60008060408385031215615337578182fd5b82516001600160401b038082111561534d578384fd5b818501915085601f830112615360578384fd5b8151602061537061511983615bdf565b8083825282820191508286018a848660051b890101111561538f578889fd5b8896505b848710156153b8576153a4816151b7565b835260019690960195918301918301615393565b50918801519196509093505050808211156153d1578283fd5b506153de858286016150f9565b9150509250929050565b6000602082840312156153f9578081fd5b815161085581615eab565b600080600080600060a0868803121561541b578283fd5b853561542681615eb9565b9450602086013561543681615eb9565b9350604086013561544681615e96565b925060608601359150608086013561545d81615eab565b809150509295509295909350565b6000806040838503121561547d578182fd5b505080516020909101519092909150565b600080600080606085870312156154a3578182fd5b843593506020850135925060408501356001600160401b038111156154c6578283fd5b6154d287828801615171565b95989497509550505050565b600080600080600080600060e0888a0312156154f8578485fd5b87356001600160401b038082111561550e578687fd5b61551a8b838c016151c9565b985060208a013591508082111561552f578687fd5b5061553c8a828b016151c9565b965050604088013561554d81615e96565b9450606088013561555d81615ec8565b9350608088013561556d81615eb9565b925060a088013561557d81615eb9565b915060c088013561558d81615e96565b8091505092959891949750929550565b600080600080600080600080610100898b0312156155b9578182fd5b6155c289615233565b9750602089015180600f0b81146155d7578283fd5b60408a015160608b0151919850965094506155f460808a016151b7565b935060a089015161560481615e96565b60c08a015190935061561581615ed8565b60e08a015190925061562681615eab565b809150509295985092959890939650565b60008060408385031215615649578182fd5b61565283615233565b915061566060208401615233565b90509250929050565b600080600080600060a08688031215615680578283fd5b61568986615233565b945060208601519350604086015192506156a560608701615233565b91506156b360808701615233565b90509295509295909350565b6000602082840312156156d0578081fd5b813561085581615ec8565b600080600080600080600060e0888a0312156156f5578081fd5b875161570081615e96565b602089015190975061571181615eb9565b604089015190965061572281615ec8565b606089015190955061573381615ec8565b608089015190945061574481615ec8565b60a089015190935060ff8116811461575a578182fd5b60c089015190925061558d81615eab565b600080600080600060a08688031215615782578283fd5b853561578d81615e96565b94506020860135935060408601356157a481615eab565b925060608601359150608086013561545d81615e96565b600080600080600060a086880312156157d2578283fd5b85356157dd81615ec8565b945060208601356157ed81615ec8565b935060408601356157fd81615ec8565b9250606086013561580d81615ed8565b9150608086013561545d81615e96565b60006020828403121561582e578081fd5b5051919050565b60008060408385031215615847578182fd5b8235915060208301356152af81615e96565b6000806040838503121561586b578182fd5b50508035926020909101359150565b6000825161588c818460208701615d83565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b03949094168452600292830b6020850152910b60408301526001600160801b0316606082015260a06080820181905260009082015260c00190565b6001600160a01b039590951685526020850193909352604084019190915260608301526001600160801b0316608082015260a00190565b6020808252825182820181905260009190848201906040850190845b8181101561596157835163ffffffff168352928401929184019160010161593f565b50909695505050505050565b60029190910b815260200190565b600294850b81529290930b60208301526001600160801b039081166040830152909116606082015260800190565b60208152600082518060208401526159c8816040850160208701615d83565b601f01601f19169190910160400192915050565b60208082526017908201527647656c61746f666965643a204f6e6c792067656c61746f60481b604082015260600190565b6020808252600490820152636d42505360e01b604082015260600190565b6020808252600f908201526e31b0b6363130b1b59031b0b63632b960891b604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b602080825260089082015267686967682066656560c01b604082015260600190565b6020808252600d908201526c6869676820736c69707061676560981b604082015260600190565b60208082526003908201526242505360e81b604082015260600190565b60208082526022908201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206d616e616760408201526132b960f11b606082015260800190565b60208082526006908201526506d696e7420360d41b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b918252602082015260400190565b604051601f8201601f191681016001600160401b0381118282101715615bd757615bd7615e80565b604052919050565b60006001600160401b03821115615bf857615bf8615e80565b5060051b60200190565b600061ffff808316818516808303821115615c1f57615c1f615e54565b01949350505050565b60006001600160a01b03828116848216808303821115615c1f57615c1f615e54565b60008219821115615c5d57615c5d615e54565b500190565b60006001600160a01b0383811680615c7c57615c7c615e6a565b92169190910492915050565b600082615c9757615c97615e6a565b500490565b60006001600160a01b0382811684821681151582840482111615615cc257615cc2615e54565b02949350505050565b6000816000190483118215151615615ce557615ce5615e54565b500290565b60008083128015600160ff1b850184121615615d0857615d08615e54565b6001600160ff1b0384018313811615615d2357615d23615e54565b50500390565b600061ffff83811690831681811015615d4457615d44615e54565b039392505050565b60006001600160a01b0383811690831681811015615d4457615d44615e54565b600082821015615d7e57615d7e615e54565b500390565b60005b83811015615d9e578181015183820152602001615d86565b83811115610e325750506000910152565b600181811c90821680615dc357607f821691505b60208210811415615de457634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415615dfe57615dfe615e54565b5060010190565b600082615e1457615e14615e6a565b500690565b60008160020b627fffff19811415615e3357615e33615e54565b9003919050565b6000600160ff1b821415615e5057615e50615e54565b0390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461429f57600080fd5b801515811461429f57600080fd5b8060020b811461429f57600080fd5b61ffff8116811461429f57600080fd5b63ffffffff8116811461429f57600080fdfec749f9ae947d4734cf1569606a8a347391ae94a063478aa853aeff48ac5f99e88be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efc28ad1de9c0c32e5394ba60323e44d8d9536312236a47231772e448a3e49de42a2646970667358221220170d5c58be0bffd3988864d87cdc1b356071783a6ebf8d42552270cc9e4d530f64736f6c634300080400330000000000000000000000003caca7b48d0573d793d3b0279b5f0029180e83b6
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106102255760003560e01c8063065756db1461022a57806306fdde0314610246578063095ea7b31461025b5780630dfe16811461027e5780631322d9541461029e57806316f0115b146102b457806318160ddd146102c757806323b872dd146102cf57806324b8fd1b146102e257806331366be4146102f7578063313ce5671461031257806339509351146103215780633d8b30e11461033457806342fb9d4414610349578063481c6a751461035257806354fd4d501461035a578063672152bd1461037e57806370a08231146103a3578063715018a6146103cc578063727dd228146103d457806378ac6357146103f557806394bf804d1461040857806395d89b411461043f5780639894f21a1461044757806399fd808c146104755780639b1344ac14610488578063a457c2d71461049c578063a50b1fe7146104af578063a9059cbb146104c4578063b135c99f146104d7578063b536bd12146104ea578063b670ed7d146104f3578063be93dd5f14610506578063c345445914610519578063cc95353e14610522578063ccdf7a021461053c578063d21220a714610551578063d348799714610564578063d6e7ff3914610577578063dd62ed3e1461058c578063df28408a146105c5578063e25e15e3146105cd578063e4077894146105e0578063eff557a7146105f3578063f2fde38b1461061a578063fa461e331461062d578063fcd3533c14610640575b600080fd5b61023360995481565b6040519081526020015b60405180910390f35b61024e610653565b60405161023d91906159a9565b61026e6102693660046152fa565b6106e5565b604051901515815260200161023d565b609e54610291906001600160a01b031681565b60405161023d9190615896565b6102a66106fb565b60405161023d929190615ba1565b609d54610291906001600160a01b031681565b603554610233565b61026e6102dd3660046152ba565b6107a4565b6102f56102f0366004615404565b61085c565b005b6102ff606481565b60405161ffff909116815260200161023d565b6040516012815260200161023d565b61026e61032f3660046152fa565b610c41565b6097546102ff90600160e01b900461ffff1681565b610233609a5481565b610291610c78565b61024e604051806040016040528060058152602001640312e302e360dc1b81525081565b60985461038e9063ffffffff1681565b60405163ffffffff909116815260200161023d565b6102336103b136600461524a565b6001600160a01b031660009081526033602052604090205490565b6102f5610c87565b6097546103e890600160b81b900460020b81565b60405161023d919061596d565b6102f5610403366004615835565b610cdd565b61041b610416366004615835565b610e38565b6040805193845260208401929092526001600160801b03169082015260600161023d565b61024e61111e565b61045a610455366004615859565b61112d565b6040805193845260208401929092529082015260600161023d565b6102f56104833660046157bb565b61127f565b6097546103e890600160a01b900460020b81565b61026e6104aa3660046152fa565b61143f565b6097546102ff90600160d01b900461ffff1681565b61026e6104d23660046152fa565b6114da565b6102f56104e536600461576b565b6114e7565b610233609b5481565b6102a661050136600461524a565b6117a4565b6102f5610514366004615835565b61184b565b610233609c5481565b60985461029190600160301b90046001600160a01b031681565b6098546102ff90600160201b900461ffff1681565b609f54610291906001600160a01b031681565b6102f561057236600461548e565b611931565b6097546102ff90600160f01b900461ffff1681565b61023361059a366004615282565b6001600160a01b03918216600090815260346020908152604080832093909416825291909152205490565b610233611995565b6102f56105db3660046154de565b6119a4565b6102f56105ee3660046156bf565b611c41565b6102917f0000000000000000000000003caca7b48d0573d793d3b0279b5f0029180e83b681565b6102f561062836600461524a565b611d4e565b6102f561063b36600461548e565b611e2e565b61041b61064e366004615835565b611e98565b60606036805461066290615daf565b80601f016020809104026020016040519081016040528092919081815260200182805461068e90615daf565b80156106db5780601f106106b0576101008083540402835291602001916106db565b820191906000526020600020905b8154815290600101906020018083116106be57829003601f168201915b5050505050905090565b60006106f23384846121d1565b50600192915050565b600080600080609d60009054906101000a90046001600160a01b03166001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561074f57600080fd5b505afa158015610763573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061078791906156db565b50505050509150915061079a82826122f6565b9350935050509091565b60006107b18484846125a7565b6001600160a01b03841660009081526034602090815260408083203384529091529020548281101561083b5760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b61084f853361084a8685615d6c565b6121d1565b60019150505b9392505050565b33610865610c78565b6001600160a01b03161461088b5760405162461bcd60e51b815260040161083290615b08565b609d546000906001600160a01b031663514ea4bf6108a761276d565b6040518263ffffffff1660e01b81526004016108c591815260200190565b60a06040518083038186803b1580156108dd57600080fd5b505afa1580156108f1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109159190615669565b5050505090506000816001600160801b0316111561099f57609754600090819061095590600160a01b8104600290810b91600160b81b9004900b856127d3565b9350935050506109658282612b60565b61096f8282612c39565b6040519193509150600080516020615f4b833981519152906109949084908490615ba1565b60405180910390a150505b60978054600287810b62ffffff908116600160b81b0262ffffff60b81b19928b900b909116600160a01b029190911665ffffffffffff60a01b1990921691909117179055609b54609954609e546040516370a0823160e01b815260009392916001600160a01b0316906370a0823190610a1c903090600401615896565b60206040518083038186803b158015610a3457600080fd5b505afa158015610a48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a6c919061581d565b610a769190615d6c565b610a809190615d6c565b609c54609a54609f546040516370a0823160e01b81529394506000936001600160a01b03909116906370a0823190610abc903090600401615896565b60206040518083038186803b158015610ad457600080fd5b505afa158015610ae8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b0c919061581d565b610b169190615d6c565b610b209190615d6c565b9050610b31888884848a8a8a612cd4565b609d546000906001600160a01b031663514ea4bf610b4d61276d565b6040518263ffffffff1660e01b8152600401610b6b91815260200190565b60a06040518083038186803b158015610b8357600080fd5b505afa158015610b97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bbb9190615669565b5050505090506000816001600160801b031611610c0b5760405162461bcd60e51b815260206004820152600e60248201526d06e657720706f736974696f6e20360941b6044820152606401610832565b600080516020615eeb83398151915289898684604051610c2e949392919061597b565b60405180910390a1505050505050505050565b3360008181526034602090815260408083206001600160a01b038716845290915281205490916106f291859061084a908690615c4a565b6097546001600160a01b031690565b33610c90610c78565b6001600160a01b031614610cb65760405162461bcd60e51b815260040161083290615b08565b60988054600160201b600160d01b031916905560006099819055609a55610cdb612e93565b565b8181336001600160a01b037f0000000000000000000000003caca7b48d0573d793d3b0279b5f0029180e83b61614610d275760405162461bcd60e51b8152600401610832906159dc565b600080610d3a609954609a548888612efa565b60006099819055609a5590925090508115610d7457609854609e54610d74916001600160a01b0391821691600160301b909104168461301e565b8015610d9f57609854609f54610d9f916001600160a01b0391821691600160301b909104168361301e565b50506001600160a01b03811673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415610dfe57610df96001600160a01b037f0000000000000000000000003caca7b48d0573d793d3b0279b5f0029180e83b61683613086565b610e32565b610e326001600160a01b0382167f0000000000000000000000003caca7b48d0573d793d3b0279b5f0029180e83b68461301e565b50505050565b600080600060026065541415610e605760405162461bcd60e51b815260040161083290615b6a565b600260655584610e825760405162461bcd60e51b815260040161083290615b4a565b6000610e8d60355490565b90506000609d60009054906101000a90046001600160a01b03166001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b158015610edf57600080fd5b505afa158015610ef3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f1791906156db565b50505050505090506000821115610f5857600080610f336106fb565b91509150610f42828a8661319c565b9650610f4f818a8661319c565b95505050610fa5565b610f9f81610f77609760149054906101000a900460020b60020b6131f3565b609754610f9190600160b81b9004600290810b900b6131f3565b610f9a8b613605565b61366e565b90955093505b8415610fc357609e54610fc3906001600160a01b0316333088613709565b8315610fe157609f54610fe1906001600160a01b0316333087613709565b61102181611000609760149054906101000a900460020b60020b6131f3565b60975461101a90600160b81b9004600290810b900b6131f3565b8888613741565b609d54609754604051633c8a7d8d60e01b81529295506001600160a01b0390911691633c8a7d8d91611071913091600160a01b8104600290810b92600160b81b909204900b9089906004016158aa565b6040805180830381600087803b15801561108a57600080fd5b505af115801561109e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110c2919061546b565b50506110ce8688613803565b7f55801cfe493000b734571da1694b21e7f66b11e8ce9fdaa0524ecb59105e73e786888787876040516111059594939291906158ec565b60405180910390a1505060016065819055509250925092565b60606037805461066290615daf565b60008060008061113c60355490565b9050801561115b5761114f8187876138d0565b91955093509150611277565b609d5460408051633850c7bd60e01b815290516000926001600160a01b031691633850c7bd9160048083019260e0929190829003018186803b1580156111a057600080fd5b505afa1580156111b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111d891906156db565b5050505050509050600061122282611201609760149054906101000a900460020b60020b6131f3565b60975461121b90600160b81b9004600290810b900b6131f3565b8b8b613741565b9050806001600160801b0316935061126f8261124f609760149054906101000a900460020b60020b6131f3565b60975461126990600160b81b9004600290810b900b6131f3565b8461366e565b909650945050505b509250925092565b33611288610c78565b6001600160a01b0316146112ae5760405162461bcd60e51b815260040161083290615b08565b6127108461ffff1611156112d45760405162461bcd60e51b815260040161083290615aeb565b6127108561ffff1611156112fa5760405162461bcd60e51b815260040161083290615aeb565b6127108361ffff1611156113205760405162461bcd60e51b815260040161083290615aeb565b6040805161ffff8781168252868116602083015285168183015263ffffffff8416606082015290517f0b7615006627cf7664941bc288d4641731f895e102f95cb8690583ad7508faa89181900360800190a161ffff851615611397576097805461ffff60d01b1916600160d01b61ffff8816021790555b61ffff8416156113bc576097805461ffff60e01b1916600160e01b61ffff8716021790555b61ffff8316156113e257609780546001600160f01b0316600160f01b61ffff8616021790555b63ffffffff821615611404576098805463ffffffff191663ffffffff84161790555b6001600160a01b038116156114385760988054600160301b600160d01b031916600160301b6001600160a01b038416021790555b5050505050565b3360009081526034602090815260408083206001600160a01b0386168452909152812054828110156114c15760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610832565b6114d0338561084a8685615d6c565b5060019392505050565b60006106f23384846125a7565b8181336001600160a01b037f0000000000000000000000003caca7b48d0573d793d3b0279b5f0029180e83b616146115315760405162461bcd60e51b8152600401610832906159dc565b85156115415761154187866139df565b609d546000906001600160a01b031663514ea4bf61155d61276d565b6040518263ffffffff1660e01b815260040161157b91815260200190565b60a06040518083038186803b15801561159357600080fd5b505afa1580156115a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115cb9190615669565b5050505090506115df818989898989613c8d565b609d546000906001600160a01b031663514ea4bf6115fb61276d565b6040518263ffffffff1660e01b815260040161161991815260200190565b60a06040518083038186803b15801561163157600080fd5b505afa158015611645573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116699190615669565b505050509050816001600160801b0316816001600160801b031610156116c65760405162461bcd60e51b81526020600482015260126024820152716c697175696469747920646563726561736560701b6044820152606401610832565b609754604051600080516020615eeb8339815191529161170091600160a01b8204600290810b92600160b81b9004900b908690869061597b565b60405180910390a150506001600160a01b03811673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415611767576117626001600160a01b037f0000000000000000000000003caca7b48d0573d793d3b0279b5f0029180e83b61683613086565b61179b565b61179b6001600160a01b0382167f0000000000000000000000003caca7b48d0573d793d3b0279b5f0029180e83b68461301e565b50505050505050565b6000806000609d60009054906101000a90046001600160a01b03166001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b1580156117f757600080fd5b505afa15801561180b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061182f91906156db565b505050505091505061184184826122f6565b9250925050915091565b8181336001600160a01b037f0000000000000000000000003caca7b48d0573d793d3b0279b5f0029180e83b616146118955760405162461bcd60e51b8152600401610832906159dc565b6000806118a8609b54609c548888612efa565b6000609b819055609c55909250905081156118f457609e546118f4906001600160a01b03167f0000000000000000000000003caca7b48d0573d793d3b0279b5f0029180e83b68461301e565b8015610d9f57609f54610d9f906001600160a01b03167f0000000000000000000000003caca7b48d0573d793d3b0279b5f0029180e83b68361301e565b609d546001600160a01b0316331461195b5760405162461bcd60e51b815260040161083290615a2b565b831561197857609e54611978906001600160a01b0316338661301e565b8215610e3257609f54610e32906001600160a01b0316338561301e565b600061199f61276d565b905090565b600054610100900460ff16806119bd575060005460ff16155b6119d95760405162461bcd60e51b815260040161083290615a54565b600054610100900460ff161580156119fb576000805461ffff19166101011790555b611a086064612710615d29565b61ffff168561ffff161115611a2f5760405162461bcd60e51b815260040161083290615a0d565b609d80546001600160a01b0319166001600160a01b03881690811790915560408051630dfe168160e01b81529051630dfe168191600480820192602092909190829003018186803b158015611a8357600080fd5b505afa158015611a97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611abb9190615266565b609e80546001600160a01b0319166001600160a01b03928316179055609d546040805163d21220a760e01b81529051919092169163d21220a7916004808301926020929190829003018186803b158015611b1457600080fd5b505afa158015611b28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b4c9190615266565b609f80546001600160a01b03199081166001600160a01b0393841617909155609880546097805461012c65ffffffffffff19909316600160201b61ffff8d160263ffffffff19161792909217600160301b600160d01b031916600160301b95881695860217909255643e800c801960d31b600165ffffff00000160a01b03909116600160a01b60028a810b62ffffff908116929092029290921792909217600165ffffff00000160a01b031916600160b81b9189900b9290921602909216919091179091179055611c1d88886141af565b611c2561422e565b8015611c37576000805461ff00191690555b5050505050505050565b33611c4a610c78565b6001600160a01b031614611c705760405162461bcd60e51b815260040161083290615b08565b609854600160201b900461ffff1615611cb15760405162461bcd60e51b815260206004820152600360248201526266656560e81b6044820152606401610832565b60008161ffff16118015611cd95750611ccd6064612710615d29565b61ffff168161ffff1611155b611cf55760405162461bcd60e51b815260040161083290615a0d565b60405161ffff821681527f8a1ffb520c943072e654fc414750dbefad5b6d6311339d041901c4752782fad39060200160405180910390a16098805461ffff909216600160201b0261ffff60201b19909216919091179055565b33611d57610c78565b6001600160a01b031614611d7d5760405162461bcd60e51b815260040161083290615b08565b6001600160a01b038116611de45760405162461bcd60e51b815260206004820152602860248201527f4f776e61626c653a206e6577206d616e6167657220697320746865207a65726f604482015267206164647265737360c01b6064820152608401610832565b6097546040516001600160a01b03808416921690600080516020615f0b83398151915290600090a3609780546001600160a01b0319166001600160a01b0392909216919091179055565b609d546001600160a01b03163314611e585760405162461bcd60e51b815260040161083290615a2b565b6000841315611e7857609e54610df9906001600160a01b0316338661301e565b6000831315610e3257609f54610e32906001600160a01b0316338561301e565b600080600060026065541415611ec05760405162461bcd60e51b815260040161083290615b6a565b600260655584611efb5760405162461bcd60e51b815260206004820152600660248201526506275726e20360d41b6044820152606401610832565b6000611f0660355490565b609d549091506000906001600160a01b031663514ea4bf611f2561276d565b6040518263ffffffff1660e01b8152600401611f4391815260200190565b60a06040518083038186803b158015611f5b57600080fd5b505afa158015611f6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f939190615669565b505050509050611fa333886142a2565b6000611fb988836001600160801b0316856143df565b9050611fc481613605565b609754909450600090819081908190611ff390600160a01b8104600290810b91600160b81b9004900b8a6127d3565b93509350935093506120058282612b60565b61200f8282612c39565b6040519193509150600080516020615f4b833981519152906120349084908490615ba1565b60405180910390a1609b54609954609e546040516370a0823160e01b81526120ef93929188916001600160a01b03909116906370a082319061207a903090600401615896565b60206040518083038186803b15801561209257600080fd5b505afa1580156120a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120ca919061581d565b6120d49190615d6c565b6120de9190615d6c565b6120e89190615d6c565b8d896143df565b6120f99085615c4a565b609c54609a54609f546040516370a0823160e01b8152939d506121369387916001600160a01b0316906370a082319061207a903090600401615896565b6121409084615c4a565b9850891561215f57609e5461215f906001600160a01b03168c8c61301e565b881561217c57609f5461217c906001600160a01b03168c8b61301e565b7f7239dff1718b550db7f36cbf69c665cfeb56d0e96b4fb76a5cba712961b655098b8d8c8c8c6040516121b39594939291906158ec565b60405180910390a15050505050505060016065819055509250925092565b6001600160a01b0383166122335760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610832565b6001600160a01b0382166122945760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610832565b6001600160a01b0383811660008181526034602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b609d546000908190819081908190819081906001600160a01b031663514ea4bf61231e61276d565b6040518263ffffffff1660e01b815260040161233c91815260200190565b60a06040518083038186803b15801561235457600080fd5b505afa158015612368573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061238c9190615669565b945094509450945094506123d5896123b5609760149054906101000a900460020b60020b6131f3565b6097546123cf90600160b81b9004600290810b900b6131f3565b8861366e565b909750955060006001600160801b0383166123f36001878c8a61448e565b6123fd9190615c4a565b90506000826001600160801b03166124186000878d8b61448e565b6124229190615c4a565b905061242e8282612c39565b609b54609954609e546040516370a0823160e01b8152949650929450909290916001600160a01b0316906370a082319061246c903090600401615896565b60206040518083038186803b15801561248457600080fd5b505afa158015612498573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124bc919061581d565b6124c69085615c4a565b6124d09190615d6c565b6124da9190615d6c565b6124e4908a615c4a565b609c54609a54609f546040516370a0823160e01b8152939c50919290916001600160a01b0316906370a082319061251f903090600401615896565b60206040518083038186803b15801561253757600080fd5b505afa15801561254b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061256f919061581d565b6125799084615c4a565b6125839190615d6c565b61258d9190615d6c565b6125979089615c4a565b9750505050505050509250929050565b6001600160a01b03831661260b5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610832565b6001600160a01b03821661266d5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610832565b6001600160a01b038316600090815260336020526040902054818110156126e55760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610832565b6126ef8282615d6c565b6001600160a01b038086166000908152603360205260408082209390935590851681529081208054849290612725908490615c4a565b92505081905550826001600160a01b0316846001600160a01b0316600080516020615f2b8339815191528460405161275f91815260200190565b60405180910390a350505050565b6097546040516001600160601b03193060601b166020820152600160a01b8204600290810b810b60e890811b6034840152600160b81b909304810b900b90911b6037820152600090603a0160405160208183030381529060405280519060200120905090565b609e546040516370a0823160e01b815260009182918291829182916001600160a01b0316906370a082319061280c903090600401615896565b60206040518083038186803b15801561282457600080fd5b505afa158015612838573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061285c919061581d565b609f546040516370a0823160e01b81529192506000916001600160a01b03909116906370a0823190612892903090600401615896565b60206040518083038186803b1580156128aa57600080fd5b505afa1580156128be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128e2919061581d565b609d5460405163a34123a760e01b815260028c810b60048301528b900b60248201526001600160801b038a1660448201529192506001600160a01b03169063a34123a7906064016040805180830381600087803b15801561294257600080fd5b505af1158015612956573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061297a919061546b565b609d546040516309e3d67b60e31b815230600482015260028d810b60248301528c900b60448201526001600160801b036064820181905260848201529298509096506001600160a01b031690634f1eb3d89060a4016040805180830381600087803b1580156129e857600080fd5b505af11580156129fc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a209190615637565b5050609e546040516370a0823160e01b8152879184916001600160a01b03909116906370a0823190612a56903090600401615896565b60206040518083038186803b158015612a6e57600080fd5b505afa158015612a82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612aa6919061581d565b612ab09190615d6c565b612aba9190615d6c565b609f546040516370a0823160e01b8152919550869183916001600160a01b0316906370a0823190612aef903090600401615896565b60206040518083038186803b158015612b0757600080fd5b505afa158015612b1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b3f919061581d565b612b499190615d6c565b612b539190615d6c565b9250505093509350935093565b612710612b6e606484615ccb565b612b789190615c88565b609b6000828254612b899190615c4a565b909155506127109050612b9d606483615ccb565b612ba79190615c88565b609c6000828254612bb89190615c4a565b909155505060985461271090612bd990600160201b900461ffff1684615ccb565b612be39190615c88565b60996000828254612bf49190615c4a565b909155505060985461271090612c1590600160201b900461ffff1683615ccb565b612c1f9190615c88565b609a6000828254612c309190615c4a565b90915550505050565b6000806000612710609860049054906101000a900461ffff166064612c5e9190615c02565b612c6c9061ffff1687615ccb565b612c769190615c88565b60985490915060009061271090612c9990600160201b900461ffff166064615c02565b612ca79061ffff1687615ccb565b612cb19190615c88565b9050612cbd8287615d6c565b9350612cc98186615d6c565b925050509250929050565b609d5460408051633850c7bd60e01b815290516000926001600160a01b031691633850c7bd9160048083019260e0929190829003018186803b158015612d1957600080fd5b505afa158015612d2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d5191906156db565b50505050505090506000612d7e82612d6b8b60020b6131f3565b612d778b60020b6131f3565b8a8a613741565b90506001600160801b03811615612e3b57609d54604051633c8a7d8d60e01b815260009182916001600160a01b0390911690633c8a7d8d90612dca9030908f908f9089906004016158aa565b6040805180830381600087803b158015612de357600080fd5b505af1158015612df7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e1b919061546b565b9092509050612e2a828a615d6c565b9850612e368189615d6c565b975050505b6000612e6a6127108686612e4f5789612e51565b8a5b612e5b9190615ccb565b612e659190615c88565b61489a565b90506000811315612e8757612e848a8a8a8a858b8a614900565b50505b50505050505050505050565b33612e9c610c78565b6001600160a01b031614612ec25760405162461bcd60e51b815260040161083290615b08565b6097546040516000916001600160a01b031690600080516020615f0b833981519152908390a3609780546001600160a01b0319169055565b609e5460009081906001600160a01b0384811691161415612f6f57609754849061271090612f3390600160e01b900461ffff1689615ccb565b612f3d9190615c88565b1015612f5b5760405162461bcd60e51b815260040161083290615aa2565b612f658487615d6c565b9150849050613015565b609f546001600160a01b0384811691161415612fdf57609754849061271090612fa390600160e01b900461ffff1688615ccb565b612fad9190615c88565b1015612fcb5760405162461bcd60e51b815260040161083290615aa2565b612fd58486615d6c565b9050859150613015565b60405162461bcd60e51b815260206004820152600b60248201526a3bb937b733903a37b5b2b760a91b6044820152606401610832565b94509492505050565b6040516001600160a01b03831660248201526044810182905261308190849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152614b49565b505050565b804710156130d65760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610832565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114613123576040519150601f19603f3d011682016040523d82523d6000602084013e613128565b606091505b50509050806130815760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c20726044820152791958da5c1a595b9d081b585e481a185d99481c995d995c9d195960321b6064820152608401610832565b60006131a98484846143df565b9050600082806131c957634e487b7160e01b600052601260045260246000fd5b84860911156108555760001981106131e057600080fd5b806131ea81615dea565b95945050505050565b60008060008360020b1261320a578260020b613217565b8260020b61321790615e3a565b9050613226620d89e719615e19565b60020b81111561325c5760405162461bcd60e51b81526020600482015260016024820152601560fa1b6044820152606401610832565b60006001821661327057600160801b613282565b6ffffcb933bd6fad37aa2d162d1a5940015b6001600160881b0316905060028216156132b75760806132b2826ffff97272373d413259a46990580e213a615ccb565b901c90505b60048216156132e15760806132dc826ffff2e50f5f656932ef12357cf3c7fdcc615ccb565b901c90505b600882161561330b576080613306826fffe5caca7e10e4e61c3624eaa0941cd0615ccb565b901c90505b6010821615613335576080613330826fffcb9843d60f6159c9db58835c926644615ccb565b901c90505b602082161561335f57608061335a826fff973b41fa98c081472e6896dfb254c0615ccb565b901c90505b6040821615613389576080613384826fff2ea16466c96a3843ec78b326b52861615ccb565b901c90505b60808216156133b35760806133ae826ffe5dee046a99a2a811c461f1969c3053615ccb565b901c90505b6101008216156133de5760806133d9826ffcbe86c7900a88aedcffc83b479aa3a4615ccb565b901c90505b610200821615613409576080613404826ff987a7253ac413176f2b074cf7815e54615ccb565b901c90505b61040082161561343457608061342f826ff3392b0822b70005940c7a398e4b70f3615ccb565b901c90505b61080082161561345f57608061345a826fe7159475a2c29b7443b29c7fa6e889d9615ccb565b901c90505b61100082161561348a576080613485826fd097f3bdfd2022b8845ad8f792aa5825615ccb565b901c90505b6120008216156134b55760806134b0826fa9f746462d870fdf8a65dc1f90e061e5615ccb565b901c90505b6140008216156134e05760806134db826f70d869a156d2a1b890bb3df62baf32f7615ccb565b901c90505b61800082161561350b576080613506826f31be135f97d08fd981231505542fcfa6615ccb565b901c90505b62010000821615613537576080613532826f09aa508b5b7a84e1c677de54f3e99bc9615ccb565b901c90505b6202000082161561356257608061355d826e5d6af8dedb81196699c329225ee604615ccb565b901c90505b6204000082161561358c576080613587826d2216e584f5fa1ea926041bedfe98615ccb565b901c90505b620800008216156135b45760806135af826b048a170391f7dc42444e8fa2615ccb565b901c90505b60008460020b13156135cf576135cc81600019615c88565b90505b6135dd600160201b82615e05565b156135e95760016135ec565b60005b6135fd9060ff16602083901c615c4a565b949350505050565b6000600160801b821061366a5760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20316044820152663238206269747360c81b6064820152608401610832565b5090565b600080836001600160a01b0316856001600160a01b0316111561368f579293925b846001600160a01b0316866001600160a01b0316116136ba576136b3858585614c1b565b9150613015565b836001600160a01b0316866001600160a01b031610156136f3576136df868585614c1b565b91506136ec858785614c85565b9050613015565b6136fe858585614c85565b905094509492505050565b6040516001600160a01b0380851660248301528316604482015260648101829052610e329085906323b872dd60e01b9060840161304a565b6000836001600160a01b0316856001600160a01b03161115613761579293925b846001600160a01b0316866001600160a01b03161161378c57613785858585614ccf565b90506131ea565b836001600160a01b0316866001600160a01b031610156137ee5760006137b3878686614ccf565b905060006137c2878986614d39565b9050806001600160801b0316826001600160801b0316106137e357806137e5565b815b925050506131ea565b6137f9858584614d39565b9695505050505050565b6001600160a01b0382166138595760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610832565b806035600082825461386b9190615c4a565b90915550506001600160a01b03821660009081526033602052604081208054839290613898908490615c4a565b90915550506040518181526001600160a01b03831690600090600080516020615f2b8339815191529060200160405180910390a35050565b60008060008060006138e06106fb565b915091508160001480156138f45750600081115b1561390b576139048689836143df565b92506139ba565b801580156139195750600082115b15613929576139048789846143df565b81158015613935575080155b1561395c5760405162461bcd60e51b81526020600482015260006024820152604401610832565b6000613969888a856143df565b90506000613978888b856143df565b905060008211801561398a5750600081115b6139a65760405162461bcd60e51b815260040161083290615b4a565b8082106139b357806139b5565b815b945050505b6139c583838a61319c565b94506139d283828a61319c565b9350505093509350939050565b6040805160028082526060820183526000926020830190803683375050609854825192935063ffffffff1691839150600090613a2b57634e487b7160e01b600052603260045260246000fd5b602002602001019063ffffffff16908163ffffffff1681525050600081600181518110613a6857634e487b7160e01b600052603260045260246000fd5b63ffffffff90921660209283029190910190910152609d5460405163883bdbfd60e01b81526000916001600160a01b03169063883bdbfd90613aae908590600401615923565b60006040518083038186803b158015613ac657600080fd5b505afa158015613ada573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052613b029190810190615325565b5090508051600214613b425760405162461bcd60e51b815260206004820152600960248201526830b93930bc903632b760b91b6044820152606401610832565b6098548151600091829163ffffffff90911660060b9084908390613b7657634e487b7160e01b600052603260045260246000fd5b602002602001015184600181518110613b9f57634e487b7160e01b600052603260045260246000fd5b60200260200101510360060b81613bc657634e487b7160e01b600052601260045260246000fd5b059050613bd58160020b6131f3565b6097549092506000915061271090613bf890600160f01b900461ffff1684615c9c565b613c029190615c62565b90508415613c4a57613c148183615d4c565b6001600160a01b0316866001600160a01b03161015613c455760405162461bcd60e51b815260040161083290615ac4565b613c85565b613c548183615c28565b6001600160a01b0316866001600160a01b03161115613c855760405162461bcd60e51b815260040161083290615ac4565b505050505050565b609b54609954609e546040516370a0823160e01b815260009392916001600160a01b0316906370a0823190613cc6903090600401615896565b60206040518083038186803b158015613cde57600080fd5b505afa158015613cf2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d16919061581d565b613d209190615d6c565b613d2a9190615d6c565b609c54609a54609f546040516370a0823160e01b81529394506000936001600160a01b03909116906370a0823190613d66903090600401615896565b60206040518083038186803b158015613d7e57600080fd5b505afa158015613d92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613db6919061581d565b613dc09190615d6c565b613dca9190615d6c565b6097549091506000908190613df590600160a01b8104600290810b91600160b81b9004900b8c6127d3565b935093505050613e058282612b60565b613e0f8282612c39565b6040519193509150600080516020615f4b83398151915290613e349084908490615ba1565b60405180910390a1613e468483615c4a565b9150613e528382615c4a565b609e549091506001600160a01b0386811691161415613ffd57609754869061271090613e8990600160d01b900461ffff1685615ccb565b613e939190615c88565b1015613eb15760405162461bcd60e51b815260040161083290615aa2565b609b54609954609e546040516370a0823160e01b8152899392916001600160a01b0316906370a0823190613ee9903090600401615896565b60206040518083038186803b158015613f0157600080fd5b505afa158015613f15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f39919061581d565b613f439190615d6c565b613f4d9190615d6c565b613f579190615d6c565b609c54609a54609f546040516370a0823160e01b8152939750919290916001600160a01b0316906370a0823190613f92903090600401615896565b60206040518083038186803b158015613faa57600080fd5b505afa158015613fbe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fe2919061581d565b613fec9190615d6c565b613ff69190615d6c565b9250614188565b609f546001600160a01b0386811691161415612fdf5760975486906127109061403190600160d01b900461ffff1684615ccb565b61403b9190615c88565b10156140595760405162461bcd60e51b815260040161083290615aa2565b609b54609954609e546040516370a0823160e01b81526001600160a01b03909116906370a082319061408f903090600401615896565b60206040518083038186803b1580156140a757600080fd5b505afa1580156140bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140df919061581d565b6140e99190615d6c565b6140f39190615d6c565b609c54609a54609f546040516370a0823160e01b815293975089936001600160a01b03909116906370a082319061412e903090600401615896565b60206040518083038186803b15801561414657600080fd5b505afa15801561415a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061417e919061581d565b613fe29190615d6c565b609754612e8790600160a01b8104600290810b91600160b81b9004900b86868d8d8d612cd4565b600054610100900460ff16806141c8575060005460ff16155b6141e45760405162461bcd60e51b815260040161083290615a54565b600054610100900460ff16158015614206576000805461ffff19166101011790555b61420e614d6f565b6142188383614dd9565b8015613081576000805461ff0019169055505050565b600054610100900460ff1680614247575060005460ff16155b6142635760405162461bcd60e51b815260040161083290615a54565b600054610100900460ff16158015614285576000805461ffff19166101011790555b61428d614e6e565b801561429f576000805461ff00191690555b50565b6001600160a01b0382166143025760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610832565b6001600160a01b038216600090815260336020526040902054818110156143765760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610832565b6143808282615d6c565b6001600160a01b038416600090815260336020526040812091909155603580548492906143ae908490615d6c565b90915550506040518281526000906001600160a01b03851690600080516020615f2b833981519152906020016122e9565b600080806000198587098587029250828110838203039150508060001415614419576000841161440e57600080fd5b508290049050610855565b80841161442557600080fd5b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b600080600080871561465b57609d60009054906101000a90046001600160a01b03166001600160a01b031663f30583996040518163ffffffff1660e01b815260040160206040518083038186803b1580156144e857600080fd5b505afa1580156144fc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614520919061581d565b609d5460975460405163f30dba9360e01b81529293506001600160a01b039091169163f30dba939161456091600160a01b90910460020b9060040161596d565b6101006040518083038186803b15801561457957600080fd5b505afa15801561458d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906145b1919061559d565b5050609d5460975460405163f30dba9360e01b8152959a506001600160a01b03909116965063f30dba9395506145fa94600160b81b90910460020b9350600401915061596d9050565b6101006040518083038186803b15801561461357600080fd5b505afa158015614627573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061464b919061559d565b5093975061481695505050505050565b609d60009054906101000a90046001600160a01b03166001600160a01b031663461413196040518163ffffffff1660e01b815260040160206040518083038186803b1580156146a957600080fd5b505afa1580156146bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906146e1919061581d565b609d5460975460405163f30dba9360e01b81529293506001600160a01b039091169163f30dba939161472191600160a01b90910460020b9060040161596d565b6101006040518083038186803b15801561473a57600080fd5b505afa15801561474e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614772919061559d565b5050609d5460975460405163f30dba9360e01b8152949a506001600160a01b03909116965063f30dba9395506147ba9450600160b81b900460020b92600401915061596d9050565b6101006040518083038186803b1580156147d357600080fd5b505afa1580156147e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061480b919061559d565b509297505050505050505b6000609760149054906101000a900460020b60020b8760020b1261483b575082614840565b508281035b6000609760179054906101000a900460020b60020b8860020b121561486657508261486b565b508282035b81830381900361488b6001600160801b0389168b8303600160801b6143df565b9b9a5050505050505050505050565b6000600160ff1b821061366a5760405162461bcd60e51b815260206004820152602860248201527f53616665436173743a2076616c756520646f65736e27742066697420696e2061604482015267371034b73a191a9b60c11b6064820152608401610832565b609d54604051630251596160e31b81523060048201528215156024820152604481018590526001600160a01b03848116606483015260a06084830152600060a4830181905292839283928392169063128acb089060c4016040805180830381600087803b15801561497057600080fd5b505af1158015614984573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906149a8919061546b565b91509150816149b68a61489a565b6149c09190615cea565b9350806149cc8961489a565b6149d69190615cea565b92506000609d60009054906101000a90046001600160a01b03166001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b158015614a2857600080fd5b505afa158015614a3c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614a6091906156db565b50505050505090506000614a8d82614a7a8f60020b6131f3565b614a868f60020b6131f3565b8989613741565b90506001600160801b03811615614b3957609d60009054906101000a90046001600160a01b03166001600160a01b0316633c8a7d8d308f8f856040518563ffffffff1660e01b8152600401614ae594939291906158aa565b6040805180830381600087803b158015614afe57600080fd5b505af1158015614b12573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614b36919061546b565b50505b5050505097509795505050505050565b6000614b9e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316614ede9092919063ffffffff16565b8051909150156130815780806020019051810190614bbc91906153e8565b6130815760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610832565b6000826001600160a01b0316846001600160a01b03161115614c3b579192915b6001600160a01b038416614c7b600160601b600160e01b03606085901b16614c638787615d4c565b6001600160a01b0316866001600160a01b03166143df565b6135fd9190615c88565b6000826001600160a01b0316846001600160a01b03161115614ca5579192915b6135fd6001600160801b038316614cbc8686615d4c565b6001600160a01b0316600160601b6143df565b6000826001600160a01b0316846001600160a01b03161115614cef579192915b6000614d12856001600160a01b0316856001600160a01b0316600160601b6143df565b90506131ea614d348483614d268989615d4c565b6001600160a01b03166143df565b614eed565b6000826001600160a01b0316846001600160a01b03161115614d59579192915b6135fd614d3483600160601b614d268888615d4c565b600054610100900460ff1680614d88575060005460ff16155b614da45760405162461bcd60e51b815260040161083290615a54565b600054610100900460ff1615801561428d576000805461ffff1916610101179055801561429f576000805461ff001916905550565b600054610100900460ff1680614df2575060005460ff16155b614e0e5760405162461bcd60e51b815260040161083290615a54565b600054610100900460ff16158015614e30576000805461ffff19166101011790555b8251614e43906036906020860190615069565b508151614e57906037906020850190615069565b508015613081576000805461ff0019169055505050565b600054610100900460ff1680614e87575060005460ff16155b614ea35760405162461bcd60e51b815260040161083290615a54565b600054610100900460ff16158015614ec5576000805461ffff19166101011790555b6001606555801561429f576000805461ff001916905550565b60606135fd8484600085614f08565b806001600160801b0381168114614f0357600080fd5b919050565b606082471015614f695760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610832565b843b614fb75760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610832565b600080866001600160a01b03168587604051614fd3919061587a565b60006040518083038185875af1925050503d8060008114615010576040519150601f19603f3d011682016040523d82523d6000602084013e615015565b606091505b5091509150615025828286615030565b979650505050505050565b6060831561503f575081610855565b82511561504f5782518084602001fd5b8160405162461bcd60e51b815260040161083291906159a9565b82805461507590615daf565b90600052602060002090601f01602090048101928261509757600085556150dd565b82601f106150b057805160ff19168380011785556150dd565b828001600101855582156150dd579182015b828111156150dd5782518255916020019190600101906150c2565b5061366a9291505b8082111561366a57600081556001016150e5565b600082601f830112615109578081fd5b8151602061511e61511983615bdf565b615baf565b80838252828201915082860187848660051b890101111561513d578586fd5b855b8581101561516457815161515281615e96565b8452928401929084019060010161513f565b5090979650505050505050565b60008083601f840112615182578182fd5b5081356001600160401b03811115615198578182fd5b6020830191508360208285010111156151b057600080fd5b9250929050565b8051600681900b8114614f0357600080fd5b600082601f8301126151d9578081fd5b81356001600160401b038111156151f2576151f2615e80565b615205601f8201601f1916602001615baf565b818152846020838601011115615219578283fd5b816020850160208301379081016020019190915292915050565b80516001600160801b0381168114614f0357600080fd5b60006020828403121561525b578081fd5b813561085581615e96565b600060208284031215615277578081fd5b815161085581615e96565b60008060408385031215615294578081fd5b823561529f81615e96565b915060208301356152af81615e96565b809150509250929050565b6000806000606084860312156152ce578081fd5b83356152d981615e96565b925060208401356152e981615e96565b929592945050506040919091013590565b6000806040838503121561530c578182fd5b823561531781615e96565b946020939093013593505050565b60008060408385031215615337578182fd5b82516001600160401b038082111561534d578384fd5b818501915085601f830112615360578384fd5b8151602061537061511983615bdf565b8083825282820191508286018a848660051b890101111561538f578889fd5b8896505b848710156153b8576153a4816151b7565b835260019690960195918301918301615393565b50918801519196509093505050808211156153d1578283fd5b506153de858286016150f9565b9150509250929050565b6000602082840312156153f9578081fd5b815161085581615eab565b600080600080600060a0868803121561541b578283fd5b853561542681615eb9565b9450602086013561543681615eb9565b9350604086013561544681615e96565b925060608601359150608086013561545d81615eab565b809150509295509295909350565b6000806040838503121561547d578182fd5b505080516020909101519092909150565b600080600080606085870312156154a3578182fd5b843593506020850135925060408501356001600160401b038111156154c6578283fd5b6154d287828801615171565b95989497509550505050565b600080600080600080600060e0888a0312156154f8578485fd5b87356001600160401b038082111561550e578687fd5b61551a8b838c016151c9565b985060208a013591508082111561552f578687fd5b5061553c8a828b016151c9565b965050604088013561554d81615e96565b9450606088013561555d81615ec8565b9350608088013561556d81615eb9565b925060a088013561557d81615eb9565b915060c088013561558d81615e96565b8091505092959891949750929550565b600080600080600080600080610100898b0312156155b9578182fd5b6155c289615233565b9750602089015180600f0b81146155d7578283fd5b60408a015160608b0151919850965094506155f460808a016151b7565b935060a089015161560481615e96565b60c08a015190935061561581615ed8565b60e08a015190925061562681615eab565b809150509295985092959890939650565b60008060408385031215615649578182fd5b61565283615233565b915061566060208401615233565b90509250929050565b600080600080600060a08688031215615680578283fd5b61568986615233565b945060208601519350604086015192506156a560608701615233565b91506156b360808701615233565b90509295509295909350565b6000602082840312156156d0578081fd5b813561085581615ec8565b600080600080600080600060e0888a0312156156f5578081fd5b875161570081615e96565b602089015190975061571181615eb9565b604089015190965061572281615ec8565b606089015190955061573381615ec8565b608089015190945061574481615ec8565b60a089015190935060ff8116811461575a578182fd5b60c089015190925061558d81615eab565b600080600080600060a08688031215615782578283fd5b853561578d81615e96565b94506020860135935060408601356157a481615eab565b925060608601359150608086013561545d81615e96565b600080600080600060a086880312156157d2578283fd5b85356157dd81615ec8565b945060208601356157ed81615ec8565b935060408601356157fd81615ec8565b9250606086013561580d81615ed8565b9150608086013561545d81615e96565b60006020828403121561582e578081fd5b5051919050565b60008060408385031215615847578182fd5b8235915060208301356152af81615e96565b6000806040838503121561586b578182fd5b50508035926020909101359150565b6000825161588c818460208701615d83565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b03949094168452600292830b6020850152910b60408301526001600160801b0316606082015260a06080820181905260009082015260c00190565b6001600160a01b039590951685526020850193909352604084019190915260608301526001600160801b0316608082015260a00190565b6020808252825182820181905260009190848201906040850190845b8181101561596157835163ffffffff168352928401929184019160010161593f565b50909695505050505050565b60029190910b815260200190565b600294850b81529290930b60208301526001600160801b039081166040830152909116606082015260800190565b60208152600082518060208401526159c8816040850160208701615d83565b601f01601f19169190910160400192915050565b60208082526017908201527647656c61746f666965643a204f6e6c792067656c61746f60481b604082015260600190565b6020808252600490820152636d42505360e01b604082015260600190565b6020808252600f908201526e31b0b6363130b1b59031b0b63632b960891b604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b602080825260089082015267686967682066656560c01b604082015260600190565b6020808252600d908201526c6869676820736c69707061676560981b604082015260600190565b60208082526003908201526242505360e81b604082015260600190565b60208082526022908201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206d616e616760408201526132b960f11b606082015260800190565b60208082526006908201526506d696e7420360d41b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b918252602082015260400190565b604051601f8201601f191681016001600160401b0381118282101715615bd757615bd7615e80565b604052919050565b60006001600160401b03821115615bf857615bf8615e80565b5060051b60200190565b600061ffff808316818516808303821115615c1f57615c1f615e54565b01949350505050565b60006001600160a01b03828116848216808303821115615c1f57615c1f615e54565b60008219821115615c5d57615c5d615e54565b500190565b60006001600160a01b0383811680615c7c57615c7c615e6a565b92169190910492915050565b600082615c9757615c97615e6a565b500490565b60006001600160a01b0382811684821681151582840482111615615cc257615cc2615e54565b02949350505050565b6000816000190483118215151615615ce557615ce5615e54565b500290565b60008083128015600160ff1b850184121615615d0857615d08615e54565b6001600160ff1b0384018313811615615d2357615d23615e54565b50500390565b600061ffff83811690831681811015615d4457615d44615e54565b039392505050565b60006001600160a01b0383811690831681811015615d4457615d44615e54565b600082821015615d7e57615d7e615e54565b500390565b60005b83811015615d9e578181015183820152602001615d86565b83811115610e325750506000910152565b600181811c90821680615dc357607f821691505b60208210811415615de457634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415615dfe57615dfe615e54565b5060010190565b600082615e1457615e14615e6a565b500690565b60008160020b627fffff19811415615e3357615e33615e54565b9003919050565b6000600160ff1b821415615e5057615e50615e54565b0390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461429f57600080fd5b801515811461429f57600080fd5b8060020b811461429f57600080fd5b61ffff8116811461429f57600080fd5b63ffffffff8116811461429f57600080fdfec749f9ae947d4734cf1569606a8a347391ae94a063478aa853aeff48ac5f99e88be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efc28ad1de9c0c32e5394ba60323e44d8d9536312236a47231772e448a3e49de42a2646970667358221220170d5c58be0bffd3988864d87cdc1b356071783a6ebf8d42552270cc9e4d530f64736f6c63430008040033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000003caca7b48d0573d793d3b0279b5f0029180e83b6
-----Decoded View---------------
Arg [0] : _gelato (address): 0x3CACa7b48D0573D793d3b0279b5F0029180E83b6
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000003caca7b48d0573d793d3b0279b5f0029180e83b6
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ 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.