More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 1,096 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Swap And Increas... | 20480796 | 26 days ago | IN | 0 ETH | 0.00134163 | ||||
Swap And Mint | 20480324 | 26 days ago | IN | 0 ETH | 0.00176774 | ||||
Swap And Increas... | 20480143 | 26 days ago | IN | 0.2 ETH | 0.00066174 | ||||
Swap And Increas... | 20480110 | 26 days ago | IN | 0.5 ETH | 0.0005786 | ||||
Swap And Increas... | 20479908 | 26 days ago | IN | 10 ETH | 0.00129858 | ||||
Swap And Mint | 20479712 | 26 days ago | IN | 0.045 ETH | 0.00257825 | ||||
Swap And Mint | 20479709 | 26 days ago | IN | 0.045 ETH | 0.00185725 | ||||
Swap And Mint | 20477703 | 26 days ago | IN | 0 ETH | 0.01238138 | ||||
Swap And Increas... | 20477006 | 26 days ago | IN | 0 ETH | 0.00297593 | ||||
Swap And Increas... | 20476989 | 26 days ago | IN | 0.5 ETH | 0.00210442 | ||||
Swap And Increas... | 20476773 | 26 days ago | IN | 0 ETH | 0.00174858 | ||||
Swap And Mint | 20476321 | 27 days ago | IN | 1.15 ETH | 0.00340435 | ||||
Swap And Mint | 20475975 | 27 days ago | IN | 0 ETH | 0.00201124 | ||||
Swap And Mint | 20475796 | 27 days ago | IN | 0.371 ETH | 0.00241148 | ||||
Swap And Mint | 20475785 | 27 days ago | IN | 4.747207 ETH | 0.00302807 | ||||
Swap And Increas... | 20475398 | 27 days ago | IN | 1 ETH | 0.00065003 | ||||
Swap And Mint | 20474883 | 27 days ago | IN | 0.09 ETH | 0.00092065 | ||||
Swap And Increas... | 20474046 | 27 days ago | IN | 0 ETH | 0.00102686 | ||||
Swap And Mint | 20473951 | 27 days ago | IN | 0.001 ETH | 0.00233562 | ||||
Swap And Mint | 20473947 | 27 days ago | IN | 0.001 ETH | 0.00191751 | ||||
Swap And Mint | 20473914 | 27 days ago | IN | 0.001 ETH | 0.00109341 | ||||
Swap And Mint | 20473914 | 27 days ago | IN | 0.0008 ETH | 0.00106874 | ||||
Swap And Increas... | 20473855 | 27 days ago | IN | 0 ETH | 0.00113213 | ||||
Swap And Increas... | 20473796 | 27 days ago | IN | 0 ETH | 0.00142282 | ||||
Swap And Mint | 20472176 | 27 days ago | IN | 0 ETH | 0.00436178 |
Advanced mode: Intended for advanced users or developers and will display all Internal Transactions including zero value transfers. Name tag integration is not available in advanced view.
Latest 25 internal transactions (View All)
Advanced mode:
Parent Transaction Hash | Block | From | To | ||||
---|---|---|---|---|---|---|---|
20481009 | 26 days ago | 0 ETH | |||||
20481009 | 26 days ago | 0 ETH | |||||
20481009 | 26 days ago | 0 ETH | |||||
20481009 | 26 days ago | 0 ETH | |||||
20481009 | 26 days ago | 0 ETH | |||||
20481009 | 26 days ago | 0 ETH | |||||
20481009 | 26 days ago | 0 ETH | |||||
20481009 | 26 days ago | 0 ETH | |||||
20481009 | 26 days ago | 0 ETH | |||||
20481009 | 26 days ago | 0 ETH | |||||
20481009 | 26 days ago | 0 ETH | |||||
20481009 | 26 days ago | 0 ETH | |||||
20481009 | 26 days ago | 0 ETH | |||||
20481009 | 26 days ago | 0 ETH | |||||
20481009 | 26 days ago | 0 ETH | |||||
20481009 | 26 days ago | 0 ETH | |||||
20481009 | 26 days ago | 0 ETH | |||||
20481009 | 26 days ago | 0 ETH | |||||
20481009 | 26 days ago | 0 ETH | |||||
20481009 | 26 days ago | 0 ETH | |||||
20481009 | 26 days ago | 0 ETH | |||||
20481009 | 26 days ago | 0 ETH | |||||
20480796 | 26 days ago | 0 ETH | |||||
20480796 | 26 days ago | 0 ETH | |||||
20480796 | 26 days ago | 0 ETH |
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
V3Utils
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.0; import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import "./Common.sol"; /// @title v3Utils v1.0 /// @notice Utility functions for Uniswap V3 positions /// This is a completely ownerless/stateless contract - does not hold any ERC20 or NFTs. /// It can be simply redeployed when new / better functionality is implemented contract V3Utils is IERC721Receiver, Common { /// @notice Action which should be executed on provided NFT enum WhatToDo { CHANGE_RANGE, WITHDRAW_AND_COLLECT_AND_SWAP, COMPOUND_FEES } /// @notice Complete description of what should be executed on provided NFT - different fields are used depending on specified WhatToDo struct Instructions { // what action to perform on provided Uniswap v3 position WhatToDo whatToDo; // protocol to provide lp Protocol protocol; // target token for swaps (if this is address(0) no swaps are executed) address targetToken; // for removing liquidity slippage uint256 amountRemoveMin0; uint256 amountRemoveMin1; // amountIn0 is used for swap and also as minAmount0 for decreased liquidity + collected fees uint256 amountIn0; // if token0 needs to be swapped to targetToken - set values uint256 amountOut0Min; bytes swapData0; // encoded data from 0x api call (address,bytes) - allowanceTarget,data // amountIn1 is used for swap and also as minAmount1 for decreased liquidity + collected fees uint256 amountIn1; // if token1 needs to be swapped to targetToken - set values uint256 amountOut1Min; bytes swapData1; // encoded data from 0x api call (address,bytes) - allowanceTarget,data // for creating new positions with CHANGE_RANGE int24 tickLower; int24 tickUpper; bool compoundFees; // remove liquidity amount for COMPOUND_FEES (in this case should be probably 0) / CHANGE_RANGE / WITHDRAW_AND_COLLECT_AND_SWAP uint128 liquidity; // for adding liquidity slippage uint256 amountAddMin0; uint256 amountAddMin1; // for all uniswap deadlineable functions uint256 deadline; // left over tokens will be sent to this address address recipient; // if tokenIn or tokenOut is WETH - unwrap bool unwrap; // protocol fees uint64 protocolFeeX64; } /// @notice Execute instruction by pulling approved NFT instead of direct safeTransferFrom call from owner /// @param tokenId Token to process /// @param instructions Instructions to execute function execute(INonfungiblePositionManager _nfpm, uint256 tokenId, Instructions calldata instructions) whenNotPaused() external { // must be approved beforehand _nfpm.safeTransferFrom( msg.sender, address(this), tokenId, abi.encode(instructions) ); } /// @notice ERC721 callback function. Called on safeTransferFrom and does manipulation as configured in encoded Instructions parameter. /// At the end the NFT (and any newly minted NFT) is returned to sender. The leftover tokens are sent to instructions.recipient. function onERC721Received(address, address from, uint256 tokenId, bytes calldata data) whenNotPaused() external override returns (bytes4) { INonfungiblePositionManager nfpm = INonfungiblePositionManager(msg.sender); // not allowed to send to itself if (from == address(this)) { revert SelfSend(); } require(_isWhitelistedNfpm(address(nfpm))); Instructions memory instructions = abi.decode(data, (Instructions)); (address token0,address token1,,,,uint24 fee) = _getPosition(nfpm, instructions.protocol, tokenId); (uint256 amount0, uint256 amount1) = _decreaseLiquidityAndCollectFees(DecreaseAndCollectFeesParams(nfpm, instructions.recipient, IERC20(token0), IERC20(token1), tokenId, instructions.liquidity, instructions.deadline, instructions.amountRemoveMin0, instructions.amountRemoveMin1, instructions.compoundFees)); // take protocol fees if (instructions.protocolFeeX64 > 0) { (amount0, amount1,,,,) = _deductFees(DeductFeesParams(amount0, amount1, 0, instructions.protocolFeeX64, FeeType.PROTOCOL_FEE, address(nfpm), tokenId, instructions.recipient, token0, token1, address(0)), true); } // check if enough tokens are available for swaps if (amount0 < instructions.amountIn0 || amount1 < instructions.amountIn1) { revert AmountError(); } if (instructions.whatToDo == WhatToDo.COMPOUND_FEES) { SwapAndIncreaseLiquidityResult memory result; if (instructions.targetToken == token0) { result = _swapAndIncrease(SwapAndIncreaseLiquidityParams(instructions.protocol, nfpm, tokenId, amount0, amount1, 0, instructions.recipient, instructions.deadline, IERC20(token1), instructions.amountIn1, instructions.amountOut1Min, instructions.swapData1, 0, 0, "", instructions.amountAddMin0, instructions.amountAddMin1, 0), IERC20(token0), IERC20(token1), instructions.unwrap); } else if (instructions.targetToken == token1) { result = _swapAndIncrease(SwapAndIncreaseLiquidityParams(instructions.protocol, nfpm, tokenId, amount0, amount1, 0, instructions.recipient, instructions.deadline, IERC20(token0), 0, 0, "", instructions.amountIn0, instructions.amountOut0Min, instructions.swapData0, instructions.amountAddMin0, instructions.amountAddMin1, 0), IERC20(token0), IERC20(token1), instructions.unwrap); } else { // no swap is done here result = _swapAndIncrease(SwapAndIncreaseLiquidityParams(instructions.protocol, nfpm, tokenId, amount0, amount1, 0, instructions.recipient, instructions.deadline, IERC20(address(0)), 0, 0, "", 0, 0, "", instructions.amountAddMin0, instructions.amountAddMin1, 0), IERC20(token0), IERC20(token1), instructions.unwrap); } emit CompoundFees(address(nfpm), tokenId, result.liquidity, result.added0, result.added1); } else if (instructions.whatToDo == WhatToDo.CHANGE_RANGE) { SwapAndMintResult memory result; if (instructions.targetToken == token0) { result = _swapAndMint(SwapAndMintParams(instructions.protocol, nfpm, IERC20(token0), IERC20(token1), fee, instructions.tickLower, instructions.tickUpper, 0, amount0, amount1, 0, instructions.recipient, instructions.deadline, IERC20(token1), instructions.amountIn1, instructions.amountOut1Min, instructions.swapData1, 0, 0, "", instructions.amountAddMin0, instructions.amountAddMin1), instructions.unwrap); } else if (instructions.targetToken == token1) { result = _swapAndMint(SwapAndMintParams(instructions.protocol, nfpm, IERC20(token0), IERC20(token1), fee, instructions.tickLower, instructions.tickUpper, 0, amount0, amount1, 0, instructions.recipient, instructions.deadline, IERC20(token0), 0, 0, "", instructions.amountIn0, instructions.amountOut0Min, instructions.swapData0, instructions.amountAddMin0, instructions.amountAddMin1), instructions.unwrap); } else { // no swap is done here result = _swapAndMint(SwapAndMintParams(instructions.protocol, nfpm, IERC20(token0), IERC20(token1), fee, instructions.tickLower, instructions.tickUpper, 0, amount0, amount1, 0, instructions.recipient, instructions.deadline, IERC20(address(0)), 0, 0, "", 0, 0, "", instructions.amountAddMin0, instructions.amountAddMin1), instructions.unwrap); } emit ChangeRange(msg.sender, tokenId, result.tokenId, result.liquidity, result.added0, result.added1); } else if (instructions.whatToDo == WhatToDo.WITHDRAW_AND_COLLECT_AND_SWAP) { IWETH9 weth = _getWeth9(nfpm, instructions.protocol); uint256 targetAmount; if (token0 != instructions.targetToken) { (uint256 amountInDelta, uint256 amountOutDelta) = _swap(IERC20(token0), IERC20(instructions.targetToken), amount0, instructions.amountOut0Min, instructions.swapData0); if (amountInDelta < amount0) { _transferToken(weth, instructions.recipient, IERC20(token0), amount0 - amountInDelta, instructions.unwrap); } targetAmount += amountOutDelta; } else { targetAmount += amount0; } if (token1 != instructions.targetToken) { (uint256 amountInDelta, uint256 amountOutDelta) = _swap(IERC20(token1), IERC20(instructions.targetToken), amount1, instructions.amountOut1Min, instructions.swapData1); if (amountInDelta < amount1) { _transferToken(weth, instructions.recipient, IERC20(token1), amount1 - amountInDelta, instructions.unwrap); } targetAmount += amountOutDelta; } else { targetAmount += amount1; } // send complete target amount if (targetAmount != 0 && instructions.targetToken != address(0)) { _transferToken(weth, instructions.recipient, IERC20(instructions.targetToken), targetAmount, instructions.unwrap); } emit WithdrawAndCollectAndSwap(address(nfpm), tokenId, instructions.targetToken, targetAmount); } else { revert NotSupportedAction(); } // return token to owner (this line guarantees that token is returned to originating owner) nfpm.transferFrom(address(this), from, tokenId); return IERC721Receiver.onERC721Received.selector; } /// @notice Params for swap() function struct SwapParams { IWETH9 weth; IERC20 tokenIn; IERC20 tokenOut; uint256 amountIn; uint256 minAmountOut; address recipient; // recipient of tokenOut and leftover tokenIn (if any leftover) bytes swapData; bool unwrap; // if tokenIn or tokenOut is WETH - unwrap } /// @notice Does 1 or 2 swaps from swapSourceToken to token0 and token1 and adds as much as possible liquidity to a newly minted position. /// @param params Swap and mint configuration /// Newly minted NFT and leftover tokens are returned to recipient function swapAndMint(SwapAndMintParams calldata params) whenNotPaused() external payable returns (SwapAndMintResult memory result) { if (params.token0 == params.token1) { revert SameToken(); } require(_isWhitelistedNfpm(address(params.nfpm))); IWETH9 weth = _getWeth9(params.nfpm, params.protocol); // validate if amount2 is enough for action if (params.swapSourceToken != params.token0 && params.swapSourceToken != params.token1 && params.amountIn0 + params.amountIn1 > params.amount2 ) { revert AmountError(); } _prepareSwap(weth, params.token0, params.token1, params.swapSourceToken, params.amount0, params.amount1, params.amount2); SwapAndMintParams memory _params = params; DeductFeesEventData memory eventData; if (params.protocolFeeX64 > 0) { uint256 feeAmount0; uint256 feeAmount1; uint256 feeAmount2; // since we do not have the tokenId here, we need to emit event later (_params.amount0, _params.amount1, _params.amount2, feeAmount0, feeAmount1, feeAmount2) = _deductFees(DeductFeesParams(params.amount0, params.amount1, params.amount2, params.protocolFeeX64, FeeType.PROTOCOL_FEE, address(params.nfpm), 0, params.recipient, address(params.token0), address(params.token1), address(params.swapSourceToken)), false); // swap source token is not token 0 and token 1 if (_params.swapSourceToken != _params.token0 && _params.swapSourceToken != _params.token1) { if (_params.amountIn0 + _params.amountIn1 > _params.amount2) { revert AmountError(); } if (_params.amountIn0 + _params.amountIn1 < _params.amount2) { uint256 leftOverAmount = _params.amount2 - (_params.amountIn0 + _params.amountIn1); // return un-needed tokens _transferToken(weth, msg.sender, _params.swapSourceToken, leftOverAmount, msg.value != 0); } } eventData = DeductFeesEventData({ token0: address(params.token0), token1: address(params.token1), token2: address(params.swapSourceToken), amount0: params.amount0, amount1: params.amount1, amount2: params.amount2, feeAmount0: feeAmount0, feeAmount1: feeAmount1, feeAmount2: feeAmount2, feeX64: params.protocolFeeX64, feeType: FeeType.PROTOCOL_FEE }); } result = _swapAndMint(_params, msg.value != 0); emit DeductFees(address(params.nfpm), result.tokenId, params.recipient, eventData); } /// @notice Does 1 or 2 swaps from swapSourceToken to token0 and token1 and adds as much as possible liquidity to any existing position (no need to be position owner). /// @param params Swap and increase liquidity configuration // Sends any leftover tokens to recipient. function swapAndIncreaseLiquidity(SwapAndIncreaseLiquidityParams calldata params) whenNotPaused() external payable returns (SwapAndIncreaseLiquidityResult memory result) { require(_isWhitelistedNfpm(address(params.nfpm))); address owner = params.nfpm.ownerOf(params.tokenId); require(owner == msg.sender, "sender is not owner of position"); (address token0,address token1,,,,) = _getPosition(params.nfpm, params.protocol, params.tokenId); IWETH9 weth = _getWeth9(params.nfpm, params.protocol); // validate if amount2 is enough for action if (address(params.swapSourceToken) != token0 && address(params.swapSourceToken) != token1 && params.amountIn0 + params.amountIn1 > params.amount2 ) { revert AmountError(); } _prepareSwap(weth, IERC20(token0), IERC20(token1), params.swapSourceToken, params.amount0, params.amount1, params.amount2); SwapAndIncreaseLiquidityParams memory _params = params; if (params.protocolFeeX64 > 0) { (_params.amount0, _params.amount1, _params.amount2,,,) = _deductFees(DeductFeesParams(params.amount0, params.amount1, params.amount2, params.protocolFeeX64, FeeType.PROTOCOL_FEE, address(params.nfpm), params.tokenId, params.recipient, token0, token1, address(params.swapSourceToken)), true); // swap source token is not token 0 and token 1 if (address(_params.swapSourceToken) != token0 && address(_params.swapSourceToken) != token1) { if (_params.amountIn0 + _params.amountIn1 < _params.amount2) { uint256 leftOverAmount = _params.amount2 - (_params.amountIn0 + _params.amountIn1); // return un-needed tokens _transferToken(weth, msg.sender, _params.swapSourceToken, leftOverAmount, msg.value != 0); } } } result = _swapAndIncrease(_params, IERC20(token0), IERC20(token1), msg.value != 0); } // needed for WETH unwrapping receive() external payable{} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.20; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be * reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "v3-periphery/interfaces/external/IWETH9.sol"; import "v3-periphery/interfaces/INonfungiblePositionManager.sol" as univ3; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "v3-core/libraries/FullMath.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import '@openzeppelin/contracts/utils/structs/EnumerableSet.sol'; import "./Pausable.sol"; interface INonfungiblePositionManager is univ3.INonfungiblePositionManager { /// @notice mintParams for algebra v1 struct AlgebraV1MintParams { address token0; address token1; int24 tickLower; int24 tickUpper; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; uint256 amount1Min; address recipient; uint256 deadline; } /// @notice Creates a new position wrapped in a NFT /// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized /// a method does not exist, i.e. the pool is assumed to be initialized. /// @param params The params necessary to mint a position, encoded as `MintParams` in calldata /// @return tokenId The ID of the token that represents the minted position /// @return liquidity The amount of liquidity for this position /// @return amount0 The amount of token0 /// @return amount1 The amount of token1 function mint(AlgebraV1MintParams calldata params) external payable returns ( uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1 ); /// @return Returns the address of WNativeToken function WNativeToken() external view returns (address); } abstract contract Common is AccessControl, Pausable { using Address for address; bytes32 public constant WITHDRAWER_ROLE = keccak256("WITHDRAWER_ROLE"); bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE"); uint256 internal constant Q64 = 2 ** 64; uint256 internal constant Q96 = 2 ** 96; // error types error SelfSend(); error NotSupportedAction(); error NotSupportedProtocol(); error SameToken(); error AmountError(); error SlippageError(); error CollectError(); error TransferError(); error EtherSendFailed(); error TooMuchEtherSent(); error NoEtherToken(); error NotWETH(); error TooMuchFee(); error GetPositionFailed(); error NoFees(); struct DeductFeesEventData { address token0; address token1; address token2; uint256 amount0; uint256 amount1; uint256 amount2; uint256 feeAmount0; uint256 feeAmount1; uint256 feeAmount2; uint64 feeX64; FeeType feeType; } // events event CompoundFees(address indexed nfpm, uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1); event DeductFees(address indexed nfpm, uint256 indexed tokenId, address indexed userAddress, DeductFeesEventData data); event ChangeRange(address indexed nfpm, uint256 indexed tokenId, uint256 newTokenId, uint256 newLiquidity, uint256 token0Added, uint256 token1Added); event WithdrawAndCollectAndSwap(address indexed nfpm, uint256 indexed tokenId, address token, uint256 amount); event Swap(address indexed tokenIn, address indexed tokenOut, uint256 amountIn, uint256 amountOut); event SwapAndMint(address indexed nfpm, uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1); event SwapAndIncreaseLiquidity(address indexed nfpm, uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1); EnumerableSet.AddressSet private _whitelistedNfpm; address public swapRouter; address public FEE_TAKER; address private _initializer; mapping (FeeType=>uint64) private _maxFeeX64; constructor() { _maxFeeX64[FeeType.GAS_FEE] = 1844674407370955264; // 10% _maxFeeX64[FeeType.PROTOCOL_FEE] = 1844674407370955264; // 10% _initializer = tx.origin; } bool private _initialized = false; function initialize(address router, address admin, address withdrawer, address feeTaker, address[] calldata whitelistedNfpms) public virtual { require(!_initialized); if (withdrawer == address(0)) { revert(); } require(msg.sender == _initializer); _grantRole(ADMIN_ROLE, admin); _grantRole(DEFAULT_ADMIN_ROLE, admin); _grantRole(WITHDRAWER_ROLE, withdrawer); _grantRole(DEFAULT_ADMIN_ROLE, withdrawer); swapRouter = router; FEE_TAKER = feeTaker; for (uint256 i = 0; i < whitelistedNfpms.length; i++) { EnumerableSet.add(_whitelistedNfpm, whitelistedNfpms[i]); } _initialized = true; } /// @notice protocol to provide lp enum Protocol { UNI_V3, ALGEBRA_V1 } enum FeeType { GAS_FEE, PROTOCOL_FEE // todo: PERFORMANCE_FEE } /// @notice Params for swapAndMint() function struct SwapAndMintParams { Protocol protocol; INonfungiblePositionManager nfpm; IERC20 token0; IERC20 token1; uint24 fee; int24 tickLower; int24 tickUpper; uint64 protocolFeeX64; // how much is provided of token0 and token1 uint256 amount0; uint256 amount1; uint256 amount2; address recipient; // recipient of tokens uint256 deadline; // source token for swaps (maybe either address(0), token0, token1 or another token) // if swapSourceToken is another token than token0 or token1 -> amountIn0 + amountIn1 of swapSourceToken are expected to be available IERC20 swapSourceToken; // if swapSourceToken needs to be swapped to token0 - set values uint256 amountIn0; uint256 amountOut0Min; bytes swapData0; // if swapSourceToken needs to be swapped to token1 - set values uint256 amountIn1; uint256 amountOut1Min; bytes swapData1; // min amount to be added after swap uint256 amountAddMin0; uint256 amountAddMin1; } /// @notice Params for swapAndIncreaseLiquidity() function struct SwapAndIncreaseLiquidityParams { Protocol protocol; INonfungiblePositionManager nfpm; uint256 tokenId; // how much is provided of token0 and token1 uint256 amount0; uint256 amount1; uint256 amount2; address recipient; // recipient of leftover tokens uint256 deadline; // source token for swaps (maybe either address(0), token0, token1 or another token) // if swapSourceToken is another token than token0 or token1 -> amountIn0 + amountIn1 of swapSourceToken are expected to be available IERC20 swapSourceToken; // if swapSourceToken needs to be swapped to token0 - set values uint256 amountIn0; uint256 amountOut0Min; bytes swapData0; // if swapSourceToken needs to be swapped to token1 - set values uint256 amountIn1; uint256 amountOut1Min; bytes swapData1; // min amount to be added after swap uint256 amountAddMin0; uint256 amountAddMin1; uint64 protocolFeeX64; } struct ReturnLeftoverTokensParams{ IWETH9 weth; address to; IERC20 token0; IERC20 token1; uint256 total0; uint256 total1; uint256 added0; uint256 added1; bool unwrap; } struct DecreaseAndCollectFeesParams { INonfungiblePositionManager nfpm; address userAddress; IERC20 token0; IERC20 token1; uint256 tokenId; uint128 liquidity; uint256 deadline; uint256 token0Min; uint256 token1Min; bool compoundFees; } struct DeductFeesParams { uint256 amount0; uint256 amount1; uint256 amount2; uint64 feeX64; FeeType feeType; // readonly params for emitting events address nfpm; uint256 tokenId; address userAddress; address token0; address token1; address token2; } /** * @notice Withdraws erc20 token balance * @param tokens Addresses of erc20 tokens to withdraw * @param to Address to send to */ function withdrawERC20(IERC20[] calldata tokens, address to) external onlyRole(WITHDRAWER_ROLE) { uint count = tokens.length; for(uint i = 0; i < count; ++i) { uint256 balance = tokens[i].balanceOf(address(this)); if (balance > 0) { SafeERC20.safeTransfer(tokens[i], to, balance); } } } /** * @notice Withdraws native token balance * @param to Address to send to */ function withdrawNative(address to) external onlyRole(WITHDRAWER_ROLE) { uint256 nativeBalance = address(this).balance; if (nativeBalance > 0) { payable(to).transfer(nativeBalance); } } /** * @notice Withdraws erc721 token balance * @param nfpm Addresses of erc721 tokens to withdraw * @param tokenId tokenId of erc721 tokens to withdraw * @param to Address to send to */ function withdrawERC721(INonfungiblePositionManager nfpm, uint256 tokenId, address to) external onlyRole(WITHDRAWER_ROLE) { nfpm.transferFrom(address(this), to, tokenId); } // checks if required amounts are provided and are exact - wraps any provided ETH as WETH // if less or more provided reverts function _prepareSwap(IWETH9 weth, IERC20 token0, IERC20 token1, IERC20 otherToken, uint256 amount0, uint256 amount1, uint256 amountOther) internal { uint256 amountAdded0; uint256 amountAdded1; uint256 amountAddedOther; // wrap ether sent if (msg.value != 0) { weth.deposit{ value: msg.value }(); if (address(weth) == address(token0)) { amountAdded0 = msg.value; if (amountAdded0 > amount0) { revert TooMuchEtherSent(); } } else if (address(weth) == address(token1)) { amountAdded1 = msg.value; if (amountAdded1 > amount1) { revert TooMuchEtherSent(); } } else if (address(weth) == address(otherToken)) { amountAddedOther = msg.value; if (amountAddedOther > amountOther) { revert TooMuchEtherSent(); } } else { revert NoEtherToken(); } } // get missing tokens (fails if not enough provided) if (amount0 > amountAdded0) { uint256 balanceBefore = token0.balanceOf(address(this)); SafeERC20.safeTransferFrom(token0, msg.sender, address(this), amount0 - amountAdded0); uint256 balanceAfter = token0.balanceOf(address(this)); if (balanceAfter - balanceBefore != amount0 - amountAdded0) { revert TransferError(); // reverts for fee-on-transfer tokens } } if (amount1 > amountAdded1) { uint256 balanceBefore = token1.balanceOf(address(this)); SafeERC20.safeTransferFrom(token1, msg.sender, address(this), amount1 - amountAdded1); uint256 balanceAfter = token1.balanceOf(address(this)); if (balanceAfter - balanceBefore != amount1 - amountAdded1) { revert TransferError(); // reverts for fee-on-transfer tokens } } if (amountOther > amountAddedOther && address(otherToken) != address(0) && token0 != otherToken && token1 != otherToken) { uint256 balanceBefore = otherToken.balanceOf(address(this)); SafeERC20.safeTransferFrom(otherToken, msg.sender, address(this), amountOther - amountAddedOther); uint256 balanceAfter = otherToken.balanceOf(address(this)); if (balanceAfter - balanceBefore != amountOther - amountAddedOther) { revert TransferError(); // reverts for fee-on-transfer tokens } } } struct SwapAndMintResult { uint256 tokenId; uint128 liquidity; uint256 added0; uint256 added1; } // swap and mint logic function _swapAndMint(SwapAndMintParams memory params, bool unwrap) internal returns (SwapAndMintResult memory result) { (uint256 total0, uint256 total1) = _swapAndPrepareAmounts(params, unwrap); if (params.protocol == Protocol.UNI_V3) { // mint is done to address(this) because it is not a safemint and safeTransferFrom needs to be done manually afterwards (result.tokenId,result.liquidity,result.added0,result.added1) = _mintUniv3(params.nfpm, univ3.INonfungiblePositionManager.MintParams( address(params.token0), address(params.token1), params.fee, params.tickLower, params.tickUpper, total0, total1, params.amountAddMin0, params.amountAddMin1, address(this), // is sent to real recipient aftwards params.deadline )); } else if (params.protocol == Protocol.ALGEBRA_V1) { // mint is done to address(this) because it is not a safemint and safeTransferFrom needs to be done manually afterwards (result.tokenId,result.liquidity,result.added0,result.added1) = _mintAlgebraV1(params.nfpm, univ3.INonfungiblePositionManager.MintParams( address(params.token0), address(params.token1), params.fee, params.tickLower, params.tickUpper, total0, total1, params.amountAddMin0, params.amountAddMin1, address(this), // is sent to real recipient aftwards params.deadline )); } else { revert NotSupportedProtocol(); } params.nfpm.transferFrom(address(this), params.recipient, result.tokenId); emit SwapAndMint(address(params.nfpm), result.tokenId, result.liquidity, result.added0, result.added1); _returnLeftoverTokens(ReturnLeftoverTokensParams(_getWeth9(params.nfpm, params.protocol), params.recipient, params.token0, params.token1, total0, total1, result.added0, result.added1, unwrap)); } function _mintUniv3(INonfungiblePositionManager nfpm, INonfungiblePositionManager.MintParams memory params) internal returns ( uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1 ) { // mint is done to address(this) because it is not a safemint and safeTransferFrom needs to be done manually afterwards return nfpm.mint(params); } function _mintAlgebraV1(INonfungiblePositionManager nfpm, INonfungiblePositionManager.MintParams memory params) internal returns ( uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1 ) { INonfungiblePositionManager.AlgebraV1MintParams memory mintParams = INonfungiblePositionManager.AlgebraV1MintParams( params.token0, params.token1, params.tickLower, params.tickUpper, params.amount0Desired, params.amount1Desired, params.amount0Min, params.amount1Min, address(this), // is sent to real recipient aftwards params.deadline ); // mint is done to address(this) because it is not a safemint and safeTransferFrom needs to be done manually afterwards return nfpm.mint(mintParams); } struct SwapAndIncreaseLiquidityResult { uint128 liquidity; uint256 added0; uint256 added1; uint256 feeAmount0; uint256 feeAmount1; } // swap and increase logic function _swapAndIncrease(SwapAndIncreaseLiquidityParams memory params, IERC20 token0, IERC20 token1, bool unwrap) internal returns (SwapAndIncreaseLiquidityResult memory result) { (uint256 total0, uint256 total1) = _swapAndPrepareAmounts( SwapAndMintParams(params.protocol, params.nfpm, token0, token1, 0, 0, 0, 0, params.amount0, params.amount1, 0, params.recipient, params.deadline, params.swapSourceToken, params.amountIn0, params.amountOut0Min, params.swapData0, params.amountIn1, params.amountOut1Min, params.swapData1, params.amountAddMin0, params.amountAddMin1), unwrap); INonfungiblePositionManager.IncreaseLiquidityParams memory increaseLiquidityParams = univ3.INonfungiblePositionManager.IncreaseLiquidityParams( params.tokenId, total0, total1, params.amountAddMin0, params.amountAddMin1, params.deadline ); (result.liquidity, result.added0, result.added1) = params.nfpm.increaseLiquidity(increaseLiquidityParams); emit SwapAndIncreaseLiquidity(address(params.nfpm), params.tokenId, result.liquidity, result.added0, result.added1); IWETH9 weth = _getWeth9(params.nfpm, params.protocol); _returnLeftoverTokens(ReturnLeftoverTokensParams(weth, params.recipient, token0, token1, total0, total1, result.added0, result.added1, unwrap)); } // swaps available tokens and prepares max amounts to be added to nfpm function _swapAndPrepareAmounts(SwapAndMintParams memory params, bool unwrap) internal returns (uint256 total0, uint256 total1) { if (params.swapSourceToken == params.token0) { if (params.amount0 < params.amountIn1) { revert AmountError(); } (uint256 amountInDelta, uint256 amountOutDelta) = _swap(params.token0, params.token1, params.amountIn1, params.amountOut1Min, params.swapData1); total0 = params.amount0 - amountInDelta; total1 = params.amount1 + amountOutDelta; } else if (params.swapSourceToken == params.token1) { if (params.amount1 < params.amountIn0) { revert AmountError(); } (uint256 amountInDelta, uint256 amountOutDelta) = _swap(params.token1, params.token0, params.amountIn0, params.amountOut0Min, params.swapData0); total1 = params.amount1 - amountInDelta; total0 = params.amount0 + amountOutDelta; } else if (address(params.swapSourceToken) != address(0)) { (uint256 amountInDelta0, uint256 amountOutDelta0) = _swap(params.swapSourceToken, params.token0, params.amountIn0, params.amountOut0Min, params.swapData0); (uint256 amountInDelta1, uint256 amountOutDelta1) = _swap(params.swapSourceToken, params.token1, params.amountIn1, params.amountOut1Min, params.swapData1); total0 = params.amount0 + amountOutDelta0; total1 = params.amount1 + amountOutDelta1; // return third token leftover if any uint256 leftOver = params.amountIn0 + params.amountIn1 - amountInDelta0 - amountInDelta1; if (leftOver != 0) { IWETH9 weth = _getWeth9(params.nfpm, params.protocol); _transferToken(weth, params.recipient, params.swapSourceToken, leftOver, unwrap); } } else { total0 = params.amount0; total1 = params.amount1; } if (total0 != 0) { _safeResetAndApprove(params.token0, address(params.nfpm), total0); } if (total1 != 0) { _safeResetAndApprove(params.token1, address(params.nfpm), total1); } } // returns leftover token balances function _returnLeftoverTokens(ReturnLeftoverTokensParams memory params) internal { uint256 left0 = params.total0 - params.added0; uint256 left1 = params.total1 - params.added1; // return leftovers if (left0 != 0) { _transferToken(params.weth, params.to, params.token0, left0, params.unwrap); } if (left1 != 0) { _transferToken(params.weth, params.to, params.token1, left1, params.unwrap); } } // transfers token (or unwraps WETH and sends ETH) function _transferToken(IWETH9 weth, address to, IERC20 token, uint256 amount, bool unwrap) internal { if (address(weth) == address(token) && unwrap) { weth.withdraw(amount); (bool sent, ) = to.call{value: amount}(""); if (!sent) { revert EtherSendFailed(); } } else { SafeERC20.safeTransfer(token, to, amount); } } // general swap function which uses external router with off-chain calculated swap instructions // does slippage check with amountOutMin param // returns token amounts deltas after swap function _swap(IERC20 tokenIn, IERC20 tokenOut, uint256 amountIn, uint256 amountOutMin, bytes memory swapData) internal returns (uint256 amountInDelta, uint256 amountOutDelta) { if (amountIn != 0 && swapData.length != 0 && address(tokenOut) != address(0)) { uint256 balanceInBefore = tokenIn.balanceOf(address(this)); uint256 balanceOutBefore = tokenOut.balanceOf(address(this)); // approve needed amount _safeApprove(tokenIn, swapRouter, amountIn); // execute swap (bool success,) = swapRouter.call(swapData); if (!success) { revert ("swap failed!"); } // reset approval _safeApprove(tokenIn, swapRouter, 0); uint256 balanceInAfter = tokenIn.balanceOf(address(this)); uint256 balanceOutAfter = tokenOut.balanceOf(address(this)); amountInDelta = balanceInBefore - balanceInAfter; amountOutDelta = balanceOutAfter - balanceOutBefore; // amountMin slippage check if (amountOutDelta < amountOutMin) { revert SlippageError(); } // event for any swap with exact swapped value emit Swap(address(tokenIn), address(tokenOut), amountInDelta, amountOutDelta); } } // decreases liquidity from uniswap v3 position function _decreaseLiquidity(INonfungiblePositionManager nfpm, uint256 tokenId, uint128 liquidity, uint256 deadline, uint256 token0Min, uint256 token1Min) internal returns (uint256 amount0, uint256 amount1) { if (liquidity != 0) { (amount0, amount1) = nfpm.decreaseLiquidity( univ3.INonfungiblePositionManager.DecreaseLiquidityParams( tokenId, liquidity, token0Min, token1Min, deadline ) ); } } // collects specified amount of fees from uniswap v3 position function _collectFees(INonfungiblePositionManager nfpm, uint256 tokenId, IERC20 token0, IERC20 token1, uint128 collectAmount0, uint128 collectAmount1) internal returns (uint256 amount0, uint256 amount1) { uint256 balanceBefore0 = token0.balanceOf(address(this)); uint256 balanceBefore1 = token1.balanceOf(address(this)); (amount0, amount1) = nfpm.collect( univ3.INonfungiblePositionManager.CollectParams(tokenId, address(this), collectAmount0, collectAmount1) ); uint256 balanceAfter0 = token0.balanceOf(address(this)); uint256 balanceAfter1 = token1.balanceOf(address(this)); // reverts for fee-on-transfer tokens if (balanceAfter0 - balanceBefore0 != amount0) { revert CollectError(); } if (balanceAfter1 - balanceBefore1 != amount1) { revert CollectError(); } } function _decreaseLiquidityAndCollectFees(DecreaseAndCollectFeesParams memory params) internal returns (uint256 amount0, uint256 amount1) { (uint256 positionAmount0, uint256 positionAmount1) = _decreaseLiquidity(params.nfpm, params.tokenId, params.liquidity, params.deadline, params.token0Min, params.token1Min); (amount0, amount1) = params.nfpm.collect( univ3.INonfungiblePositionManager.CollectParams( params.tokenId, address(this), type(uint128).max, type(uint128).max ) ); if (!params.compoundFees) { { uint256 fees0Return = amount0 - positionAmount0; uint256 fees1Return = amount1 - positionAmount1; // return feesToken if (fees0Return > 0) { SafeERC20.safeTransfer(params.token0, params.userAddress, fees0Return); } if (fees1Return > 0) { SafeERC20.safeTransfer(params.token1, params.userAddress, fees1Return); } } amount0 = positionAmount0; amount1 = positionAmount1; } } function _getWeth9(INonfungiblePositionManager nfpm, Protocol protocol) view internal returns (IWETH9 weth) { if (protocol == Protocol.UNI_V3) { weth = IWETH9(nfpm.WETH9()); } else if (protocol == Protocol.ALGEBRA_V1) { weth = IWETH9(nfpm.WNativeToken()); } else { revert NotSupportedProtocol(); } } function _getPosition(INonfungiblePositionManager nfpm, Protocol protocol, uint256 tokenId) internal returns (address token0, address token1, uint128 liquidity, int24 tickLower, int24 tickUpper, uint24 fee) { (bool success, bytes memory data) = address(nfpm).call(abi.encodeWithSignature("positions(uint256)", tokenId)); if (!success) { revert GetPositionFailed(); } if (protocol == Protocol.UNI_V3) { (,, token0, token1, fee,tickLower, tickUpper, liquidity,,,,) = abi.decode(data, (uint96,address,address,address,uint24,int24,int24,uint128,uint256,uint256,uint128,uint128)); } else if (protocol == Protocol.ALGEBRA_V1) { (,, token0, token1, tickLower, tickUpper, liquidity,,,,) = abi.decode(data, (uint96,address,address,address,int24,int24,uint128,uint256,uint256,uint128,uint128)); } } /** * @notice calculate fee * @param emitEvent: whether to emit event or not. Since swap and mint have not had token id yet. * we need to emit event latter */ function _deductFees(DeductFeesParams memory params, bool emitEvent) internal returns(uint256 amount0Left, uint256 amount1Left, uint256 amount2Left, uint256 feeAmount0, uint256 feeAmount1, uint256 feeAmount2) { if (params.feeX64 > _maxFeeX64[params.feeType]) { revert TooMuchFee(); } // to save gas, we always need to check if fee exists before deductFees if (params.feeX64 == 0) { revert NoFees(); } if (params.amount0 > 0) { feeAmount0 = FullMath.mulDiv(params.amount0, params.feeX64, Q64); amount0Left = params.amount0 - feeAmount0; SafeERC20.safeTransfer(IERC20(params.token0), FEE_TAKER, feeAmount0); } if (params.amount1 > 0) { feeAmount1 = FullMath.mulDiv(params.amount1, params.feeX64, Q64); amount1Left = params.amount1 - feeAmount1; SafeERC20.safeTransfer(IERC20(params.token1), FEE_TAKER, feeAmount1); } if (params.amount2 > 0) { feeAmount2 = FullMath.mulDiv(params.amount2, params.feeX64, Q64); amount2Left = params.amount2 - feeAmount2; SafeERC20.safeTransfer(IERC20(params.token2), FEE_TAKER, feeAmount2); } if (emitEvent) { emit DeductFees(address(params.nfpm), params.tokenId, params.userAddress, DeductFeesEventData( params.token0, params.token1, params.token2, params.amount0, params.amount1, params.amount2, feeAmount0, feeAmount1, feeAmount2, params.feeX64, params.feeType )); } } function pause() external onlyRole(ADMIN_ROLE) { _pause(); } function unpause() external onlyRole(ADMIN_ROLE) { _unpause(); } function setMaxFeeX64(FeeType feeType, uint64 feex64) external onlyRole(ADMIN_ROLE) { _maxFeeX64[feeType] = feex64; } function getMaxFeeX64(FeeType feeType) external view returns (uint64) { return _maxFeeX64[feeType]; } /// @dev some tokens require allowance == 0 to approve new amount /// but some tokens does not allow approve ammount = 0 /// we try to set allowance = 0 before approve new amount. if it revert means that /// the token not allow to approve 0, which means the following line code will work properly function _safeResetAndApprove(IERC20 token, address _spender, uint256 _value) internal { /// @dev ommited approve(0) result because it might fail and does not break the flow address(token).call(abi.encodeWithSelector(token.approve.selector, _spender, 0)); /// @dev value for approval after reset must greater than 0 require(_value > 0); _safeApprove(token, _spender, _value); } function _safeApprove(IERC20 token, address _spender, uint256 _value) internal { bytes memory returnData = address(token).functionCall(abi.encodeWithSelector(token.approve.selector, _spender, _value)); if (returnData.length > 0) { // Return data is optional require(abi.decode(returnData, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } function _isWhitelistedNfpm(address nfpm) internal view returns(bool) { return EnumerableSet.contains(_whitelistedNfpm, nfpm); } function setWhitelistNfpm(address[] calldata nfpms, bool isWhitelist) external onlyRole(ADMIN_ROLE) { uint256 length = nfpms.length; for (uint256 i = 0; i < length; i++) { if (isWhitelist) { EnumerableSet.add(_whitelistedNfpm, nfpms[i]); } else { EnumerableSet.remove(_whitelistedNfpm, nfpms[i]); } } } function setFeeTaker(address feeTaker) external onlyRole(ADMIN_ROLE) { FEE_TAKER = feeTaker; } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.8.15; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; /// @title Interface for WETH9 interface IWETH9 is IERC20 { /// @notice Deposit ether to get wrapped ether function deposit() external payable; /// @notice Withdraw wrapped ether to get ether function withdraw(uint256) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; pragma abicoder v2; import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol'; import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol'; import './IPoolInitializer.sol'; import './IERC721Permit.sol'; import './IPeripheryPayments.sol'; import './IPeripheryImmutableState.sol'; import '../libraries/PoolAddress.sol'; /// @title Non-fungible token for positions /// @notice Wraps Uniswap V3 positions in a non-fungible token interface which allows for them to be transferred /// and authorized. interface INonfungiblePositionManager is IPoolInitializer, IPeripheryPayments, IPeripheryImmutableState, IERC721Metadata, IERC721Enumerable, IERC721Permit { /// @notice Emitted when liquidity is increased for a position NFT /// @dev Also emitted when a token is minted /// @param tokenId The ID of the token for which liquidity was increased /// @param liquidity The amount by which liquidity for the NFT position was increased /// @param amount0 The amount of token0 that was paid for the increase in liquidity /// @param amount1 The amount of token1 that was paid for the increase in liquidity event IncreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1); /// @notice Emitted when liquidity is decreased for a position NFT /// @param tokenId The ID of the token for which liquidity was decreased /// @param liquidity The amount by which liquidity for the NFT position was decreased /// @param amount0 The amount of token0 that was accounted for the decrease in liquidity /// @param amount1 The amount of token1 that was accounted for the decrease in liquidity event DecreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1); /// @notice Emitted when tokens are collected for a position NFT /// @dev The amounts reported may not be exactly equivalent to the amounts transferred, due to rounding behavior /// @param tokenId The ID of the token for which underlying tokens were collected /// @param recipient The address of the account that received the collected tokens /// @param amount0 The amount of token0 owed to the position that was collected /// @param amount1 The amount of token1 owed to the position that was collected event Collect(uint256 indexed tokenId, address recipient, uint256 amount0, uint256 amount1); /// @notice Returns the position information associated with a given token ID. /// @dev Throws if the token ID is not valid. /// @param tokenId The ID of the token that represents the position /// @return nonce The nonce for permits /// @return operator The address that is approved for spending /// @return token0 The address of the token0 for a specific pool /// @return token1 The address of the token1 for a specific pool /// @return fee The fee associated with the pool /// @return tickLower The lower end of the tick range for the position /// @return tickUpper The higher end of the tick range for the position /// @return liquidity The liquidity of the position /// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position /// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position /// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation /// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation function positions(uint256 tokenId) external view returns ( uint96 nonce, address operator, address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1 ); struct MintParams { address token0; address token1; uint24 fee; int24 tickLower; int24 tickUpper; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; uint256 amount1Min; address recipient; uint256 deadline; } /// @notice Creates a new position wrapped in a NFT /// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized /// a method does not exist, i.e. the pool is assumed to be initialized. /// @param params The params necessary to mint a position, encoded as `MintParams` in calldata /// @return tokenId The ID of the token that represents the minted position /// @return liquidity The amount of liquidity for this position /// @return amount0 The amount of token0 /// @return amount1 The amount of token1 function mint(MintParams calldata params) external payable returns ( uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1 ); struct IncreaseLiquidityParams { uint256 tokenId; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; uint256 amount1Min; uint256 deadline; } /// @notice Increases the amount of liquidity in a position, with tokens paid by the `msg.sender` /// @param params tokenId The ID of the token for which liquidity is being increased, /// amount0Desired The desired amount of token0 to be spent, /// amount1Desired The desired amount of token1 to be spent, /// amount0Min The minimum amount of token0 to spend, which serves as a slippage check, /// amount1Min The minimum amount of token1 to spend, which serves as a slippage check, /// deadline The time by which the transaction must be included to effect the change /// @return liquidity The new liquidity amount as a result of the increase /// @return amount0 The amount of token0 to acheive resulting liquidity /// @return amount1 The amount of token1 to acheive resulting liquidity function increaseLiquidity(IncreaseLiquidityParams calldata params) external payable returns ( uint128 liquidity, uint256 amount0, uint256 amount1 ); struct DecreaseLiquidityParams { uint256 tokenId; uint128 liquidity; uint256 amount0Min; uint256 amount1Min; uint256 deadline; } /// @notice Decreases the amount of liquidity in a position and accounts it to the position /// @param params tokenId The ID of the token for which liquidity is being decreased, /// amount The amount by which liquidity will be decreased, /// amount0Min The minimum amount of token0 that should be accounted for the burned liquidity, /// amount1Min The minimum amount of token1 that should be accounted for the burned liquidity, /// deadline The time by which the transaction must be included to effect the change /// @return amount0 The amount of token0 accounted to the position's tokens owed /// @return amount1 The amount of token1 accounted to the position's tokens owed function decreaseLiquidity(DecreaseLiquidityParams calldata params) external payable returns (uint256 amount0, uint256 amount1); struct CollectParams { uint256 tokenId; address recipient; uint128 amount0Max; uint128 amount1Max; } /// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient /// @param params tokenId The ID of the NFT for which tokens are being collected, /// recipient The account that should receive the tokens, /// amount0Max The maximum amount of token0 to collect, /// amount1Max The maximum amount of token1 to collect /// @return amount0 The amount of fees collected in token0 /// @return amount1 The amount of fees collected in token1 function collect(CollectParams calldata params) external payable returns (uint256 amount0, uint256 amount1); /// @notice Burns a token ID, which deletes it from the NFT contract. The token must have 0 liquidity and all tokens /// must be collected first. /// @param tokenId The ID of the token that is being burned function burn(uint256 tokenId) external payable; }
// SPDX-License-Identifier: 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 pragma solidity ^0.8.0; /// @title Contains 512-bit math functions /// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision /// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits library FullMath { /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv function mulDiv( uint256 a, uint256 b, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = a * b // Compute the product mod 2**256 and mod 2**256 - 1 // then use the Chinese Remainder Theorem to reconstruct // the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2**256 + prod0 uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(a, b, not(0)) prod0 := mul(a, b) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division if (prod1 == 0) { require(denominator > 0); assembly { result := div(prod0, denominator) } return result; } // Make sure the result is less than 2**256. // Also prevents denominator == 0 require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0] // Compute remainder using mulmod uint256 remainder; assembly { remainder := mulmod(a, b, denominator) } // Subtract 256 bit number from 512 bit number assembly { prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator // Compute largest power of two divisor of denominator. // Always >= 1. uint256 twos = (0 - denominator) & denominator; // Divide denominator by power of two assembly { denominator := div(denominator, twos) } // Divide [prod1 prod0] by the factors of two assembly { prod0 := div(prod0, twos) } // Shift in bits from prod1 into prod0. For this we need // to flip `twos` such that it is 2**256 / twos. // If twos is zero, then it becomes one assembly { twos := add(div(sub(0, twos), twos), 1) } prod0 |= prod1 * twos; // Invert denominator mod 2**256 // Now that denominator is an odd number, it has an inverse // modulo 2**256 such that denominator * inv = 1 mod 2**256. // Compute the inverse by starting with a seed that is correct // correct for four bits. That is, denominator * inv = 1 mod 2**4 uint256 inv = (3 * denominator) ^ 2; // Now use Newton-Raphson iteration to improve the precision. // Thanks to Hensel's lifting lemma, this also works in modular // arithmetic, doubling the correct bits in each step. inv *= 2 - denominator * inv; // inverse mod 2**8 inv *= 2 - denominator * inv; // inverse mod 2**16 inv *= 2 - denominator * inv; // inverse mod 2**32 inv *= 2 - denominator * inv; // inverse mod 2**64 inv *= 2 - denominator * inv; // inverse mod 2**128 inv *= 2 - denominator * inv; // inverse mod 2**256 // Because the division is now exact we can divide by multiplying // with the modular inverse of denominator. This will give us the // correct result modulo 2**256. Since the precoditions guarantee // that the outcome is less than 2**256, this is the final result. // We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inv; return result; } } /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result function mulDivRoundingUp( uint256 a, uint256 b, uint256 denominator ) internal pure returns (uint256 result) { unchecked { result = mulDiv(a, b, denominator); if (mulmod(a, b, denominator) > 0) { require(result < type(uint256).max); result++; } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol) pragma solidity ^0.8.20; import {IAccessControl} from "./IAccessControl.sol"; import {Context} from "../utils/Context.sol"; import {ERC165} from "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ```solidity * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ```solidity * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} * to enforce additional security measures for this role. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address account => bool) hasRole; bytes32 adminRole; } mapping(bytes32 role => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with an {AccessControlUnauthorizedAccount} error including the required role. */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual returns (bool) { return _roles[role].hasRole[account]; } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()` * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier. */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account` * is missing `role`. */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert AccessControlUnauthorizedAccount(account, role); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `callerConfirmation`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address callerConfirmation) public virtual { if (callerConfirmation != _msgSender()) { revert AccessControlBadConfirmation(); } _revokeRole(role, callerConfirmation); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual returns (bool) { if (!hasRole(role, account)) { _roles[role].hasRole[account] = true; emit RoleGranted(role, account, _msgSender()); return true; } else { return false; } } /** * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual returns (bool) { if (hasRole(role, account)) { _roles[role].hasRole[account] = false; emit RoleRevoked(role, account, _msgSender()); return true; } else { return false; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js. pragma solidity ^0.8.20; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ```solidity * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableSet. * ==== */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position is the index of the value in the `values` array plus 1. // Position 0 is used to mean a value is not in the set. mapping(bytes32 value => uint256) _positions; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._positions[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We cache the value's position to prevent multiple reads from the same storage slot uint256 position = set._positions[value]; if (position != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 valueIndex = position - 1; uint256 lastIndex = set._values.length - 1; if (valueIndex != lastIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the lastValue to the index where the value to delete is set._values[valueIndex] = lastValue; // Update the tracked position of the lastValue (that was just moved) set._positions[lastValue] = position; } // Delete the slot where the moved value was stored set._values.pop(); // Delete the tracked position for the deleted slot delete set._positions[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._positions[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values in the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol) pragma solidity ^0.8.20; import {Context} from "@openzeppelin/contracts/utils/Context.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 Pausable is Context { bool private _paused; /** * @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); /** * @dev The operation failed because the contract is paused. */ error EnforcedPause(); /** * @dev The operation failed because the contract is not paused. */ error ExpectedPause(); /** * @dev Initializes the contract in unpaused state. */ constructor() { _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 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 { if (paused()) { revert EnforcedPause(); } } /** * @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 { _paused = false; emit Unpaused(_msgSender()); } }
// 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/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.20; import {IERC721} from "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.20; import {IERC721} from "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; pragma abicoder v2; /// @title Creates and initializes V3 Pools /// @notice Provides a method for creating and initializing a pool, if necessary, for bundling with other methods that /// require the pool to exist. interface IPoolInitializer { /// @notice Creates a new pool if it does not exist, then initializes if not initialized /// @dev This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool /// @param token0 The contract address of token0 of the pool /// @param token1 The contract address of token1 of the pool /// @param fee The fee amount of the v3 pool for the specified token pair /// @param sqrtPriceX96 The initial square root price of the pool as a Q64.96 value /// @return pool Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary function createAndInitializePoolIfNecessary( address token0, address token1, uint24 fee, uint160 sqrtPriceX96 ) external payable returns (address pool); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; import '@openzeppelin/contracts/token/ERC721/IERC721.sol'; /// @title ERC721 with permit /// @notice Extension to ERC721 that includes a permit function for signature based approvals interface IERC721Permit is IERC721 { /// @notice The permit typehash used in the permit signature /// @return The typehash for the permit function PERMIT_TYPEHASH() external pure returns (bytes32); /// @notice The domain separator used in the permit signature /// @return The domain seperator used in encoding of permit signature function DOMAIN_SEPARATOR() external view returns (bytes32); /// @notice Approve of a specific token ID for spending by spender via signature /// @param spender The account that is being approved /// @param tokenId The ID of the token that is being approved for spending /// @param deadline The deadline timestamp by which the call must be mined for the approve to work /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s` /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s` /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v` function permit( address spender, uint256 tokenId, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external payable; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; /// @title Periphery Payments /// @notice Functions to ease deposits and withdrawals of ETH interface IPeripheryPayments { /// @notice Unwraps the contract's WETH9 balance and sends it to recipient as ETH. /// @dev The amountMinimum parameter prevents malicious contracts from stealing WETH9 from users. /// @param amountMinimum The minimum amount of WETH9 to unwrap /// @param recipient The address receiving ETH function unwrapWETH9(uint256 amountMinimum, address recipient) external payable; /// @notice Refunds any ETH balance held by this contract to the `msg.sender` /// @dev Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps /// that use ether for the input amount function refundETH() external payable; /// @notice Transfers the full amount of a token held by this contract to recipient /// @dev The amountMinimum parameter prevents malicious contracts from stealing the token from users /// @param token The contract address of the token which will be transferred to `recipient` /// @param amountMinimum The minimum amount of token required for a transfer /// @param recipient The destination address of the token function sweepToken( address token, uint256 amountMinimum, address recipient ) external payable; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Immutable state /// @notice Functions that return immutable state of the router interface IPeripheryImmutableState { /// @return Returns the address of the Uniswap V3 factory function factory() external view returns (address); /// @return Returns the address of WETH9 function WETH9() external view returns (address); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Provides functions for deriving a pool address from the factory, tokens, and the fee library PoolAddress { bytes32 internal constant POOL_INIT_CODE_HASH = 0xa598dd2fba360510c5a8f02f44423a4468e902df5857dbce3ca162a43a3a31ff; /// @notice The identifying key of the pool struct PoolKey { address token0; address token1; uint24 fee; } /// @notice Returns PoolKey: the ordered tokens with the matched fee levels /// @param tokenA The first token of a pool, unsorted /// @param tokenB The second token of a pool, unsorted /// @param fee The fee level of the pool /// @return Poolkey The pool details with ordered token0 and token1 assignments function getPoolKey( address tokenA, address tokenB, uint24 fee ) internal pure returns (PoolKey memory) { if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA); return PoolKey({token0: tokenA, token1: tokenB, fee: fee}); } /// @notice Deterministically computes the pool address given the factory and PoolKey /// @param factory The Uniswap V3 factory contract address /// @param key The PoolKey /// @return pool The contract address of the V3 pool function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) { require(key.token0 < key.token1); pool = address( uint160( uint256( keccak256( abi.encodePacked( hex'ff', factory, keccak256(abi.encode(key.token0, key.token1, key.fee)), POOL_INIT_CODE_HASH ) ) ) ) ); } }
// SPDX-License-Identifier: 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) (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) (access/IAccessControl.sol) pragma solidity ^0.8.20; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev The `account` is missing a role. */ error AccessControlUnauthorizedAccount(address account, bytes32 neededRole); /** * @dev The caller of a function is not the expected one. * * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}. */ error AccessControlBadConfirmation(); /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `callerConfirmation`. */ function renounceRole(bytes32 role, address callerConfirmation) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon * a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or * {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon * a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the address zero. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
{ "remappings": [ "@openzeppelin/=lib/openzeppelin-contracts/", "@uniswap/v3-core/=lib/v3-core/", "@uniswap/v3-periphery/=lib/v3-periphery/", "v3-core/=lib/v3-core/contracts/", "v3-periphery/=lib/v3-periphery/contracts/", "@cryptoalgebra/AlgebraV1/=lib/AlgebraV1/", "algebra-core/=lib/AlgebraV1/src/core/", "algebra-periphery/=lib/AlgebraV1/src/periphery/", "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", "AlgebraV1/=lib/AlgebraV1/src/", "ds-test/=lib/forge-std/lib/ds-test/src/", "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/", "forge-std/=lib/forge-std/src/", "openzeppelin-contracts/=lib/openzeppelin-contracts/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "paris", "viaIR": false, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"AmountError","type":"error"},{"inputs":[],"name":"CollectError","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"EtherSendFailed","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"GetPositionFailed","type":"error"},{"inputs":[],"name":"NoEtherToken","type":"error"},{"inputs":[],"name":"NoFees","type":"error"},{"inputs":[],"name":"NotSupportedAction","type":"error"},{"inputs":[],"name":"NotSupportedProtocol","type":"error"},{"inputs":[],"name":"NotWETH","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"SameToken","type":"error"},{"inputs":[],"name":"SelfSend","type":"error"},{"inputs":[],"name":"SlippageError","type":"error"},{"inputs":[],"name":"TooMuchEtherSent","type":"error"},{"inputs":[],"name":"TooMuchFee","type":"error"},{"inputs":[],"name":"TransferError","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"nfpm","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newLiquidity","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"token0Added","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"token1Added","type":"uint256"}],"name":"ChangeRange","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"nfpm","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint128","name":"liquidity","type":"uint128"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"CompoundFees","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"nfpm","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"userAddress","type":"address"},{"components":[{"internalType":"address","name":"token0","type":"address"},{"internalType":"address","name":"token1","type":"address"},{"internalType":"address","name":"token2","type":"address"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"},{"internalType":"uint256","name":"amount2","type":"uint256"},{"internalType":"uint256","name":"feeAmount0","type":"uint256"},{"internalType":"uint256","name":"feeAmount1","type":"uint256"},{"internalType":"uint256","name":"feeAmount2","type":"uint256"},{"internalType":"uint64","name":"feeX64","type":"uint64"},{"internalType":"enum Common.FeeType","name":"feeType","type":"uint8"}],"indexed":false,"internalType":"struct Common.DeductFeesEventData","name":"data","type":"tuple"}],"name":"DeductFees","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"tokenIn","type":"address"},{"indexed":true,"internalType":"address","name":"tokenOut","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountOut","type":"uint256"}],"name":"Swap","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"nfpm","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint128","name":"liquidity","type":"uint128"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"SwapAndIncreaseLiquidity","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"nfpm","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint128","name":"liquidity","type":"uint128"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"SwapAndMint","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"nfpm","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawAndCollectAndSwap","type":"event"},{"inputs":[],"name":"ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FEE_TAKER","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WITHDRAWER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract INonfungiblePositionManager","name":"_nfpm","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"components":[{"internalType":"enum V3Utils.WhatToDo","name":"whatToDo","type":"uint8"},{"internalType":"enum Common.Protocol","name":"protocol","type":"uint8"},{"internalType":"address","name":"targetToken","type":"address"},{"internalType":"uint256","name":"amountRemoveMin0","type":"uint256"},{"internalType":"uint256","name":"amountRemoveMin1","type":"uint256"},{"internalType":"uint256","name":"amountIn0","type":"uint256"},{"internalType":"uint256","name":"amountOut0Min","type":"uint256"},{"internalType":"bytes","name":"swapData0","type":"bytes"},{"internalType":"uint256","name":"amountIn1","type":"uint256"},{"internalType":"uint256","name":"amountOut1Min","type":"uint256"},{"internalType":"bytes","name":"swapData1","type":"bytes"},{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"},{"internalType":"bool","name":"compoundFees","type":"bool"},{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"amountAddMin0","type":"uint256"},{"internalType":"uint256","name":"amountAddMin1","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"bool","name":"unwrap","type":"bool"},{"internalType":"uint64","name":"protocolFeeX64","type":"uint64"}],"internalType":"struct V3Utils.Instructions","name":"instructions","type":"tuple"}],"name":"execute","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum Common.FeeType","name":"feeType","type":"uint8"}],"name":"getMaxFeeX64","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"router","type":"address"},{"internalType":"address","name":"admin","type":"address"},{"internalType":"address","name":"withdrawer","type":"address"},{"internalType":"address","name":"feeTaker","type":"address"},{"internalType":"address[]","name":"whitelistedNfpms","type":"address[]"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"feeTaker","type":"address"}],"name":"setFeeTaker","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum Common.FeeType","name":"feeType","type":"uint8"},{"internalType":"uint64","name":"feex64","type":"uint64"}],"name":"setMaxFeeX64","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"nfpms","type":"address[]"},{"internalType":"bool","name":"isWhitelist","type":"bool"}],"name":"setWhitelistNfpm","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"enum Common.Protocol","name":"protocol","type":"uint8"},{"internalType":"contract INonfungiblePositionManager","name":"nfpm","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"},{"internalType":"uint256","name":"amount2","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"contract IERC20","name":"swapSourceToken","type":"address"},{"internalType":"uint256","name":"amountIn0","type":"uint256"},{"internalType":"uint256","name":"amountOut0Min","type":"uint256"},{"internalType":"bytes","name":"swapData0","type":"bytes"},{"internalType":"uint256","name":"amountIn1","type":"uint256"},{"internalType":"uint256","name":"amountOut1Min","type":"uint256"},{"internalType":"bytes","name":"swapData1","type":"bytes"},{"internalType":"uint256","name":"amountAddMin0","type":"uint256"},{"internalType":"uint256","name":"amountAddMin1","type":"uint256"},{"internalType":"uint64","name":"protocolFeeX64","type":"uint64"}],"internalType":"struct Common.SwapAndIncreaseLiquidityParams","name":"params","type":"tuple"}],"name":"swapAndIncreaseLiquidity","outputs":[{"components":[{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"added0","type":"uint256"},{"internalType":"uint256","name":"added1","type":"uint256"},{"internalType":"uint256","name":"feeAmount0","type":"uint256"},{"internalType":"uint256","name":"feeAmount1","type":"uint256"}],"internalType":"struct Common.SwapAndIncreaseLiquidityResult","name":"result","type":"tuple"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"enum Common.Protocol","name":"protocol","type":"uint8"},{"internalType":"contract INonfungiblePositionManager","name":"nfpm","type":"address"},{"internalType":"contract IERC20","name":"token0","type":"address"},{"internalType":"contract IERC20","name":"token1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"},{"internalType":"uint64","name":"protocolFeeX64","type":"uint64"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"},{"internalType":"uint256","name":"amount2","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"contract IERC20","name":"swapSourceToken","type":"address"},{"internalType":"uint256","name":"amountIn0","type":"uint256"},{"internalType":"uint256","name":"amountOut0Min","type":"uint256"},{"internalType":"bytes","name":"swapData0","type":"bytes"},{"internalType":"uint256","name":"amountIn1","type":"uint256"},{"internalType":"uint256","name":"amountOut1Min","type":"uint256"},{"internalType":"bytes","name":"swapData1","type":"bytes"},{"internalType":"uint256","name":"amountAddMin0","type":"uint256"},{"internalType":"uint256","name":"amountAddMin1","type":"uint256"}],"internalType":"struct Common.SwapAndMintParams","name":"params","type":"tuple"}],"name":"swapAndMint","outputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"added0","type":"uint256"},{"internalType":"uint256","name":"added1","type":"uint256"}],"internalType":"struct Common.SwapAndMintResult","name":"result","type":"tuple"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"swapRouter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20[]","name":"tokens","type":"address[]"},{"internalType":"address","name":"to","type":"address"}],"name":"withdrawERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract INonfungiblePositionManager","name":"nfpm","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"withdrawERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"withdrawNative","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60806040526008805460ff1916905534801561001a57600080fd5b506001805460ff1916815560076020527f6d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6df8054671999999999999a006001600160401b031991821681179092556000929092527fb39221ace053465ec3453ce2b36430bd138b997ecea25c1043da0c366812b828805490921617905560068054326001600160a01b031990911617905561599080620000ba6000396000f3fe6080604052600436106101855760003560e01c80637b9f76b5116100d1578063b60739b91161008a578063c8bfbbbe11610064578063c8bfbbbe146104ff578063d547741f14610537578063d6ee2b4214610557578063f8453e7c1461057757600080fd5b8063b60739b914610432578063c012794214610490578063c31c9c07146104df57600080fd5b80637b9f76b5146103865780638456cb59146103a657806385f438c1146103bb5780639155c7c0146103dd57806391d14854146103fd578063a217fddf1461041d57600080fd5b8063340ed32a1161013e5780634ec5908d116101185780634ec5908d146102f4578063552e94a9146103145780635c975abb1461034c57806375b238fc1461036457600080fd5b8063340ed32a1461029f57806336568abe146102bf5780633f4ba83a146102df57600080fd5b806301ffc9a7146101915780631017cd57146101c6578063150b7a02146101e8578063248a9ca3146102215780632f2ff15d1461025f5780632f622e6b1461027f57600080fd5b3661018c57005b600080fd5b34801561019d57600080fd5b506101b16101ac3660046145ed565b610597565b60405190151581526020015b60405180910390f35b3480156101d257600080fd5b506101e66101e136600461463c565b6105ce565b005b3480156101f457600080fd5b5061020861020336600461469c565b61065e565b6040516001600160e01b031990911681526020016101bd565b34801561022d57600080fd5b5061025161023c36600461473a565b60009081526020819052604090206001015490565b6040519081526020016101bd565b34801561026b57600080fd5b506101e661027a366004614753565b6112b2565b34801561028b57600080fd5b506101e661029a366004614783565b6112dd565b3480156102ab57600080fd5b506101e66102ba3660046147e4565b611337565b3480156102cb57600080fd5b506101e66102da366004614753565b611438565b3480156102eb57600080fd5b506101e661146b565b34801561030057600080fd5b506101e661030f366004614783565b61148e565b34801561032057600080fd5b50600554610334906001600160a01b031681565b6040516001600160a01b0390911681526020016101bd565b34801561035857600080fd5b5060015460ff166101b1565b34801561037057600080fd5b5061025160008051602061593b83398151915281565b34801561039257600080fd5b506101e66103a136600461482f565b6114c9565b3480156103b257600080fd5b506101e6611549565b3480156103c757600080fd5b5061025160008051602061591b83398151915281565b3480156103e957600080fd5b506101e66103f836600461487f565b611569565b34801561040957600080fd5b506101b1610418366004614753565b611605565b34801561042957600080fd5b50610251600081565b6104456104403660046148ca565b61162e565b6040516101bd9190600060a0820190506001600160801b0383511682526020830151602083015260408301516040830152606083015160608301526080830151608083015292915050565b6104a361049e366004614905565b611a32565b6040516101bd9190815181526020808301516001600160801b031690820152604080830151908201526060918201519181019190915260800190565b3480156104eb57600080fd5b50600454610334906001600160a01b031681565b34801561050b57600080fd5b5061051f61051a366004614958565b611f68565b6040516001600160401b0390911681526020016101bd565b34801561054357600080fd5b506101e6610552366004614753565b611fb1565b34801561056357600080fd5b506101e661057236600461498c565b611fd6565b34801561058357600080fd5b506101e66105923660046149c1565b61204d565b60006001600160e01b03198216637965db0b60e01b14806105c857506301ffc9a760e01b6001600160e01b03198316145b92915050565b6105d6612142565b826001600160a01b031663b88d4fde333085856040516020016105f99190614b3f565b6040516020818303038152906040526040518563ffffffff1660e01b81526004016106279493929190614d60565b600060405180830381600087803b15801561064157600080fd5b505af1158015610655573d6000803e3d6000fd5b50505050505050565b6000610668612142565b33306001600160a01b0387160361069257604051632797715160e01b815260040160405180910390fd5b61069b81612168565b6106a457600080fd5b60006106b284860186614ec5565b905060008060006106c88585602001518b612175565b95505050509250925060008061076d604051806101400160405280896001600160a01b031681526020018861024001516001600160a01b03168152602001876001600160a01b03168152602001866001600160a01b031681526020018d8152602001886101c001516001600160801b0316815260200188610220015181526020018860600151815260200188608001518152602001886101a001511515815250612312565b61028088015191935091506001600160401b03161561081d57610812604051806101600160405280848152602001838152602001600081526020018861028001516001600160401b031681526020016001808111156107ce576107ce614a5d565b81526001600160a01b03808b166020830152604082018f90526102408a0151811660608301528881166080830152871660a0820152600060c0909101526001612466565b509395509193505050505b8560a00151821080610833575085610100015181105b1561085157604051634ff64a9f60e01b815260040160405180910390fd5b60028651600281111561086657610866614a5d565b03610bfe576108736144f6565b856001600160a01b031687604001516001600160a01b03160361098c57610985604051806102400160405280896020015160018111156108b5576108b5614a5d565b81526020018a6001600160a01b031681526020018e8152602001858152602001848152602001600081526020018961024001516001600160a01b031681526020018961022001518152602001876001600160a01b031681526020018961010001518152602001896101200151815260200189610140015181526020016000815260200160008152602001604051806020016040528060008152508152602001896101e001518152602001896102000151815260200160006001600160401b031681525087878a6102600151612721565b9050610b96565b846001600160a01b031687604001516001600160a01b031603610a9b57610985604051806102400160405280896020015160018111156109ce576109ce614a5d565b81526020018a6001600160a01b031681526020018e8152602001858152602001848152602001600081526020018961024001516001600160a01b031681526020018961022001518152602001886001600160a01b0316815260200160008152602001600081526020016040518060200160405280600081525081526020018960a0015181526020018960c0015181526020018960e001518152602001896101e001518152602001896102000151815260200160006001600160401b031681525087878a6102600151612721565b610b9360405180610240016040528089602001516001811115610ac057610ac0614a5d565b81526020018a6001600160a01b031681526020018e8152602001858152602001848152602001600081526020018961024001516001600160a01b03168152602001896102200151815260200160006001600160a01b0316815260200160008152602001600081526020016040518060200160405280600081525081526020016000815260200160008152602001604051806020016040528060008152508152602001896101e001518152602001896102000151815260200160006001600160401b031681525087878a6102600151612721565b90505b805160208083015160408085015181516001600160801b039095168552928401919091528201528c906001600160a01b038a16907f4a3d983c4891bedb0622c5a26f90b626e9451fe3a832b73ed9c886f1aa489cda906060015b60405180910390a350611236565b600086516002811115610c1357610c13614a5d565b0361105b57610c2061452e565b856001600160a01b031687604001516001600160a01b031603610d7657610d6f604051806102c0016040528089602001516001811115610c6257610c62614a5d565b81526020018a6001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b031681526020018662ffffff16815260200189610160015160020b815260200189610180015160020b815260200160006001600160401b03168152602001858152602001848152602001600081526020018961024001516001600160a01b031681526020018961022001518152602001876001600160a01b031681526020018961010001518152602001896101200151815260200189610140015181526020016000815260200160008152602001604051806020016040528060008152508152602001896101e001518152602001896102000151815250886102600151612a65565b9050610ffa565b846001600160a01b031687604001516001600160a01b031603610ec257610d6f604051806102c0016040528089602001516001811115610db857610db8614a5d565b81526020018a6001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b031681526020018662ffffff16815260200189610160015160020b815260200189610180015160020b815260200160006001600160401b03168152602001858152602001848152602001600081526020018961024001516001600160a01b031681526020018961022001518152602001886001600160a01b0316815260200160008152602001600081526020016040518060200160405280600081525081526020018960a0015181526020018960c0015181526020018960e001518152602001896101e001518152602001896102000151815250886102600151612a65565b610ff7604051806102c0016040528089602001516001811115610ee757610ee7614a5d565b81526020018a6001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b031681526020018662ffffff16815260200189610160015160020b815260200189610180015160020b815260200160006001600160401b03168152602001858152602001848152602001600081526020018961024001516001600160a01b03168152602001896102200151815260200160006001600160a01b0316815260200160008152602001600081526020016040518060200160405280600081525081526020016000815260200160008152602001604051806020016040528060008152508152602001896101e001518152602001896102000151815250886102600151612a65565b90505b805160208083015160408085015160608087015183519687526001600160801b039094169486019490945290840152908201528c9033907fe878b7324da2e10eb701c2cf0474248cdf5c088bb68aaf3045a6c15d1008b12d90608001610bf0565b60018651600281111561107057611070614a5d565b0361121d576000611085888860200151612dad565b9050600087604001516001600160a01b0316876001600160a01b031614611103576000806110c2898b60400151888d60c001518e60e00151612e87565b91509150858210156110f0576110f0848b61024001518b858a6110e59190615090565b8e61026001516131d9565b6110fa81846150a3565b92505050611110565b61110d84826150a3565b90505b87604001516001600160a01b0316866001600160a01b0316146111815760008061114b888b60400151878d61012001518e6101400151612e87565b915091508482101561116e5761116e848b61024001518a85896110e59190615090565b61117881846150a3565b9250505061118e565b61118b83826150a3565b90505b80158015906111a9575060408801516001600160a01b031615155b156111c9576111c9828961024001518a60400151848c61026001516131d9565b60408089015181516001600160a01b039182168152602081018490528f92918c16917fc082f11600156d64071ed597a7b831f56741ad4e14954598e674e1ec2b61da0c910160405180910390a35050611236565b60405163e83deb0f60e01b815260040160405180910390fd5b866001600160a01b03166323b872dd308e8e6040518463ffffffff1660e01b8152600401611266939291906150b6565b600060405180830381600087803b15801561128057600080fd5b505af1158015611294573d6000803e3d6000fd5b50630a85bd0160e11b9a505050505050505050505095945050505050565b6000828152602081905260409020600101546112cd816132e2565b6112d783836132ec565b50505050565b60008051602061591b8339815191526112f5816132e2565b478015611332576040516001600160a01b0384169082156108fc029083906000818181858888f193505050501580156112d7573d6000803e3d6000fd5b505050565b60008051602061591b83398151915261134f816132e2565b8260005b8181101561143057600086868381811061136f5761136f6150da565b90506020020160208101906113849190614783565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa1580156113ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113ee91906150f0565b905080156114275761142787878481811061140b5761140b6150da565b90506020020160208101906114209190614783565b868361337e565b50600101611353565b505050505050565b6001600160a01b03811633146114615760405163334bd91960e11b815260040160405180910390fd5b61133282826133dd565b60008051602061593b833981519152611483816132e2565b61148b613448565b50565b60008051602061593b8339815191526114a6816132e2565b50600580546001600160a01b0319166001600160a01b0392909216919091179055565b60008051602061591b8339815191526114e1816132e2565b6040516323b872dd60e01b81526001600160a01b038516906323b872dd90611511903090869088906004016150b6565b600060405180830381600087803b15801561152b57600080fd5b505af115801561153f573d6000803e3d6000fd5b5050505050505050565b60008051602061593b833981519152611561816132e2565b61148b613492565b60008051602061593b833981519152611581816132e2565b8260005b818110156114305783156115ca576115c460028787848181106115aa576115aa6150da565b90506020020160208101906115bf9190614783565b6134cd565b506115fd565b6115fb60028787848181106115e1576115e16150da565b90506020020160208101906115f69190614783565b6134e9565b505b600101611585565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6116366144f6565b61163e612142565b6116566116516040840160208501614783565b612168565b61165f57600080fd5b60006116716040840160208501614783565b6001600160a01b0316636352211e84604001356040518263ffffffff1660e01b81526004016116a291815260200190565b602060405180830381865afa1580156116bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116e39190615109565b90506001600160a01b03811633146117425760405162461bcd60e51b815260206004820152601f60248201527f73656e646572206973206e6f74206f776e6572206f6620706f736974696f6e0060448201526064015b60405180910390fd5b60008061176f6117586040870160208801614783565b6117656020880188614958565b8760400135612175565b505050509150915060006117a186602001602081019061178f9190614783565b61179c6020890189614958565b612dad565b90506001600160a01b0383166117bf61012088016101008901614783565b6001600160a01b0316141580156117f957506001600160a01b0382166117ed61012088016101008901614783565b6001600160a01b031614155b801561181b575060a08601356118196101808801356101208901356150a3565b115b1561183957604051634ff64a9f60e01b815260040160405180910390fd5b6118658184846118516101208b016101008c01614783565b8a606001358b608001358c60a001356134fe565b600061187087615126565b9050600061188661024089016102208a01615267565b6001600160401b03161115611a195761196860405180610160016040528089606001358152602001896080013581526020018960a001358152602001896102200160208101906118d69190615267565b6001600160401b03168152602001600181526020018960200160208101906118fe9190614783565b6001600160a01b031681526040808b013560208301520161192560e08b0160c08c01614783565b6001600160a01b0390811682528781166020830152861660408201526060016119566101208b016101008c01614783565b6001600160a01b031690526001612466565b50505060a0840152608083015260608201526101008101516001600160a01b038581169116148015906119b25750826001600160a01b03168161010001516001600160a01b031614155b15611a19578060a001518161018001518261012001516119d291906150a3565b1015611a195760008161018001518261012001516119f091906150a3565b8260a001516119ff9190615090565b9050611a1783338461010001518434600014156131d9565b505b611a27818585341515612721565b979650505050505050565b611a3a61452e565b611a42612142565b611a526080830160608401614783565b6001600160a01b0316611a6b6060840160408501614783565b6001600160a01b031603611a925760405163100dac0560e11b815260040160405180910390fd5b611aa56116516040840160208501614783565b611aae57600080fd5b6000611ad0611ac36040850160208601614783565b61179c6020860186614958565b9050611ae26060840160408501614783565b6001600160a01b0316611afd6101c085016101a08601614783565b6001600160a01b031614158015611b465750611b1f6080840160608501614783565b6001600160a01b0316611b3a6101c085016101a08601614783565b6001600160a01b031614155b8015611b695750610140830135611b676102208501356101c08601356150a3565b115b15611b8757604051634ff64a9f60e01b815260040160405180910390fd5b611bd481611b9b6060860160408701614783565b611bab6080870160608801614783565b611bbd6101c088016101a08901614783565b8761010001358861012001358961014001356134fe565b6000611bdf8461529e565b9050611be961455f565b6000611bfc610100870160e08801615267565b6001600160401b03161115611ee1576000806000611d106040518061016001604052808a610100013581526020018a610120013581526020018a610140013581526020018a60e0016020810190611c539190615267565b6001600160401b03168152602001600181526020018a6020016020810190611c7b9190614783565b6001600160a01b0316815260006020820152604001611ca26101808c016101608d01614783565b6001600160a01b03168152602001611cc060608c0160408d01614783565b6001600160a01b03168152602001611cde60808c0160608d01614783565b6001600160a01b03168152602001611cfe6101c08c016101a08d01614783565b6001600160a01b031690526000612466565b6101408b01939093526101208a019390935261010089019390935260408801516101a089015193965091945092506001600160a01b03918216911614801590611d74575084606001516001600160a01b0316856101a001516001600160a01b031614155b15611e1857846101400151856102200151866101c00151611d9591906150a3565b1115611db457604051634ff64a9f60e01b815260040160405180910390fd5b846101400151856102200151866101c00151611dd091906150a3565b1015611e18576000856102200151866101c00151611dee91906150a3565b866101400151611dfe9190615090565b9050611e168733886101a001518434600014156131d9565b505b604051806101600160405280896040016020810190611e379190614783565b6001600160a01b03168152602001611e5560808b0160608c01614783565b6001600160a01b03168152602001611e756101c08b016101a08c01614783565b6001600160a01b031681526020018961010001358152602001896101200135815260200189610140013581526020018481526020018381526020018281526020018960e0016020810190611ec99190615267565b6001600160401b031681526020016001905293505050505b611eed82341515612a65565b9350611f0161018086016101608701614783565b84516001600160a01b039190911690611f206040880160208901614783565b6001600160a01b03167f07b9ff32d43e39b450a13b642c1e93282a8ea460336f1422bddc6164b304c2da84604051611f58919061542f565b60405180910390a4505050919050565b600060076000836001811115611f8057611f80614a5d565b6001811115611f9157611f91614a5d565b81526020810191909152604001600020546001600160401b031692915050565b600082815260208190526040902060010154611fcc816132e2565b6112d783836133dd565b60008051602061593b833981519152611fee816132e2565b816007600085600181111561200557612005614a5d565b600181111561201657612016614a5d565b815260200190815260200160002060006101000a8154816001600160401b0302191690836001600160401b03160217905550505050565b60085460ff161561205d57600080fd5b6001600160a01b03841661207057600080fd5b6006546001600160a01b0316331461208757600080fd5b61209f60008051602061593b833981519152866132ec565b506120ab6000866132ec565b506120c460008051602061591b833981519152856132ec565b506120d06000856132ec565b50600480546001600160a01b038089166001600160a01b031992831617909255600580549286169290911691909117905560005b8181101561212c5761212360028484848181106115aa576115aa6150da565b50600101612104565b50506008805460ff191660011790555050505050565b60015460ff16156121665760405163d93c066560e01b815260040160405180910390fd5b565b60006105c8600283613a06565b6000806000806000806000808a6001600160a01b03168960405160240161219e91815260200190565b60408051601f198184030181529181526020820180516001600160e01b031663133f757160e31b179052516121d391906154e5565b6000604051808303816000865af19150503d8060008114612210576040519150601f19603f3d011682016040523d82523d6000602084013e612215565b606091505b50915091508161223857604051631916db6f60e21b815260040160405180910390fd5b60008a600181111561224c5761224c614a5d565b036122a357808060200190518101906122659190615528565b909192939495969798999a50909192939495969798995090919250909150905050809b50819950829a50839850849c50859d50505050505050612304565b60018a60018111156122b7576122b7614a5d565b0361230457808060200190518101906122d09190615607565b90919293949596979899509091929394959697985090919250909150905050809a50819850829950839b50849c5050505050505b505093975093979195509350565b60008060008061233f856000015186608001518760a001518860c001518960e001518a6101000151613a28565b865160408051608080820183528a0151815230602082019081526001600160801b0382840181815260608401828152945163fc6f786560e01b81529351600485015291516001600160a01b03908116602485015291518116604484015292519092166064820152939550919350169063fc6f78659060840160408051808303816000875af11580156123d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123f991906156df565b610120870151919550935061245f5760006124148386615090565b905060006124228386615090565b9050811561243d5761243d876040015188602001518461337e565b801561245657612456876060015188602001518361337e565b50508193508092505b5050915091565b600080600080600080600760008960800151600181111561248957612489614a5d565b600181111561249a5761249a614a5d565b815260208101919091526040016000205460608901516001600160401b03918216911611156124dc57604051639a33400560e01b815260040160405180910390fd5b87606001516001600160401b031660000361250a576040516303fbecdf60e51b815260040160405180910390fd5b87511561256057612531886000015189606001516001600160401b0316600160401b613b05565b8851909350612541908490615090565b610100890151600554919750612560916001600160a01b03168561337e565b6020880151156125bb5761258a886020015189606001516001600160401b0316600160401b613b05565b915081886020015161259c9190615090565b6101208901516005549196506125bb916001600160a01b03168461337e565b604088015115612616576125e5886040015189606001516001600160401b0316600160401b613b05565b90508088604001516125f79190615090565b610140890151600554919550612616916001600160a01b03168361337e565b8615612717578760e001516001600160a01b03168860c001518960a001516001600160a01b03167f07b9ff32d43e39b450a13b642c1e93282a8ea460336f1422bddc6164b304c2da6040518061016001604052808d61010001516001600160a01b031681526020018d61012001516001600160a01b031681526020018d61014001516001600160a01b031681526020018d6000015181526020018d6020015181526020018d6040015181526020018881526020018781526020018681526020018d606001516001600160401b031681526020018d6080015160018111156126ff576126ff614a5d565b905260405161270e919061542f565b60405180910390a45b9295509295509295565b6127296144f6565b60008061285f604051806102c001604052808960000151600181111561275157612751614a5d565b815260200189602001516001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b03168152602001600062ffffff168152602001600060020b8152602001600060020b815260200160006001600160401b031681526020018960600151815260200189608001518152602001600081526020018960c001516001600160a01b031681526020018960e0015181526020018961010001516001600160a01b031681526020018961012001518152602001896101400151815260200189610160015181526020018961018001518152602001896101a001518152602001896101c001518152602001896101e00151815260200189610200015181525085613bb7565b9150915060006040518060c0016040528089604001518152602001848152602001838152602001896101e00151815260200189610200015181526020018960e00151815250905087602001516001600160a01b031663219f5d17826040518263ffffffff1660e01b81526004016129159190600060c082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015292915050565b6060604051808303816000875af1158015612934573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129589190615703565b604087810182905260208089018490526001600160801b03949094168089528c8201518d860151835192835295820194909452808201929092525191926001600160a01b0316917fe96b62a2783f0eb40eb1daf87ed80a62c56c56e33c3669bf7f1ce575bd5d81ac9181900360600190a360006129dd89602001518a60000151612dad565b9050612a59604051806101200160405280836001600160a01b031681526020018b60c001516001600160a01b031681526020018a6001600160a01b03168152602001896001600160a01b031681526020018681526020018581526020018760200151815260200187604001518152602001881515815250613e4d565b50505050949350505050565b612a6d61452e565b600080612a7a8585613bb7565b9092509050600085516001811115612a9457612a94614a5d565b03612b5a57612b3b856020015160405180610160016040528088604001516001600160a01b0316815260200188606001516001600160a01b03168152602001886080015162ffffff1681526020018860a0015160020b81526020018860c0015160020b81526020018581526020018481526020018861028001518152602001886102a001518152602001306001600160a01b03168152602001886101800151815250613ec5565b606087015260408601526001600160801b031660208501528352612c2f565b600185516001811115612b6f57612b6f614a5d565b03612c1657612b3b856020015160405180610160016040528088604001516001600160a01b0316815260200188606001516001600160a01b03168152602001886080015162ffffff1681526020018860a0015160020b81526020018860c0015160020b81526020018581526020018481526020018861028001518152602001886102a001518152602001306001600160a01b03168152602001886101800151815250613f4a565b604051630e7b96f560e41b815260040160405180910390fd5b602085015161016086015184516040516323b872dd60e01b81526001600160a01b03909316926323b872dd92612c699230926004016150b6565b600060405180830381600087803b158015612c8357600080fd5b505af1158015612c97573d6000803e3d6000fd5b50505050826000015185602001516001600160a01b03167fa9c03b58d729c750f50b2c6854d5db412e7faa78156e5ddf9225285e19011ff7856020015186604001518760600151604051612d09939291906001600160801b039390931683526020830191909152604082015260600190565b60405180910390a3612da5604051806101200160405280612d3288602001518960000151612dad565b6001600160a01b031681526020018761016001516001600160a01b0316815260200187604001516001600160a01b0316815260200187606001516001600160a01b031681526020018481526020018381526020018560400151815260200185606001518152602001861515815250613e4d565b505092915050565b600080826001811115612dc257612dc2614a5d565b03612e3057826001600160a01b0316634aa4a4fc6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612e05573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e299190615109565b90506105c8565b6001826001811115612e4457612e44614a5d565b03612c1657826001600160a01b0316638af3ac856040518163ffffffff1660e01b8152600401602060405180830381865afa158015612e05573d6000803e3d6000fd5b6000808415801590612e995750825115155b8015612ead57506001600160a01b03861615155b156131cf576040516370a0823160e01b81523060048201526000906001600160a01b038916906370a0823190602401602060405180830381865afa158015612ef9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f1d91906150f0565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038916906370a0823190602401602060405180830381865afa158015612f67573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f8b91906150f0565b600454909150612fa6908a906001600160a01b031689614061565b6004546040516000916001600160a01b031690612fc49088906154e5565b6000604051808303816000865af19150503d8060008114613001576040519150601f19603f3d011682016040523d82523d6000602084013e613006565b606091505b50509050806130465760405162461bcd60e51b815260206004820152600c60248201526b73776170206661696c65642160a01b6044820152606401611739565b60045461305f908b906001600160a01b03166000614061565b6040516370a0823160e01b81523060048201526000906001600160a01b038c16906370a0823190602401602060405180830381865afa1580156130a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130ca91906150f0565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038c16906370a0823190602401602060405180830381865afa158015613114573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061313891906150f0565b90506131448286615090565b96506131508482615090565b95508886101561317357604051630d4205a160e11b815260040160405180910390fd5b8a6001600160a01b03168c6001600160a01b03167ffa2dda1cc1b86e41239702756b13effbc1a092b5c57e3ad320fbe4f3b13fe23589896040516131c1929190918252602082015260400190565b60405180910390a350505050505b9550959350505050565b826001600160a01b0316856001600160a01b03161480156131f75750805b156132d057604051632e1a7d4d60e01b8152600481018390526001600160a01b03861690632e1a7d4d90602401600060405180830381600087803b15801561323e57600080fd5b505af1158015613252573d6000803e3d6000fd5b505050506000846001600160a01b03168360405160006040518083038185875af1925050503d80600081146132a3576040519150601f19603f3d011682016040523d82523d6000602084013e6132a8565b606091505b50509050806132ca57604051637cd69c3960e11b815260040160405180910390fd5b506132db565b6132db83858461337e565b5050505050565b61148b8133614136565b60006132f88383611605565b613376576000838152602081815260408083206001600160a01b03861684529091529020805460ff1916600117905561332e3390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45060016105c8565b5060006105c8565b6040516001600160a01b0383811660248301526044820183905261133291859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050614173565b60006133e98383611605565b15613376576000838152602081815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45060016105c8565b6001805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b61349a612142565b6001805460ff1916811790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25833613475565b60006134e2836001600160a01b0384166141d6565b9392505050565b60006134e2836001600160a01b03841661421d565b60008080341561363057896001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561354357600080fd5b505af1158015613557573d6000803e3d6000fd5b5050505050886001600160a01b03168a6001600160a01b03160361359e5734925085831115613599576040516307e205e160e41b815260040160405180910390fd5b613630565b876001600160a01b03168a6001600160a01b0316036135db5734915084821115613599576040516307e205e160e41b815260040160405180910390fd5b866001600160a01b03168a6001600160a01b03160361361757503483811115613599576040516307e205e160e41b815260040160405180910390fd5b6040516392b0337360e01b815260040160405180910390fd5b8286111561375c576040516370a0823160e01b81523060048201526000906001600160a01b038b16906370a0823190602401602060405180830381865afa15801561367f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136a391906150f0565b90506136ba8a33306136b5888c615090565b614310565b6040516370a0823160e01b81523060048201526000906001600160a01b038c16906370a0823190602401602060405180830381865afa158015613701573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061372591906150f0565b90506137318589615090565b61373b8383615090565b14613759576040516313ff771f60e21b815260040160405180910390fd5b50505b81851115613883576040516370a0823160e01b81523060048201526000906001600160a01b038a16906370a0823190602401602060405180830381865afa1580156137ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137cf91906150f0565b90506137e18933306136b5878b615090565b6040516370a0823160e01b81523060048201526000906001600160a01b038b16906370a0823190602401602060405180830381865afa158015613828573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061384c91906150f0565b90506138588488615090565b6138628383615090565b14613880576040516313ff771f60e21b815260040160405180910390fd5b50505b808411801561389a57506001600160a01b03871615155b80156138b85750866001600160a01b0316896001600160a01b031614155b80156138d65750866001600160a01b0316886001600160a01b031614155b156139fa576040516370a0823160e01b81523060048201526000906001600160a01b038916906370a0823190602401602060405180830381865afa158015613922573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061394691906150f0565b90506139588833306136b5868a615090565b6040516370a0823160e01b81523060048201526000906001600160a01b038a16906370a0823190602401602060405180830381865afa15801561399f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139c391906150f0565b90506139cf8387615090565b6139d98383615090565b146139f7576040516313ff771f60e21b815260040160405180910390fd5b50505b50505050505050505050565b6001600160a01b038116600090815260018301602052604081205415156134e2565b6000806001600160801b03861615613afa576040805160a0810182528881526001600160801b038089166020830190815282840188815260608401888152608085018b81529551630624e65f60e11b8152945160048601529151909216602484015290516044830152516064820152905160848201526001600160a01b03891690630c49ccbe9060a40160408051808303816000875af1158015613ad0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613af491906156df565b90925090505b965096945050505050565b6000808060001985870985870292508281108382030391505080600003613b3e5760008411613b3357600080fd5b5082900490506134e2565b808411613b4a57600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b60008083604001516001600160a01b0316846101a001516001600160a01b031603613c5f578361022001518461010001511015613c0757604051634ff64a9f60e01b815260040160405180910390fd5b600080613c2e866040015187606001518861022001518961024001518a6102600151612e87565b9150915081866101000151613c439190615090565b935080866101200151613c5691906150a3565b92505050613e14565b83606001516001600160a01b0316846101a001516001600160a01b031603613d0457836101c001518461012001511015613cac57604051634ff64a9f60e01b815260040160405180910390fd5b600080613cd386606001518760400151886101c00151896101e001518a6102000151612e87565b9150915081866101200151613ce89190615090565b925080866101000151613cfb91906150a3565b93505050613e14565b6101a08401516001600160a01b031615613e0557600080613d40866101a001518760400151886101c00151896101e001518a6102000151612e87565b91509150600080613d6c886101a0015189606001518a61022001518b61024001518c6102600151612e87565b9150915082886101000151613d8191906150a3565b955080886101200151613d9491906150a3565b9450600082858a61022001518b6101c00151613db091906150a3565b613dba9190615090565b613dc49190615090565b90508015613dfb576000613de08a602001518b60000151612dad565b9050613df9818b61016001518c6101a00151858d6131d9565b505b5050505050613e14565b50506101008201516101208301515b8115613e2d57613e2d8460400151856020015184614338565b8015613e4657613e468460600151856020015183614338565b9250929050565b60008160c001518260800151613e639190615090565b905060008260e001518360a00151613e7b9190615090565b90508115613ea157613ea1836000015184602001518560400151858761010001516131d9565b801561133257611332836000015184602001518560600151848761010001516131d9565b600080600080856001600160a01b03166388316456866040518263ffffffff1660e01b8152600401613ef7919061573a565b6080604051808303816000875af1158015613f16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f3a91906157fe565b9299919850965090945092505050565b600080600080600060405180610140016040528087600001516001600160a01b0316815260200187602001516001600160a01b03168152602001876060015160020b8152602001876080015160020b81526020018760a0015181526020018760c0015181526020018760e0015181526020018761010001518152602001306001600160a01b031681526020018761014001518152509050866001600160a01b0316639cc1a283826040518263ffffffff1660e01b815260040161400d919061583c565b6080604051808303816000875af115801561402c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061405091906157fe565b929a91995097509095509350505050565b604080516001600160a01b03848116602483015260448083018590528351808403909101815260649092019092526020810180516001600160e01b031663095ea7b360e01b1790526000916140b991908616906143ef565b8051909150156112d757808060200190518101906140d791906158e7565b6112d75760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401611739565b6141408282611605565b61416f5760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401611739565b5050565b60006141886001600160a01b038416836143ef565b905080516000141580156141ad5750808060200190518101906141ab91906158e7565b155b1561133257604051635274afe760e01b81526001600160a01b0384166004820152602401611739565b6000818152600183016020526040812054613376575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556105c8565b60008181526001830160205260408120548015614306576000614241600183615090565b855490915060009061425590600190615090565b90508082146142ba576000866000018281548110614275576142756150da565b9060005260206000200154905080876000018481548110614298576142986150da565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806142cb576142cb615904565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506105c8565b60009150506105c8565b6112d784856001600160a01b03166323b872dd8686866040516024016133ab939291906150b6565b604080516001600160a01b038481166024830152600060448084019190915283518084039091018152606490920183526020820180516001600160e01b031663095ea7b360e01b17905291519185169161439291906154e5565b6000604051808303816000865af19150503d80600081146143cf576040519150601f19603f3d011682016040523d82523d6000602084013e6143d4565b606091505b505050600081116143e457600080fd5b611332838383614061565b60606134e28383600084600080856001600160a01b0316848660405161441591906154e5565b60006040518083038185875af1925050503d8060008114614452576040519150601f19603f3d011682016040523d82523d6000602084013e614457565b606091505b5091509150614467868383614471565b9695505050505050565b60608261448657614481826144cd565b6134e2565b815115801561449d57506001600160a01b0384163b155b156144c657604051639996b31560e01b81526001600160a01b0385166004820152602401611739565b50806134e2565b8051156144dd5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b6040518060a0016040528060006001600160801b03168152602001600081526020016000815260200160008152602001600081525090565b60405180608001604052806000815260200160006001600160801b0316815260200160008152602001600081525090565b60405180610160016040528060006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b0316815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160401b03168152602001600060018111156145e8576145e8614a5d565b905290565b6000602082840312156145ff57600080fd5b81356001600160e01b0319811681146134e257600080fd5b6001600160a01b038116811461148b57600080fd5b803561463781614617565b919050565b60008060006060848603121561465157600080fd5b833561465c81614617565b92506020840135915060408401356001600160401b0381111561467e57600080fd5b84016102a0818703121561469157600080fd5b809150509250925092565b6000806000806000608086880312156146b457600080fd5b85356146bf81614617565b945060208601356146cf81614617565b93506040860135925060608601356001600160401b03808211156146f257600080fd5b818801915088601f83011261470657600080fd5b81358181111561471557600080fd5b89602082850101111561472757600080fd5b9699959850939650602001949392505050565b60006020828403121561474c57600080fd5b5035919050565b6000806040838503121561476657600080fd5b82359150602083013561477881614617565b809150509250929050565b60006020828403121561479557600080fd5b81356134e281614617565b60008083601f8401126147b257600080fd5b5081356001600160401b038111156147c957600080fd5b6020830191508360208260051b8501011115613e4657600080fd5b6000806000604084860312156147f957600080fd5b83356001600160401b0381111561480f57600080fd5b61481b868287016147a0565b909450925050602084013561469181614617565b60008060006060848603121561484457600080fd5b833561484f81614617565b925060208401359150604084013561469181614617565b801515811461148b57600080fd5b803561463781614866565b60008060006040848603121561489457600080fd5b83356001600160401b038111156148aa57600080fd5b6148b6868287016147a0565b909450925050602084013561469181614866565b6000602082840312156148dc57600080fd5b81356001600160401b038111156148f257600080fd5b820161024081850312156134e257600080fd5b60006020828403121561491757600080fd5b81356001600160401b0381111561492d57600080fd5b82016102c081850312156134e257600080fd5b6002811061148b57600080fd5b803561463781614940565b60006020828403121561496a57600080fd5b81356134e281614940565b80356001600160401b038116811461463757600080fd5b6000806040838503121561499f57600080fd5b82356149aa81614940565b91506149b860208401614975565b90509250929050565b60008060008060008060a087890312156149da57600080fd5b86356149e581614617565b955060208701356149f581614617565b94506040870135614a0581614617565b93506060870135614a1581614617565b925060808701356001600160401b03811115614a3057600080fd5b614a3c89828a016147a0565b979a9699509497509295939492505050565b80356003811061463757600080fd5b634e487b7160e01b600052602160045260246000fd5b60038110614a8357614a83614a5d565b9052565b60028110614a8357614a83614a5d565b6000808335601e19843603018112614aae57600080fd5b83016020810192503590506001600160401b03811115614acd57600080fd5b803603821315613e4657600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b8060020b811461148b57600080fd5b803561463781614b05565b6001600160801b038116811461148b57600080fd5b803561463781614b1f565b60208152614b5860208201614b5384614a4e565b614a73565b6000614b666020840161494d565b614b736040840182614a87565b50614b806040840161462c565b6001600160a01b03811660608401525060608301356080830152608083013560a083015260a083013560c083015260c083013560e0830152614bc560e0840184614a97565b6102a06101008181870152614bdf6102c087018486614adc565b935061012092508087013583870152506101408287013581870152614c0681880188614a97565b93509050610160601f198786030181880152614c23858584614adc565b9450614c30818901614b14565b93505050610180614c458187018460020b9052565b614c50818801614b14565b9250506101a0614c648187018460020b9052565b614c6f818801614874565b9250506101c0614c828187018415159052565b614c8d818801614b34565b9250506101e0614ca7818701846001600160801b03169052565b610200925080870135838701525061022082870135818701526102409250808701358387015250614cd982870161462c565b9150610260614cf2818701846001600160a01b03169052565b614cfd818801614874565b925050610280614d108187018415159052565b614d1b818801614975565b925050614d32818601836001600160401b03169052565b5090949350505050565b60005b83811015614d57578181015183820152602001614d3f565b50506000910152565b600060018060a01b038087168352808616602084015250836040830152608060608301528251806080840152614d9d8160a0850160208701614d3c565b601f01601f19169190910160a00195945050505050565b634e487b7160e01b600052604160045260246000fd5b6040516102a081016001600160401b0381118282101715614ded57614ded614db4565b60405290565b60405161024081016001600160401b0381118282101715614ded57614ded614db4565b6040516102c081016001600160401b0381118282101715614ded57614ded614db4565b600082601f830112614e4a57600080fd5b81356001600160401b0380821115614e6457614e64614db4565b604051601f8301601f19908116603f01168101908282118183101715614e8c57614e8c614db4565b81604052838152866020858801011115614ea557600080fd5b836020870160208301376000602085830101528094505050505092915050565b600060208284031215614ed757600080fd5b81356001600160401b0380821115614eee57600080fd5b908301906102a08286031215614f0357600080fd5b614f0b614dca565b614f1483614a4e565b8152614f226020840161494d565b6020820152614f336040840161462c565b6040820152606083013560608201526080830135608082015260a083013560a082015260c083013560c082015260e083013582811115614f7257600080fd5b614f7e87828601614e39565b60e083015250610100838101359082015261012080840135908201526101408084013583811115614fae57600080fd5b614fba88828701614e39565b8284015250506101609150614fd0828401614b14565b828201526101809150614fe4828401614b14565b828201526101a09150614ff8828401614874565b828201526101c0915061500c828401614b34565b918101919091526101e08281013590820152610200808301359082015261022080830135908201526102409061504382840161462c565b828201526102609150615057828401614874565b82820152610280915061506b828401614975565b91810191909152949350505050565b634e487b7160e01b600052601160045260246000fd5b818103818111156105c8576105c861507a565b808201808211156105c8576105c861507a565b6001600160a01b039384168152919092166020820152604081019190915260600190565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561510257600080fd5b5051919050565b60006020828403121561511b57600080fd5b81516134e281614617565b6000610240823603121561513957600080fd5b615141614df3565b61514a8361494d565b81526151586020840161462c565b602082015260408301356040820152606083013560608201526080830135608082015260a083013560a082015261519160c0840161462c565b60c082015260e083013560e08201526101006151ae81850161462c565b9082015261012083810135908201526101408084013590820152610160808401356001600160401b03808211156151e457600080fd5b6151f036838801614e39565b928401929092525061018084810135908301526101a080850135908301526101c09081850135908082111561522457600080fd5b5061523136828701614e39565b8284015250506101e080840135818301525061020080840135818301525061022061525d818501614975565b9082015292915050565b60006020828403121561527957600080fd5b6134e282614975565b62ffffff8116811461148b57600080fd5b803561463781615282565b60006102c082360312156152b157600080fd5b6152b9614e16565b6152c28361494d565b81526152d06020840161462c565b60208201526152e16040840161462c565b60408201526152f26060840161462c565b606082015261530360808401615293565b608082015261531460a08401614b14565b60a082015261532560c08401614b14565b60c082015261533660e08401614975565b60e082015261010083810135908201526101208084013590820152610140808401359082015261016061536a81850161462c565b9082015261018083810135908201526101a061538781850161462c565b908201526101c083810135908201526101e08084013590820152610200808401356001600160401b03808211156153bd57600080fd5b6153c936838801614e39565b928401929092525061022084810135908301526102408085013590830152610260908185013590808211156153fd57600080fd5b5061540a36828701614e39565b918301919091525061028083810135908201526102a092830135928101929092525090565b81516001600160a01b031681526101608101602083015161545b60208401826001600160a01b03169052565b50604083015161547660408401826001600160a01b03169052565b50606083015160608301526080830151608083015260a083015160a083015260c083015160c083015260e083015160e0830152610100808401518184015250610120808401516154d0828501826001600160401b03169052565b505061014080840151612da582850182614a87565b600082516154f7818460208701614d3c565b9190910192915050565b80516bffffffffffffffffffffffff8116811461463757600080fd5b805161463781614b1f565b6000806000806000806000806000806000806101808d8f03121561554b57600080fd5b6155548d615501565b9b5060208d015161556481614617565b60408e0151909b5061557581614617565b60608e0151909a5061558681614617565b60808e015190995061559781615282565b60a08e01519098506155a881614b05565b60c08e01519097506155b981614b05565b95506155c760e08e0161551d565b94506101008d015193506101208d015192506155e66101408e0161551d565b91506155f56101608e0161551d565b90509295989b509295989b509295989b565b60008060008060008060008060008060006101608c8e03121561562957600080fd5b6156328c615501565b9a5060208c015161564281614617565b60408d0151909a5061565381614617565b60608d015190995061566481614617565b60808d015190985061567581614b05565b60a08d015190975061568681614b05565b60c08d015190965061569781614b1f565b8095505060e08c015193506101008c015192506101208c01516156b981614b1f565b6101408d01519092506156cb81614b1f565b809150509295989b509295989b9093969950565b600080604083850312156156f257600080fd5b505080516020909101519092909150565b60008060006060848603121561571857600080fd5b835161572381614b1f565b602085015160409095015190969495509392505050565b81516001600160a01b031681526101608101602083015161576660208401826001600160a01b03169052565b50604083015161577d604084018262ffffff169052565b506060830151615792606084018260020b9052565b5060808301516157a7608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e0830152610100808401518184015250610120808401516157ed828501826001600160a01b03169052565b505061014092830151919092015290565b6000806000806080858703121561581457600080fd5b84519350602085015161582681614b1f565b6040860151606090960151949790965092505050565b81516001600160a01b031681526101408101602083015161586860208401826001600160a01b03169052565b50604083015161587d604084018260020b9052565b506060830151615892606084018260020b9052565b506080830151608083015260a083015160a083015260c083015160c083015260e083015160e0830152610100808401516158d6828501826001600160a01b03169052565b505061012092830151919092015290565b6000602082840312156158f957600080fd5b81516134e281614866565b634e487b7160e01b600052603160045260246000fdfe10dac8c06a04bec0b551627dad28bc00d6516b0caacd1c7b345fcdb5211334e4a49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775a2646970667358221220e2ed042abfc069b5e8e373e657131e6d7aa210eb9f79401a206351a631f8234e64736f6c63430008170033
Deployed Bytecode
0x6080604052600436106101855760003560e01c80637b9f76b5116100d1578063b60739b91161008a578063c8bfbbbe11610064578063c8bfbbbe146104ff578063d547741f14610537578063d6ee2b4214610557578063f8453e7c1461057757600080fd5b8063b60739b914610432578063c012794214610490578063c31c9c07146104df57600080fd5b80637b9f76b5146103865780638456cb59146103a657806385f438c1146103bb5780639155c7c0146103dd57806391d14854146103fd578063a217fddf1461041d57600080fd5b8063340ed32a1161013e5780634ec5908d116101185780634ec5908d146102f4578063552e94a9146103145780635c975abb1461034c57806375b238fc1461036457600080fd5b8063340ed32a1461029f57806336568abe146102bf5780633f4ba83a146102df57600080fd5b806301ffc9a7146101915780631017cd57146101c6578063150b7a02146101e8578063248a9ca3146102215780632f2ff15d1461025f5780632f622e6b1461027f57600080fd5b3661018c57005b600080fd5b34801561019d57600080fd5b506101b16101ac3660046145ed565b610597565b60405190151581526020015b60405180910390f35b3480156101d257600080fd5b506101e66101e136600461463c565b6105ce565b005b3480156101f457600080fd5b5061020861020336600461469c565b61065e565b6040516001600160e01b031990911681526020016101bd565b34801561022d57600080fd5b5061025161023c36600461473a565b60009081526020819052604090206001015490565b6040519081526020016101bd565b34801561026b57600080fd5b506101e661027a366004614753565b6112b2565b34801561028b57600080fd5b506101e661029a366004614783565b6112dd565b3480156102ab57600080fd5b506101e66102ba3660046147e4565b611337565b3480156102cb57600080fd5b506101e66102da366004614753565b611438565b3480156102eb57600080fd5b506101e661146b565b34801561030057600080fd5b506101e661030f366004614783565b61148e565b34801561032057600080fd5b50600554610334906001600160a01b031681565b6040516001600160a01b0390911681526020016101bd565b34801561035857600080fd5b5060015460ff166101b1565b34801561037057600080fd5b5061025160008051602061593b83398151915281565b34801561039257600080fd5b506101e66103a136600461482f565b6114c9565b3480156103b257600080fd5b506101e6611549565b3480156103c757600080fd5b5061025160008051602061591b83398151915281565b3480156103e957600080fd5b506101e66103f836600461487f565b611569565b34801561040957600080fd5b506101b1610418366004614753565b611605565b34801561042957600080fd5b50610251600081565b6104456104403660046148ca565b61162e565b6040516101bd9190600060a0820190506001600160801b0383511682526020830151602083015260408301516040830152606083015160608301526080830151608083015292915050565b6104a361049e366004614905565b611a32565b6040516101bd9190815181526020808301516001600160801b031690820152604080830151908201526060918201519181019190915260800190565b3480156104eb57600080fd5b50600454610334906001600160a01b031681565b34801561050b57600080fd5b5061051f61051a366004614958565b611f68565b6040516001600160401b0390911681526020016101bd565b34801561054357600080fd5b506101e6610552366004614753565b611fb1565b34801561056357600080fd5b506101e661057236600461498c565b611fd6565b34801561058357600080fd5b506101e66105923660046149c1565b61204d565b60006001600160e01b03198216637965db0b60e01b14806105c857506301ffc9a760e01b6001600160e01b03198316145b92915050565b6105d6612142565b826001600160a01b031663b88d4fde333085856040516020016105f99190614b3f565b6040516020818303038152906040526040518563ffffffff1660e01b81526004016106279493929190614d60565b600060405180830381600087803b15801561064157600080fd5b505af1158015610655573d6000803e3d6000fd5b50505050505050565b6000610668612142565b33306001600160a01b0387160361069257604051632797715160e01b815260040160405180910390fd5b61069b81612168565b6106a457600080fd5b60006106b284860186614ec5565b905060008060006106c88585602001518b612175565b95505050509250925060008061076d604051806101400160405280896001600160a01b031681526020018861024001516001600160a01b03168152602001876001600160a01b03168152602001866001600160a01b031681526020018d8152602001886101c001516001600160801b0316815260200188610220015181526020018860600151815260200188608001518152602001886101a001511515815250612312565b61028088015191935091506001600160401b03161561081d57610812604051806101600160405280848152602001838152602001600081526020018861028001516001600160401b031681526020016001808111156107ce576107ce614a5d565b81526001600160a01b03808b166020830152604082018f90526102408a0151811660608301528881166080830152871660a0820152600060c0909101526001612466565b509395509193505050505b8560a00151821080610833575085610100015181105b1561085157604051634ff64a9f60e01b815260040160405180910390fd5b60028651600281111561086657610866614a5d565b03610bfe576108736144f6565b856001600160a01b031687604001516001600160a01b03160361098c57610985604051806102400160405280896020015160018111156108b5576108b5614a5d565b81526020018a6001600160a01b031681526020018e8152602001858152602001848152602001600081526020018961024001516001600160a01b031681526020018961022001518152602001876001600160a01b031681526020018961010001518152602001896101200151815260200189610140015181526020016000815260200160008152602001604051806020016040528060008152508152602001896101e001518152602001896102000151815260200160006001600160401b031681525087878a6102600151612721565b9050610b96565b846001600160a01b031687604001516001600160a01b031603610a9b57610985604051806102400160405280896020015160018111156109ce576109ce614a5d565b81526020018a6001600160a01b031681526020018e8152602001858152602001848152602001600081526020018961024001516001600160a01b031681526020018961022001518152602001886001600160a01b0316815260200160008152602001600081526020016040518060200160405280600081525081526020018960a0015181526020018960c0015181526020018960e001518152602001896101e001518152602001896102000151815260200160006001600160401b031681525087878a6102600151612721565b610b9360405180610240016040528089602001516001811115610ac057610ac0614a5d565b81526020018a6001600160a01b031681526020018e8152602001858152602001848152602001600081526020018961024001516001600160a01b03168152602001896102200151815260200160006001600160a01b0316815260200160008152602001600081526020016040518060200160405280600081525081526020016000815260200160008152602001604051806020016040528060008152508152602001896101e001518152602001896102000151815260200160006001600160401b031681525087878a6102600151612721565b90505b805160208083015160408085015181516001600160801b039095168552928401919091528201528c906001600160a01b038a16907f4a3d983c4891bedb0622c5a26f90b626e9451fe3a832b73ed9c886f1aa489cda906060015b60405180910390a350611236565b600086516002811115610c1357610c13614a5d565b0361105b57610c2061452e565b856001600160a01b031687604001516001600160a01b031603610d7657610d6f604051806102c0016040528089602001516001811115610c6257610c62614a5d565b81526020018a6001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b031681526020018662ffffff16815260200189610160015160020b815260200189610180015160020b815260200160006001600160401b03168152602001858152602001848152602001600081526020018961024001516001600160a01b031681526020018961022001518152602001876001600160a01b031681526020018961010001518152602001896101200151815260200189610140015181526020016000815260200160008152602001604051806020016040528060008152508152602001896101e001518152602001896102000151815250886102600151612a65565b9050610ffa565b846001600160a01b031687604001516001600160a01b031603610ec257610d6f604051806102c0016040528089602001516001811115610db857610db8614a5d565b81526020018a6001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b031681526020018662ffffff16815260200189610160015160020b815260200189610180015160020b815260200160006001600160401b03168152602001858152602001848152602001600081526020018961024001516001600160a01b031681526020018961022001518152602001886001600160a01b0316815260200160008152602001600081526020016040518060200160405280600081525081526020018960a0015181526020018960c0015181526020018960e001518152602001896101e001518152602001896102000151815250886102600151612a65565b610ff7604051806102c0016040528089602001516001811115610ee757610ee7614a5d565b81526020018a6001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b031681526020018662ffffff16815260200189610160015160020b815260200189610180015160020b815260200160006001600160401b03168152602001858152602001848152602001600081526020018961024001516001600160a01b03168152602001896102200151815260200160006001600160a01b0316815260200160008152602001600081526020016040518060200160405280600081525081526020016000815260200160008152602001604051806020016040528060008152508152602001896101e001518152602001896102000151815250886102600151612a65565b90505b805160208083015160408085015160608087015183519687526001600160801b039094169486019490945290840152908201528c9033907fe878b7324da2e10eb701c2cf0474248cdf5c088bb68aaf3045a6c15d1008b12d90608001610bf0565b60018651600281111561107057611070614a5d565b0361121d576000611085888860200151612dad565b9050600087604001516001600160a01b0316876001600160a01b031614611103576000806110c2898b60400151888d60c001518e60e00151612e87565b91509150858210156110f0576110f0848b61024001518b858a6110e59190615090565b8e61026001516131d9565b6110fa81846150a3565b92505050611110565b61110d84826150a3565b90505b87604001516001600160a01b0316866001600160a01b0316146111815760008061114b888b60400151878d61012001518e6101400151612e87565b915091508482101561116e5761116e848b61024001518a85896110e59190615090565b61117881846150a3565b9250505061118e565b61118b83826150a3565b90505b80158015906111a9575060408801516001600160a01b031615155b156111c9576111c9828961024001518a60400151848c61026001516131d9565b60408089015181516001600160a01b039182168152602081018490528f92918c16917fc082f11600156d64071ed597a7b831f56741ad4e14954598e674e1ec2b61da0c910160405180910390a35050611236565b60405163e83deb0f60e01b815260040160405180910390fd5b866001600160a01b03166323b872dd308e8e6040518463ffffffff1660e01b8152600401611266939291906150b6565b600060405180830381600087803b15801561128057600080fd5b505af1158015611294573d6000803e3d6000fd5b50630a85bd0160e11b9a505050505050505050505095945050505050565b6000828152602081905260409020600101546112cd816132e2565b6112d783836132ec565b50505050565b60008051602061591b8339815191526112f5816132e2565b478015611332576040516001600160a01b0384169082156108fc029083906000818181858888f193505050501580156112d7573d6000803e3d6000fd5b505050565b60008051602061591b83398151915261134f816132e2565b8260005b8181101561143057600086868381811061136f5761136f6150da565b90506020020160208101906113849190614783565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a0823190602401602060405180830381865afa1580156113ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113ee91906150f0565b905080156114275761142787878481811061140b5761140b6150da565b90506020020160208101906114209190614783565b868361337e565b50600101611353565b505050505050565b6001600160a01b03811633146114615760405163334bd91960e11b815260040160405180910390fd5b61133282826133dd565b60008051602061593b833981519152611483816132e2565b61148b613448565b50565b60008051602061593b8339815191526114a6816132e2565b50600580546001600160a01b0319166001600160a01b0392909216919091179055565b60008051602061591b8339815191526114e1816132e2565b6040516323b872dd60e01b81526001600160a01b038516906323b872dd90611511903090869088906004016150b6565b600060405180830381600087803b15801561152b57600080fd5b505af115801561153f573d6000803e3d6000fd5b5050505050505050565b60008051602061593b833981519152611561816132e2565b61148b613492565b60008051602061593b833981519152611581816132e2565b8260005b818110156114305783156115ca576115c460028787848181106115aa576115aa6150da565b90506020020160208101906115bf9190614783565b6134cd565b506115fd565b6115fb60028787848181106115e1576115e16150da565b90506020020160208101906115f69190614783565b6134e9565b505b600101611585565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6116366144f6565b61163e612142565b6116566116516040840160208501614783565b612168565b61165f57600080fd5b60006116716040840160208501614783565b6001600160a01b0316636352211e84604001356040518263ffffffff1660e01b81526004016116a291815260200190565b602060405180830381865afa1580156116bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116e39190615109565b90506001600160a01b03811633146117425760405162461bcd60e51b815260206004820152601f60248201527f73656e646572206973206e6f74206f776e6572206f6620706f736974696f6e0060448201526064015b60405180910390fd5b60008061176f6117586040870160208801614783565b6117656020880188614958565b8760400135612175565b505050509150915060006117a186602001602081019061178f9190614783565b61179c6020890189614958565b612dad565b90506001600160a01b0383166117bf61012088016101008901614783565b6001600160a01b0316141580156117f957506001600160a01b0382166117ed61012088016101008901614783565b6001600160a01b031614155b801561181b575060a08601356118196101808801356101208901356150a3565b115b1561183957604051634ff64a9f60e01b815260040160405180910390fd5b6118658184846118516101208b016101008c01614783565b8a606001358b608001358c60a001356134fe565b600061187087615126565b9050600061188661024089016102208a01615267565b6001600160401b03161115611a195761196860405180610160016040528089606001358152602001896080013581526020018960a001358152602001896102200160208101906118d69190615267565b6001600160401b03168152602001600181526020018960200160208101906118fe9190614783565b6001600160a01b031681526040808b013560208301520161192560e08b0160c08c01614783565b6001600160a01b0390811682528781166020830152861660408201526060016119566101208b016101008c01614783565b6001600160a01b031690526001612466565b50505060a0840152608083015260608201526101008101516001600160a01b038581169116148015906119b25750826001600160a01b03168161010001516001600160a01b031614155b15611a19578060a001518161018001518261012001516119d291906150a3565b1015611a195760008161018001518261012001516119f091906150a3565b8260a001516119ff9190615090565b9050611a1783338461010001518434600014156131d9565b505b611a27818585341515612721565b979650505050505050565b611a3a61452e565b611a42612142565b611a526080830160608401614783565b6001600160a01b0316611a6b6060840160408501614783565b6001600160a01b031603611a925760405163100dac0560e11b815260040160405180910390fd5b611aa56116516040840160208501614783565b611aae57600080fd5b6000611ad0611ac36040850160208601614783565b61179c6020860186614958565b9050611ae26060840160408501614783565b6001600160a01b0316611afd6101c085016101a08601614783565b6001600160a01b031614158015611b465750611b1f6080840160608501614783565b6001600160a01b0316611b3a6101c085016101a08601614783565b6001600160a01b031614155b8015611b695750610140830135611b676102208501356101c08601356150a3565b115b15611b8757604051634ff64a9f60e01b815260040160405180910390fd5b611bd481611b9b6060860160408701614783565b611bab6080870160608801614783565b611bbd6101c088016101a08901614783565b8761010001358861012001358961014001356134fe565b6000611bdf8461529e565b9050611be961455f565b6000611bfc610100870160e08801615267565b6001600160401b03161115611ee1576000806000611d106040518061016001604052808a610100013581526020018a610120013581526020018a610140013581526020018a60e0016020810190611c539190615267565b6001600160401b03168152602001600181526020018a6020016020810190611c7b9190614783565b6001600160a01b0316815260006020820152604001611ca26101808c016101608d01614783565b6001600160a01b03168152602001611cc060608c0160408d01614783565b6001600160a01b03168152602001611cde60808c0160608d01614783565b6001600160a01b03168152602001611cfe6101c08c016101a08d01614783565b6001600160a01b031690526000612466565b6101408b01939093526101208a019390935261010089019390935260408801516101a089015193965091945092506001600160a01b03918216911614801590611d74575084606001516001600160a01b0316856101a001516001600160a01b031614155b15611e1857846101400151856102200151866101c00151611d9591906150a3565b1115611db457604051634ff64a9f60e01b815260040160405180910390fd5b846101400151856102200151866101c00151611dd091906150a3565b1015611e18576000856102200151866101c00151611dee91906150a3565b866101400151611dfe9190615090565b9050611e168733886101a001518434600014156131d9565b505b604051806101600160405280896040016020810190611e379190614783565b6001600160a01b03168152602001611e5560808b0160608c01614783565b6001600160a01b03168152602001611e756101c08b016101a08c01614783565b6001600160a01b031681526020018961010001358152602001896101200135815260200189610140013581526020018481526020018381526020018281526020018960e0016020810190611ec99190615267565b6001600160401b031681526020016001905293505050505b611eed82341515612a65565b9350611f0161018086016101608701614783565b84516001600160a01b039190911690611f206040880160208901614783565b6001600160a01b03167f07b9ff32d43e39b450a13b642c1e93282a8ea460336f1422bddc6164b304c2da84604051611f58919061542f565b60405180910390a4505050919050565b600060076000836001811115611f8057611f80614a5d565b6001811115611f9157611f91614a5d565b81526020810191909152604001600020546001600160401b031692915050565b600082815260208190526040902060010154611fcc816132e2565b6112d783836133dd565b60008051602061593b833981519152611fee816132e2565b816007600085600181111561200557612005614a5d565b600181111561201657612016614a5d565b815260200190815260200160002060006101000a8154816001600160401b0302191690836001600160401b03160217905550505050565b60085460ff161561205d57600080fd5b6001600160a01b03841661207057600080fd5b6006546001600160a01b0316331461208757600080fd5b61209f60008051602061593b833981519152866132ec565b506120ab6000866132ec565b506120c460008051602061591b833981519152856132ec565b506120d06000856132ec565b50600480546001600160a01b038089166001600160a01b031992831617909255600580549286169290911691909117905560005b8181101561212c5761212360028484848181106115aa576115aa6150da565b50600101612104565b50506008805460ff191660011790555050505050565b60015460ff16156121665760405163d93c066560e01b815260040160405180910390fd5b565b60006105c8600283613a06565b6000806000806000806000808a6001600160a01b03168960405160240161219e91815260200190565b60408051601f198184030181529181526020820180516001600160e01b031663133f757160e31b179052516121d391906154e5565b6000604051808303816000865af19150503d8060008114612210576040519150601f19603f3d011682016040523d82523d6000602084013e612215565b606091505b50915091508161223857604051631916db6f60e21b815260040160405180910390fd5b60008a600181111561224c5761224c614a5d565b036122a357808060200190518101906122659190615528565b909192939495969798999a50909192939495969798995090919250909150905050809b50819950829a50839850849c50859d50505050505050612304565b60018a60018111156122b7576122b7614a5d565b0361230457808060200190518101906122d09190615607565b90919293949596979899509091929394959697985090919250909150905050809a50819850829950839b50849c5050505050505b505093975093979195509350565b60008060008061233f856000015186608001518760a001518860c001518960e001518a6101000151613a28565b865160408051608080820183528a0151815230602082019081526001600160801b0382840181815260608401828152945163fc6f786560e01b81529351600485015291516001600160a01b03908116602485015291518116604484015292519092166064820152939550919350169063fc6f78659060840160408051808303816000875af11580156123d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123f991906156df565b610120870151919550935061245f5760006124148386615090565b905060006124228386615090565b9050811561243d5761243d876040015188602001518461337e565b801561245657612456876060015188602001518361337e565b50508193508092505b5050915091565b600080600080600080600760008960800151600181111561248957612489614a5d565b600181111561249a5761249a614a5d565b815260208101919091526040016000205460608901516001600160401b03918216911611156124dc57604051639a33400560e01b815260040160405180910390fd5b87606001516001600160401b031660000361250a576040516303fbecdf60e51b815260040160405180910390fd5b87511561256057612531886000015189606001516001600160401b0316600160401b613b05565b8851909350612541908490615090565b610100890151600554919750612560916001600160a01b03168561337e565b6020880151156125bb5761258a886020015189606001516001600160401b0316600160401b613b05565b915081886020015161259c9190615090565b6101208901516005549196506125bb916001600160a01b03168461337e565b604088015115612616576125e5886040015189606001516001600160401b0316600160401b613b05565b90508088604001516125f79190615090565b610140890151600554919550612616916001600160a01b03168361337e565b8615612717578760e001516001600160a01b03168860c001518960a001516001600160a01b03167f07b9ff32d43e39b450a13b642c1e93282a8ea460336f1422bddc6164b304c2da6040518061016001604052808d61010001516001600160a01b031681526020018d61012001516001600160a01b031681526020018d61014001516001600160a01b031681526020018d6000015181526020018d6020015181526020018d6040015181526020018881526020018781526020018681526020018d606001516001600160401b031681526020018d6080015160018111156126ff576126ff614a5d565b905260405161270e919061542f565b60405180910390a45b9295509295509295565b6127296144f6565b60008061285f604051806102c001604052808960000151600181111561275157612751614a5d565b815260200189602001516001600160a01b03168152602001886001600160a01b03168152602001876001600160a01b03168152602001600062ffffff168152602001600060020b8152602001600060020b815260200160006001600160401b031681526020018960600151815260200189608001518152602001600081526020018960c001516001600160a01b031681526020018960e0015181526020018961010001516001600160a01b031681526020018961012001518152602001896101400151815260200189610160015181526020018961018001518152602001896101a001518152602001896101c001518152602001896101e00151815260200189610200015181525085613bb7565b9150915060006040518060c0016040528089604001518152602001848152602001838152602001896101e00151815260200189610200015181526020018960e00151815250905087602001516001600160a01b031663219f5d17826040518263ffffffff1660e01b81526004016129159190600060c082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015292915050565b6060604051808303816000875af1158015612934573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129589190615703565b604087810182905260208089018490526001600160801b03949094168089528c8201518d860151835192835295820194909452808201929092525191926001600160a01b0316917fe96b62a2783f0eb40eb1daf87ed80a62c56c56e33c3669bf7f1ce575bd5d81ac9181900360600190a360006129dd89602001518a60000151612dad565b9050612a59604051806101200160405280836001600160a01b031681526020018b60c001516001600160a01b031681526020018a6001600160a01b03168152602001896001600160a01b031681526020018681526020018581526020018760200151815260200187604001518152602001881515815250613e4d565b50505050949350505050565b612a6d61452e565b600080612a7a8585613bb7565b9092509050600085516001811115612a9457612a94614a5d565b03612b5a57612b3b856020015160405180610160016040528088604001516001600160a01b0316815260200188606001516001600160a01b03168152602001886080015162ffffff1681526020018860a0015160020b81526020018860c0015160020b81526020018581526020018481526020018861028001518152602001886102a001518152602001306001600160a01b03168152602001886101800151815250613ec5565b606087015260408601526001600160801b031660208501528352612c2f565b600185516001811115612b6f57612b6f614a5d565b03612c1657612b3b856020015160405180610160016040528088604001516001600160a01b0316815260200188606001516001600160a01b03168152602001886080015162ffffff1681526020018860a0015160020b81526020018860c0015160020b81526020018581526020018481526020018861028001518152602001886102a001518152602001306001600160a01b03168152602001886101800151815250613f4a565b604051630e7b96f560e41b815260040160405180910390fd5b602085015161016086015184516040516323b872dd60e01b81526001600160a01b03909316926323b872dd92612c699230926004016150b6565b600060405180830381600087803b158015612c8357600080fd5b505af1158015612c97573d6000803e3d6000fd5b50505050826000015185602001516001600160a01b03167fa9c03b58d729c750f50b2c6854d5db412e7faa78156e5ddf9225285e19011ff7856020015186604001518760600151604051612d09939291906001600160801b039390931683526020830191909152604082015260600190565b60405180910390a3612da5604051806101200160405280612d3288602001518960000151612dad565b6001600160a01b031681526020018761016001516001600160a01b0316815260200187604001516001600160a01b0316815260200187606001516001600160a01b031681526020018481526020018381526020018560400151815260200185606001518152602001861515815250613e4d565b505092915050565b600080826001811115612dc257612dc2614a5d565b03612e3057826001600160a01b0316634aa4a4fc6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612e05573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e299190615109565b90506105c8565b6001826001811115612e4457612e44614a5d565b03612c1657826001600160a01b0316638af3ac856040518163ffffffff1660e01b8152600401602060405180830381865afa158015612e05573d6000803e3d6000fd5b6000808415801590612e995750825115155b8015612ead57506001600160a01b03861615155b156131cf576040516370a0823160e01b81523060048201526000906001600160a01b038916906370a0823190602401602060405180830381865afa158015612ef9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f1d91906150f0565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038916906370a0823190602401602060405180830381865afa158015612f67573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f8b91906150f0565b600454909150612fa6908a906001600160a01b031689614061565b6004546040516000916001600160a01b031690612fc49088906154e5565b6000604051808303816000865af19150503d8060008114613001576040519150601f19603f3d011682016040523d82523d6000602084013e613006565b606091505b50509050806130465760405162461bcd60e51b815260206004820152600c60248201526b73776170206661696c65642160a01b6044820152606401611739565b60045461305f908b906001600160a01b03166000614061565b6040516370a0823160e01b81523060048201526000906001600160a01b038c16906370a0823190602401602060405180830381865afa1580156130a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130ca91906150f0565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038c16906370a0823190602401602060405180830381865afa158015613114573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061313891906150f0565b90506131448286615090565b96506131508482615090565b95508886101561317357604051630d4205a160e11b815260040160405180910390fd5b8a6001600160a01b03168c6001600160a01b03167ffa2dda1cc1b86e41239702756b13effbc1a092b5c57e3ad320fbe4f3b13fe23589896040516131c1929190918252602082015260400190565b60405180910390a350505050505b9550959350505050565b826001600160a01b0316856001600160a01b03161480156131f75750805b156132d057604051632e1a7d4d60e01b8152600481018390526001600160a01b03861690632e1a7d4d90602401600060405180830381600087803b15801561323e57600080fd5b505af1158015613252573d6000803e3d6000fd5b505050506000846001600160a01b03168360405160006040518083038185875af1925050503d80600081146132a3576040519150601f19603f3d011682016040523d82523d6000602084013e6132a8565b606091505b50509050806132ca57604051637cd69c3960e11b815260040160405180910390fd5b506132db565b6132db83858461337e565b5050505050565b61148b8133614136565b60006132f88383611605565b613376576000838152602081815260408083206001600160a01b03861684529091529020805460ff1916600117905561332e3390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45060016105c8565b5060006105c8565b6040516001600160a01b0383811660248301526044820183905261133291859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050614173565b60006133e98383611605565b15613376576000838152602081815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45060016105c8565b6001805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b61349a612142565b6001805460ff1916811790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25833613475565b60006134e2836001600160a01b0384166141d6565b9392505050565b60006134e2836001600160a01b03841661421d565b60008080341561363057896001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561354357600080fd5b505af1158015613557573d6000803e3d6000fd5b5050505050886001600160a01b03168a6001600160a01b03160361359e5734925085831115613599576040516307e205e160e41b815260040160405180910390fd5b613630565b876001600160a01b03168a6001600160a01b0316036135db5734915084821115613599576040516307e205e160e41b815260040160405180910390fd5b866001600160a01b03168a6001600160a01b03160361361757503483811115613599576040516307e205e160e41b815260040160405180910390fd5b6040516392b0337360e01b815260040160405180910390fd5b8286111561375c576040516370a0823160e01b81523060048201526000906001600160a01b038b16906370a0823190602401602060405180830381865afa15801561367f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136a391906150f0565b90506136ba8a33306136b5888c615090565b614310565b6040516370a0823160e01b81523060048201526000906001600160a01b038c16906370a0823190602401602060405180830381865afa158015613701573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061372591906150f0565b90506137318589615090565b61373b8383615090565b14613759576040516313ff771f60e21b815260040160405180910390fd5b50505b81851115613883576040516370a0823160e01b81523060048201526000906001600160a01b038a16906370a0823190602401602060405180830381865afa1580156137ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137cf91906150f0565b90506137e18933306136b5878b615090565b6040516370a0823160e01b81523060048201526000906001600160a01b038b16906370a0823190602401602060405180830381865afa158015613828573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061384c91906150f0565b90506138588488615090565b6138628383615090565b14613880576040516313ff771f60e21b815260040160405180910390fd5b50505b808411801561389a57506001600160a01b03871615155b80156138b85750866001600160a01b0316896001600160a01b031614155b80156138d65750866001600160a01b0316886001600160a01b031614155b156139fa576040516370a0823160e01b81523060048201526000906001600160a01b038916906370a0823190602401602060405180830381865afa158015613922573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061394691906150f0565b90506139588833306136b5868a615090565b6040516370a0823160e01b81523060048201526000906001600160a01b038a16906370a0823190602401602060405180830381865afa15801561399f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139c391906150f0565b90506139cf8387615090565b6139d98383615090565b146139f7576040516313ff771f60e21b815260040160405180910390fd5b50505b50505050505050505050565b6001600160a01b038116600090815260018301602052604081205415156134e2565b6000806001600160801b03861615613afa576040805160a0810182528881526001600160801b038089166020830190815282840188815260608401888152608085018b81529551630624e65f60e11b8152945160048601529151909216602484015290516044830152516064820152905160848201526001600160a01b03891690630c49ccbe9060a40160408051808303816000875af1158015613ad0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613af491906156df565b90925090505b965096945050505050565b6000808060001985870985870292508281108382030391505080600003613b3e5760008411613b3357600080fd5b5082900490506134e2565b808411613b4a57600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b60008083604001516001600160a01b0316846101a001516001600160a01b031603613c5f578361022001518461010001511015613c0757604051634ff64a9f60e01b815260040160405180910390fd5b600080613c2e866040015187606001518861022001518961024001518a6102600151612e87565b9150915081866101000151613c439190615090565b935080866101200151613c5691906150a3565b92505050613e14565b83606001516001600160a01b0316846101a001516001600160a01b031603613d0457836101c001518461012001511015613cac57604051634ff64a9f60e01b815260040160405180910390fd5b600080613cd386606001518760400151886101c00151896101e001518a6102000151612e87565b9150915081866101200151613ce89190615090565b925080866101000151613cfb91906150a3565b93505050613e14565b6101a08401516001600160a01b031615613e0557600080613d40866101a001518760400151886101c00151896101e001518a6102000151612e87565b91509150600080613d6c886101a0015189606001518a61022001518b61024001518c6102600151612e87565b9150915082886101000151613d8191906150a3565b955080886101200151613d9491906150a3565b9450600082858a61022001518b6101c00151613db091906150a3565b613dba9190615090565b613dc49190615090565b90508015613dfb576000613de08a602001518b60000151612dad565b9050613df9818b61016001518c6101a00151858d6131d9565b505b5050505050613e14565b50506101008201516101208301515b8115613e2d57613e2d8460400151856020015184614338565b8015613e4657613e468460600151856020015183614338565b9250929050565b60008160c001518260800151613e639190615090565b905060008260e001518360a00151613e7b9190615090565b90508115613ea157613ea1836000015184602001518560400151858761010001516131d9565b801561133257611332836000015184602001518560600151848761010001516131d9565b600080600080856001600160a01b03166388316456866040518263ffffffff1660e01b8152600401613ef7919061573a565b6080604051808303816000875af1158015613f16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f3a91906157fe565b9299919850965090945092505050565b600080600080600060405180610140016040528087600001516001600160a01b0316815260200187602001516001600160a01b03168152602001876060015160020b8152602001876080015160020b81526020018760a0015181526020018760c0015181526020018760e0015181526020018761010001518152602001306001600160a01b031681526020018761014001518152509050866001600160a01b0316639cc1a283826040518263ffffffff1660e01b815260040161400d919061583c565b6080604051808303816000875af115801561402c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061405091906157fe565b929a91995097509095509350505050565b604080516001600160a01b03848116602483015260448083018590528351808403909101815260649092019092526020810180516001600160e01b031663095ea7b360e01b1790526000916140b991908616906143ef565b8051909150156112d757808060200190518101906140d791906158e7565b6112d75760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401611739565b6141408282611605565b61416f5760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401611739565b5050565b60006141886001600160a01b038416836143ef565b905080516000141580156141ad5750808060200190518101906141ab91906158e7565b155b1561133257604051635274afe760e01b81526001600160a01b0384166004820152602401611739565b6000818152600183016020526040812054613376575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556105c8565b60008181526001830160205260408120548015614306576000614241600183615090565b855490915060009061425590600190615090565b90508082146142ba576000866000018281548110614275576142756150da565b9060005260206000200154905080876000018481548110614298576142986150da565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806142cb576142cb615904565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506105c8565b60009150506105c8565b6112d784856001600160a01b03166323b872dd8686866040516024016133ab939291906150b6565b604080516001600160a01b038481166024830152600060448084019190915283518084039091018152606490920183526020820180516001600160e01b031663095ea7b360e01b17905291519185169161439291906154e5565b6000604051808303816000865af19150503d80600081146143cf576040519150601f19603f3d011682016040523d82523d6000602084013e6143d4565b606091505b505050600081116143e457600080fd5b611332838383614061565b60606134e28383600084600080856001600160a01b0316848660405161441591906154e5565b60006040518083038185875af1925050503d8060008114614452576040519150601f19603f3d011682016040523d82523d6000602084013e614457565b606091505b5091509150614467868383614471565b9695505050505050565b60608261448657614481826144cd565b6134e2565b815115801561449d57506001600160a01b0384163b155b156144c657604051639996b31560e01b81526001600160a01b0385166004820152602401611739565b50806134e2565b8051156144dd5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b6040518060a0016040528060006001600160801b03168152602001600081526020016000815260200160008152602001600081525090565b60405180608001604052806000815260200160006001600160801b0316815260200160008152602001600081525090565b60405180610160016040528060006001600160a01b0316815260200160006001600160a01b0316815260200160006001600160a01b0316815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160401b03168152602001600060018111156145e8576145e8614a5d565b905290565b6000602082840312156145ff57600080fd5b81356001600160e01b0319811681146134e257600080fd5b6001600160a01b038116811461148b57600080fd5b803561463781614617565b919050565b60008060006060848603121561465157600080fd5b833561465c81614617565b92506020840135915060408401356001600160401b0381111561467e57600080fd5b84016102a0818703121561469157600080fd5b809150509250925092565b6000806000806000608086880312156146b457600080fd5b85356146bf81614617565b945060208601356146cf81614617565b93506040860135925060608601356001600160401b03808211156146f257600080fd5b818801915088601f83011261470657600080fd5b81358181111561471557600080fd5b89602082850101111561472757600080fd5b9699959850939650602001949392505050565b60006020828403121561474c57600080fd5b5035919050565b6000806040838503121561476657600080fd5b82359150602083013561477881614617565b809150509250929050565b60006020828403121561479557600080fd5b81356134e281614617565b60008083601f8401126147b257600080fd5b5081356001600160401b038111156147c957600080fd5b6020830191508360208260051b8501011115613e4657600080fd5b6000806000604084860312156147f957600080fd5b83356001600160401b0381111561480f57600080fd5b61481b868287016147a0565b909450925050602084013561469181614617565b60008060006060848603121561484457600080fd5b833561484f81614617565b925060208401359150604084013561469181614617565b801515811461148b57600080fd5b803561463781614866565b60008060006040848603121561489457600080fd5b83356001600160401b038111156148aa57600080fd5b6148b6868287016147a0565b909450925050602084013561469181614866565b6000602082840312156148dc57600080fd5b81356001600160401b038111156148f257600080fd5b820161024081850312156134e257600080fd5b60006020828403121561491757600080fd5b81356001600160401b0381111561492d57600080fd5b82016102c081850312156134e257600080fd5b6002811061148b57600080fd5b803561463781614940565b60006020828403121561496a57600080fd5b81356134e281614940565b80356001600160401b038116811461463757600080fd5b6000806040838503121561499f57600080fd5b82356149aa81614940565b91506149b860208401614975565b90509250929050565b60008060008060008060a087890312156149da57600080fd5b86356149e581614617565b955060208701356149f581614617565b94506040870135614a0581614617565b93506060870135614a1581614617565b925060808701356001600160401b03811115614a3057600080fd5b614a3c89828a016147a0565b979a9699509497509295939492505050565b80356003811061463757600080fd5b634e487b7160e01b600052602160045260246000fd5b60038110614a8357614a83614a5d565b9052565b60028110614a8357614a83614a5d565b6000808335601e19843603018112614aae57600080fd5b83016020810192503590506001600160401b03811115614acd57600080fd5b803603821315613e4657600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b8060020b811461148b57600080fd5b803561463781614b05565b6001600160801b038116811461148b57600080fd5b803561463781614b1f565b60208152614b5860208201614b5384614a4e565b614a73565b6000614b666020840161494d565b614b736040840182614a87565b50614b806040840161462c565b6001600160a01b03811660608401525060608301356080830152608083013560a083015260a083013560c083015260c083013560e0830152614bc560e0840184614a97565b6102a06101008181870152614bdf6102c087018486614adc565b935061012092508087013583870152506101408287013581870152614c0681880188614a97565b93509050610160601f198786030181880152614c23858584614adc565b9450614c30818901614b14565b93505050610180614c458187018460020b9052565b614c50818801614b14565b9250506101a0614c648187018460020b9052565b614c6f818801614874565b9250506101c0614c828187018415159052565b614c8d818801614b34565b9250506101e0614ca7818701846001600160801b03169052565b610200925080870135838701525061022082870135818701526102409250808701358387015250614cd982870161462c565b9150610260614cf2818701846001600160a01b03169052565b614cfd818801614874565b925050610280614d108187018415159052565b614d1b818801614975565b925050614d32818601836001600160401b03169052565b5090949350505050565b60005b83811015614d57578181015183820152602001614d3f565b50506000910152565b600060018060a01b038087168352808616602084015250836040830152608060608301528251806080840152614d9d8160a0850160208701614d3c565b601f01601f19169190910160a00195945050505050565b634e487b7160e01b600052604160045260246000fd5b6040516102a081016001600160401b0381118282101715614ded57614ded614db4565b60405290565b60405161024081016001600160401b0381118282101715614ded57614ded614db4565b6040516102c081016001600160401b0381118282101715614ded57614ded614db4565b600082601f830112614e4a57600080fd5b81356001600160401b0380821115614e6457614e64614db4565b604051601f8301601f19908116603f01168101908282118183101715614e8c57614e8c614db4565b81604052838152866020858801011115614ea557600080fd5b836020870160208301376000602085830101528094505050505092915050565b600060208284031215614ed757600080fd5b81356001600160401b0380821115614eee57600080fd5b908301906102a08286031215614f0357600080fd5b614f0b614dca565b614f1483614a4e565b8152614f226020840161494d565b6020820152614f336040840161462c565b6040820152606083013560608201526080830135608082015260a083013560a082015260c083013560c082015260e083013582811115614f7257600080fd5b614f7e87828601614e39565b60e083015250610100838101359082015261012080840135908201526101408084013583811115614fae57600080fd5b614fba88828701614e39565b8284015250506101609150614fd0828401614b14565b828201526101809150614fe4828401614b14565b828201526101a09150614ff8828401614874565b828201526101c0915061500c828401614b34565b918101919091526101e08281013590820152610200808301359082015261022080830135908201526102409061504382840161462c565b828201526102609150615057828401614874565b82820152610280915061506b828401614975565b91810191909152949350505050565b634e487b7160e01b600052601160045260246000fd5b818103818111156105c8576105c861507a565b808201808211156105c8576105c861507a565b6001600160a01b039384168152919092166020820152604081019190915260600190565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561510257600080fd5b5051919050565b60006020828403121561511b57600080fd5b81516134e281614617565b6000610240823603121561513957600080fd5b615141614df3565b61514a8361494d565b81526151586020840161462c565b602082015260408301356040820152606083013560608201526080830135608082015260a083013560a082015261519160c0840161462c565b60c082015260e083013560e08201526101006151ae81850161462c565b9082015261012083810135908201526101408084013590820152610160808401356001600160401b03808211156151e457600080fd5b6151f036838801614e39565b928401929092525061018084810135908301526101a080850135908301526101c09081850135908082111561522457600080fd5b5061523136828701614e39565b8284015250506101e080840135818301525061020080840135818301525061022061525d818501614975565b9082015292915050565b60006020828403121561527957600080fd5b6134e282614975565b62ffffff8116811461148b57600080fd5b803561463781615282565b60006102c082360312156152b157600080fd5b6152b9614e16565b6152c28361494d565b81526152d06020840161462c565b60208201526152e16040840161462c565b60408201526152f26060840161462c565b606082015261530360808401615293565b608082015261531460a08401614b14565b60a082015261532560c08401614b14565b60c082015261533660e08401614975565b60e082015261010083810135908201526101208084013590820152610140808401359082015261016061536a81850161462c565b9082015261018083810135908201526101a061538781850161462c565b908201526101c083810135908201526101e08084013590820152610200808401356001600160401b03808211156153bd57600080fd5b6153c936838801614e39565b928401929092525061022084810135908301526102408085013590830152610260908185013590808211156153fd57600080fd5b5061540a36828701614e39565b918301919091525061028083810135908201526102a092830135928101929092525090565b81516001600160a01b031681526101608101602083015161545b60208401826001600160a01b03169052565b50604083015161547660408401826001600160a01b03169052565b50606083015160608301526080830151608083015260a083015160a083015260c083015160c083015260e083015160e0830152610100808401518184015250610120808401516154d0828501826001600160401b03169052565b505061014080840151612da582850182614a87565b600082516154f7818460208701614d3c565b9190910192915050565b80516bffffffffffffffffffffffff8116811461463757600080fd5b805161463781614b1f565b6000806000806000806000806000806000806101808d8f03121561554b57600080fd5b6155548d615501565b9b5060208d015161556481614617565b60408e0151909b5061557581614617565b60608e0151909a5061558681614617565b60808e015190995061559781615282565b60a08e01519098506155a881614b05565b60c08e01519097506155b981614b05565b95506155c760e08e0161551d565b94506101008d015193506101208d015192506155e66101408e0161551d565b91506155f56101608e0161551d565b90509295989b509295989b509295989b565b60008060008060008060008060008060006101608c8e03121561562957600080fd5b6156328c615501565b9a5060208c015161564281614617565b60408d0151909a5061565381614617565b60608d015190995061566481614617565b60808d015190985061567581614b05565b60a08d015190975061568681614b05565b60c08d015190965061569781614b1f565b8095505060e08c015193506101008c015192506101208c01516156b981614b1f565b6101408d01519092506156cb81614b1f565b809150509295989b509295989b9093969950565b600080604083850312156156f257600080fd5b505080516020909101519092909150565b60008060006060848603121561571857600080fd5b835161572381614b1f565b602085015160409095015190969495509392505050565b81516001600160a01b031681526101608101602083015161576660208401826001600160a01b03169052565b50604083015161577d604084018262ffffff169052565b506060830151615792606084018260020b9052565b5060808301516157a7608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e0830152610100808401518184015250610120808401516157ed828501826001600160a01b03169052565b505061014092830151919092015290565b6000806000806080858703121561581457600080fd5b84519350602085015161582681614b1f565b6040860151606090960151949790965092505050565b81516001600160a01b031681526101408101602083015161586860208401826001600160a01b03169052565b50604083015161587d604084018260020b9052565b506060830151615892606084018260020b9052565b506080830151608083015260a083015160a083015260c083015160c083015260e083015160e0830152610100808401516158d6828501826001600160a01b03169052565b505061012092830151919092015290565b6000602082840312156158f957600080fd5b81516134e281614866565b634e487b7160e01b600052603160045260246000fdfe10dac8c06a04bec0b551627dad28bc00d6516b0caacd1c7b345fcdb5211334e4a49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775a2646970667358221220e2ed042abfc069b5e8e373e657131e6d7aa210eb9f79401a206351a631f8234e64736f6c63430008170033
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.