Overview
S Balance
0 S
S Value
-More Info
Private Name Tags
ContractCreator
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
StrategyPassiveManagerUniswap
Compiler Version
v0.8.23+commit.f704f362
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.23; import {IERC20Metadata} from "@openzeppelin-4/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import {SafeERC20} from "@openzeppelin-4/contracts/token/ERC20/utils/SafeERC20.sol"; import {SignedMath} from "@openzeppelin-4/contracts/utils/math/SignedMath.sol"; import {StratFeeManagerInitializable, IFeeConfig} from "../StratFeeManagerInitializable.sol"; import {IUniswapV3Pool} from "../../interfaces/uniswap/IUniswapV3Pool.sol"; import {LiquidityAmounts} from "../../utils/LiquidityAmounts.sol"; import {TickMath} from "../../utils/TickMath.sol"; import {TickUtils, FullMath} from "../../utils/TickUtils.sol"; import {UniV3Utils} from "../../utils/UniV3Utils.sol"; import {IBeefyVaultConcLiq} from "../../interfaces/beefy/IBeefyVaultConcLiq.sol"; import {IStrategyFactory} from "../../interfaces/beefy/IStrategyFactory.sol"; import {IStrategyConcLiq} from "../../interfaces/beefy/IStrategyConcLiq.sol"; import {IStrategyUniswapV3} from "../../interfaces/beefy/IStrategyUniswapV3.sol"; import {IBeefySwapper} from "../../interfaces/beefy/IBeefySwapper.sol"; import {IQuoter} from "../../interfaces/uniswap/IQuoter.sol"; /// @title Beefy Passive Position Manager. Version: Uniswap /// @author weso, Beefy /// @notice This is a contract for managing a passive concentrated liquidity position on Uniswap V3. contract StrategyPassiveManagerUniswap is StratFeeManagerInitializable, IStrategyConcLiq, IStrategyUniswapV3 { using SafeERC20 for IERC20Metadata; using TickMath for int24; /// @notice The precision for pricing. uint256 private constant PRECISION = 1e36; uint256 private constant SQRT_PRECISION = 1e18; /// @notice The max and min ticks univ3 allows. int56 private constant MIN_TICK = -887272; int56 private constant MAX_TICK = 887272; /// @notice The address of the Uniswap V3 pool. address public pool; /// @notice The address of the quoter. address public quoter; /// @notice The address of the first token in the liquidity pool. address public lpToken0; /// @notice The address of the second token in the liquidity pool. address public lpToken1; /// @notice The fees that are collected in the strategy but have not yet completed the harvest process. uint256 public fees0; uint256 public fees1; /// @notice The path to swap the first token to the native token for fee harvesting. bytes public lpToken0ToNativePath; /// @notice The path to swap the second token to the native token for fee harvesting. bytes public lpToken1ToNativePath; /// @notice The struct to store our tick positioning. struct Position { int24 tickLower; int24 tickUpper; } /// @notice The main position of the strategy. /// @dev this will always be a 50/50 position that will be equal to position width * tickSpacing on each side. Position public positionMain; /// @notice The alternative position of the strategy. /// @dev this will always be a single sided (limit order) position that will start closest to current tick and continue to width * tickSpacing. /// This will always be in the token that has the most value after we fill our main position. Position public positionAlt; /// @notice The width of the position, thats a multiplier for tick spacing to find our range. int24 public positionWidth; /// @notice the max tick deviations we will allow for deposits/harvests. int56 public maxTickDeviation; /// @notice The twap interval seconds we use for the twap check. uint32 public twapInterval; /// @notice Bool switch to prevent reentrancy on the mint callback. bool private minting; /// @notice Initializes the ticks on first deposit. bool private initTicks; // Errors error NotAuthorized(); error NotPool(); error InvalidEntry(); error NotVault(); error InvalidInput(); error InvalidOutput(); error NotCalm(); error TooMuchSlippage(); error InvalidTicks(); // Events event TVL(uint256 bal0, uint256 bal1); event Harvest(uint256 fee0, uint256 fee1); event SetPositionWidth(int24 oldWidth, int24 width); event SetDeviation(int56 maxTickDeviation); event SetTwapInterval(uint32 oldInterval, uint32 interval); event SetLpToken0ToNativePath(bytes path); event SetLpToken1ToNativePath(bytes path); event SetQuoter(address quoter); event ChargedFees(uint256 callFeeAmount, uint256 beefyFeeAmount, uint256 strategistFeeAmount); event ClaimedFees(uint256 feeMain0, uint256 feeMain1, uint256 feeAlt0, uint256 feeAlt1); /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } /// @notice Modifier to only allow deposit/harvest actions when current price is within a certain deviation of twap. modifier onlyCalmPeriods() { _onlyCalmPeriods(); _; } modifier onlyRebalancers() { if (!IStrategyFactory(factory).rebalancers(msg.sender)) revert NotAuthorized(); _; } /// @notice function to only allow deposit/harvest actions when current price is within a certain deviation of twap. function _onlyCalmPeriods() private view { if (!isCalm()) revert NotCalm(); } /// @notice function to only allow deposit/harvest actions when current price is within a certain deviation of twap. function isCalm() public view returns (bool) { int24 tick = currentTick(); int56 twapTick = twap(); int56 minCalmTick = int56(SignedMath.max(twapTick - maxTickDeviation, MIN_TICK)); int56 maxCalmTick = int56(SignedMath.min(twapTick + maxTickDeviation, MAX_TICK)); // Calculate if greater than deviation % from twap and revert if it is. if(minCalmTick > tick || maxCalmTick < tick) return false; else return true; } /** * @notice Initializes the strategy and the inherited strat fee manager. * @dev Make sure cardinality is set appropriately for the twap. * @param _pool The underlying Uniswap V3 pool. * @param _quoter The address of the quoter. * @param _positionWidth The multiplier for tick spacing to find our range. * @param _lpToken0ToNativePath The bytes path for swapping the first token to the native token. * @param _lpToken1ToNativePath The bytes path for swapping the second token to the native token. * @param _commonAddresses The common addresses needed for the strat fee manager. */ function initialize ( address _pool, address _quoter, int24 _positionWidth, bytes calldata _lpToken0ToNativePath, bytes calldata _lpToken1ToNativePath, CommonAddresses calldata _commonAddresses ) external initializer { __StratFeeManager_init(_commonAddresses); pool = _pool; quoter = _quoter; lpToken0 = IUniswapV3Pool(_pool).token0(); lpToken1 = IUniswapV3Pool(_pool).token1(); // Our width multiplier. The tick distance of each side will be width * tickSpacing. positionWidth = _positionWidth; // Set up our paths for swapping to native. setLpToken0ToNativePath(_lpToken0ToNativePath); setLpToken1ToNativePath(_lpToken1ToNativePath); // Set the twap interval to 120 seconds. twapInterval = 120; _giveAllowances(); } /// @notice Only allows the vault to call a function. function _onlyVault () private view { if (msg.sender != vault) revert NotVault(); } /// @notice Called during deposit and withdraw to remove liquidity and harvest fees for accounting purposes. function beforeAction() external { _onlyVault(); _claimEarnings(); _removeLiquidity(); } /// @notice Called during deposit to add all liquidity back to their positions. function deposit() external onlyCalmPeriods { _onlyVault(); // Add all liquidity if (!initTicks) { _setTicks(); initTicks = true; } _addLiquidity(); (uint256 bal0, uint256 bal1) = balances(); // TVL Balances after deposit emit TVL(bal0, bal1); } /** * @notice Withdraws the specified amount of tokens from the strategy as calculated by the vault. * @param _amount0 The amount of token0 to withdraw. * @param _amount1 The amount of token1 to withdraw. */ function withdraw(uint256 _amount0, uint256 _amount1) external { _onlyVault(); // Liquidity has already been removed in beforeAction() so this is just a simple withdraw. if (_amount0 > 0) IERC20Metadata(lpToken0).safeTransfer(vault, _amount0); if (_amount1 > 0) IERC20Metadata(lpToken1).safeTransfer(vault, _amount1); // After we take what is needed we add it all back to our positions. if (!_isPaused()) _addLiquidity(); (uint256 bal0, uint256 bal1) = balances(); // TVL Balances after withdraw emit TVL(bal0, bal1); } /// @notice Adds liquidity to the main and alternative positions called on deposit, harvest and withdraw. function _addLiquidity() private { _whenStrategyNotPaused(); (uint256 bal0, uint256 bal1) = balancesOfThis(); // Then we fetch how much liquidity we get for adding at the main position ticks with our token balances. uint160 sqrtprice = sqrtPrice(); uint128 liquidity = LiquidityAmounts.getLiquidityForAmounts( sqrtprice, TickMath.getSqrtRatioAtTick(positionMain.tickLower), TickMath.getSqrtRatioAtTick(positionMain.tickUpper), bal0, bal1 ); bool amountsOk = _checkAmounts(liquidity, positionMain.tickLower, positionMain.tickUpper); // Flip minting to true and call the pool to mint the liquidity. if (liquidity > 0 && amountsOk) { minting = true; IUniswapV3Pool(pool).mint(address(this), positionMain.tickLower, positionMain.tickUpper, liquidity, "Beefy Main"); } else _onlyCalmPeriods(); (bal0, bal1) = balancesOfThis(); // Fetch how much liquidity we get for adding at the alternative position ticks with our token balances. liquidity = LiquidityAmounts.getLiquidityForAmounts( sqrtprice, TickMath.getSqrtRatioAtTick(positionAlt.tickLower), TickMath.getSqrtRatioAtTick(positionAlt.tickUpper), bal0, bal1 ); // Flip minting to true and call the pool to mint the liquidity. if (liquidity > 0) { minting = true; IUniswapV3Pool(pool).mint(address(this), positionAlt.tickLower, positionAlt.tickUpper, liquidity, "Beefy Alt"); } } /// @notice Removes liquidity from the main and alternative positions, called on deposit, withdraw and harvest. function _removeLiquidity() private { // First we fetch our position keys in order to get our liquidity balances from the pool. (bytes32 keyMain, bytes32 keyAlt) = getKeys(); // Fetch the liquidity balances from the pool. (uint128 liquidity,,,,) = IUniswapV3Pool(pool).positions(keyMain); (uint128 liquidityAlt,,,,) = IUniswapV3Pool(pool).positions(keyAlt); // If we have liquidity in the positions we remove it and collect our tokens. if (liquidity > 0) { IUniswapV3Pool(pool).burn(positionMain.tickLower, positionMain.tickUpper, liquidity); IUniswapV3Pool(pool).collect(address(this), positionMain.tickLower, positionMain.tickUpper, type(uint128).max, type(uint128).max); } if (liquidityAlt > 0) { IUniswapV3Pool(pool).burn(positionAlt.tickLower, positionAlt.tickUpper, liquidityAlt); IUniswapV3Pool(pool).collect(address(this), positionAlt.tickLower, positionAlt.tickUpper, type(uint128).max, type(uint128).max); } } /** * @notice Checks if the amounts are ok to add liquidity. * @param _liquidity The liquidity to add. * @param _tickLower The lower tick of the position. * @param _tickUpper The upper tick of the position. * @return bool True if the amounts are ok, false if not. */ function _checkAmounts(uint128 _liquidity, int24 _tickLower, int24 _tickUpper) private view returns (bool) { (uint256 amount0, uint256 amount1) = LiquidityAmounts.getAmountsForLiquidity( sqrtPrice(), TickMath.getSqrtRatioAtTick(_tickLower), TickMath.getSqrtRatioAtTick(_tickUpper), _liquidity ); if (amount0 == 0 || amount1 == 0) return false; else return true; } /// @notice Harvest call to claim fees from pool, charge fees for Beefy, then readjust our positions. /// @param _callFeeRecipient The address to send the call fee to. function harvest(address _callFeeRecipient) external { _harvest(_callFeeRecipient); } /// @notice Harvest call to claim fees from the pool, charge fees for Beefy, then readjust our positions. /// @dev Call fee goes to the tx.origin. function harvest() external { _harvest(tx.origin); } /// @notice Internal function to claim fees from the pool, charge fees for Beefy, then readjust our positions. function _harvest (address _callFeeRecipient) private { // Claim fees from the pool and collect them. _claimEarnings(); _removeLiquidity(); // Charge fees for Beefy and send them to the appropriate addresses, charge fees to accrued state fee amounts. (uint256 fee0, uint256 fee1) = _chargeFees(_callFeeRecipient, fees0, fees1); _addLiquidity(); // Reset state fees to 0. fees0 = 0; fees1 = 0; // We stream the rewards over time to the LP. (uint256 currentLock0, uint256 currentLock1) = lockedProfit(); totalLocked0 = fee0 + currentLock0; totalLocked1 = fee1 + currentLock1; // Log the last time we claimed fees. lastHarvest = block.timestamp; // Log the fees post Beefy fees. emit Harvest(fee0, fee1); } /// @notice Function called to moveTicks of the position function moveTicks() external onlyCalmPeriods onlyRebalancers { _claimEarnings(); _removeLiquidity(); _setTicks(); _addLiquidity(); (uint256 bal0, uint256 bal1) = balances(); emit TVL(bal0, bal1); } /// @notice Claims fees from the pool and collects them. function claimEarnings() external returns (uint256 fee0, uint256 fee1, uint256 feeAlt0, uint256 feeAlt1) { (fee0, fee1, feeAlt0, feeAlt1) = _claimEarnings(); } /// @notice Internal function to claim fees from the pool and collect them. function _claimEarnings() private returns (uint256 fee0, uint256 fee1, uint256 feeAlt0, uint256 feeAlt1) { // Claim fees (bytes32 keyMain, bytes32 keyAlt) = getKeys(); (uint128 liquidity,,,,) = IUniswapV3Pool(pool).positions(keyMain); (uint128 liquidityAlt,,,,) = IUniswapV3Pool(pool).positions(keyAlt); // Burn 0 liquidity to make fees available to claim. if (liquidity > 0) IUniswapV3Pool(pool).burn(positionMain.tickLower, positionMain.tickUpper, 0); if (liquidityAlt > 0) IUniswapV3Pool(pool).burn(positionAlt.tickLower, positionAlt.tickUpper, 0); // Collect fees from the pool. (fee0, fee1) = IUniswapV3Pool(pool).collect(address(this), positionMain.tickLower, positionMain.tickUpper, type(uint128).max, type(uint128).max); (feeAlt0, feeAlt1) = IUniswapV3Pool(pool).collect(address(this), positionAlt.tickLower, positionAlt.tickUpper, type(uint128).max, type(uint128).max); // Set the total fees collected to state. fees0 = fees0 + fee0 + feeAlt0; fees1 = fees1 + fee1 + feeAlt1; emit ClaimedFees(fee0, fee1, feeAlt0, feeAlt1); } /** * @notice Internal function to charge fees for Beefy and send them to the appropriate addresses. * @param _callFeeRecipient The address to send the call fee to. * @param _amount0 The amount of token0 to charge fees on. * @param _amount1 The amount of token1 to charge fees on. * @return _amountLeft0 The amount of token0 left after fees. * @return _amountLeft1 The amount of token1 left after fees. */ function _chargeFees(address _callFeeRecipient, uint256 _amount0, uint256 _amount1) private returns (uint256 _amountLeft0, uint256 _amountLeft1){ /// Fetch our fee percentage amounts from the fee config. IFeeConfig.FeeCategory memory fees = getFees(); /// We calculate how much to swap and then swap both tokens to native and charge fees. uint256 nativeEarned; if (_amount0 > 0) { // Calculate amount of token 0 to swap for fees. uint256 amountToSwap0 = _amount0 * fees.total / DIVISOR; _amountLeft0 = _amount0 - amountToSwap0; // If token0 is not native, swap to native the fee amount. uint256 out0; if (lpToken0 != native) out0 = IBeefySwapper(unirouter).swap(lpToken0, native, amountToSwap0); // Add the native earned to the total of native we earned for beefy fees, handle if token0 is native. if (lpToken0 == native) nativeEarned += amountToSwap0; else nativeEarned += out0; } if (_amount1 > 0) { // Calculate amount of token 1 to swap for fees. uint256 amountToSwap1 = _amount1 * fees.total / DIVISOR; _amountLeft1 = _amount1 - amountToSwap1; // If token1 is not native, swap to native the fee amount. uint256 out1; if (lpToken1 != native) out1 = IBeefySwapper(unirouter).swap(lpToken1, native, amountToSwap1); // Add the native earned to the total of native we earned for beefy fees, handle if token1 is native. if (lpToken1 == native) nativeEarned += amountToSwap1; else nativeEarned += out1; } // Distribute the native earned to the appropriate addresses. uint256 callFeeAmount = nativeEarned * fees.call / DIVISOR; IERC20Metadata(native).safeTransfer(_callFeeRecipient, callFeeAmount); uint256 strategistFeeAmount = nativeEarned * fees.strategist / DIVISOR; IERC20Metadata(native).safeTransfer(strategist, strategistFeeAmount); uint256 beefyFeeAmount = nativeEarned - callFeeAmount - strategistFeeAmount; IERC20Metadata(native).safeTransfer(beefyFeeRecipient(), beefyFeeAmount); emit ChargedFees(callFeeAmount, beefyFeeAmount, strategistFeeAmount); } /** * @notice Returns total token balances in the strategy. * @return token0Bal The amount of token0 in the strategy. * @return token1Bal The amount of token1 in the strategy. */ function balances() public view returns (uint256 token0Bal, uint256 token1Bal) { (uint256 thisBal0, uint256 thisBal1) = balancesOfThis(); (uint256 poolBal0, uint256 poolBal1,,,,) = balancesOfPool(); (uint256 locked0, uint256 locked1) = lockedProfit(); uint256 total0 = thisBal0 + poolBal0 - locked0; uint256 total1 = thisBal1 + poolBal1 - locked1; uint256 unharvestedFees0 = fees0; uint256 unharvestedFees1 = fees1; // If pair is so imbalanced that we no longer have any enough tokens to pay fees, we set them to 0. if (unharvestedFees0 > total0) unharvestedFees0 = total0; if (unharvestedFees1 > total1) unharvestedFees1 = total1; // For token0 and token1 we return balance of this contract + balance of positions - locked profit - feesUnharvested. return (total0 - unharvestedFees0, total1 - unharvestedFees1); } /** * @notice Returns total tokens sitting in the strategy. * @return token0Bal The amount of token0 in the strategy. * @return token1Bal The amount of token1 in the strategy. */ function balancesOfThis() public view returns (uint256 token0Bal, uint256 token1Bal) { return (IERC20Metadata(lpToken0).balanceOf(address(this)), IERC20Metadata(lpToken1).balanceOf(address(this))); } /** * @notice Returns total tokens in pool positions (is a calculation which means it could be a little off by a few wei). * @return token0Bal The amount of token0 in the pool. * @return token1Bal The amount of token1 in the pool. * @return mainAmount0 The amount of token0 in the main position. * @return mainAmount1 The amount of token1 in the main position. * @return altAmount0 The amount of token0 in the alt position. * @return altAmount1 The amount of token1 in the alt position. */ function balancesOfPool() public view returns (uint256 token0Bal, uint256 token1Bal, uint256 mainAmount0, uint256 mainAmount1, uint256 altAmount0, uint256 altAmount1) { (bytes32 keyMain, bytes32 keyAlt) = getKeys(); uint160 sqrtPriceX96 = sqrtPrice(); (uint128 liquidity,,,uint256 owed0, uint256 owed1) = IUniswapV3Pool(pool).positions(keyMain); (uint128 altLiquidity,,,uint256 altOwed0, uint256 altOwed1) =IUniswapV3Pool(pool).positions(keyAlt); (mainAmount0, mainAmount1) = LiquidityAmounts.getAmountsForLiquidity( sqrtPriceX96, TickMath.getSqrtRatioAtTick(positionMain.tickLower), TickMath.getSqrtRatioAtTick(positionMain.tickUpper), liquidity ); (altAmount0, altAmount1) = LiquidityAmounts.getAmountsForLiquidity( sqrtPriceX96, TickMath.getSqrtRatioAtTick(positionAlt.tickLower), TickMath.getSqrtRatioAtTick(positionAlt.tickUpper), altLiquidity ); mainAmount0 += owed0; mainAmount1 += owed1; altAmount0 += altOwed0; altAmount1 += altOwed1; token0Bal = mainAmount0 + altAmount0; token1Bal = mainAmount1 + altAmount1; } /** * @notice Returns the amount of locked profit in the strategy, this is linearly release over a duration defined in the fee manager. * @return locked0 The amount of token0 locked in the strategy. * @return locked1 The amount of token1 locked in the strategy. */ function lockedProfit() public override view returns (uint256 locked0, uint256 locked1) { (uint256 balThis0, uint256 balThis1) = balancesOfThis(); (uint256 balPool0, uint256 balPool1,,,,) = balancesOfPool(); uint256 totalBal0 = balThis0 + balPool0; uint256 totalBal1 = balThis1 + balPool1; uint256 elapsed = block.timestamp - lastHarvest; uint256 remaining = elapsed < DURATION ? DURATION - elapsed : 0; // Make sure we don't lock more than we have. if (totalBal0 > totalLocked0) locked0 = totalLocked0 * remaining / DURATION; else locked0 = totalBal0 * remaining / DURATION; if (totalBal1 > totalLocked1) locked1 = totalLocked1 * remaining / DURATION; else locked1 = totalBal1 * remaining / DURATION; } /** * @notice Returns the range of the pool, will always be the main position. * @return lowerPrice The lower price of the position. * @return upperPrice The upper price of the position. */ function range() external view returns (uint256 lowerPrice, uint256 upperPrice) { // the main position is always covering the alt range lowerPrice = FullMath.mulDiv(uint256(TickMath.getSqrtRatioAtTick(positionMain.tickLower)), SQRT_PRECISION, (2 ** 96)) ** 2; upperPrice = FullMath.mulDiv(uint256(TickMath.getSqrtRatioAtTick(positionMain.tickUpper)), SQRT_PRECISION, (2 ** 96)) ** 2; } /** * @notice Returns the keys for the main and alternative positions. * @return keyMain The key for the main position. * @return keyAlt The key for the alternative position. */ function getKeys() public view returns (bytes32 keyMain, bytes32 keyAlt) { keyMain = keccak256(abi.encodePacked(address(this), positionMain.tickLower, positionMain.tickUpper)); keyAlt = keccak256(abi.encodePacked(address(this), positionAlt.tickLower, positionAlt.tickUpper)); } /** * @notice The current tick of the pool. * @return tick The current tick of the pool. */ function currentTick() public view returns (int24 tick) { (,tick,,,,,) = IUniswapV3Pool(pool).slot0(); } /** * @notice The current price of the pool in token1, encoded with `36 + lpToken1.decimals - lpToken0.decimals`. * @return _price The current price of the pool. */ function price() public view returns (uint256 _price) { uint160 sqrtPriceX96 = sqrtPrice(); _price = FullMath.mulDiv(uint256(sqrtPriceX96), SQRT_PRECISION, (2 ** 96)) ** 2; } /** * @notice The sqrt price of the pool. * @return sqrtPriceX96 The sqrt price of the pool. */ function sqrtPrice() public view returns (uint160 sqrtPriceX96) { (sqrtPriceX96,,,,,,) = IUniswapV3Pool(pool).slot0(); } /** * @notice The swap fee variable is the fee charged for swaps in the underlying pool in 18 decimals * @return fee The swap fee of the underlying pool */ function swapFee() external override view returns (uint256 fee) { fee = uint256(IUniswapV3Pool(pool).fee()) * SQRT_PRECISION / 1e6; } /** * @notice The tick distance of the pool. * @return int24 The tick distance/spacing of the pool. */ function _tickDistance() private view returns (int24) { return IUniswapV3Pool(pool).tickSpacing(); } /** * @notice Callback function for Uniswap V3 pool to call when minting liquidity. * @param amount0 Amount of token0 owed to the pool * @param amount1 Amount of token1 owed to the pool * bytes Additional data but unused in this case. */ function uniswapV3MintCallback(uint256 amount0, uint256 amount1, bytes memory /*data*/) external { if (msg.sender != pool) revert NotPool(); if (!minting) revert InvalidEntry(); if (amount0 > 0) IERC20Metadata(lpToken0).safeTransfer(pool, amount0); if (amount1 > 0) IERC20Metadata(lpToken1).safeTransfer(pool, amount1); minting = false; } /// @notice Sets the tick positions for the main and alternative positions. function _setTicks() private onlyCalmPeriods { int24 tick = currentTick(); int24 distance = _tickDistance(); int24 width = positionWidth * distance; _setMainTick(tick, distance, width); _setAltTick(tick, distance, width); lastPositionAdjustment = block.timestamp; } /// @notice Sets the main tick position. function _setMainTick(int24 tick, int24 distance, int24 width) private { (positionMain.tickLower, positionMain.tickUpper) = TickUtils.baseTicks( tick, width, distance ); } /// @notice Sets the alternative tick position. function _setAltTick(int24 tick, int24 distance, int24 width) private { (uint256 bal0, uint256 bal1) = balancesOfThis(); // We calculate how much token0 we have in the price of token1. uint256 amount0; if (bal0 > 0) { amount0 = bal0 * price() / PRECISION; } // We set the alternative position based on the token that has the most value available. if (amount0 < bal1) { (positionAlt.tickLower, ) = TickUtils.baseTicks( tick, width, distance ); (positionAlt.tickUpper, ) = TickUtils.baseTicks( tick, distance, distance ); } else if (bal1 < amount0) { (, positionAlt.tickLower) = TickUtils.baseTicks( tick, distance, distance ); (, positionAlt.tickUpper) = TickUtils.baseTicks( tick, width, distance ); } if (positionMain.tickLower == positionAlt.tickLower && positionMain.tickUpper == positionAlt.tickUpper) revert InvalidTicks(); } /** * @notice Sets the path to swap the first token to the native token for fee harvesting. * @param _path The path to swap the first token to the native token. */ function setLpToken0ToNativePath(bytes calldata _path) public onlyOwner { if (_path.length > 0) { (address[] memory _route) = UniV3Utils.pathToRoute(_path); if (_route[0] != lpToken0) revert InvalidInput(); if (_route[_route.length - 1] != native) revert InvalidOutput(); lpToken0ToNativePath = _path; emit SetLpToken0ToNativePath(_path); } } /** * @notice Sets the path to swap the second token to the native token for fee harvesting. * @param _path The path to swap the second token to the native token. */ function setLpToken1ToNativePath(bytes calldata _path) public onlyOwner { if (_path.length > 0) { (address[] memory _route) = UniV3Utils.pathToRoute(_path); if (_route[0] != lpToken1) revert InvalidInput(); if (_route[_route.length - 1] != native) revert InvalidOutput(); lpToken1ToNativePath = _path; emit SetLpToken1ToNativePath(_path); } } /** * @notice Sets the deviation from the twap we will allow on adding liquidity. * @param _maxDeviation The max deviation from twap we will allow. */ function setDeviation(int56 _maxDeviation) external onlyOwner { emit SetDeviation(_maxDeviation); // Require the deviation to be less than or equal to 4 times the tick spacing. if (_maxDeviation >= _tickDistance() * 4) revert InvalidInput(); maxTickDeviation = _maxDeviation; } /** * @notice Returns the route to swap the first token to the native token for fee harvesting. * @return address[] The route to swap the first token to the native token. */ function lpToken0ToNative() external view returns (address[] memory) { if (lpToken0ToNativePath.length == 0) return new address[](0); return UniV3Utils.pathToRoute(lpToken0ToNativePath); } /** * @notice Returns the route to swap the second token to the native token for fee harvesting. * @return address[] The route to swap the second token to the native token. */ function lpToken1ToNative() external view returns (address[] memory) { if (lpToken1ToNativePath.length == 0) return new address[](0); return UniV3Utils.pathToRoute(lpToken1ToNativePath); } /// @notice Returns the price of the first token in native token. function lpToken0ToNativePrice() external returns (uint256) { uint amount = 10**IERC20Metadata(lpToken0).decimals() / 10; if (lpToken0 == native) return amount * 10; return IQuoter(quoter).quoteExactInput(lpToken0ToNativePath, amount) * 10; } /// @notice Returns the price of the second token in native token. function lpToken1ToNativePrice() external returns (uint256) { uint amount = 10**IERC20Metadata(lpToken1).decimals() / 10; if (lpToken1 == native) return amount * 10; return IQuoter(quoter).quoteExactInput(lpToken1ToNativePath, amount) * 10; } /** * @notice The twap of the last minute from the pool. * @return twapTick The twap of the last minute from the pool. */ function twap() public view returns (int56 twapTick) { uint32[] memory secondsAgo = new uint32[](2); secondsAgo[0] = uint32(twapInterval); secondsAgo[1] = 0; (int56[] memory tickCuml,) = IUniswapV3Pool(pool).observe(secondsAgo); twapTick = (tickCuml[1] - tickCuml[0]) / int32(twapInterval); } function setTwapInterval(uint32 _interval) external onlyOwner { emit SetTwapInterval(twapInterval, _interval); // Require the interval to be greater than 60 seconds. if (_interval < 60) revert InvalidInput(); twapInterval = _interval; } /** * @notice Sets our position width and readjusts our positions. * @param _width The new width multiplier of the position. */ function setPositionWidth(int24 _width) external onlyOwner { emit SetPositionWidth(positionWidth, _width); _claimEarnings(); _removeLiquidity(); positionWidth = _width; _setTicks(); _addLiquidity(); } /** * @notice set the unirouter address * @param _unirouter The new unirouter address */ function setUnirouter(address _unirouter) external override onlyOwner { _removeAllowances(); unirouter = _unirouter; _giveAllowances(); emit SetUnirouter(_unirouter); } /// @notice Retire the strategy and return all the dust to the fee recipient. function retireVault() external onlyOwner { if (IBeefyVaultConcLiq(vault).totalSupply() != 10**3) revert NotAuthorized(); panic(0,0); address feeRecipient = beefyFeeRecipient(); (uint bal0, uint bal1) = balancesOfThis(); if (bal0 > 0) IERC20Metadata(lpToken0).safeTransfer(feeRecipient, IERC20Metadata(lpToken0).balanceOf(address(this))); if (bal1 > 0) IERC20Metadata(lpToken1).safeTransfer(feeRecipient, IERC20Metadata(lpToken1).balanceOf(address(this))); _transferOwnership(address(0)); } /** * @notice Remove Liquidity and Allowances, then pause deposits. * @param _minAmount0 The minimum amount of token0 in the strategy after panic. * @param _minAmount1 The minimum amount of token1 in the strategy after panic. */ function panic(uint256 _minAmount0, uint256 _minAmount1) public onlyManager { _claimEarnings(); _removeLiquidity(); _removeAllowances(); _pause(); (uint256 bal0, uint256 bal1) = balances(); if (bal0 < _minAmount0 || bal1 < _minAmount1) revert TooMuchSlippage(); } /// @notice Unpause deposits, give allowances and add liquidity. function unpause() external onlyManager { if (owner() == address(0)) revert NotAuthorized(); _giveAllowances(); _unpause(); _setTicks(); _addLiquidity(); } /// @notice gives swap permisions for the tokens to the unirouter. function _giveAllowances() private { IERC20Metadata(lpToken0).forceApprove(unirouter, type(uint256).max); IERC20Metadata(lpToken1).forceApprove(unirouter, type(uint256).max); } /// @notice removes swap permisions for the tokens from the unirouter. function _removeAllowances() private { IERC20Metadata(lpToken0).forceApprove(unirouter, 0); IERC20Metadata(lpToken1).forceApprove(unirouter, 0); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. */ interface IERC20Metadata is IERC20 { /** * @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 // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * CAUTION: See Security Considerations above. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 value) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; import {IERC20Permit} from "../extensions/IERC20Permit.sol"; import {Address} from "../../../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; /** * @dev An operation with an ERC20 token failed. */ error SafeERC20FailedOperation(address token); /** * @dev Indicates a failed `decreaseAllowance` request. */ error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease); /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value))); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value))); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); forceApprove(token, spender, oldAllowance + value); } /** * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no * value, non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal { unchecked { uint256 currentAllowance = token.allowance(address(this), spender); if (currentAllowance < requestedDecrease) { revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease); } forceApprove(token, spender, currentAllowance - requestedDecrease); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value)); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0))); _callOptionalReturn(token, approvalCall); } } /** * @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); if (returndata.length != 0 && !abi.decode(returndata, (bool))) { revert SafeERC20FailedOperation(address(token)); } } /** * @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). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // 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 cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol) pragma solidity ^0.8.20; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error AddressInsufficientBalance(address account); /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedInnerCall(); /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert AddressInsufficientBalance(address(this)); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert FailedInnerCall(); } } /** * @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 or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {FailedInnerCall} error. * * 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. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @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`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert AddressInsufficientBalance(address(this)); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an * unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {FailedInnerCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}. */ function _revert(bytes memory returndata) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert FailedInnerCall(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.20; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized != type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol) pragma solidity ^0.8.0; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IBeefySwapper { function swap( address fromToken, address toToken, uint256 amountIn ) external returns (uint256 amountOut); function swap( address fromToken, address toToken, uint256 amountIn, uint256 minAmountOut ) external returns (uint256 amountOut); function getAmountOut( address _fromToken, address _toToken, uint256 _amountIn ) external view returns (uint256 amountOut); struct SwapInfo { address router; bytes data; uint256 amountIndex; uint256 minIndex; int8 minAmountSign; } function setSwapInfo( address _fromToken, address _toToken, SwapInfo calldata _swapInfo ) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.23; interface IBeefyVaultConcLiq { function previewDeposit(uint256 _amount0, uint256 _amount1) external view returns (uint256 shares, uint256 amount0, uint256 amount1, uint256 fee0, uint256 fee1); function previewWithdraw(uint256 shares) external view returns (uint256 amount0, uint256 amount1); function strategy() external view returns (address); function totalSupply() external view returns (uint256); function wants() external view returns (address, address); function balances() external view returns (uint256, uint256); function deposit(uint256 amount0, uint256 amount1, uint256 minShares) external; function isCalm() external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IFeeConfig { struct FeeCategory { uint256 total; uint256 beefy; uint256 call; uint256 strategist; string label; bool active; } struct AllFees { FeeCategory performance; uint256 deposit; uint256 withdraw; } function getFees(address strategy) external view returns (FeeCategory memory); function stratFeeId(address strategy) external view returns (uint256); function setStratFeeId(uint256 feeId) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.23; interface IStrategyConcLiq { function balances() external view returns (uint256, uint256); function beforeAction() external; function deposit() external; function withdraw(uint256 _amount0, uint256 _amount1) external; function pool() external view returns (address); function lpToken0() external view returns (address); function lpToken1() external view returns (address); function isCalm() external view returns (bool); function swapFee() external view returns (uint256); /// @notice The current price of the pool in token1, encoded with `36 + lpToken1.decimals - lpToken0.decimals`. /// @return _price The current price of the pool in token1. function price() external view returns (uint256 _price); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IStrategyFactory { function native() external view returns (address); function globalPause() external view returns (bool); function keeper() external view returns (address); function beefyFeeRecipient() external view returns (address); function beefyFeeConfig() external view returns (address); function rebalancers(address) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.23; /// @notice Interface for the Uniswap V3 strategy contract. interface IStrategyUniswapV3 { /// @notice The sqrt price of the pool. function sqrtPrice() external view returns (uint160 sqrtPriceX96); /// @notice The range covered by the strategy. function range() external view returns (uint256 lowerPrice, uint256 upperPrice); /// @notice Returns the route to swap the first token to the native token for fee harvesting. function lpToken0ToNativePath() external view returns (bytes memory); /// @notice Returns the route to swap the second token to the native token for fee harvesting. function lpToken1ToNativePath() external view returns (bytes memory); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.23; interface IQuoter { function quoteExactInput(bytes memory path, uint amountIn) external returns (uint amountOut); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IUniswapRouterV3 { struct ExactInputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 amountIn; uint256 amountOutMinimum; uint160 sqrtPriceLimitX96; } /// @notice Swaps `amountIn` of one token for as much as possible of another token /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata /// @return amountOut The amount of the received token function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut); struct ExactInputParams { bytes path; address recipient; uint256 amountIn; uint256 amountOutMinimum; } /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata /// @return amountOut The amount of the received token function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut); struct ExactOutputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 amountOut; uint256 amountInMaximum; uint160 sqrtPriceLimitX96; } /// @notice Swaps as little as possible of one token for `amountOut` of another token /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata /// @return amountIn The amount of the input token function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn); struct ExactOutputParams { bytes path; address recipient; uint256 amountOut; uint256 amountInMaximum; } /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed) /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata /// @return amountIn The amount of the input token function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.23; interface IUniswapV3Pool { /// @notice The contract that deployed the pool, which must adhere to the IPancakeV3Factory 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); /// @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, uint32 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 ); /// @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 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 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); function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.23; import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import {PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import {IFeeConfig} from "../interfaces/beefy/IFeeConfig.sol"; import {IStrategyFactory} from "../interfaces/beefy/IStrategyFactory.sol"; contract StratFeeManagerInitializable is OwnableUpgradeable, PausableUpgradeable { struct CommonAddresses { address vault; address unirouter; address strategist; address factory; } /// @notice The native address of the chain address public native; /// @notice The address of the vault address public vault; /// @notice The address of the unirouter address public unirouter; /// @notice The address of the strategist address public strategist; /// @notice The address of the strategy factory IStrategyFactory public factory; /// @notice The total amount of token0 locked in the vault uint256 public totalLocked0; /// @notice The total amount of token1 locked in the vault uint256 public totalLocked1; /// @notice The last time the strat harvested uint256 public lastHarvest; /// @notice The last time we adjusted the position uint256 public lastPositionAdjustment; /// @notice The duration of the locked rewards uint256 constant DURATION = 1 hours; /// @notice The divisor used to calculate the fee uint256 constant DIVISOR = 1 ether; // Events event SetStratFeeId(uint256 feeId); event SetUnirouter(address unirouter); event SetStrategist(address strategist); // Errors error NotManager(); error NotStrategist(); error OverLimit(); error StrategyPaused(); /** * @notice Initialize the Strategy Fee Manager inherited contract with the common addresses * @param _commonAddresses The common addresses of the vault, unirouter, keeper, strategist, beefyFeeRecipient and beefyFeeConfig */ function __StratFeeManager_init(CommonAddresses calldata _commonAddresses) internal onlyInitializing { __Ownable_init(); __Pausable_init(); vault = _commonAddresses.vault; unirouter = _commonAddresses.unirouter; strategist = _commonAddresses.strategist; factory = IStrategyFactory(_commonAddresses.factory); native = factory.native(); } /** * @notice function that throws if the strategy is paused */ function _whenStrategyNotPaused() internal view { if (paused() || factory.globalPause()) revert StrategyPaused(); } /** * @notice function that returns true if the strategy is paused */ function _isPaused() internal view returns (bool) { return paused() || factory.globalPause(); } /** * @notice Modifier that throws if called by any account other than the manager or the owner */ modifier onlyManager() { if (msg.sender != owner() && msg.sender != keeper()) revert NotManager(); _; } /// @notice The address of the keeper, set on the factory. function keeper() public view returns (address) { return factory.keeper(); } /// @notice The address of the beefy fee recipient, set on the factory. function beefyFeeRecipient() public view returns (address) { return factory.beefyFeeRecipient(); } /// @notice The address of the beefy fee config, set on the factory. function beefyFeeConfig() public view returns (IFeeConfig) { return IFeeConfig(factory.beefyFeeConfig()); } /** * @notice get the fees breakdown from the fee config for this contract * @return IFeeConfig.FeeCategory The fees breakdown */ function getFees() internal view returns (IFeeConfig.FeeCategory memory) { return beefyFeeConfig().getFees(address(this)); } /** * @notice get all the fees from the fee config for this contract * @return IFeeConfig.AllFees The fees */ function getAllFees() external view returns (IFeeConfig.AllFees memory) { return IFeeConfig.AllFees(getFees(), depositFee(), withdrawFee()); } /** * @notice get the strat fee id from the fee config * @return uint256 The strat fee id */ function getStratFeeId() external view returns (uint256) { return beefyFeeConfig().stratFeeId(address(this)); } /** * @notice set the strat fee id in the fee config * @param _feeId The new strat fee id */ function setStratFeeId(uint256 _feeId) external onlyManager { beefyFeeConfig().setStratFeeId(_feeId); emit SetStratFeeId(_feeId); } /** * @notice set the unirouter address * @param _unirouter The new unirouter address */ function setUnirouter(address _unirouter) external virtual onlyOwner { unirouter = _unirouter; emit SetUnirouter(_unirouter); } /** * @notice set the strategist address * @param _strategist The new strategist address */ function setStrategist(address _strategist) external { if (msg.sender != strategist) revert NotStrategist(); strategist = _strategist; emit SetStrategist(_strategist); } /** * @notice The deposit fee variable will alwasy be 0. This is used by the UI. * @return uint256 The deposit fee */ function depositFee() public virtual view returns (uint256) { return 0; } /** * @notice The withdraw fee variable will alwasy be 0. This is used by the UI. * @return uint256 The withdraw fee */ function withdrawFee() public virtual view returns (uint256) { return 0; } /** * @notice The locked profit is the amount of token0 and token1 that is locked in the vault, this can be overriden by the strategy contract. * @return locked0 The amount of token0 locked * @return locked1 The amount of token1 locked */ function lockedProfit() public virtual view returns (uint256 locked0, uint256 locked1) { uint256 elapsed = block.timestamp - lastHarvest; uint256 remaining = elapsed < DURATION ? DURATION - elapsed : 0; return (totalLocked0 * remaining / DURATION, totalLocked1 * remaining / DURATION); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: Unlicense /* * @title Solidity Bytes Arrays Utils * @author Gonçalo Sá <[email protected]> * * @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity. * The library lets you concatenate, slice and type cast bytes arrays both in memory and storage. */ pragma solidity >=0.8.0 <0.9.0; library BytesLib { function concat( bytes memory _preBytes, bytes memory _postBytes ) internal pure returns (bytes memory) { bytes memory tempBytes; assembly { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // Store the length of the first bytes array at the beginning of // the memory for tempBytes. let length := mload(_preBytes) mstore(tempBytes, length) // Maintain a memory counter for the current write location in the // temp bytes array by adding the 32 bytes for the array length to // the starting location. let mc := add(tempBytes, 0x20) // Stop copying when the memory counter reaches the length of the // first bytes array. let end := add(mc, length) for { // Initialize a copy counter to the start of the _preBytes data, // 32 bytes into its memory. let cc := add(_preBytes, 0x20) } lt(mc, end) { // Increase both counters by 32 bytes each iteration. mc := add(mc, 0x20) cc := add(cc, 0x20) } { // Write the _preBytes data into the tempBytes memory 32 bytes // at a time. mstore(mc, mload(cc)) } // Add the length of _postBytes to the current length of tempBytes // and store it as the new length in the first 32 bytes of the // tempBytes memory. length := mload(_postBytes) mstore(tempBytes, add(length, mload(tempBytes))) // Move the memory counter back from a multiple of 0x20 to the // actual end of the _preBytes data. mc := end // Stop copying when the memory counter reaches the new combined // length of the arrays. end := add(mc, length) for { let cc := add(_postBytes, 0x20) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } // Update the free-memory pointer by padding our last write location // to 32 bytes: add 31 bytes to the end of tempBytes to move to the // next 32 byte block, then round down to the nearest multiple of // 32. If the sum of the length of the two arrays is zero then add // one before rounding down to leave a blank 32 bytes (the length block with 0). mstore(0x40, and( add(add(end, iszero(add(length, mload(_preBytes)))), 31), not(31) // Round down to the nearest 32 bytes. )) } return tempBytes; } function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal { assembly { // Read the first 32 bytes of _preBytes storage, which is the length // of the array. (We don't need to use the offset into the slot // because arrays use the entire slot.) let fslot := sload(_preBytes.slot) // Arrays of 31 bytes or less have an even value in their slot, // while longer arrays have an odd value. The actual length is // the slot divided by two for odd values, and the lowest order // byte divided by two for even values. // If the slot is even, bitwise and the slot with 255 and divide by // two to get the length. If the slot is odd, bitwise and the slot // with -1 and divide by two. let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) let newlength := add(slength, mlength) // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage switch add(lt(slength, 32), lt(newlength, 32)) case 2 { // Since the new array still fits in the slot, we just need to // update the contents of the slot. // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length sstore( _preBytes.slot, // all the modifications to the slot are inside this // next block add( // we can just add to the slot contents because the // bytes we want to change are the LSBs fslot, add( mul( div( // load the bytes from memory mload(add(_postBytes, 0x20)), // zero all bytes to the right exp(0x100, sub(32, mlength)) ), // and now shift left the number of bytes to // leave space for the length in the slot exp(0x100, sub(32, newlength)) ), // increase length by the double of the memory // bytes length mul(mlength, 2) ) ) ) } case 1 { // The stored value fits in the slot, but the combined value // will exceed it. // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes.slot, add(mul(newlength, 2), 1)) // The contents of the _postBytes array start 32 bytes into // the structure. Our first read should obtain the `submod` // bytes that can fit into the unused space in the last word // of the stored array. To get this, we read 32 bytes starting // from `submod`, so the data we read overlaps with the array // contents by `submod` bytes. Masking the lowest-order // `submod` bytes allows us to add that value directly to the // stored value. let submod := sub(32, slength) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore( sc, add( and( fslot, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00 ), and(mload(mc), mask) ) ) for { mc := add(mc, 0x20) sc := add(sc, 1) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } default { // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) // Start copying to the last used word of the stored array. let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes.slot, add(mul(newlength, 2), 1)) // Copy over the first `submod` bytes of the new data as in // case 1 above. let slengthmod := mod(slength, 32) let mlengthmod := mod(mlength, 32) let submod := sub(32, slengthmod) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore(sc, add(sload(sc), and(mload(mc), mask))) for { sc := add(sc, 1) mc := add(mc, 0x20) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } } } function slice( bytes memory _bytes, uint256 _start, uint256 _length ) internal pure returns (bytes memory) { require(_length + 31 >= _length, "slice_overflow"); require(_bytes.length >= _start + _length, "slice_outOfBounds"); bytes memory tempBytes; assembly { switch iszero(_length) case 0 { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // The first word of the slice result is potentially a partial // word read from the original array. To read it, we calculate // the length of that partial word and start copying that many // bytes into the array. The first word we copy will start with // data we don't care about, but the last `lengthmod` bytes will // land at the beginning of the contents of the new array. When // we're done copying, we overwrite the full first word with // the actual length of the slice. let lengthmod := and(_length, 31) // The multiplication in the next line is necessary // because when slicing multiples of 32 bytes (lengthmod == 0) // the following copy loop was copying the origin's length // and then ending prematurely not copying everything it should. let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod))) let end := add(mc, _length) for { // The multiplication in the next line has the same exact purpose // as the one above. let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } mstore(tempBytes, _length) //update free-memory pointer //allocating the array padded to 32 bytes like the compiler does now mstore(0x40, and(add(mc, 31), not(31))) } //if we want a zero-length slice let's just return a zero-length array default { tempBytes := mload(0x40) //zero out the 32 bytes slice we are about to return //we need to do it because Solidity does not garbage collect mstore(tempBytes, 0) mstore(0x40, add(tempBytes, 0x20)) } } return tempBytes; } function toAddress(bytes memory _bytes, uint256 _start) internal pure returns (address) { require(_bytes.length >= _start + 20, "toAddress_outOfBounds"); address tempAddress; assembly { tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000) } return tempAddress; } function toUint8(bytes memory _bytes, uint256 _start) internal pure returns (uint8) { require(_bytes.length >= _start + 1 , "toUint8_outOfBounds"); uint8 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x1), _start)) } return tempUint; } function toUint16(bytes memory _bytes, uint256 _start) internal pure returns (uint16) { require(_bytes.length >= _start + 2, "toUint16_outOfBounds"); uint16 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x2), _start)) } return tempUint; } function toUint24(bytes memory _bytes, uint256 _start) internal pure returns (uint24) { require(_start + 3 >= _start, 'toUint24_overflow'); require(_bytes.length >= _start + 3, 'toUint24_outOfBounds'); uint24 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x3), _start)) } return tempUint; } function toUint32(bytes memory _bytes, uint256 _start) internal pure returns (uint32) { require(_bytes.length >= _start + 4, "toUint32_outOfBounds"); uint32 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x4), _start)) } return tempUint; } function toUint64(bytes memory _bytes, uint256 _start) internal pure returns (uint64) { require(_bytes.length >= _start + 8, "toUint64_outOfBounds"); uint64 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x8), _start)) } return tempUint; } function toUint96(bytes memory _bytes, uint256 _start) internal pure returns (uint96) { require(_bytes.length >= _start + 12, "toUint96_outOfBounds"); uint96 tempUint; assembly { tempUint := mload(add(add(_bytes, 0xc), _start)) } return tempUint; } function toUint128(bytes memory _bytes, uint256 _start) internal pure returns (uint128) { require(_bytes.length >= _start + 16, "toUint128_outOfBounds"); uint128 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x10), _start)) } return tempUint; } function toUint256(bytes memory _bytes, uint256 _start) internal pure returns (uint256) { require(_bytes.length >= _start + 32, "toUint256_outOfBounds"); uint256 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x20), _start)) } return tempUint; } function toBytes32(bytes memory _bytes, uint256 _start) internal pure returns (bytes32) { require(_bytes.length >= _start + 32, "toBytes32_outOfBounds"); bytes32 tempBytes32; assembly { tempBytes32 := mload(add(add(_bytes, 0x20), _start)) } return tempBytes32; } function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) { bool success = true; assembly { let length := mload(_preBytes) // if lengths don't match the arrays are not equal switch eq(length, mload(_postBytes)) case 1 { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 let mc := add(_preBytes, 0x20) let end := add(mc, length) for { let cc := add(_postBytes, 0x20) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) } eq(add(lt(mc, end), cb), 2) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { // if any of these checks fails then arrays are not equal if iszero(eq(mload(mc), mload(cc))) { // unsuccess: success := 0 cb := 0 } } } default { // unsuccess: success := 0 } } return success; } function equalStorage( bytes storage _preBytes, bytes memory _postBytes ) internal view returns (bool) { bool success = true; assembly { // we know _preBytes_offset is 0 let fslot := sload(_preBytes.slot) // Decode the length of the stored array like in concatStorage(). let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) // if lengths don't match the arrays are not equal switch eq(slength, mlength) case 1 { // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage if iszero(iszero(slength)) { switch lt(slength, 32) case 1 { // blank the last byte which is the length fslot := mul(div(fslot, 0x100), 0x100) if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) { // unsuccess: success := 0 } } default { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) let sc := keccak256(0x0, 0x20) let mc := add(_postBytes, 0x20) let end := add(mc, mlength) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) for {} eq(add(lt(mc, end), cb), 2) { sc := add(sc, 1) mc := add(mc, 0x20) } { if iszero(eq(sload(sc), mload(mc))) { // unsuccess: success := 0 cb := 0 } } } } } default { // unsuccess: success := 0 } } return success; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title Contains 512-bit math functions /// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision /// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits library FullMath { /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv function mulDiv( uint256 a, uint256 b, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = a * b // Compute the product mod 2**256 and mod 2**256 - 1 // then use the Chinese Remainder Theorem to reconstruct // the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2**256 + prod0 uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(a, b, not(0)) prod0 := mul(a, b) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division if (prod1 == 0) { require(denominator > 0); assembly { result := div(prod0, denominator) } return result; } // Make sure the result is less than 2**256. // Also prevents denominator == 0 require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0] // Compute remainder using mulmod uint256 remainder; assembly { remainder := mulmod(a, b, denominator) } // Subtract 256 bit number from 512 bit number assembly { prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator // Compute largest power of two divisor of denominator. // Always >= 1. // 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: MIT pragma solidity ^0.8.0; import "./FullMath.sol"; /// @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; } /// @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-2.0-or-later pragma solidity ^0.8.0; import './BytesLib.sol'; /// @title Functions for manipulating path data for multihop swaps library Path { using BytesLib for bytes; /// @dev The length of the bytes encoded address uint256 private constant ADDR_SIZE = 20; /// @dev The length of the bytes encoded fee uint256 private constant FEE_SIZE = 3; /// @dev The offset of a single token address and pool fee uint256 private constant NEXT_OFFSET = ADDR_SIZE + FEE_SIZE; /// @dev The offset of an encoded pool key uint256 private constant POP_OFFSET = NEXT_OFFSET + ADDR_SIZE; /// @dev The minimum length of an encoding that contains 2 or more pools uint256 private constant MULTIPLE_POOLS_MIN_LENGTH = POP_OFFSET + NEXT_OFFSET; /// @notice Returns true iff the path contains two or more pools /// @param path The encoded swap path /// @return True if path contains two or more pools, otherwise false function hasMultiplePools(bytes memory path) internal pure returns (bool) { return path.length >= MULTIPLE_POOLS_MIN_LENGTH; } /// @notice Returns the number of pools in the path /// @param path The encoded swap path /// @return The number of pools in the path function numPools(bytes memory path) internal pure returns (uint256) { // Ignore the first token address. From then on every fee and token offset indicates a pool. return ((path.length - ADDR_SIZE) / NEXT_OFFSET); } /// @notice Decodes the first pool in path /// @param path The bytes encoded swap path /// @return tokenA The first token of the given pool /// @return tokenB The second token of the given pool /// @return fee The fee level of the pool function decodeFirstPool(bytes memory path) internal pure returns ( address tokenA, address tokenB, uint24 fee ) { tokenA = path.toAddress(0); fee = path.toUint24(ADDR_SIZE); tokenB = path.toAddress(NEXT_OFFSET); } /// @notice Gets the segment corresponding to the first pool in the path /// @param path The bytes encoded swap path /// @return The segment containing all data necessary to target the first pool in the path function getFirstPool(bytes memory path) internal pure returns (bytes memory) { return path.slice(0, POP_OFFSET); } /// @notice Skips a token + fee element from the buffer and returns the remainder /// @param path The swap path /// @return The remaining token + fee elements in the path function skipToken(bytes memory path) internal pure returns (bytes memory) { return path.slice(NEXT_OFFSET, path.length - NEXT_OFFSET); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; /// @title Math library for computing sqrt prices from ticks and vice versa /// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports /// prices between 2**-128 and 2**128 library TickMath { /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128 int24 internal constant MIN_TICK = -887272; /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128 int24 internal constant MAX_TICK = -MIN_TICK; /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK) uint160 internal constant MIN_SQRT_RATIO = 4295128739; /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK) uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342; /// @notice Calculates sqrt(1.0001^tick) * 2^96 /// @dev Throws if |tick| > max tick /// @param tick The input tick for the above formula /// @return sqrtP 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 sqrtP) { unchecked { uint256 absTick = uint256(tick < 0 ? -int256(tick) : int256(tick)); require(absTick <= uint256(int256(MAX_TICK)), 'T'); // do bitwise comparison, if i-th bit is turned on, // multiply ratio by hardcoded values of sqrt(1.0001^-(2^i)) * 2^128 // where 0 <= i <= 19 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; // take reciprocal for positive tick values 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 sqrtP = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1)); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./Path.sol"; import "./TickMath.sol"; import "./LiquidityAmounts.sol"; library TickUtils { using Path for bytes; using TickMath for int24; function floor(int24 tick, int24 tickSpacing) internal pure returns (int24) { int24 compressed = tick / tickSpacing; if (tick < 0 && tick % tickSpacing != 0) compressed--; return compressed * tickSpacing; } /// @dev Calc base ticks depending on base threshold and tickspacing function baseTicks( int24 currentTick, int24 baseThreshold, int24 tickSpacing ) internal pure returns (int24 tickLower, int24 tickUpper) { int24 tickFloor = floor(currentTick, tickSpacing); tickLower = tickFloor - baseThreshold; tickUpper = tickFloor + baseThreshold; } function quoteAddLiquidity(int24 _currentTick, int24 _lowerTick, int24 _upperTick, uint256 _amt0, uint256 _amt1) internal pure returns(uint256 _actualAmount0, uint256 _actualAmount1, uint256 _liquidity) { // Grab the amount of liquidity for our token balances _liquidity = LiquidityAmounts.getLiquidityForAmounts( _currentTick.getSqrtRatioAtTick(), _lowerTick.getSqrtRatioAtTick(), _upperTick.getSqrtRatioAtTick(), _amt0, _amt1 ); ( _actualAmount0, _actualAmount1) = LiquidityAmounts.getAmountsForLiquidity( _currentTick.getSqrtRatioAtTick(), _lowerTick.getSqrtRatioAtTick(), _upperTick.getSqrtRatioAtTick(), uint128(_liquidity) ); } function getQuoteAtTick( int24 tick, uint128 baseAmount, address baseToken, address quoteToken ) internal pure returns (uint256 quoteAmount) { uint160 sqrtRatioX96 = TickMath.getSqrtRatioAtTick(tick); // Calculate quoteAmount with better precision if it doesn't overflow when multiplied by itself if (sqrtRatioX96 <= type(uint128).max) { uint256 ratioX192 = uint256(sqrtRatioX96) * sqrtRatioX96; quoteAmount = baseToken < quoteToken ? FullMath.mulDiv(ratioX192, baseAmount, 1 << 192) : FullMath.mulDiv(1 << 192, baseAmount, ratioX192); } else { uint256 ratioX128 = FullMath.mulDiv(sqrtRatioX96, sqrtRatioX96, 1 << 64); quoteAmount = baseToken < quoteToken ? FullMath.mulDiv(ratioX128, baseAmount, 1 << 128) : FullMath.mulDiv(1 << 128, baseAmount, ratioX128); } } // Convert encoded path to token route function pathToRoute(bytes memory _path) internal pure returns (address[] memory, uint24[] memory) { uint256 numPools = _path.numPools(); address[] memory route = new address[](numPools + 1); uint24[] memory fees = new uint24[](numPools); for (uint256 i; i < numPools; i++) { (address tokenA, address tokenB, uint24 fee) = _path.decodeFirstPool(); route[i] = tokenA; route[i + 1] = tokenB; fees[i] = fee; _path = _path.skipToken(); } return (route, fees); } // Convert token route to encoded path // uint24 type for fees so path is packed tightly function routeToPath( address[] memory _route, uint24[] memory _fee ) internal pure returns (bytes memory path) { path = abi.encodePacked(_route[0]); uint256 feeLength = _fee.length; for (uint256 i = 0; i < feeLength; i++) { path = abi.encodePacked(path, _fee[i], _route[i+1]); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import './Path.sol'; import "../interfaces/uniswap/IUniswapRouterV3.sol"; library UniV3Utils { using Path for bytes; // Swap along an encoded path using known amountIn function swap( address _user, address _router, bytes memory _path, uint256 _amountIn ) internal returns (uint256 amountOut) { IUniswapRouterV3.ExactInputParams memory params = IUniswapRouterV3.ExactInputParams({ path: _path, recipient: _user, amountIn: _amountIn, amountOutMinimum: 0 }); return IUniswapRouterV3(_router).exactInput(params); } function swap( address _router, bytes memory _path, uint256 _amountIn ) internal returns (uint256 amountOut) { IUniswapRouterV3.ExactInputParams memory params = IUniswapRouterV3.ExactInputParams({ path: _path, recipient: address(this), amountIn: _amountIn, amountOutMinimum: 0 }); return IUniswapRouterV3(_router).exactInput(params); } // Swap along a token route using known fees and amountIn function swap( address _router, address[] memory _route, uint24[] memory _fee, uint256 _amountIn ) internal returns (uint256 amountOut) { return swap(_router, routeToPath(_route, _fee), _amountIn); } // Convert encoded path to token route function pathToRoute(bytes memory _path) internal pure returns (address[] memory) { uint256 numPools = _path.numPools(); address[] memory route = new address[](numPools + 1); for (uint256 i; i < numPools; i++) { (address tokenA, address tokenB,) = _path.decodeFirstPool(); route[i] = tokenA; route[i + 1] = tokenB; _path = _path.skipToken(); } return route; } // Convert token route to encoded path // uint24 type for fees so path is packed tightly function routeToPath( address[] memory _route, uint24[] memory _fee ) internal pure returns (bytes memory path) { path = abi.encodePacked(_route[0]); uint256 feeLength = _fee.length; for (uint256 i = 0; i < feeLength; i++) { path = abi.encodePacked(path, _fee[i], _route[i+1]); } } }
{ "optimizer": { "enabled": true, "runs": 200 }, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"InvalidEntry","type":"error"},{"inputs":[],"name":"InvalidInput","type":"error"},{"inputs":[],"name":"InvalidOutput","type":"error"},{"inputs":[],"name":"InvalidTicks","type":"error"},{"inputs":[],"name":"NotAuthorized","type":"error"},{"inputs":[],"name":"NotCalm","type":"error"},{"inputs":[],"name":"NotManager","type":"error"},{"inputs":[],"name":"NotPool","type":"error"},{"inputs":[],"name":"NotStrategist","type":"error"},{"inputs":[],"name":"NotVault","type":"error"},{"inputs":[],"name":"OverLimit","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"StrategyPaused","type":"error"},{"inputs":[],"name":"TooMuchSlippage","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"callFeeAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"beefyFeeAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"strategistFeeAmount","type":"uint256"}],"name":"ChargedFees","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"feeMain0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feeMain1","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feeAlt0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feeAlt1","type":"uint256"}],"name":"ClaimedFees","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"fee0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee1","type":"uint256"}],"name":"Harvest","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"int56","name":"maxTickDeviation","type":"int56"}],"name":"SetDeviation","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"path","type":"bytes"}],"name":"SetLpToken0ToNativePath","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"path","type":"bytes"}],"name":"SetLpToken1ToNativePath","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"int24","name":"oldWidth","type":"int24"},{"indexed":false,"internalType":"int24","name":"width","type":"int24"}],"name":"SetPositionWidth","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"quoter","type":"address"}],"name":"SetQuoter","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"feeId","type":"uint256"}],"name":"SetStratFeeId","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"strategist","type":"address"}],"name":"SetStrategist","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"oldInterval","type":"uint32"},{"indexed":false,"internalType":"uint32","name":"interval","type":"uint32"}],"name":"SetTwapInterval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"unirouter","type":"address"}],"name":"SetUnirouter","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"bal0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"bal1","type":"uint256"}],"name":"TVL","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"balances","outputs":[{"internalType":"uint256","name":"token0Bal","type":"uint256"},{"internalType":"uint256","name":"token1Bal","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"balancesOfPool","outputs":[{"internalType":"uint256","name":"token0Bal","type":"uint256"},{"internalType":"uint256","name":"token1Bal","type":"uint256"},{"internalType":"uint256","name":"mainAmount0","type":"uint256"},{"internalType":"uint256","name":"mainAmount1","type":"uint256"},{"internalType":"uint256","name":"altAmount0","type":"uint256"},{"internalType":"uint256","name":"altAmount1","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"balancesOfThis","outputs":[{"internalType":"uint256","name":"token0Bal","type":"uint256"},{"internalType":"uint256","name":"token1Bal","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"beefyFeeConfig","outputs":[{"internalType":"contract IFeeConfig","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"beefyFeeRecipient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"beforeAction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimEarnings","outputs":[{"internalType":"uint256","name":"fee0","type":"uint256"},{"internalType":"uint256","name":"fee1","type":"uint256"},{"internalType":"uint256","name":"feeAlt0","type":"uint256"},{"internalType":"uint256","name":"feeAlt1","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"currentTick","outputs":[{"internalType":"int24","name":"tick","type":"int24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"depositFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"contract IStrategyFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fees0","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fees1","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllFees","outputs":[{"components":[{"components":[{"internalType":"uint256","name":"total","type":"uint256"},{"internalType":"uint256","name":"beefy","type":"uint256"},{"internalType":"uint256","name":"call","type":"uint256"},{"internalType":"uint256","name":"strategist","type":"uint256"},{"internalType":"string","name":"label","type":"string"},{"internalType":"bool","name":"active","type":"bool"}],"internalType":"struct IFeeConfig.FeeCategory","name":"performance","type":"tuple"},{"internalType":"uint256","name":"deposit","type":"uint256"},{"internalType":"uint256","name":"withdraw","type":"uint256"}],"internalType":"struct IFeeConfig.AllFees","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getKeys","outputs":[{"internalType":"bytes32","name":"keyMain","type":"bytes32"},{"internalType":"bytes32","name":"keyAlt","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStratFeeId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_callFeeRecipient","type":"address"}],"name":"harvest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"harvest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pool","type":"address"},{"internalType":"address","name":"_quoter","type":"address"},{"internalType":"int24","name":"_positionWidth","type":"int24"},{"internalType":"bytes","name":"_lpToken0ToNativePath","type":"bytes"},{"internalType":"bytes","name":"_lpToken1ToNativePath","type":"bytes"},{"components":[{"internalType":"address","name":"vault","type":"address"},{"internalType":"address","name":"unirouter","type":"address"},{"internalType":"address","name":"strategist","type":"address"},{"internalType":"address","name":"factory","type":"address"}],"internalType":"struct StratFeeManagerInitializable.CommonAddresses","name":"_commonAddresses","type":"tuple"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isCalm","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"keeper","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastHarvest","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastPositionAdjustment","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lockedProfit","outputs":[{"internalType":"uint256","name":"locked0","type":"uint256"},{"internalType":"uint256","name":"locked1","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lpToken0","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lpToken0ToNative","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lpToken0ToNativePath","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lpToken0ToNativePrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lpToken1","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lpToken1ToNative","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lpToken1ToNativePath","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lpToken1ToNativePrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maxTickDeviation","outputs":[{"internalType":"int56","name":"","type":"int56"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"moveTicks","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"native","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minAmount0","type":"uint256"},{"internalType":"uint256","name":"_minAmount1","type":"uint256"}],"name":"panic","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pool","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"positionAlt","outputs":[{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"positionMain","outputs":[{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"positionWidth","outputs":[{"internalType":"int24","name":"","type":"int24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"price","outputs":[{"internalType":"uint256","name":"_price","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"quoter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"range","outputs":[{"internalType":"uint256","name":"lowerPrice","type":"uint256"},{"internalType":"uint256","name":"upperPrice","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"retireVault","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"int56","name":"_maxDeviation","type":"int56"}],"name":"setDeviation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"_path","type":"bytes"}],"name":"setLpToken0ToNativePath","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"_path","type":"bytes"}],"name":"setLpToken1ToNativePath","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"int24","name":"_width","type":"int24"}],"name":"setPositionWidth","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_feeId","type":"uint256"}],"name":"setStratFeeId","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_strategist","type":"address"}],"name":"setStrategist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_interval","type":"uint32"}],"name":"setTwapInterval","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_unirouter","type":"address"}],"name":"setUnirouter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sqrtPrice","outputs":[{"internalType":"uint160","name":"sqrtPriceX96","type":"uint160"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"strategist","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"swapFee","outputs":[{"internalType":"uint256","name":"fee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalLocked0","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalLocked1","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"twap","outputs":[{"internalType":"int56","name":"twapTick","type":"int56"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"twapInterval","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unirouter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"uniswapV3MintCallback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"vault","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount0","type":"uint256"},{"internalType":"uint256","name":"_amount1","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b506200001c62000022565b620000e3565b600054610100900460ff16156200008f5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff90811614620000e1576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b615c3e80620000f36000396000f3fe608060405234801561001057600080fd5b50600436106104065760003560e01c8063715018a611610220578063b3a60cb311610130578063d3487997116100b8578063e97206a911610087578063e97206a914610826578063f1a392da1461082e578063f2fde38b14610837578063fbfa77cf1461084a578063fcc25e131461085d57600080fd5b8063d3487997146107d8578063d92f3d73146107eb578063d9ceab13146107fe578063e941fa781461065d57600080fd5b8063c6bbd5a7116100ff578063c6bbd5a71461079a578063c6ebd4ae146107ad578063c7b9d530146107b5578063c7d54132146107c8578063d0e30db0146107d057600080fd5b8063b3a60cb31461075e578063b83d268314610766578063bc415d8a1461076e578063c45a01551461078757600080fd5b80638e145459116101b35780639bdde46b116101825780639bdde46b146107295780639c6d490414610731578063a035b1fe14610739578063aced166114610741578063b20feaaf1461074957600080fd5b80638e145459146106dd57806393f1c442146106e5578063953d329f146106ee57806399cd2446146106f657600080fd5b8063865238d4116101ef578063865238d4146106a8578063877562b6146106b15780638cfc0250146106c45780638da5cb5b146106cc57600080fd5b8063715018a6146106785780637bb98a68146106805780637f10e4b9146106885780638097e2491461069b57600080fd5b80632b950b661161031b5780634641257d116102ae5780635c975abb1161027d5780635c975abb146106205780635ee167c014610637578063609913461461064a57806367a527931461065d578063696c58e51461066457600080fd5b80634641257d146105ff5780634746fb55146106075780634c02a21c1461060f57806354cf2aeb1461061857600080fd5b80633e55f932116102ea5780633e55f932146105c95780633f4ba83a146105dc578063441a3e70146105e457806344b81396146105f757600080fd5b80632b950b661461056c5780632e773d3214610575578063362c28c61461058a5780633c1d5df01461059d57600080fd5b806316b9cd9c1161039e5780631dcfeddd1161036d5780631dcfeddd146105165780631fe4a6861461052b5780632150c5181461053e578063236db04214610546578063257ae0de1461055957600080fd5b806316b9cd9c146104e057806316f0115b146104e857806317dd7a72146104fb5780631d27050f1461050357600080fd5b80630e5c011e116103da5780630e5c011e1461047457806311b0b42d146104875780631208aa18146104b257806312cf1381146104cd57600080fd5b8062a4b5c91461040b57806304c404b31461042d578063065e53601461044457806308898ea01461045f575b600080fd5b610413610892565b604080519283526020830191909152015b60405180910390f35b610436609d5481565b604051908152602001610424565b61044c610977565b60405160029190910b8152602001610424565b61047261046d366004614d1d565b6109f1565b005b610472610482366004614d74565b610b3d565b60975461049a906001600160a01b031681565b6040516001600160a01b039091168152602001610424565b6104ba610b49565b60405160069190910b8152602001610424565b6104726104db366004614da0565b610cb8565b610436610d39565b60d15461049a906001600160a01b031681565b610472610e77565b610472610511366004614dcf565b610e95565b61051e610f36565b6040516104249190614e3c565b609a5461049a906001600160a01b031681565b610413610fc4565b610472610554366004614d1d565b611050565b60995461049a906001600160a01b031681565b610436609c5481565b61057d61118e565b6040516104249190614e4f565b610472610598366004614eab565b611270565b60db546105b490600160501b900463ffffffff1681565b60405163ffffffff9091168152602001610424565b6104726105d7366004614ec8565b611313565b610472611408565b6104726105f2366004614ee1565b6114b5565b610413611567565b610472611674565b61049a61167d565b61043660d65481565b6104366116eb565b60655460ff165b6040519015158152602001610424565b60d35461049a906001600160a01b031681565b610472610658366004614ee1565b61178a565b6000610436565b60db546104ba906301000000900460060b81565b610472611840565b610413611852565b610472610696366004614f03565b6118fe565b60db5461044c9060020b81565b610436609f5481565b60d45461049a906001600160a01b031681565b610436611b97565b6033546001600160a01b031661049a565b61049a611c0b565b61043660d55481565b61051e611c55565b60da5461070f90600281810b9163010000009004900b82565b60408051600293840b81529190920b602082015201610424565b610627611c62565b610436611d0a565b610436611df4565b61049a611e2d565b610751611e77565b6040516104249190614fc7565b610472611ea7565b61049a612093565b60d95461070f90600281810b9163010000009004900b82565b609b5461049a906001600160a01b031681565b60d25461049a906001600160a01b031681565b61057d61210d565b6104726107c3366004614d74565b61213c565b6104726121b5565b6104726122b8565b6104726107e63660046150dc565b6122fc565b6104726107f9366004614d74565b6123a9565b610806612415565b604080519485526020850193909352918301526060820152608001610424565b610413612431565b610436609e5481565b610472610845366004614d74565b6124a0565b60985461049a906001600160a01b031681565b610865612516565b604080519687526020870195909552938501929092526060840152608083015260a082015260c001610424565b60d3546040516370a0823160e01b815230600482015260009182916001600160a01b03909116906370a0823190602401602060405180830381865afa1580156108df573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610903919061516f565b60d4546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa15801561094b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061096f919061516f565b915091509091565b60d15460408051633850c7bd60e01b815290516000926001600160a01b031691633850c7bd9160048083019260e09291908290030181865afa1580156109c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109e591906151aa565b50939695505050505050565b6109f9612713565b8015610b39576000610a4083838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061276d92505050565b60d45481519192506001600160a01b0316908290600090610a6357610a63615237565b60200260200101516001600160a01b031614610a925760405163b4fa3fb360e01b815260040160405180910390fd5b60975481516001600160a01b03909116908290610ab190600190615263565b81518110610ac157610ac1615237565b60200260200101516001600160a01b031614610af0576040516398f7360960e01b815260040160405180910390fd5b60d8610afd8385836152f8565b507f1b9728f4ac995937074d8e70e21a1660544fb7c16be984e1c289f262f2be9c748383604051610b2f9291906153b8565b60405180910390a1505b5050565b610b468161286e565b50565b6040805160028082526060820183526000928392919060208301908036833701905050905060db600a9054906101000a900463ffffffff1681600081518110610b9457610b94615237565b602002602001019063ffffffff16908163ffffffff1681525050600081600181518110610bc357610bc3615237565b63ffffffff9092166020928302919091019091015260d15460405163883bdbfd60e01b81526000916001600160a01b03169063883bdbfd90610c099085906004016153e7565b600060405180830381865afa158015610c26573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610c4e91908101906154bc565b50905060db600a9054906101000a900463ffffffff1660030b81600081518110610c7a57610c7a615237565b602002602001015182600181518110610c9557610c95615237565b6020026020010151610ca79190615581565b610cb191906155c4565b9250505090565b610cc0612713565b60db5460408051600292830b81529183900b60208301527f69d927977053f4ff4a26e8d792564e367e844a869cda4df12630bf7b62a632de910160405180910390a1610d0a612918565b50505050610d16612d17565b60db805462ffffff191662ffffff8316179055610d31613071565b610b466130c7565b600080600a60d460009054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610db59190615602565b610dc090600a615709565b610dca9190615718565b60975460d4549192506001600160a01b03908116911603610df657610df081600a61572c565b91505090565b60d25460405163cdca175360e01b81526001600160a01b039091169063cdca175390610e299060d8908590600401615743565b6020604051808303816000875af1158015610e48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e6c919061516f565b610df090600a61572c565b610e7f613362565b610e87612918565b50505050610e93612d17565b565b610e9d612713565b60db546040805163ffffffff600160501b9093048316815291831660208301527f86139943149914833c057d2c24f3a3967cce8e6aba2eb12e422500d8a51ffc7b910160405180910390a1603c8163ffffffff161015610f105760405163b4fa3fb360e01b815260040160405180910390fd5b60db805463ffffffff909216600160501b0263ffffffff60501b19909216919091179055565b60d78054610f4390615276565b80601f0160208091040260200160405190810160405280929190818152602001828054610f6f90615276565b8015610fbc5780601f10610f9157610100808354040283529160200191610fbc565b820191906000526020600020905b815481529060010190602001808311610f9f57829003601f168201915b505050505081565b60d954604080513060601b6bffffffffffffffffffffffff1916602080830182905260e885811b6034850152630100000095869004811b60378501528451601a818603018152603a8501865280519083012060da54605a86019490945283821b606e8601529590920490911b607183015282516054818403018152607490920190925280519101209091565b611058612713565b8015610b3957600061109f83838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061276d92505050565b60d35481519192506001600160a01b03169082906000906110c2576110c2615237565b60200260200101516001600160a01b0316146110f15760405163b4fa3fb360e01b815260040160405180910390fd5b60975481516001600160a01b0390911690829061111090600190615263565b8151811061112057611120615237565b60200260200101516001600160a01b03161461114f576040516398f7360960e01b815260040160405180910390fd5b60d761115c8385836152f8565b507f203244158601764729526c0736d6b833b1f3da905ae0a631a059bbb9040541f08383604051610b2f9291906153b8565b606060d7805461119d90615276565b90506000036111d85760005b6040519080825280602002602001820160405280156111d2578160200160208202803683370190505b50905090565b61126b60d780546111e890615276565b80601f016020809104026020016040519081016040528092919081815260200182805461121490615276565b80156112615780601f1061123657610100808354040283529160200191611261565b820191906000526020600020905b81548152906001019060200180831161124457829003601f168201915b505050505061276d565b905090565b611278612713565b604051600682900b81527f69d3f73bfb3c2f0de63dc1de2ed486cf45d88ebfff8cb1e8f124b085d2bafb979060200160405180910390a16112b761338d565b6112c29060046157da565b60020b8160060b126112e75760405163b4fa3fb360e01b815260040160405180910390fd5b60db805466ffffffffffffff90921663010000000269ffffffffffffff00000019909216919091179055565b6033546001600160a01b031633148015906113475750611331611e2d565b6001600160a01b0316336001600160a01b031614155b156113655760405163607e454560e11b815260040160405180910390fd5b61136d61167d565b6001600160a01b0316633e55f932826040518263ffffffff1660e01b815260040161139a91815260200190565b600060405180830381600087803b1580156113b457600080fd5b505af11580156113c8573d6000803e3d6000fd5b505050507f9163810ee1e29168d4ce900e48a333fb8fbd3fd070d2bef67f6d4db0846a469f816040516113fd91815260200190565b60405180910390a150565b6033546001600160a01b0316331480159061143c5750611426611e2d565b6001600160a01b0316336001600160a01b031614155b1561145a5760405163607e454560e11b815260040160405180910390fd5b600061146e6033546001600160a01b031690565b6001600160a01b0316036114955760405163ea8e4eb560e01b815260040160405180910390fd5b61149d6133fb565b6114a5613439565b6114ad613071565b610e936130c7565b6114bd613362565b81156114e05760985460d3546114e0916001600160a01b0391821691168461348b565b80156115035760985460d454611503916001600160a01b0391821691168361348b565b61150b6134ea565b611517576115176130c7565b600080611522611852565b60408051838152602081018390529294509092507f631c4f79c14099a717f4be2f25e6cef89e310b3944ef0e44ea2c0811ebb982a8910160405180910390a150505050565b600080600080611575610892565b91509150600080611584612516565b50505050915091506000828561159a9190615801565b905060006115a88386615801565b90506000609e54426115ba9190615263565b90506000610e1082106115ce5760006115da565b6115da82610e10615263565b9050609c5484111561160857610e1081609c546115f7919061572c565b6116019190615718565b9950611622565b610e10611615828661572c565b61161f9190615718565b99505b609d5483111561164e57610e1081609d5461163d919061572c565b6116479190615718565b9850611668565b610e1061165b828561572c565b6116659190615718565b98505b50505050505050509091565b610e933261286e565b609b5460408051634746fb5560e01b815290516000926001600160a01b031691634746fb559160048083019260209291908290030181865afa1580156116c7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061126b9190615814565b6000620f4240670de0b6b3a764000060d160009054906101000a90046001600160a01b03166001600160a01b031663ddca3f436040518163ffffffff1660e01b8152600401602060405180830381865afa15801561174d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117719190615831565b62ffffff16611780919061572c565b61126b9190615718565b6033546001600160a01b031633148015906117be57506117a8611e2d565b6001600160a01b0316336001600160a01b031614155b156117dc5760405163607e454560e11b815260040160405180910390fd5b6117e4612918565b505050506117f0612d17565b6117f8613575565b6118006135b1565b60008061180b611852565b915091508382108061181c57508281105b1561183a5760405163fa6ad35560e01b815260040160405180910390fd5b50505050565b611848612713565b610e9360006135ee565b600080600080611860610892565b9150915060008061186f612516565b5050505091509150600080611882611567565b90925090506000826118948689615801565b61189e9190615263565b90506000826118ad8689615801565b6118b79190615263565b60d55460d65491925090838211156118cd578391505b828111156118d85750815b6118e28285615263565b6118ec8285615263565b9b509b50505050505050505050509091565b600054610100900460ff161580801561191e5750600054600160ff909116105b806119385750303b158015611938575060005460ff166001145b6119a05760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff1916600117905580156119c3576000805461ff0019166101001790555b6119cc82613640565b60d180546001600160a01b03808c166001600160a01b0319928316811790935560d28054918c169190921617905560408051630dfe168160e01b81529051630dfe1681916004808201926020929091908290030181865afa158015611a35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a599190615814565b60d360006101000a8154816001600160a01b0302191690836001600160a01b03160217905550886001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611abd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ae19190615814565b60d480546001600160a01b0319166001600160a01b039290921691909117905560db805462ffffff191662ffffff8916179055611b1e8686611050565b611b2884846109f1565b60db805463ffffffff60501b1916600f60531b179055611b466133fb565b8015611b8c576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050565b6000611ba161167d565b604051636788231160e11b81523060048201526001600160a01b03919091169063cf10462290602401602060405180830381865afa158015611be7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061126b919061516f565b609b5460408051638e14545960e01b815290516000926001600160a01b031691638e1454599160048083019260209291908290030181865afa1580156116c7573d6000803e3d6000fd5b60d88054610f4390615276565b600080611c6d610977565b90506000611c79610b49565b60db54909150600090611ca790611c9a906301000000900460060b84615581565b60060b620d89e7196137b5565b60db54909150600090611cd490611cc8906301000000900460060b85615856565b60060b620d89e86137cf565b90508360020b8260060b1380611cef57508360020b8160060b125b15611cff57600094505050505090565b600194505050505090565b600080600a60d360009054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d869190615602565b611d9190600a615709565b611d9b9190615718565b60975460d3549192506001600160a01b03908116911603611dc157610df081600a61572c565b60d25460405163cdca175360e01b81526001600160a01b039091169063cdca175390610e299060d7908590600401615743565b600080611dff612093565b90506002611e23826001600160a01b0316670de0b6b3a7640000600160601b6137de565b610df09190615709565b609b546040805163aced166160e01b815290516000926001600160a01b03169163aced16619160048083019260209291908290030181865afa1580156116c7573d6000803e3d6000fd5b611e7f614c7a565b6040518060600160405280611e92613892565b81526020016000815260200160009052919050565b611eaf612713565b609860009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f02573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f26919061516f565b6103e814611f475760405163ea8e4eb560e01b815260040160405180910390fd5b611f5260008061178a565b6000611f5c611c0b565b9050600080611f69610892565b90925090508115611ff95760d3546040516370a0823160e01b8152306004820152611ff99185916001600160a01b03909116906370a0823190602401602060405180830381865afa158015611fc2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fe6919061516f565b60d3546001600160a01b0316919061348b565b80156120845760d4546040516370a0823160e01b81523060048201526120849185916001600160a01b03909116906370a0823190602401602060405180830381865afa15801561204d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612071919061516f565b60d4546001600160a01b0316919061348b565b61208e60006135ee565b505050565b60d15460408051633850c7bd60e01b815290516000926001600160a01b031691633850c7bd9160048083019260e09291908290030181865afa1580156120dd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061210191906151aa565b50949695505050505050565b606060d8805461211c90615276565b905060000361212c5760006111a9565b61126b60d880546111e890615276565b609a546001600160a01b0316331461216757604051633163ba6d60e11b815260040160405180910390fd5b609a80546001600160a01b0319166001600160a01b0383169081179091556040519081527f46d58e3fa07bf19b1d27240f0e286b27e9f7c1b0d88933333fe833b60eec5412906020016113fd565b6121bd613943565b609b546040516305226abd60e51b81523360048201526001600160a01b039091169063a44d57a090602401602060405180830381865afa158015612205573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122299190615883565b6122465760405163ea8e4eb560e01b815260040160405180910390fd5b61224e612918565b5050505061225a612d17565b612262613071565b61226a6130c7565b600080612275611852565b60408051838152602081018390529294509092507f631c4f79c14099a717f4be2f25e6cef89e310b3944ef0e44ea2c0811ebb982a8910160405180910390a15050565b6122c0613943565b6122c8613362565b60db54600160781b900460ff16612262576122e1613071565b60db805460ff60781b1916600160781b17905561226a6130c7565b60d1546001600160a01b0316331461232757604051636f61f64160e01b815260040160405180910390fd5b60db54600160701b900460ff166123515760405163887efaa560e01b815260040160405180910390fd5b82156123745760d15460d354612374916001600160a01b0391821691168561348b565b81156123975760d15460d454612397916001600160a01b0391821691168461348b565b505060db805460ff60701b1916905550565b6123b1612713565b6123b9613575565b609980546001600160a01b0319166001600160a01b0383161790556123dc6133fb565b6040516001600160a01b03821681527f5ca6e64c4522e68e154aa9372f2c5969cd37d9640e59f66953dc472f54ee86fa906020016113fd565b600080600080612423612918565b929791965094509092509050565b60d95460009081906002906124679061244b90830b613968565b6001600160a01b0316670de0b6b3a7640000600160601b6137de565b6124719190615709565b60d9549092506002906124909061244b9063010000009004830b613968565b61249a9190615709565b90509091565b6124a8612713565b6001600160a01b03811661250d5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401611997565b610b46816135ee565b60008060008060008060008061252a610fc4565b915091506000612538612093565b60d15460405163514ea4bf60e01b815260048101869052919250600091829182916001600160a01b039091169063514ea4bf9060240160a060405180830381865afa15801561258b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125af91906158b5565b60d15460405163514ea4bf60e01b8152600481018c90529598506001600160801b039283169750911694506000938493508392506001600160a01b039091169063514ea4bf9060240160a060405180830381865afa158015612615573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061263991906158b5565b60d9549497506001600160801b03918216965016935061267f928a9250612663915060020b613968565b60d954612679906301000000900460020b613968565b89613c9e565b60da54919e509c506126b59088906126999060020b613968565b60da546126af906301000000900460020b613968565b86613c9e565b909b5099506126c4858e615801565b9c506126d0848d615801565b9b506126dc828c615801565b9a506126e8818b615801565b99506126f48b8e615801565b9e506127008a8d615801565b9d50505050505050505050909192939495565b6033546001600160a01b03163314610e935760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401611997565b6060600061277a83613d3a565b90506000612789826001615801565b67ffffffffffffffff8111156127a1576127a1615044565b6040519080825280602002602001820160405280156127ca578160200160208202803683370190505b50905060005b82811015612866576000806127e487613d60565b5091509150818484815181106127fc576127fc615237565b6001600160a01b03909216602092830291909101909101528084612821856001615801565b8151811061283157612831615237565b60200260200101906001600160a01b031690816001600160a01b03168152505061285a87613d9c565b965050506001016127d0565b509392505050565b612876612918565b50505050612882612d17565b6000806128948360d55460d654613dcd565b915091506128a06130c7565b600060d581905560d6819055806128b5611567565b90925090506128c48285615801565b609c556128d18184615801565b609d5542609e5560408051858152602081018590527f6c8433a8e155f0af04dba058d4e4695f7da554578963d876bdf4a6d8d6399d9c910160405180910390a15050505050565b600080600080600080612929610fc4565b60d15460405163514ea4bf60e01b8152600481018490529294509092506000916001600160a01b039091169063514ea4bf9060240160a060405180830381865afa15801561297b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061299f91906158b5565b505060d15460405163514ea4bf60e01b8152600481018790529394506000936001600160a01b03909116925063514ea4bf915060240160a060405180830381865afa1580156129f2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a1691906158b5565b5050505090506000826001600160801b03161115612ab75760d15460d95460405163a34123a760e01b81526001600160a01b039092169163a34123a791612a7291600282810b9263010000009004900b9060009060040161590c565b60408051808303816000875af1158015612a90573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ab49190615932565b50505b6001600160801b03811615612b4f5760d15460da5460405163a34123a760e01b81526001600160a01b039092169163a34123a791612b0a91600282810b9263010000009004900b9060009060040161590c565b60408051808303816000875af1158015612b28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b4c9190615932565b50505b60d15460d9546040516309e3d67b60e31b81526001600160a01b0390921691634f1eb3d891612b9e913091600281810b926301000000909204900b906001600160801b03908190600401615956565b60408051808303816000875af1158015612bbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612be09190615993565b60d15460da546040516309e3d67b60e31b81526001600160801b039485169c509284169a506001600160a01b0390911692634f1eb3d892612c38923092600282810b936301000000909304900b918190600401615956565b60408051808303816000875af1158015612c56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c7a9190615993565b60d5546001600160801b039283169850911695508690612c9b908a90615801565b612ca59190615801565b60d55560d6548590612cb8908990615801565b612cc29190615801565b60d6556040805189815260208101899052908101879052606081018690527f6fe7c663aa15def6e80578b76ddd894fcefeabf14a0106afbec24da4a6c578729060800160405180910390a15050505090919293565b600080612d22610fc4565b60d15460405163514ea4bf60e01b8152600481018490529294509092506000916001600160a01b039091169063514ea4bf9060240160a060405180830381865afa158015612d74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d9891906158b5565b505060d15460405163514ea4bf60e01b8152600481018790529394506000936001600160a01b03909116925063514ea4bf915060240160a060405180830381865afa158015612deb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e0f91906158b5565b5050505090506000826001600160801b03161115612f425760d15460d95460405163a34123a760e01b81526001600160a01b039092169163a34123a791612e6a91600282810b9263010000009004900b90879060040161590c565b60408051808303816000875af1158015612e88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eac9190615932565b505060d15460d9546040516309e3d67b60e31b81526001600160a01b0390921691634f1eb3d891612efd913091600281810b926301000000909204900b906001600160801b03908190600401615956565b60408051808303816000875af1158015612f1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f3f9190615993565b50505b6001600160801b0381161561183a5760d15460da5460405163a34123a760e01b81526001600160a01b039092169163a34123a791612f9491600282810b9263010000009004900b90869060040161590c565b60408051808303816000875af1158015612fb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fd69190615932565b505060d15460da546040516309e3d67b60e31b81526001600160a01b0390921691634f1eb3d891613027913091600281810b926301000000909204900b906001600160801b03908190600401615956565b60408051808303816000875af1158015613045573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130699190615993565b505050505050565b613079613943565b6000613083610977565b9050600061308f61338d565b60db549091506000906130a690839060020b6157da565b90506130b383838361410d565b6130be838383614148565b505042609f5550565b6130cf614298565b6000806130da610892565b9150915060006130e8612093565b60d9549091506000906131209083906131039060020b613968565b60d954613119906301000000900460020b613968565b8787614339565b60d954909150600090613143908390600281810b9163010000009004900b6143fd565b90506000826001600160801b031611801561315b5750805b156132345760db805460ff60701b1916600160701b17905560d15460d954604051633c8a7d8d60e01b8152306004820152600282810b6024830152630100000090920490910b60448201526001600160801b038416606482015260a06084820152600a60a4820152692132b2b33c9026b0b4b760b11b60c48201526001600160a01b0390911690633c8a7d8d9060e40160408051808303816000875af1158015613209573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061322d9190615932565b505061323c565b61323c613943565b613244610892565b60da54919650945061327b90849061325e9060020b613968565b60da54613274906301000000900460020b613968565b8888614339565b91506001600160801b0382161561335b5760db805460ff60701b1916600160701b17905560d15460da54604051633c8a7d8d60e01b8152306004820152600282810b6024830152630100000090920490910b60448201526001600160801b038416606482015260a06084820152600960a482015268109959599e48105b1d60ba1b60c48201526001600160a01b0390911690633c8a7d8d9060e40160408051808303816000875af1158015613334573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133589190615932565b50505b5050505050565b6098546001600160a01b03163314610e93576040516362df054560e01b815260040160405180910390fd5b60d154604080516334324e9f60e21b815290516000926001600160a01b03169163d0c93a7c9160048083019260209291908290030181865afa1580156133d7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061126b91906159c6565b60995460d35461341a916001600160a01b03918216911660001961444b565b60995460d454610e93916001600160a01b03918216911660001961444b565b6134416144db565b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6040516001600160a01b0383811660248301526044820183905261208e91859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050614524565b60006134f860655460ff1690565b8061126b5750609b60009054906101000a90046001600160a01b03166001600160a01b031663f12d54d86040518163ffffffff1660e01b8152600401602060405180830381865afa158015613551573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061126b9190615883565b60995460d354613593916001600160a01b039182169116600061444b565b60995460d454610e93916001600160a01b039182169116600061444b565b6135b9614587565b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861346e3390565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff166136675760405162461bcd60e51b8152600401611997906159e3565b61366f6145cd565b6136776145fc565b6136846020820182614d74565b609880546001600160a01b0319166001600160a01b03929092169190911790556136b46040820160208301614d74565b609980546001600160a01b0319166001600160a01b03929092169190911790556136e46060820160408301614d74565b609a80546001600160a01b0319166001600160a01b03929092169190911790556137146080820160608301614d74565b609b80546001600160a01b0319166001600160a01b03929092169182179055604080516311b0b42d60e01b815290516311b0b42d916004808201926020929091908290030181865afa15801561376e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137929190615814565b609780546001600160a01b0319166001600160a01b039290921691909117905550565b60008183136137c457816137c6565b825b90505b92915050565b60008183126137c457816137c6565b6000808060001985870985870292508281108382030391505080600003613817576000841161380c57600080fd5b50829004905061388b565b80841161382357600080fd5b600084868809851960019081018716968790049682860381900495909211909303600082900391909104909201919091029190911760038402600290811880860282030280860282030280860282030280860282030280860282030280860290910302029150505b9392505050565b6138cd6040518060c0016040528060008152602001600081526020016000815260200160008152602001606081526020016000151581525090565b6138d561167d565b604051639af608c960e01b81523060048201526001600160a01b039190911690639af608c990602401600060405180830381865afa15801561391b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261126b9190810190615a2e565b61394b611c62565b610e93576040516313643c3b60e11b815260040160405180910390fd5b60008060008360020b1261397f578260020b613987565b8260020b6000035b9050620d89e88111156139c05760405162461bcd60e51b81526020600482015260016024820152601560fa1b6044820152606401611997565b6000816001166000036139d757600160801b6139e9565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff1690506002821615613a1d576ffff97272373d413259a46990580e213a0260801c5b6004821615613a3c576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b6008821615613a5b576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615613a7a576fffcb9843d60f6159c9db58835c9266440260801c5b6020821615613a99576fff973b41fa98c081472e6896dfb254c00260801c5b6040821615613ab8576fff2ea16466c96a3843ec78b326b528610260801c5b6080821615613ad7576ffe5dee046a99a2a811c461f1969c30530260801c5b610100821615613af7576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b610200821615613b17576ff987a7253ac413176f2b074cf7815e540260801c5b610400821615613b37576ff3392b0822b70005940c7a398e4b70f30260801c5b610800821615613b57576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615613b77576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615613b97576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615613bb7576f70d869a156d2a1b890bb3df62baf32f70260801c5b618000821615613bd7576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615613bf8576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b62020000821615613c18576e5d6af8dedb81196699c329225ee6040260801c5b62040000821615613c37576d2216e584f5fa1ea926041bedfe980260801c5b62080000821615613c54576b048a170391f7dc42444e8fa20260801c5b60008460020b1315613c75578060001981613c7157613c716155ae565b0490505b640100000000810615613c89576001613c8c565b60005b60ff16602082901c0192505050919050565b600080836001600160a01b0316856001600160a01b03161115613cbf579293925b846001600160a01b0316866001600160a01b031611613cea57613ce385858561462b565b9150613d31565b836001600160a01b0316866001600160a01b03161015613d2357613d0f86858561462b565b9150613d1c8587856146a6565b9050613d31565b613d2e8585856146a6565b90505b94509492505050565b6000613d4860036014615801565b60148351613d569190615263565b6137c99190615718565b60008080613d6e84826146f0565b9250613d7b846014614755565b9050613d93613d8c60036014615801565b85906146f0565b91509193909250565b60606137c9613dad60036014615801565b613db960036014615801565b8451613dc59190615263565b849190614800565b6000806000613dda613892565b905060008515613ef1578151600090670de0b6b3a764000090613dfd908961572c565b613e079190615718565b9050613e138188615263565b60975460d3549196506000916001600160a01b03908116911614613eb85760995460d354609754604051630df791e560e41b81526001600160a01b03928316600482015290821660248201526044810185905291169063df791e50906064016020604051808303816000875af1158015613e91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613eb5919061516f565b90505b60975460d3546001600160a01b03918216911603613ee157613eda8284615801565b9250613eee565b613eeb8184615801565b92505b50505b8415614004578151600090670de0b6b3a764000090613f10908861572c565b613f1a9190615718565b9050613f268187615263565b60975460d4549195506000916001600160a01b03908116911614613fcb5760995460d454609754604051630df791e560e41b81526001600160a01b03928316600482015290821660248201526044810185905291169063df791e50906064016020604051808303816000875af1158015613fa4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fc8919061516f565b90505b60975460d4546001600160a01b03918216911603613ff457613fed8284615801565b9250614001565b613ffe8184615801565b92505b50505b6000670de0b6b3a764000083604001518361401f919061572c565b6140299190615718565b609754909150614043906001600160a01b0316898361348b565b6000670de0b6b3a764000084606001518461405e919061572c565b6140689190615718565b609a54609754919250614088916001600160a01b0390811691168361348b565b6000816140958486615263565b61409f9190615263565b90506140bf6140ac611c0b565b6097546001600160a01b0316908361348b565b60408051848152602081018390529081018390527fd255b592c7f268a73e534da5219a60ff911b4cf6daae21c7d20527dd657bd99a9060600160405180910390a15050505050935093915050565b61411883828461490d565b60d9805465ffffffffffff1916630100000062ffffff9384160262ffffff19161792909116919091179055505050565b600080614153610892565b90925090506000821561418f576ec097ce7bc90715b34b9f1000000000614178611df4565b614182908561572c565b61418c9190615718565b90505b818110156141ee576141a286858761490d565b5060da805462ffffff191662ffffff929092169190911790556141c686868061490d565b5060da805462ffffff90921663010000000265ffffff00000019909216919091179055614249565b808210156142495761420186868761490d565b60da805462ffffff191662ffffff929092169190911790555061422586858761490d565b60da805462ffffff90921663010000000265ffffff00000019909216919091179055505b60da5460d954600291820b910b14801561427a575060da5460d954630100000091829004600290810b92909104900b145b1561306957604051631434ed7f60e01b815260040160405180910390fd5b60655460ff168061431b5750609b60009054906101000a90046001600160a01b03166001600160a01b031663f12d54d86040518163ffffffff1660e01b8152600401602060405180830381865afa1580156142f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061431b9190615883565b15610e935760405163e628b94960e01b815260040160405180910390fd5b6000836001600160a01b0316856001600160a01b03161115614359579293925b846001600160a01b0316866001600160a01b0316116143845761437d85858561493f565b90506143f4565b836001600160a01b0316866001600160a01b031610156143e65760006143ab87868661493f565b905060006143ba8789866149a9565b9050806001600160801b0316826001600160801b0316106143db57806143dd565b815b925050506143f4565b6143f18585846149a9565b90505b95945050505050565b600080600061441f61440d612093565b61441687613968565b61267987613968565b915091508160001480614430575080155b156144405760009250505061388b565b60019250505061388b565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b17905261449c84826149df565b61183a576040516001600160a01b038481166024830152600060448301526144d191869182169063095ea7b3906064016134b8565b61183a8482614524565b60655460ff16610e935760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401611997565b60006145396001600160a01b03841683614a82565b9050805160001415801561455e57508080602001905181019061455c9190615883565b155b1561208e57604051635274afe760e01b81526001600160a01b0384166004820152602401611997565b60655460ff1615610e935760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401611997565b600054610100900460ff166145f45760405162461bcd60e51b8152600401611997906159e3565b610e93614a90565b600054610100900460ff166146235760405162461bcd60e51b8152600401611997906159e3565b610e93614ac0565b6000826001600160a01b0316846001600160a01b0316111561464b579192915b6001600160a01b0384166146946fffffffffffffffffffffffffffffffff60601b606085901b1661467c8787615b0c565b6001600160a01b0316866001600160a01b03166137de565b61469e9190615718565b949350505050565b6000826001600160a01b0316846001600160a01b031611156146c6579192915b61469e6001600160801b0383166146dd8686615b0c565b6001600160a01b0316600160601b6137de565b60006146fd826014615801565b835110156147455760405162461bcd60e51b8152602060048201526015602482015274746f416464726573735f6f75744f66426f756e647360581b6044820152606401611997565b500160200151600160601b900490565b600081614763816003615801565b10156147a55760405162461bcd60e51b8152602060048201526011602482015270746f55696e7432345f6f766572666c6f7760781b6044820152606401611997565b6147b0826003615801565b835110156147f75760405162461bcd60e51b8152602060048201526014602482015273746f55696e7432345f6f75744f66426f756e647360601b6044820152606401611997565b50016003015190565b60608161480e81601f615801565b101561484d5760405162461bcd60e51b815260206004820152600e60248201526d736c6963655f6f766572666c6f7760901b6044820152606401611997565b6148578284615801565b8451101561489b5760405162461bcd60e51b8152602060048201526011602482015270736c6963655f6f75744f66426f756e647360781b6044820152606401611997565b6060821580156148ba5760405191506000825260208201604052614904565b6040519150601f8416801560200281840101858101878315602002848b0101015b818310156148f35780518352602092830192016148db565b5050858452601f01601f1916604052505b50949350505050565b600080600061491c8685614af3565b90506149288582615b2c565b92506149348582615b51565b915050935093915050565b6000826001600160a01b0316846001600160a01b0316111561495f579192915b6000614982856001600160a01b0316856001600160a01b0316600160601b6137de565b90506143f46149a484836149968989615b0c565b6001600160a01b03166137de565b614b3d565b6000826001600160a01b0316846001600160a01b031611156149c9579192915b61469e6149a483600160601b6149968888615b0c565b6000806000846001600160a01b0316846040516149fc9190615b76565b6000604051808303816000865af19150503d8060008114614a39576040519150601f19603f3d011682016040523d82523d6000602084013e614a3e565b606091505b5091509150818015614a68575080511580614a68575080806020019051810190614a689190615883565b80156143f45750505050506001600160a01b03163b151590565b60606137c683836000614b58565b600054610100900460ff16614ab75760405162461bcd60e51b8152600401611997906159e3565b610e93336135ee565b600054610100900460ff16614ae75760405162461bcd60e51b8152600401611997906159e3565b6065805460ff19169055565b600080614b008385615b92565b905060008460020b128015614b205750614b1a8385615bc3565b60020b15155b15614b335780614b2f81615be5565b9150505b61469e83826157da565b806001600160801b0381168114614b5357600080fd5b919050565b606081471015614b7d5760405163cd78605960e01b8152306004820152602401611997565b600080856001600160a01b03168486604051614b999190615b76565b60006040518083038185875af1925050503d8060008114614bd6576040519150601f19603f3d011682016040523d82523d6000602084013e614bdb565b606091505b5091509150614beb868383614bf5565b9695505050505050565b606082614c0a57614c0582614c51565b61388b565b8151158015614c2157506001600160a01b0384163b155b15614c4a57604051639996b31560e01b81526001600160a01b0385166004820152602401611997565b508061388b565b805115614c615780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b6040518060600160405280614cc06040518060c0016040528060008152602001600081526020016000815260200160008152602001606081526020016000151581525090565b815260200160008152602001600081525090565b60008083601f840112614ce657600080fd5b50813567ffffffffffffffff811115614cfe57600080fd5b602083019150836020828501011115614d1657600080fd5b9250929050565b60008060208385031215614d3057600080fd5b823567ffffffffffffffff811115614d4757600080fd5b614d5385828601614cd4565b90969095509350505050565b6001600160a01b0381168114610b4657600080fd5b600060208284031215614d8657600080fd5b813561388b81614d5f565b8060020b8114610b4657600080fd5b600060208284031215614db257600080fd5b813561388b81614d91565b63ffffffff81168114610b4657600080fd5b600060208284031215614de157600080fd5b813561388b81614dbd565b60005b83811015614e07578181015183820152602001614def565b50506000910152565b60008151808452614e28816020860160208601614dec565b601f01601f19169290920160200192915050565b6020815260006137c66020830184614e10565b6020808252825182820181905260009190848201906040850190845b81811015614e905783516001600160a01b031683529284019291840191600101614e6b565b50909695505050505050565b8060060b8114610b4657600080fd5b600060208284031215614ebd57600080fd5b813561388b81614e9c565b600060208284031215614eda57600080fd5b5035919050565b60008060408385031215614ef457600080fd5b50508035926020909101359150565b600080600080600080600080888a03610120811215614f2157600080fd5b8935614f2c81614d5f565b985060208a0135614f3c81614d5f565b975060408a0135614f4c81614d91565b965060608a013567ffffffffffffffff80821115614f6957600080fd5b614f758d838e01614cd4565b909850965060808c0135915080821115614f8e57600080fd5b50614f9b8c828d01614cd4565b9095509350506080609f1982011215614fb357600080fd5b5060a0890190509295985092959890939650565b60208152600082516060602084015280516080840152602081015160a0840152604081015160c0840152606081015160e0840152608081015160c0610100850152615016610140850182614e10565b905060a082015115156101208501526020850151604085015260408501516060850152809250505092915050565b634e487b7160e01b600052604160045260246000fd5b60405160c0810167ffffffffffffffff8111828210171561507d5761507d615044565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156150ac576150ac615044565b604052919050565b600067ffffffffffffffff8211156150ce576150ce615044565b50601f01601f191660200190565b6000806000606084860312156150f157600080fd5b8335925060208401359150604084013567ffffffffffffffff81111561511657600080fd5b8401601f8101861361512757600080fd5b803561513a615135826150b4565b615083565b81815287602083850101111561514f57600080fd5b816020840160208301376000602083830101528093505050509250925092565b60006020828403121561518157600080fd5b5051919050565b805161ffff81168114614b5357600080fd5b80518015158114614b5357600080fd5b600080600080600080600060e0888a0312156151c557600080fd5b87516151d081614d5f565b60208901519097506151e181614d91565b95506151ef60408901615188565b94506151fd60608901615188565b935061520b60808901615188565b925060a088015161521b81614dbd565b915061522960c0890161519a565b905092959891949750929550565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b818103818111156137c9576137c961524d565b600181811c9082168061528a57607f821691505b6020821081036152aa57634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111561208e576000816000526020600020601f850160051c810160208610156152d95750805b601f850160051c820191505b81811015613069578281556001016152e5565b67ffffffffffffffff83111561531057615310615044565b6153248361531e8354615276565b836152b0565b6000601f84116001811461535857600085156153405750838201355b600019600387901b1c1916600186901b17835561335b565b600083815260209020601f19861690835b828110156153895786850135825560209485019460019092019101615369565b50868210156153a65760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b6020808252825182820181905260009190848201906040850190845b81811015614e9057835163ffffffff1683529284019291840191600101615403565b600067ffffffffffffffff82111561543f5761543f615044565b5060051b60200190565b600082601f83011261545a57600080fd5b8151602061546a61513583615425565b8083825260208201915060208460051b87010193508684111561548c57600080fd5b602086015b848110156154b15780516154a481614d5f565b8352918301918301615491565b509695505050505050565b600080604083850312156154cf57600080fd5b825167ffffffffffffffff808211156154e757600080fd5b818501915085601f8301126154fb57600080fd5b8151602061550b61513583615425565b82815260059290921b8401810191818101908984111561552a57600080fd5b948201945b8386101561555157855161554281614e9c565b8252948201949082019061552f565b9188015191965090935050508082111561556a57600080fd5b5061557785828601615449565b9150509250929050565b600682810b9082900b03667fffffffffffff198112667fffffffffffff821317156137c9576137c961524d565b634e487b7160e01b600052601260045260246000fd5b60008160060b8360060b806155db576155db6155ae565b667fffffffffffff198214600019821416156155f9576155f961524d565b90059392505050565b60006020828403121561561457600080fd5b815160ff8116811461388b57600080fd5b600181815b808511156156605781600019048211156156465761564661524d565b8085161561565357918102915b93841c939080029061562a565b509250929050565b600082615677575060016137c9565b81615684575060006137c9565b816001811461569a57600281146156a4576156c0565b60019150506137c9565b60ff8411156156b5576156b561524d565b50506001821b6137c9565b5060208310610133831016604e8410600b84101617156156e3575081810a6137c9565b6156ed8383615625565b80600019048211156157015761570161524d565b029392505050565b60006137c660ff841683615668565b600082615727576157276155ae565b500490565b80820281158282048414176137c9576137c961524d565b60408152600080845461575581615276565b80604086015260606001808416600081146157775760018114615793576157c5565b60ff1985166060890152606084151560051b89010195506157c5565b8960005260208060002060005b868110156157bb5781548b82018701529084019082016157a0565b8a01606001975050505b50505050506020929092019290925292915050565b60008260020b8260020b028060020b91508082146157fa576157fa61524d565b5092915050565b808201808211156137c9576137c961524d565b60006020828403121561582657600080fd5b815161388b81614d5f565b60006020828403121561584357600080fd5b815162ffffff8116811461388b57600080fd5b600681810b9083900b01667fffffffffffff8113667fffffffffffff19821217156137c9576137c961524d565b60006020828403121561589557600080fd5b6137c68261519a565b80516001600160801b0381168114614b5357600080fd5b600080600080600060a086880312156158cd57600080fd5b6158d68661589e565b945060208601519350604086015192506158f26060870161589e565b91506159006080870161589e565b90509295509295909350565b600293840b81529190920b60208201526001600160801b03909116604082015260600190565b6000806040838503121561594557600080fd5b505080516020909101519092909150565b6001600160a01b03959095168552600293840b60208601529190920b60408401526001600160801b03918216606084015216608082015260a00190565b600080604083850312156159a657600080fd5b6159af8361589e565b91506159bd6020840161589e565b90509250929050565b6000602082840312156159d857600080fd5b815161388b81614d91565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60006020808385031215615a4157600080fd5b825167ffffffffffffffff80821115615a5957600080fd5b9084019060c08287031215615a6d57600080fd5b615a7561505a565b8251815283830151848201526040830151604082015260608301516060820152608083015182811115615aa757600080fd5b83019150601f82018713615aba57600080fd5b8151615ac8615135826150b4565b8181528886838601011115615adc57600080fd5b615aeb82878301888701614dec565b608083015250615afd60a0840161519a565b60a08201529695505050505050565b6001600160a01b038281168282160390808211156157fa576157fa61524d565b600282810b9082900b03627fffff198112627fffff821317156137c9576137c961524d565b600281810b9083900b01627fffff8113627fffff19821217156137c9576137c961524d565b60008251615b88818460208701614dec565b9190910192915050565b60008160020b8360020b80615ba957615ba96155ae565b627fffff198214600019821416156155f9576155f961524d565b60008260020b80615bd657615bd66155ae565b808360020b0791505092915050565b60008160020b627fffff198103615bfe57615bfe61524d565b600019019291505056fea2646970667358221220159c03c9284a01d6db08f1ca7cb67c60de37031451d89ade41e34546febffeeb64736f6c63430008170033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106104065760003560e01c8063715018a611610220578063b3a60cb311610130578063d3487997116100b8578063e97206a911610087578063e97206a914610826578063f1a392da1461082e578063f2fde38b14610837578063fbfa77cf1461084a578063fcc25e131461085d57600080fd5b8063d3487997146107d8578063d92f3d73146107eb578063d9ceab13146107fe578063e941fa781461065d57600080fd5b8063c6bbd5a7116100ff578063c6bbd5a71461079a578063c6ebd4ae146107ad578063c7b9d530146107b5578063c7d54132146107c8578063d0e30db0146107d057600080fd5b8063b3a60cb31461075e578063b83d268314610766578063bc415d8a1461076e578063c45a01551461078757600080fd5b80638e145459116101b35780639bdde46b116101825780639bdde46b146107295780639c6d490414610731578063a035b1fe14610739578063aced166114610741578063b20feaaf1461074957600080fd5b80638e145459146106dd57806393f1c442146106e5578063953d329f146106ee57806399cd2446146106f657600080fd5b8063865238d4116101ef578063865238d4146106a8578063877562b6146106b15780638cfc0250146106c45780638da5cb5b146106cc57600080fd5b8063715018a6146106785780637bb98a68146106805780637f10e4b9146106885780638097e2491461069b57600080fd5b80632b950b661161031b5780634641257d116102ae5780635c975abb1161027d5780635c975abb146106205780635ee167c014610637578063609913461461064a57806367a527931461065d578063696c58e51461066457600080fd5b80634641257d146105ff5780634746fb55146106075780634c02a21c1461060f57806354cf2aeb1461061857600080fd5b80633e55f932116102ea5780633e55f932146105c95780633f4ba83a146105dc578063441a3e70146105e457806344b81396146105f757600080fd5b80632b950b661461056c5780632e773d3214610575578063362c28c61461058a5780633c1d5df01461059d57600080fd5b806316b9cd9c1161039e5780631dcfeddd1161036d5780631dcfeddd146105165780631fe4a6861461052b5780632150c5181461053e578063236db04214610546578063257ae0de1461055957600080fd5b806316b9cd9c146104e057806316f0115b146104e857806317dd7a72146104fb5780631d27050f1461050357600080fd5b80630e5c011e116103da5780630e5c011e1461047457806311b0b42d146104875780631208aa18146104b257806312cf1381146104cd57600080fd5b8062a4b5c91461040b57806304c404b31461042d578063065e53601461044457806308898ea01461045f575b600080fd5b610413610892565b604080519283526020830191909152015b60405180910390f35b610436609d5481565b604051908152602001610424565b61044c610977565b60405160029190910b8152602001610424565b61047261046d366004614d1d565b6109f1565b005b610472610482366004614d74565b610b3d565b60975461049a906001600160a01b031681565b6040516001600160a01b039091168152602001610424565b6104ba610b49565b60405160069190910b8152602001610424565b6104726104db366004614da0565b610cb8565b610436610d39565b60d15461049a906001600160a01b031681565b610472610e77565b610472610511366004614dcf565b610e95565b61051e610f36565b6040516104249190614e3c565b609a5461049a906001600160a01b031681565b610413610fc4565b610472610554366004614d1d565b611050565b60995461049a906001600160a01b031681565b610436609c5481565b61057d61118e565b6040516104249190614e4f565b610472610598366004614eab565b611270565b60db546105b490600160501b900463ffffffff1681565b60405163ffffffff9091168152602001610424565b6104726105d7366004614ec8565b611313565b610472611408565b6104726105f2366004614ee1565b6114b5565b610413611567565b610472611674565b61049a61167d565b61043660d65481565b6104366116eb565b60655460ff165b6040519015158152602001610424565b60d35461049a906001600160a01b031681565b610472610658366004614ee1565b61178a565b6000610436565b60db546104ba906301000000900460060b81565b610472611840565b610413611852565b610472610696366004614f03565b6118fe565b60db5461044c9060020b81565b610436609f5481565b60d45461049a906001600160a01b031681565b610436611b97565b6033546001600160a01b031661049a565b61049a611c0b565b61043660d55481565b61051e611c55565b60da5461070f90600281810b9163010000009004900b82565b60408051600293840b81529190920b602082015201610424565b610627611c62565b610436611d0a565b610436611df4565b61049a611e2d565b610751611e77565b6040516104249190614fc7565b610472611ea7565b61049a612093565b60d95461070f90600281810b9163010000009004900b82565b609b5461049a906001600160a01b031681565b60d25461049a906001600160a01b031681565b61057d61210d565b6104726107c3366004614d74565b61213c565b6104726121b5565b6104726122b8565b6104726107e63660046150dc565b6122fc565b6104726107f9366004614d74565b6123a9565b610806612415565b604080519485526020850193909352918301526060820152608001610424565b610413612431565b610436609e5481565b610472610845366004614d74565b6124a0565b60985461049a906001600160a01b031681565b610865612516565b604080519687526020870195909552938501929092526060840152608083015260a082015260c001610424565b60d3546040516370a0823160e01b815230600482015260009182916001600160a01b03909116906370a0823190602401602060405180830381865afa1580156108df573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610903919061516f565b60d4546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa15801561094b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061096f919061516f565b915091509091565b60d15460408051633850c7bd60e01b815290516000926001600160a01b031691633850c7bd9160048083019260e09291908290030181865afa1580156109c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109e591906151aa565b50939695505050505050565b6109f9612713565b8015610b39576000610a4083838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061276d92505050565b60d45481519192506001600160a01b0316908290600090610a6357610a63615237565b60200260200101516001600160a01b031614610a925760405163b4fa3fb360e01b815260040160405180910390fd5b60975481516001600160a01b03909116908290610ab190600190615263565b81518110610ac157610ac1615237565b60200260200101516001600160a01b031614610af0576040516398f7360960e01b815260040160405180910390fd5b60d8610afd8385836152f8565b507f1b9728f4ac995937074d8e70e21a1660544fb7c16be984e1c289f262f2be9c748383604051610b2f9291906153b8565b60405180910390a1505b5050565b610b468161286e565b50565b6040805160028082526060820183526000928392919060208301908036833701905050905060db600a9054906101000a900463ffffffff1681600081518110610b9457610b94615237565b602002602001019063ffffffff16908163ffffffff1681525050600081600181518110610bc357610bc3615237565b63ffffffff9092166020928302919091019091015260d15460405163883bdbfd60e01b81526000916001600160a01b03169063883bdbfd90610c099085906004016153e7565b600060405180830381865afa158015610c26573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610c4e91908101906154bc565b50905060db600a9054906101000a900463ffffffff1660030b81600081518110610c7a57610c7a615237565b602002602001015182600181518110610c9557610c95615237565b6020026020010151610ca79190615581565b610cb191906155c4565b9250505090565b610cc0612713565b60db5460408051600292830b81529183900b60208301527f69d927977053f4ff4a26e8d792564e367e844a869cda4df12630bf7b62a632de910160405180910390a1610d0a612918565b50505050610d16612d17565b60db805462ffffff191662ffffff8316179055610d31613071565b610b466130c7565b600080600a60d460009054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610db59190615602565b610dc090600a615709565b610dca9190615718565b60975460d4549192506001600160a01b03908116911603610df657610df081600a61572c565b91505090565b60d25460405163cdca175360e01b81526001600160a01b039091169063cdca175390610e299060d8908590600401615743565b6020604051808303816000875af1158015610e48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e6c919061516f565b610df090600a61572c565b610e7f613362565b610e87612918565b50505050610e93612d17565b565b610e9d612713565b60db546040805163ffffffff600160501b9093048316815291831660208301527f86139943149914833c057d2c24f3a3967cce8e6aba2eb12e422500d8a51ffc7b910160405180910390a1603c8163ffffffff161015610f105760405163b4fa3fb360e01b815260040160405180910390fd5b60db805463ffffffff909216600160501b0263ffffffff60501b19909216919091179055565b60d78054610f4390615276565b80601f0160208091040260200160405190810160405280929190818152602001828054610f6f90615276565b8015610fbc5780601f10610f9157610100808354040283529160200191610fbc565b820191906000526020600020905b815481529060010190602001808311610f9f57829003601f168201915b505050505081565b60d954604080513060601b6bffffffffffffffffffffffff1916602080830182905260e885811b6034850152630100000095869004811b60378501528451601a818603018152603a8501865280519083012060da54605a86019490945283821b606e8601529590920490911b607183015282516054818403018152607490920190925280519101209091565b611058612713565b8015610b3957600061109f83838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061276d92505050565b60d35481519192506001600160a01b03169082906000906110c2576110c2615237565b60200260200101516001600160a01b0316146110f15760405163b4fa3fb360e01b815260040160405180910390fd5b60975481516001600160a01b0390911690829061111090600190615263565b8151811061112057611120615237565b60200260200101516001600160a01b03161461114f576040516398f7360960e01b815260040160405180910390fd5b60d761115c8385836152f8565b507f203244158601764729526c0736d6b833b1f3da905ae0a631a059bbb9040541f08383604051610b2f9291906153b8565b606060d7805461119d90615276565b90506000036111d85760005b6040519080825280602002602001820160405280156111d2578160200160208202803683370190505b50905090565b61126b60d780546111e890615276565b80601f016020809104026020016040519081016040528092919081815260200182805461121490615276565b80156112615780601f1061123657610100808354040283529160200191611261565b820191906000526020600020905b81548152906001019060200180831161124457829003601f168201915b505050505061276d565b905090565b611278612713565b604051600682900b81527f69d3f73bfb3c2f0de63dc1de2ed486cf45d88ebfff8cb1e8f124b085d2bafb979060200160405180910390a16112b761338d565b6112c29060046157da565b60020b8160060b126112e75760405163b4fa3fb360e01b815260040160405180910390fd5b60db805466ffffffffffffff90921663010000000269ffffffffffffff00000019909216919091179055565b6033546001600160a01b031633148015906113475750611331611e2d565b6001600160a01b0316336001600160a01b031614155b156113655760405163607e454560e11b815260040160405180910390fd5b61136d61167d565b6001600160a01b0316633e55f932826040518263ffffffff1660e01b815260040161139a91815260200190565b600060405180830381600087803b1580156113b457600080fd5b505af11580156113c8573d6000803e3d6000fd5b505050507f9163810ee1e29168d4ce900e48a333fb8fbd3fd070d2bef67f6d4db0846a469f816040516113fd91815260200190565b60405180910390a150565b6033546001600160a01b0316331480159061143c5750611426611e2d565b6001600160a01b0316336001600160a01b031614155b1561145a5760405163607e454560e11b815260040160405180910390fd5b600061146e6033546001600160a01b031690565b6001600160a01b0316036114955760405163ea8e4eb560e01b815260040160405180910390fd5b61149d6133fb565b6114a5613439565b6114ad613071565b610e936130c7565b6114bd613362565b81156114e05760985460d3546114e0916001600160a01b0391821691168461348b565b80156115035760985460d454611503916001600160a01b0391821691168361348b565b61150b6134ea565b611517576115176130c7565b600080611522611852565b60408051838152602081018390529294509092507f631c4f79c14099a717f4be2f25e6cef89e310b3944ef0e44ea2c0811ebb982a8910160405180910390a150505050565b600080600080611575610892565b91509150600080611584612516565b50505050915091506000828561159a9190615801565b905060006115a88386615801565b90506000609e54426115ba9190615263565b90506000610e1082106115ce5760006115da565b6115da82610e10615263565b9050609c5484111561160857610e1081609c546115f7919061572c565b6116019190615718565b9950611622565b610e10611615828661572c565b61161f9190615718565b99505b609d5483111561164e57610e1081609d5461163d919061572c565b6116479190615718565b9850611668565b610e1061165b828561572c565b6116659190615718565b98505b50505050505050509091565b610e933261286e565b609b5460408051634746fb5560e01b815290516000926001600160a01b031691634746fb559160048083019260209291908290030181865afa1580156116c7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061126b9190615814565b6000620f4240670de0b6b3a764000060d160009054906101000a90046001600160a01b03166001600160a01b031663ddca3f436040518163ffffffff1660e01b8152600401602060405180830381865afa15801561174d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117719190615831565b62ffffff16611780919061572c565b61126b9190615718565b6033546001600160a01b031633148015906117be57506117a8611e2d565b6001600160a01b0316336001600160a01b031614155b156117dc5760405163607e454560e11b815260040160405180910390fd5b6117e4612918565b505050506117f0612d17565b6117f8613575565b6118006135b1565b60008061180b611852565b915091508382108061181c57508281105b1561183a5760405163fa6ad35560e01b815260040160405180910390fd5b50505050565b611848612713565b610e9360006135ee565b600080600080611860610892565b9150915060008061186f612516565b5050505091509150600080611882611567565b90925090506000826118948689615801565b61189e9190615263565b90506000826118ad8689615801565b6118b79190615263565b60d55460d65491925090838211156118cd578391505b828111156118d85750815b6118e28285615263565b6118ec8285615263565b9b509b50505050505050505050509091565b600054610100900460ff161580801561191e5750600054600160ff909116105b806119385750303b158015611938575060005460ff166001145b6119a05760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff1916600117905580156119c3576000805461ff0019166101001790555b6119cc82613640565b60d180546001600160a01b03808c166001600160a01b0319928316811790935560d28054918c169190921617905560408051630dfe168160e01b81529051630dfe1681916004808201926020929091908290030181865afa158015611a35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a599190615814565b60d360006101000a8154816001600160a01b0302191690836001600160a01b03160217905550886001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611abd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ae19190615814565b60d480546001600160a01b0319166001600160a01b039290921691909117905560db805462ffffff191662ffffff8916179055611b1e8686611050565b611b2884846109f1565b60db805463ffffffff60501b1916600f60531b179055611b466133fb565b8015611b8c576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050505050565b6000611ba161167d565b604051636788231160e11b81523060048201526001600160a01b03919091169063cf10462290602401602060405180830381865afa158015611be7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061126b919061516f565b609b5460408051638e14545960e01b815290516000926001600160a01b031691638e1454599160048083019260209291908290030181865afa1580156116c7573d6000803e3d6000fd5b60d88054610f4390615276565b600080611c6d610977565b90506000611c79610b49565b60db54909150600090611ca790611c9a906301000000900460060b84615581565b60060b620d89e7196137b5565b60db54909150600090611cd490611cc8906301000000900460060b85615856565b60060b620d89e86137cf565b90508360020b8260060b1380611cef57508360020b8160060b125b15611cff57600094505050505090565b600194505050505090565b600080600a60d360009054906101000a90046001600160a01b03166001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d869190615602565b611d9190600a615709565b611d9b9190615718565b60975460d3549192506001600160a01b03908116911603611dc157610df081600a61572c565b60d25460405163cdca175360e01b81526001600160a01b039091169063cdca175390610e299060d7908590600401615743565b600080611dff612093565b90506002611e23826001600160a01b0316670de0b6b3a7640000600160601b6137de565b610df09190615709565b609b546040805163aced166160e01b815290516000926001600160a01b03169163aced16619160048083019260209291908290030181865afa1580156116c7573d6000803e3d6000fd5b611e7f614c7a565b6040518060600160405280611e92613892565b81526020016000815260200160009052919050565b611eaf612713565b609860009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f02573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f26919061516f565b6103e814611f475760405163ea8e4eb560e01b815260040160405180910390fd5b611f5260008061178a565b6000611f5c611c0b565b9050600080611f69610892565b90925090508115611ff95760d3546040516370a0823160e01b8152306004820152611ff99185916001600160a01b03909116906370a0823190602401602060405180830381865afa158015611fc2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fe6919061516f565b60d3546001600160a01b0316919061348b565b80156120845760d4546040516370a0823160e01b81523060048201526120849185916001600160a01b03909116906370a0823190602401602060405180830381865afa15801561204d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612071919061516f565b60d4546001600160a01b0316919061348b565b61208e60006135ee565b505050565b60d15460408051633850c7bd60e01b815290516000926001600160a01b031691633850c7bd9160048083019260e09291908290030181865afa1580156120dd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061210191906151aa565b50949695505050505050565b606060d8805461211c90615276565b905060000361212c5760006111a9565b61126b60d880546111e890615276565b609a546001600160a01b0316331461216757604051633163ba6d60e11b815260040160405180910390fd5b609a80546001600160a01b0319166001600160a01b0383169081179091556040519081527f46d58e3fa07bf19b1d27240f0e286b27e9f7c1b0d88933333fe833b60eec5412906020016113fd565b6121bd613943565b609b546040516305226abd60e51b81523360048201526001600160a01b039091169063a44d57a090602401602060405180830381865afa158015612205573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122299190615883565b6122465760405163ea8e4eb560e01b815260040160405180910390fd5b61224e612918565b5050505061225a612d17565b612262613071565b61226a6130c7565b600080612275611852565b60408051838152602081018390529294509092507f631c4f79c14099a717f4be2f25e6cef89e310b3944ef0e44ea2c0811ebb982a8910160405180910390a15050565b6122c0613943565b6122c8613362565b60db54600160781b900460ff16612262576122e1613071565b60db805460ff60781b1916600160781b17905561226a6130c7565b60d1546001600160a01b0316331461232757604051636f61f64160e01b815260040160405180910390fd5b60db54600160701b900460ff166123515760405163887efaa560e01b815260040160405180910390fd5b82156123745760d15460d354612374916001600160a01b0391821691168561348b565b81156123975760d15460d454612397916001600160a01b0391821691168461348b565b505060db805460ff60701b1916905550565b6123b1612713565b6123b9613575565b609980546001600160a01b0319166001600160a01b0383161790556123dc6133fb565b6040516001600160a01b03821681527f5ca6e64c4522e68e154aa9372f2c5969cd37d9640e59f66953dc472f54ee86fa906020016113fd565b600080600080612423612918565b929791965094509092509050565b60d95460009081906002906124679061244b90830b613968565b6001600160a01b0316670de0b6b3a7640000600160601b6137de565b6124719190615709565b60d9549092506002906124909061244b9063010000009004830b613968565b61249a9190615709565b90509091565b6124a8612713565b6001600160a01b03811661250d5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401611997565b610b46816135ee565b60008060008060008060008061252a610fc4565b915091506000612538612093565b60d15460405163514ea4bf60e01b815260048101869052919250600091829182916001600160a01b039091169063514ea4bf9060240160a060405180830381865afa15801561258b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125af91906158b5565b60d15460405163514ea4bf60e01b8152600481018c90529598506001600160801b039283169750911694506000938493508392506001600160a01b039091169063514ea4bf9060240160a060405180830381865afa158015612615573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061263991906158b5565b60d9549497506001600160801b03918216965016935061267f928a9250612663915060020b613968565b60d954612679906301000000900460020b613968565b89613c9e565b60da54919e509c506126b59088906126999060020b613968565b60da546126af906301000000900460020b613968565b86613c9e565b909b5099506126c4858e615801565b9c506126d0848d615801565b9b506126dc828c615801565b9a506126e8818b615801565b99506126f48b8e615801565b9e506127008a8d615801565b9d50505050505050505050909192939495565b6033546001600160a01b03163314610e935760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401611997565b6060600061277a83613d3a565b90506000612789826001615801565b67ffffffffffffffff8111156127a1576127a1615044565b6040519080825280602002602001820160405280156127ca578160200160208202803683370190505b50905060005b82811015612866576000806127e487613d60565b5091509150818484815181106127fc576127fc615237565b6001600160a01b03909216602092830291909101909101528084612821856001615801565b8151811061283157612831615237565b60200260200101906001600160a01b031690816001600160a01b03168152505061285a87613d9c565b965050506001016127d0565b509392505050565b612876612918565b50505050612882612d17565b6000806128948360d55460d654613dcd565b915091506128a06130c7565b600060d581905560d6819055806128b5611567565b90925090506128c48285615801565b609c556128d18184615801565b609d5542609e5560408051858152602081018590527f6c8433a8e155f0af04dba058d4e4695f7da554578963d876bdf4a6d8d6399d9c910160405180910390a15050505050565b600080600080600080612929610fc4565b60d15460405163514ea4bf60e01b8152600481018490529294509092506000916001600160a01b039091169063514ea4bf9060240160a060405180830381865afa15801561297b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061299f91906158b5565b505060d15460405163514ea4bf60e01b8152600481018790529394506000936001600160a01b03909116925063514ea4bf915060240160a060405180830381865afa1580156129f2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a1691906158b5565b5050505090506000826001600160801b03161115612ab75760d15460d95460405163a34123a760e01b81526001600160a01b039092169163a34123a791612a7291600282810b9263010000009004900b9060009060040161590c565b60408051808303816000875af1158015612a90573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ab49190615932565b50505b6001600160801b03811615612b4f5760d15460da5460405163a34123a760e01b81526001600160a01b039092169163a34123a791612b0a91600282810b9263010000009004900b9060009060040161590c565b60408051808303816000875af1158015612b28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b4c9190615932565b50505b60d15460d9546040516309e3d67b60e31b81526001600160a01b0390921691634f1eb3d891612b9e913091600281810b926301000000909204900b906001600160801b03908190600401615956565b60408051808303816000875af1158015612bbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612be09190615993565b60d15460da546040516309e3d67b60e31b81526001600160801b039485169c509284169a506001600160a01b0390911692634f1eb3d892612c38923092600282810b936301000000909304900b918190600401615956565b60408051808303816000875af1158015612c56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c7a9190615993565b60d5546001600160801b039283169850911695508690612c9b908a90615801565b612ca59190615801565b60d55560d6548590612cb8908990615801565b612cc29190615801565b60d6556040805189815260208101899052908101879052606081018690527f6fe7c663aa15def6e80578b76ddd894fcefeabf14a0106afbec24da4a6c578729060800160405180910390a15050505090919293565b600080612d22610fc4565b60d15460405163514ea4bf60e01b8152600481018490529294509092506000916001600160a01b039091169063514ea4bf9060240160a060405180830381865afa158015612d74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d9891906158b5565b505060d15460405163514ea4bf60e01b8152600481018790529394506000936001600160a01b03909116925063514ea4bf915060240160a060405180830381865afa158015612deb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e0f91906158b5565b5050505090506000826001600160801b03161115612f425760d15460d95460405163a34123a760e01b81526001600160a01b039092169163a34123a791612e6a91600282810b9263010000009004900b90879060040161590c565b60408051808303816000875af1158015612e88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eac9190615932565b505060d15460d9546040516309e3d67b60e31b81526001600160a01b0390921691634f1eb3d891612efd913091600281810b926301000000909204900b906001600160801b03908190600401615956565b60408051808303816000875af1158015612f1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f3f9190615993565b50505b6001600160801b0381161561183a5760d15460da5460405163a34123a760e01b81526001600160a01b039092169163a34123a791612f9491600282810b9263010000009004900b90869060040161590c565b60408051808303816000875af1158015612fb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fd69190615932565b505060d15460da546040516309e3d67b60e31b81526001600160a01b0390921691634f1eb3d891613027913091600281810b926301000000909204900b906001600160801b03908190600401615956565b60408051808303816000875af1158015613045573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130699190615993565b505050505050565b613079613943565b6000613083610977565b9050600061308f61338d565b60db549091506000906130a690839060020b6157da565b90506130b383838361410d565b6130be838383614148565b505042609f5550565b6130cf614298565b6000806130da610892565b9150915060006130e8612093565b60d9549091506000906131209083906131039060020b613968565b60d954613119906301000000900460020b613968565b8787614339565b60d954909150600090613143908390600281810b9163010000009004900b6143fd565b90506000826001600160801b031611801561315b5750805b156132345760db805460ff60701b1916600160701b17905560d15460d954604051633c8a7d8d60e01b8152306004820152600282810b6024830152630100000090920490910b60448201526001600160801b038416606482015260a06084820152600a60a4820152692132b2b33c9026b0b4b760b11b60c48201526001600160a01b0390911690633c8a7d8d9060e40160408051808303816000875af1158015613209573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061322d9190615932565b505061323c565b61323c613943565b613244610892565b60da54919650945061327b90849061325e9060020b613968565b60da54613274906301000000900460020b613968565b8888614339565b91506001600160801b0382161561335b5760db805460ff60701b1916600160701b17905560d15460da54604051633c8a7d8d60e01b8152306004820152600282810b6024830152630100000090920490910b60448201526001600160801b038416606482015260a06084820152600960a482015268109959599e48105b1d60ba1b60c48201526001600160a01b0390911690633c8a7d8d9060e40160408051808303816000875af1158015613334573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133589190615932565b50505b5050505050565b6098546001600160a01b03163314610e93576040516362df054560e01b815260040160405180910390fd5b60d154604080516334324e9f60e21b815290516000926001600160a01b03169163d0c93a7c9160048083019260209291908290030181865afa1580156133d7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061126b91906159c6565b60995460d35461341a916001600160a01b03918216911660001961444b565b60995460d454610e93916001600160a01b03918216911660001961444b565b6134416144db565b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6040516001600160a01b0383811660248301526044820183905261208e91859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050614524565b60006134f860655460ff1690565b8061126b5750609b60009054906101000a90046001600160a01b03166001600160a01b031663f12d54d86040518163ffffffff1660e01b8152600401602060405180830381865afa158015613551573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061126b9190615883565b60995460d354613593916001600160a01b039182169116600061444b565b60995460d454610e93916001600160a01b039182169116600061444b565b6135b9614587565b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861346e3390565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff166136675760405162461bcd60e51b8152600401611997906159e3565b61366f6145cd565b6136776145fc565b6136846020820182614d74565b609880546001600160a01b0319166001600160a01b03929092169190911790556136b46040820160208301614d74565b609980546001600160a01b0319166001600160a01b03929092169190911790556136e46060820160408301614d74565b609a80546001600160a01b0319166001600160a01b03929092169190911790556137146080820160608301614d74565b609b80546001600160a01b0319166001600160a01b03929092169182179055604080516311b0b42d60e01b815290516311b0b42d916004808201926020929091908290030181865afa15801561376e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137929190615814565b609780546001600160a01b0319166001600160a01b039290921691909117905550565b60008183136137c457816137c6565b825b90505b92915050565b60008183126137c457816137c6565b6000808060001985870985870292508281108382030391505080600003613817576000841161380c57600080fd5b50829004905061388b565b80841161382357600080fd5b600084868809851960019081018716968790049682860381900495909211909303600082900391909104909201919091029190911760038402600290811880860282030280860282030280860282030280860282030280860282030280860290910302029150505b9392505050565b6138cd6040518060c0016040528060008152602001600081526020016000815260200160008152602001606081526020016000151581525090565b6138d561167d565b604051639af608c960e01b81523060048201526001600160a01b039190911690639af608c990602401600060405180830381865afa15801561391b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261126b9190810190615a2e565b61394b611c62565b610e93576040516313643c3b60e11b815260040160405180910390fd5b60008060008360020b1261397f578260020b613987565b8260020b6000035b9050620d89e88111156139c05760405162461bcd60e51b81526020600482015260016024820152601560fa1b6044820152606401611997565b6000816001166000036139d757600160801b6139e9565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff1690506002821615613a1d576ffff97272373d413259a46990580e213a0260801c5b6004821615613a3c576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b6008821615613a5b576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615613a7a576fffcb9843d60f6159c9db58835c9266440260801c5b6020821615613a99576fff973b41fa98c081472e6896dfb254c00260801c5b6040821615613ab8576fff2ea16466c96a3843ec78b326b528610260801c5b6080821615613ad7576ffe5dee046a99a2a811c461f1969c30530260801c5b610100821615613af7576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b610200821615613b17576ff987a7253ac413176f2b074cf7815e540260801c5b610400821615613b37576ff3392b0822b70005940c7a398e4b70f30260801c5b610800821615613b57576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615613b77576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615613b97576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615613bb7576f70d869a156d2a1b890bb3df62baf32f70260801c5b618000821615613bd7576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615613bf8576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b62020000821615613c18576e5d6af8dedb81196699c329225ee6040260801c5b62040000821615613c37576d2216e584f5fa1ea926041bedfe980260801c5b62080000821615613c54576b048a170391f7dc42444e8fa20260801c5b60008460020b1315613c75578060001981613c7157613c716155ae565b0490505b640100000000810615613c89576001613c8c565b60005b60ff16602082901c0192505050919050565b600080836001600160a01b0316856001600160a01b03161115613cbf579293925b846001600160a01b0316866001600160a01b031611613cea57613ce385858561462b565b9150613d31565b836001600160a01b0316866001600160a01b03161015613d2357613d0f86858561462b565b9150613d1c8587856146a6565b9050613d31565b613d2e8585856146a6565b90505b94509492505050565b6000613d4860036014615801565b60148351613d569190615263565b6137c99190615718565b60008080613d6e84826146f0565b9250613d7b846014614755565b9050613d93613d8c60036014615801565b85906146f0565b91509193909250565b60606137c9613dad60036014615801565b613db960036014615801565b8451613dc59190615263565b849190614800565b6000806000613dda613892565b905060008515613ef1578151600090670de0b6b3a764000090613dfd908961572c565b613e079190615718565b9050613e138188615263565b60975460d3549196506000916001600160a01b03908116911614613eb85760995460d354609754604051630df791e560e41b81526001600160a01b03928316600482015290821660248201526044810185905291169063df791e50906064016020604051808303816000875af1158015613e91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613eb5919061516f565b90505b60975460d3546001600160a01b03918216911603613ee157613eda8284615801565b9250613eee565b613eeb8184615801565b92505b50505b8415614004578151600090670de0b6b3a764000090613f10908861572c565b613f1a9190615718565b9050613f268187615263565b60975460d4549195506000916001600160a01b03908116911614613fcb5760995460d454609754604051630df791e560e41b81526001600160a01b03928316600482015290821660248201526044810185905291169063df791e50906064016020604051808303816000875af1158015613fa4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fc8919061516f565b90505b60975460d4546001600160a01b03918216911603613ff457613fed8284615801565b9250614001565b613ffe8184615801565b92505b50505b6000670de0b6b3a764000083604001518361401f919061572c565b6140299190615718565b609754909150614043906001600160a01b0316898361348b565b6000670de0b6b3a764000084606001518461405e919061572c565b6140689190615718565b609a54609754919250614088916001600160a01b0390811691168361348b565b6000816140958486615263565b61409f9190615263565b90506140bf6140ac611c0b565b6097546001600160a01b0316908361348b565b60408051848152602081018390529081018390527fd255b592c7f268a73e534da5219a60ff911b4cf6daae21c7d20527dd657bd99a9060600160405180910390a15050505050935093915050565b61411883828461490d565b60d9805465ffffffffffff1916630100000062ffffff9384160262ffffff19161792909116919091179055505050565b600080614153610892565b90925090506000821561418f576ec097ce7bc90715b34b9f1000000000614178611df4565b614182908561572c565b61418c9190615718565b90505b818110156141ee576141a286858761490d565b5060da805462ffffff191662ffffff929092169190911790556141c686868061490d565b5060da805462ffffff90921663010000000265ffffff00000019909216919091179055614249565b808210156142495761420186868761490d565b60da805462ffffff191662ffffff929092169190911790555061422586858761490d565b60da805462ffffff90921663010000000265ffffff00000019909216919091179055505b60da5460d954600291820b910b14801561427a575060da5460d954630100000091829004600290810b92909104900b145b1561306957604051631434ed7f60e01b815260040160405180910390fd5b60655460ff168061431b5750609b60009054906101000a90046001600160a01b03166001600160a01b031663f12d54d86040518163ffffffff1660e01b8152600401602060405180830381865afa1580156142f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061431b9190615883565b15610e935760405163e628b94960e01b815260040160405180910390fd5b6000836001600160a01b0316856001600160a01b03161115614359579293925b846001600160a01b0316866001600160a01b0316116143845761437d85858561493f565b90506143f4565b836001600160a01b0316866001600160a01b031610156143e65760006143ab87868661493f565b905060006143ba8789866149a9565b9050806001600160801b0316826001600160801b0316106143db57806143dd565b815b925050506143f4565b6143f18585846149a9565b90505b95945050505050565b600080600061441f61440d612093565b61441687613968565b61267987613968565b915091508160001480614430575080155b156144405760009250505061388b565b60019250505061388b565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b17905261449c84826149df565b61183a576040516001600160a01b038481166024830152600060448301526144d191869182169063095ea7b3906064016134b8565b61183a8482614524565b60655460ff16610e935760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401611997565b60006145396001600160a01b03841683614a82565b9050805160001415801561455e57508080602001905181019061455c9190615883565b155b1561208e57604051635274afe760e01b81526001600160a01b0384166004820152602401611997565b60655460ff1615610e935760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401611997565b600054610100900460ff166145f45760405162461bcd60e51b8152600401611997906159e3565b610e93614a90565b600054610100900460ff166146235760405162461bcd60e51b8152600401611997906159e3565b610e93614ac0565b6000826001600160a01b0316846001600160a01b0316111561464b579192915b6001600160a01b0384166146946fffffffffffffffffffffffffffffffff60601b606085901b1661467c8787615b0c565b6001600160a01b0316866001600160a01b03166137de565b61469e9190615718565b949350505050565b6000826001600160a01b0316846001600160a01b031611156146c6579192915b61469e6001600160801b0383166146dd8686615b0c565b6001600160a01b0316600160601b6137de565b60006146fd826014615801565b835110156147455760405162461bcd60e51b8152602060048201526015602482015274746f416464726573735f6f75744f66426f756e647360581b6044820152606401611997565b500160200151600160601b900490565b600081614763816003615801565b10156147a55760405162461bcd60e51b8152602060048201526011602482015270746f55696e7432345f6f766572666c6f7760781b6044820152606401611997565b6147b0826003615801565b835110156147f75760405162461bcd60e51b8152602060048201526014602482015273746f55696e7432345f6f75744f66426f756e647360601b6044820152606401611997565b50016003015190565b60608161480e81601f615801565b101561484d5760405162461bcd60e51b815260206004820152600e60248201526d736c6963655f6f766572666c6f7760901b6044820152606401611997565b6148578284615801565b8451101561489b5760405162461bcd60e51b8152602060048201526011602482015270736c6963655f6f75744f66426f756e647360781b6044820152606401611997565b6060821580156148ba5760405191506000825260208201604052614904565b6040519150601f8416801560200281840101858101878315602002848b0101015b818310156148f35780518352602092830192016148db565b5050858452601f01601f1916604052505b50949350505050565b600080600061491c8685614af3565b90506149288582615b2c565b92506149348582615b51565b915050935093915050565b6000826001600160a01b0316846001600160a01b0316111561495f579192915b6000614982856001600160a01b0316856001600160a01b0316600160601b6137de565b90506143f46149a484836149968989615b0c565b6001600160a01b03166137de565b614b3d565b6000826001600160a01b0316846001600160a01b031611156149c9579192915b61469e6149a483600160601b6149968888615b0c565b6000806000846001600160a01b0316846040516149fc9190615b76565b6000604051808303816000865af19150503d8060008114614a39576040519150601f19603f3d011682016040523d82523d6000602084013e614a3e565b606091505b5091509150818015614a68575080511580614a68575080806020019051810190614a689190615883565b80156143f45750505050506001600160a01b03163b151590565b60606137c683836000614b58565b600054610100900460ff16614ab75760405162461bcd60e51b8152600401611997906159e3565b610e93336135ee565b600054610100900460ff16614ae75760405162461bcd60e51b8152600401611997906159e3565b6065805460ff19169055565b600080614b008385615b92565b905060008460020b128015614b205750614b1a8385615bc3565b60020b15155b15614b335780614b2f81615be5565b9150505b61469e83826157da565b806001600160801b0381168114614b5357600080fd5b919050565b606081471015614b7d5760405163cd78605960e01b8152306004820152602401611997565b600080856001600160a01b03168486604051614b999190615b76565b60006040518083038185875af1925050503d8060008114614bd6576040519150601f19603f3d011682016040523d82523d6000602084013e614bdb565b606091505b5091509150614beb868383614bf5565b9695505050505050565b606082614c0a57614c0582614c51565b61388b565b8151158015614c2157506001600160a01b0384163b155b15614c4a57604051639996b31560e01b81526001600160a01b0385166004820152602401611997565b508061388b565b805115614c615780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b6040518060600160405280614cc06040518060c0016040528060008152602001600081526020016000815260200160008152602001606081526020016000151581525090565b815260200160008152602001600081525090565b60008083601f840112614ce657600080fd5b50813567ffffffffffffffff811115614cfe57600080fd5b602083019150836020828501011115614d1657600080fd5b9250929050565b60008060208385031215614d3057600080fd5b823567ffffffffffffffff811115614d4757600080fd5b614d5385828601614cd4565b90969095509350505050565b6001600160a01b0381168114610b4657600080fd5b600060208284031215614d8657600080fd5b813561388b81614d5f565b8060020b8114610b4657600080fd5b600060208284031215614db257600080fd5b813561388b81614d91565b63ffffffff81168114610b4657600080fd5b600060208284031215614de157600080fd5b813561388b81614dbd565b60005b83811015614e07578181015183820152602001614def565b50506000910152565b60008151808452614e28816020860160208601614dec565b601f01601f19169290920160200192915050565b6020815260006137c66020830184614e10565b6020808252825182820181905260009190848201906040850190845b81811015614e905783516001600160a01b031683529284019291840191600101614e6b565b50909695505050505050565b8060060b8114610b4657600080fd5b600060208284031215614ebd57600080fd5b813561388b81614e9c565b600060208284031215614eda57600080fd5b5035919050565b60008060408385031215614ef457600080fd5b50508035926020909101359150565b600080600080600080600080888a03610120811215614f2157600080fd5b8935614f2c81614d5f565b985060208a0135614f3c81614d5f565b975060408a0135614f4c81614d91565b965060608a013567ffffffffffffffff80821115614f6957600080fd5b614f758d838e01614cd4565b909850965060808c0135915080821115614f8e57600080fd5b50614f9b8c828d01614cd4565b9095509350506080609f1982011215614fb357600080fd5b5060a0890190509295985092959890939650565b60208152600082516060602084015280516080840152602081015160a0840152604081015160c0840152606081015160e0840152608081015160c0610100850152615016610140850182614e10565b905060a082015115156101208501526020850151604085015260408501516060850152809250505092915050565b634e487b7160e01b600052604160045260246000fd5b60405160c0810167ffffffffffffffff8111828210171561507d5761507d615044565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156150ac576150ac615044565b604052919050565b600067ffffffffffffffff8211156150ce576150ce615044565b50601f01601f191660200190565b6000806000606084860312156150f157600080fd5b8335925060208401359150604084013567ffffffffffffffff81111561511657600080fd5b8401601f8101861361512757600080fd5b803561513a615135826150b4565b615083565b81815287602083850101111561514f57600080fd5b816020840160208301376000602083830101528093505050509250925092565b60006020828403121561518157600080fd5b5051919050565b805161ffff81168114614b5357600080fd5b80518015158114614b5357600080fd5b600080600080600080600060e0888a0312156151c557600080fd5b87516151d081614d5f565b60208901519097506151e181614d91565b95506151ef60408901615188565b94506151fd60608901615188565b935061520b60808901615188565b925060a088015161521b81614dbd565b915061522960c0890161519a565b905092959891949750929550565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b818103818111156137c9576137c961524d565b600181811c9082168061528a57607f821691505b6020821081036152aa57634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111561208e576000816000526020600020601f850160051c810160208610156152d95750805b601f850160051c820191505b81811015613069578281556001016152e5565b67ffffffffffffffff83111561531057615310615044565b6153248361531e8354615276565b836152b0565b6000601f84116001811461535857600085156153405750838201355b600019600387901b1c1916600186901b17835561335b565b600083815260209020601f19861690835b828110156153895786850135825560209485019460019092019101615369565b50868210156153a65760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b6020808252825182820181905260009190848201906040850190845b81811015614e9057835163ffffffff1683529284019291840191600101615403565b600067ffffffffffffffff82111561543f5761543f615044565b5060051b60200190565b600082601f83011261545a57600080fd5b8151602061546a61513583615425565b8083825260208201915060208460051b87010193508684111561548c57600080fd5b602086015b848110156154b15780516154a481614d5f565b8352918301918301615491565b509695505050505050565b600080604083850312156154cf57600080fd5b825167ffffffffffffffff808211156154e757600080fd5b818501915085601f8301126154fb57600080fd5b8151602061550b61513583615425565b82815260059290921b8401810191818101908984111561552a57600080fd5b948201945b8386101561555157855161554281614e9c565b8252948201949082019061552f565b9188015191965090935050508082111561556a57600080fd5b5061557785828601615449565b9150509250929050565b600682810b9082900b03667fffffffffffff198112667fffffffffffff821317156137c9576137c961524d565b634e487b7160e01b600052601260045260246000fd5b60008160060b8360060b806155db576155db6155ae565b667fffffffffffff198214600019821416156155f9576155f961524d565b90059392505050565b60006020828403121561561457600080fd5b815160ff8116811461388b57600080fd5b600181815b808511156156605781600019048211156156465761564661524d565b8085161561565357918102915b93841c939080029061562a565b509250929050565b600082615677575060016137c9565b81615684575060006137c9565b816001811461569a57600281146156a4576156c0565b60019150506137c9565b60ff8411156156b5576156b561524d565b50506001821b6137c9565b5060208310610133831016604e8410600b84101617156156e3575081810a6137c9565b6156ed8383615625565b80600019048211156157015761570161524d565b029392505050565b60006137c660ff841683615668565b600082615727576157276155ae565b500490565b80820281158282048414176137c9576137c961524d565b60408152600080845461575581615276565b80604086015260606001808416600081146157775760018114615793576157c5565b60ff1985166060890152606084151560051b89010195506157c5565b8960005260208060002060005b868110156157bb5781548b82018701529084019082016157a0565b8a01606001975050505b50505050506020929092019290925292915050565b60008260020b8260020b028060020b91508082146157fa576157fa61524d565b5092915050565b808201808211156137c9576137c961524d565b60006020828403121561582657600080fd5b815161388b81614d5f565b60006020828403121561584357600080fd5b815162ffffff8116811461388b57600080fd5b600681810b9083900b01667fffffffffffff8113667fffffffffffff19821217156137c9576137c961524d565b60006020828403121561589557600080fd5b6137c68261519a565b80516001600160801b0381168114614b5357600080fd5b600080600080600060a086880312156158cd57600080fd5b6158d68661589e565b945060208601519350604086015192506158f26060870161589e565b91506159006080870161589e565b90509295509295909350565b600293840b81529190920b60208201526001600160801b03909116604082015260600190565b6000806040838503121561594557600080fd5b505080516020909101519092909150565b6001600160a01b03959095168552600293840b60208601529190920b60408401526001600160801b03918216606084015216608082015260a00190565b600080604083850312156159a657600080fd5b6159af8361589e565b91506159bd6020840161589e565b90509250929050565b6000602082840312156159d857600080fd5b815161388b81614d91565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60006020808385031215615a4157600080fd5b825167ffffffffffffffff80821115615a5957600080fd5b9084019060c08287031215615a6d57600080fd5b615a7561505a565b8251815283830151848201526040830151604082015260608301516060820152608083015182811115615aa757600080fd5b83019150601f82018713615aba57600080fd5b8151615ac8615135826150b4565b8181528886838601011115615adc57600080fd5b615aeb82878301888701614dec565b608083015250615afd60a0840161519a565b60a08201529695505050505050565b6001600160a01b038281168282160390808211156157fa576157fa61524d565b600282810b9082900b03627fffff198112627fffff821317156137c9576137c961524d565b600281810b9083900b01627fffff8113627fffff19821217156137c9576137c961524d565b60008251615b88818460208701614dec565b9190910192915050565b60008160020b8360020b80615ba957615ba96155ae565b627fffff198214600019821416156155f9576155f961524d565b60008260020b80615bd657615bd66155ae565b808360020b0791505092915050565b60008160020b627fffff198103615bfe57615bfe61524d565b600019019291505056fea2646970667358221220159c03c9284a01d6db08f1ca7cb67c60de37031451d89ade41e34546febffeeb64736f6c63430008170033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.